@Override public Action[] getActions(Object target, Object sender) { if (target == null) { return new Action[] {}; } Object parent = mibsTree.getParent(target); if (parent == null) { return new Action[] {}; } if (parent.equals(COMPILED)) { return new Action[] { ACTION_EVENTS, ACTION_COLLECT, ACTION_VIEW, ACTION_DELETE }; } else { return new Action[] { ACTION_EDIT, ACTION_DELETE, ACTION_COMPILE }; } }
@Override public boolean accept(DragAndDropEvent dragEvent) { try { TreeTargetDetails eventDetails = (TreeTargetDetails) dragEvent .getTargetDetails(); if (eventDetails.getItemIdOver() != null) { Object itemId = eventDetails.getItemIdOver(); int i = 0; while (itemId != null && (depthToCheck == -1 || i <= depthToCheck)) { if (itemId.equals(rootId)) { return true; } itemId = getParent(itemId); i++; } } return false; } catch (Exception e) { return false; } }
/** * If the event is on a node that can not have children (see * {@link Tree#areChildrenAllowed(Object)}), this method returns the * parent item id of the target item (see {@link #getItemIdOver()} ). * The identifier of the parent node is also returned if the cursor is * on the top part of node. Else this method returns the same as * {@link #getItemIdOver()}. * <p> * In other words this method returns the identifier of the "folder" * into the drag operation is targeted. * <p> * If the method returns null, the current target is on a root node or * on other undefined area over the tree component. * <p> * The default Tree implementation marks the targetted tree node with * CSS classnames v-tree-node-dragfolder and * v-tree-node-caption-dragfolder (for the caption element). */ public Object getItemIdInto() { Object itemIdOver = getItemIdOver(); if (areChildrenAllowed(itemIdOver) && getDropLocation() == VerticalDropLocation.MIDDLE) { return itemIdOver; } return getParent(itemIdOver); }