Example usage for org.eclipse.jface.viewers ViewerDropAdapter LOCATION_AFTER

List of usage examples for org.eclipse.jface.viewers ViewerDropAdapter LOCATION_AFTER

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ViewerDropAdapter LOCATION_AFTER.

Prototype

int LOCATION_AFTER

To view the source code for org.eclipse.jface.viewers ViewerDropAdapter LOCATION_AFTER.

Click Source Link

Document

Constant describing the position of the cursor relative to the target object.

Usage

From source file:com.siteview.mde.internal.ui.editor.monitor.DependencyManagementSection.java

License:Open Source License

public boolean canDropMove(Object targetObject, Object[] sourceObjects, int targetLocation) {
    // Sanity check
    if (validateDropMoveSanity(targetObject, sourceObjects) == false) {
        return false;
    }//from  ww  w . j av a 2  s  .  c o  m
    // Multiple selection not supported
    String sourcePlugin = (String) sourceObjects[0];
    String targetPlugin = (String) targetObject;
    // Get the secondary dependencies build entry
    BuildEntry entry = getSecondaryDepBuildEntry();
    // Validate entry
    if (entry == null) {
        return false;
    }
    // Validate move
    if (targetLocation == ViewerDropAdapter.LOCATION_BEFORE) {
        // Get the previous plugin of the target 
        String previousPlugin = entry.getPreviousToken(targetPlugin);
        // Ensure the previous token is not the source
        if (sourcePlugin.equals(previousPlugin)) {
            return false;
        }
        return true;
    } else if (targetLocation == ViewerDropAdapter.LOCATION_AFTER) {
        // Get the next plugin of the target 
        String nextPlugin = entry.getNextToken(targetPlugin);
        // Ensure the next plugin is not the source
        if (sourcePlugin.equals(nextPlugin)) {
            return false;
        }
        return true;
    } else if (targetLocation == ViewerDropAdapter.LOCATION_ON) {
        // Not supported
        return false;
    }

    return false;
}

From source file:com.siteview.mde.internal.ui.editor.monitor.DependencyManagementSection.java

License:Open Source License

public void doDropMove(Object targetObject, Object[] sourceObjects, int targetLocation) {
    // Sanity check
    if (validateDropMoveSanity(targetObject, sourceObjects) == false) {
        Display.getDefault().beep();/* w  ww  .  j  a  va  2s  . c o  m*/
        return;
    }
    // Multiple selection not supported
    String sourcePlugin = (String) sourceObjects[0];
    String targetPlugin = (String) targetObject;
    // Validate move
    if ((targetLocation == ViewerDropAdapter.LOCATION_BEFORE)
            || (targetLocation == ViewerDropAdapter.LOCATION_AFTER)) {
        // Do move
        doDropMove(sourcePlugin, targetPlugin, targetLocation);
    } else if (targetLocation == ViewerDropAdapter.LOCATION_ON) {
        // Not supported
    }
}

From source file:com.siteview.mde.internal.ui.editor.monitor.DependencyManagementSection.java

License:Open Source License

/**
 * @param sourcePlugin/*from  w w  w  .  ja  va2  s.  c o m*/
 * @param targetPlugin
 * @param targetLocation
 */
private void doDropMove(String sourcePlugin, String targetPlugin, int targetLocation) {
    // Remove the original source object
    // Normally we remove the original source object after inserting the
    // serialized source object; however, the plug-ins are removed via ID
    // and having both objects with the same ID co-existing will confound
    // the remove operation
    doDragRemove();
    // Get the secondary dependencies build entry
    BuildEntry entry = getSecondaryDepBuildEntry();
    // Validate entry
    if (entry == null) {
        return;
    }
    // Get the index of the target
    int index = entry.getIndexOf(targetPlugin);
    // Ensure the target index was found
    if (index == -1) {
        return;
    }
    // Determine the location index
    int targetIndex = index;
    if (targetLocation == ViewerDropAdapter.LOCATION_AFTER) {
        targetIndex++;
    }
    // Add source as sibling of target      
    entry.addToken(sourcePlugin, targetIndex);
}

