/** * Returns the position of the given event's coordinates relative to its target. * The position is determined to be before, after, or on the item, based on * some threshold value. * * @param event the event * @return one of the <code>LOCATION_* </code>constants defined in this class */ protected int determineLocation(DropTargetEvent event) { if (!(event.item instanceof Item)) { return LOCATION_NONE; } // Item item = (Item) event.item; Point coordinates = new Point(event.x, event.y); coordinates = getViewer().getControl().toControl(coordinates); // if (item != null) { // Rectangle bounds = getBounds(item); // if (bounds == null) { // return LOCATION_NONE; // } // if ((coordinates.y - bounds.y) < 5) { // return LOCATION_BEFORE; // } // if ((bounds.y + bounds.height - coordinates.y) < 5) { // return LOCATION_AFTER; // } // } return LOCATION_ON; }
} else { Object target = aDropTarget != null ? aDropTarget : getViewer().getInput(); CommonDropAdapterAssistant[] assistants = dndService .findCommonDropAdapterAssistants(target,
public void drop(DropTargetEvent event) { if (PluginTransfer.getInstance().isSupportedType(event.currentDataType)) { super.drop(event); } else { Object target = getCurrentTarget() != null ? getCurrentTarget() : getViewer().getInput(); CommonDropAdapterAssistant[] assistants = dndService .findCommonDropAdapterAssistants(target, getCurrentTransfer()); IStatus valid = null; for (int i = 0; i < assistants.length; i++) { try { valid = assistants[i].validateDrop(getCurrentTarget(), getCurrentOperation(), getCurrentTransfer()); if (valid != null && valid.isOK()) { assistants[i].handleDrop(this, event, getCurrentTarget()); return; } } catch (Throwable t) { NavigatorPlugin.logError(0, t.getMessage(), t); } } } }