List of usage examples for org.eclipse.jface.viewers ViewerDropAdapter LOCATION_ON
int LOCATION_ON
To view the source code for org.eclipse.jface.viewers ViewerDropAdapter LOCATION_ON.
Click Source Link
From source file:ar.com.fluxit.jqa.viewer.LayersListTableDropListener.java
License:Open Source License
@Override public boolean validateDrop(Object target, int operation, TransferData data) { final boolean result = determineLocation(getCurrentEvent()) == ViewerDropAdapter.LOCATION_ON; if (result) { Layer targetLayer = (Layer) determineTarget(getCurrentEvent()); getViewer().setSelection(new StructuredSelection(targetLayer)); getViewer().refresh();//from ww w. j a v a2 s . c o m } return result; }
From source file:ar.com.fluxit.jqa.viewer.LayersTableDropListener.java
License:Open Source License
@Override public boolean validateDrop(Object target, int operation, TransferData data) { final boolean result = determineLocation(getCurrentEvent()) == ViewerDropAdapter.LOCATION_ON; if (result) { // shows the current layer content LayerDescriptor targetLayer = (LayerDescriptor) determineTarget(getCurrentEvent()); getViewer().setSelection(new StructuredSelection(targetLayer)); getViewer().refresh();/*from w ww. j av a 2s . c om*/ } return result; }
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 w w w . j a v 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();//from w w w . j a va2 s .co 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; }/*ww w . j a v a 2 s. co 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();// ww w .ja va 2s .c o 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 w w .ja v a 2s.c o 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 w ww.j a v a 2 s .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 a va 2s. c o 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 v a 2 s . co m*/ * @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 } }