List of usage examples for org.eclipse.jface.viewers ViewerDropAdapter LOCATION_BEFORE
int LOCATION_BEFORE
To view the source code for org.eclipse.jface.viewers ViewerDropAdapter LOCATION_BEFORE.
Click Source Link
From source file:ca.uvic.cs.tagsea.dnd.RoutesTreeDragAndDropManager.java
License:Open Source License
@Override public boolean performDrop(Object data) { Object target = getCurrentTarget(); if (target == null) target = getViewer().getInput(); String[] toDrop = (String[]) data; Vector<Waypoint> waypoints = new Vector<Waypoint>(); for (String wpid : toDrop) { Waypoint w = TagSEAPlugin.getDefault().getTagCollection().getWaypointCollection().getWaypoint(wpid); if (w != null) waypoints.add(w);//ww w . ja v a2s . c om } TreeViewer viewer = (TreeViewer) getViewer(); Route route = null; int index = 0; if (target instanceof Route) { index = 0; route = (Route) target; } else if (target instanceof Waypoint) { route = (Route) fItem.getParentItem().getData(); for (TreeItem item : fItem.getParentItem().getItems()) { if (item == fItem) break; index++; } int location = getCurrentLocation(); if (location != ViewerDropAdapter.LOCATION_BEFORE) index += 1; } else return false; if (fSelection != null) { // we have an internal dnd // we will handle this in the drop operation as a special case if (getCurrentOperation() == DND.DROP_MOVE) { for (int i = waypoints.size() - 1; i >= 0; i--) route.getWaypoints().add(index, waypoints.get(i)); } } else { for (int i = waypoints.size() - 1; i >= 0; i--) route.getWaypoints().add(index, waypoints.get(i)); } viewer.reveal(fItem); viewer.refresh(); fItem = null; return true; }
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 . jav a 2 s. co 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();//from www. j av a 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.ExecutionEnvironmentSection.java
License:Open Source License
public boolean canDropMove(Object targetObject, Object[] sourceObjects, int targetLocation) { // Sanity check if (validateDropMoveSanity(targetObject, sourceObjects) == false) { return false; }/*from w ww . j a va 2 s. c o m*/ // 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 a v a 2s. c om*/ 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 ww w . j a v a 2 s. c om * @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/* w ww . j a v a 2s .c om*/ * @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//from w w w .j av a2s.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/* w w w . j a va2 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//from w w w.ja va 2 s . c o m * @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); } }