From source file:com.siteview.mde.internal.ui.editor.monitor.ExecutionEnvironmentSection.java

License:Open Source License

public boolean canDropMove(Object targetObject, Object[] sourceObjects, int targetLocation) {
    // Sanity check
    if (validateDropMoveSanity(targetObject, sourceObjects) == false) {
        return false;
    }// w  w w  . jav  a2 s .c om
    // Multiple selection not supported
    ExecutionEnvironment sourceEEObject = (ExecutionEnvironment) sourceObjects[0];
    ExecutionEnvironment targetEEObject = (ExecutionEnvironment) targetObject;
    // Validate model
    if (validateDropMoveModel(sourceEEObject, targetEEObject) == false) {
        return false;
    }
    // Validate move
    if (targetLocation == ViewerDropAdapter.LOCATION_BEFORE) {
        // Get the previous element of the target 
        RequiredExecutionEnvironmentHeader header = getHeader();
        // Ensure we have a header
        if (header == null) {
            return false;
        }
        // Get the previous element of the target
        PDEManifestElement previousElement = header.getPreviousElement(targetEEObject);
        // Ensure the previous element is not the source
        if (sourceEEObject.equals(previousElement)) {
            return false;
        }
        return true;
    } else if (targetLocation == ViewerDropAdapter.LOCATION_AFTER) {
        // Get the next element of the target 
        RequiredExecutionEnvironmentHeader header = getHeader();
        // Ensure we have a header
        if (header == null) {
            return false;
        }
        // Get the next element of the target
        PDEManifestElement nextElement = header.getNextElement(targetEEObject);
        // Ensure the next element is not the source
        if (sourceEEObject.equals(nextElement)) {
            return false;
        }
        return true;
    } else if (targetLocation == ViewerDropAdapter.LOCATION_ON) {
        // Not supported
        return false;
    }
    return false;
}

From source file:com.siteview.mde.internal.ui.editor.monitor.ExecutionEnvironmentSection.java

License:Open Source License

public void doDropMove(Object targetObject, Object[] sourceObjects, int targetLocation) {
    // Sanity check
    if (validateDropMoveSanity(targetObject, sourceObjects) == false) {
        Display.getDefault().beep();//from  w w w. j av a 2s. co  m
        return;
    }
    // Multiple selection not supported
    ExecutionEnvironment sourceEEObject = (ExecutionEnvironment) sourceObjects[0];
    ExecutionEnvironment targetEEObject = (ExecutionEnvironment) targetObject;
    // Validate move
    if (targetLocation == ViewerDropAdapter.LOCATION_BEFORE) {
        // Get the header
        RequiredExecutionEnvironmentHeader header = getHeader();
        // Ensure we have a header
        if (header == null) {
            return;
        }
        // Get the index of the target
        int index = header.indexOf(targetEEObject);
        // Ensure the target index was found
        if (index == -1) {
            return;
        }
        // Add source as sibling of target (before)         
        header.addExecutionEnvironment(sourceEEObject, index);
        return;
    } else if (targetLocation == ViewerDropAdapter.LOCATION_AFTER) {
        // Get the header
        RequiredExecutionEnvironmentHeader header = getHeader();
        // Ensure we have a header
        if (header == null) {
            return;
        }
        // Get the index of the target
        int index = header.indexOf(targetEEObject);
        // Ensure the target index was found
        if (index == -1) {
            return;
        }
        // Add source as sibling of target (before)         
        header.addExecutionEnvironment(sourceEEObject, index + 1);
        return;
    } else if (targetLocation == ViewerDropAdapter.LOCATION_ON) {
        // NO-OP.  Not supported
    }
}

From source file:com.siteview.mde.internal.ui.editor.monitor.ExtensionsSection.java

License:Open Source License

/**
 * @param targetElementObject//from   w  ww.  j  av  a  2 s  .  co  m
 * @param sourceElementObject
 * @param targetLocation
 */
private boolean canDropMove(IMonitorElement targetElementObject, IMonitorElement sourceElementObject,
        int targetLocation) {

    // Verify that the source is not the parent of the target
    if (validateDropMoveParent(targetElementObject, sourceElementObject) == false) {
        return false;
    }

    if (targetLocation == ViewerDropAdapter.LOCATION_BEFORE) {
        IDocumentElementNode previousNode = ((IDocumentElementNode) targetElementObject).getPreviousSibling();
        if (sourceElementObject.equals(previousNode)) {
            return false;
        }
        IMonitorObject targetParentObject = targetElementObject.getParent();
        if ((targetParentObject instanceof IMonitorParent) == false) {
            return false;
        }
        // Paste element as a sibling of the other element (before)
        return validateDropMoveSchema((IMonitorParent) targetParentObject, sourceElementObject);
    } else if (targetLocation == ViewerDropAdapter.LOCATION_AFTER) {
        IDocumentElementNode nextNode = ((IDocumentElementNode) sourceElementObject).getPreviousSibling();
        if (targetElementObject.equals(nextNode)) {
            return false;
        }
        IMonitorObject targetParentObject = targetElementObject.getParent();
        if ((targetParentObject instanceof IMonitorParent) == false) {
            return false;
        }
        // Paste element as a sibling of the other element (after)
        return validateDropMoveSchema((IMonitorParent) targetParentObject, sourceElementObject);
    } else if (targetLocation == ViewerDropAdapter.LOCATION_ON) {
        IDocumentElementNode targetExtensionNode = (IDocumentElementNode) targetElementObject;
        int childCount = targetExtensionNode.getChildCount();
        if (childCount != 0) {
            IDocumentElementNode lastNode = targetExtensionNode.getChildAt(childCount - 1);
            if (sourceElementObject.equals(lastNode)) {
                return false;
            }
        }
        // Paste element as the last child of the element
        return validateDropMoveSchema(targetElementObject, sourceElementObject);
    }
    return false;
}

From source file:com.siteview.mde.internal.ui.editor.monitor.ExtensionsSection.java

License:Open Source License

/**
 * @param targetExtensionObject/*from   ww  w.j a  va2  s  .c o m*/
 * @param sourceElementObject
 * @param targetLocation
 */
private boolean canDropMove(IMonitorExtension targetExtensionObject, IMonitorElement sourceElementObject,
        int targetLocation) {

    if (targetLocation == ViewerDropAdapter.LOCATION_BEFORE) {
        return false;
    } else if (targetLocation == ViewerDropAdapter.LOCATION_AFTER) {
        return false;
    } else if (targetLocation == ViewerDropAdapter.LOCATION_ON) {
        IDocumentElementNode targetExtensionNode = (IDocumentElementNode) targetExtensionObject;
        int childCount = targetExtensionNode.getChildCount();
        if (childCount != 0) {
            IDocumentElementNode lastNode = targetExtensionNode.getChildAt(childCount - 1);
            if (sourceElementObject.equals(lastNode)) {
                return false;
            }
        }
        // Paste element as the last child of the extension
        return validateDropMoveSchema(targetExtensionObject, sourceElementObject);
    }
    return false;
}

From source file:com.siteview.mde.internal.ui.editor.monitor.ExtensionsSection.java

License:Open Source License

/**
 * @param targetExtensionObject// w  w w . j a v  a  2s  .  co m
 * @param sourceExtensionObject
 * @param targetLocation
 */
private boolean canDropMove(IMonitorExtension targetExtensionObject, IMonitorExtension sourceExtensionObject,
        int targetLocation) {

    if (targetLocation == ViewerDropAdapter.LOCATION_BEFORE) {
        IDocumentElementNode previousNode = ((IDocumentElementNode) targetExtensionObject).getPreviousSibling();
        if (sourceExtensionObject.equals(previousNode)) {
            return false;
        }
        // Paste extension as sibling of extension (before)
        return true;
    } else if (targetLocation == ViewerDropAdapter.LOCATION_AFTER) {
        IDocumentElementNode nextNode = ((IDocumentElementNode) sourceExtensionObject).getPreviousSibling();
        if (targetExtensionObject.equals(nextNode)) {
            return false;
        }
        // Paste extension as sibling of extension (after)
        return true;
    } else if (targetLocation == ViewerDropAdapter.LOCATION_ON) {
        return false;
    }
    return false;
}

From source file:com.siteview.mde.internal.ui.editor.monitor.ExtensionsSection.java

License:Open Source License

/**
 * @param targetExtensionObject/*from  w ww  .j a v  a 2 s . c om*/
 * @param sourceExtensionObject
 * @param targetLocation
 */
private void doDropMove(IMonitorExtension targetExtensionObject, IMonitorExtension sourceExtensionObject,
        int targetLocation) throws CoreException {
    // Get the model
    IMonitorModelBase model = getPluginModelBase();
    // Ensure the model is defined
    if (model == null) {
        return;
    }
    // Get the plugin base
    IMonitorBase pluginBase = model.getMonitorBase();
    // Ensure the plugin base is a document node
    if ((pluginBase instanceof IDocumentElementNode) == false) {
        return;
    } else if ((pluginBase instanceof MonitorBaseNode) == false) {
        return;
    }
    // Plug-in base node
    IDocumentElementNode pluginBaseNode = (IDocumentElementNode) pluginBase;
    // Source extension node
    IDocumentElementNode sourceExtensionNode = (IDocumentElementNode) sourceExtensionObject;
    // Target extension node
    IDocumentElementNode targetExtensionNode = (IDocumentElementNode) targetExtensionObject;
    // Do drop move
    if (targetLocation == ViewerDropAdapter.LOCATION_BEFORE) {
        // Adjust all the source object transient field values to
        // acceptable values
        sourceExtensionNode.reconnect(pluginBaseNode, model);
        // Get index of target extension
        int index = (pluginBaseNode.indexOf(targetExtensionNode));
        // Ensure the target index was found
        if (index == -1) {
            return;
        }
        // Paste extension as sibling of extension (before)
        ((MonitorBaseNode) pluginBaseNode).add(sourceExtensionObject, index);
    } else if (targetLocation == ViewerDropAdapter.LOCATION_AFTER) {
        // Adjust all the source object transient field values to
        // acceptable values
        sourceExtensionNode.reconnect(pluginBaseNode, model);
        // Get index of target extension
        int index = (pluginBaseNode.indexOf(targetExtensionNode));
        // Ensure the target index was found
        if (index == -1) {
            return;
        }
        // Paste extension as sibling of extension (after)
        ((MonitorBaseNode) pluginBaseNode).add(sourceExtensionObject, index + 1);
    } else if (targetLocation == ViewerDropAdapter.LOCATION_ON) {
        // NO-OP
    }
}

From source file:com.siteview.mde.internal.ui.editor.monitor.ExtensionsSection.java

License:Open Source License

/**
 * @param targetExtensionObject/*  ww w  . j a v  a2  s  .c  om*/
 * @param sourceElementObject
 * @param targetLocation
 */
private void doDropMove(IMonitorExtension targetExtensionObject, IMonitorElement sourceElementObject,
        int targetLocation) throws CoreException {
    // Get the model
    IMonitorModelBase model = getPluginModelBase();
    // Ensure the model is defined
    if (model == null) {
        return;
    }
    // Target extension node
    IDocumentElementNode targetExtensionNode = (IDocumentElementNode) targetExtensionObject;
    // Source extension node
    IDocumentElementNode sourceElementNode = (IDocumentElementNode) sourceElementObject;
    // Do drop move
    if (targetLocation == ViewerDropAdapter.LOCATION_BEFORE) {
        // NO-OP
    } else if (targetLocation == ViewerDropAdapter.LOCATION_AFTER) {
        // NO-OP
    } else if (targetLocation == ViewerDropAdapter.LOCATION_ON) {
        // Adjust all the source object transient field values to
        // acceptable values
        sourceElementNode.reconnect(targetExtensionNode, model);
        // Paste element as the last child of the extension
        targetExtensionObject.add(sourceElementObject);
    }
}