public boolean equals(Object object) { if (!(object instanceof ActionUrl)) { return false; } ActionUrl url = (ActionUrl) object; Object comp = myComponent instanceof Pair ? ((Pair) myComponent).first : myComponent; Object thatComp = url.myComponent instanceof Pair ? ((Pair) url.myComponent).first : url.myComponent; return Comparing.equal(comp, thatComp) && myGroupPath.equals(url.myGroupPath) && myAbsolutePosition == url.getAbsolutePosition(); }
private static void removePathFromActionsTree(JTree tree, ActionUrl url) { if (url.myComponent == null) return; final TreePath treePath = CustomizationUtil.getTreePath(tree, url); if (treePath == null) return; DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent(); final int absolutePosition = url.getAbsolutePosition(); if (node.getChildCount() > absolutePosition && absolutePosition >= 0) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(absolutePosition); if (child.getUserObject().equals(url.getComponent())) { node.remove(child); } } }
private static void addPathToActionsTree(JTree tree, ActionUrl url) { final TreePath treePath = CustomizationUtil.getTreePath(tree, url); if (treePath == null) return; DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent(); final int absolutePosition = url.getAbsolutePosition(); if (node.getChildCount() >= absolutePosition && absolutePosition >= 0) { if (url.getComponent() instanceof Group) { node.insert(ActionsTreeUtil.createNode((Group) url.getComponent()), absolutePosition); } else { node.insert(new DefaultMutableTreeNode(url.getComponent()), absolutePosition); } } }
private void patchActionsTreeCorrespondingToSchema(DefaultMutableTreeNode root) { root.removeAllChildren(); if (mySelectedSchema != null) { mySelectedSchema.fillActionGroups(root); for (final ActionUrl actionUrl : mySelectedSchema.getActions()) { ActionUrl.changePathInActionsTree(myActionsTree, actionUrl); } } ((DefaultTreeModel) myActionsTree.getModel()).reload(); }
private static void movePathInActionsTree(JTree tree, ActionUrl url) { final TreePath treePath = CustomizationUtil.getTreePath(tree, url); if (treePath != null) { if (treePath.getLastPathComponent() != null) { final DefaultMutableTreeNode parent = ((DefaultMutableTreeNode) treePath.getLastPathComponent()); final int absolutePosition = url.getAbsolutePosition(); final int initialPosition = url.getInitialPosition(); if (parent.getChildCount() > absolutePosition && absolutePosition >= 0) { if (parent.getChildCount() > initialPosition && initialPosition >= 0) { final DefaultMutableTreeNode child = (DefaultMutableTreeNode) parent.getChildAt(initialPosition); if (child.getUserObject().equals(url.getComponent())) { parent.remove(child); parent.insert(child, absolutePosition); } } } } } }
private List<ActionUrl> findActionsUnderSelection() { final ArrayList<ActionUrl> actions = new ArrayList<ActionUrl>(); final TreePath[] selectionPaths = myActionsTree.getSelectionPaths(); if (selectionPaths != null) { for (TreePath path : selectionPaths) { final ActionUrl selectedUrl = CustomizationUtil.getActionUrl(path, ActionUrl.MOVE); final ArrayList<String> selectedGroupPath = new ArrayList<String>(selectedUrl.getGroupPath()); final Object component = selectedUrl.getComponent(); if (component instanceof Group) { selectedGroupPath.add(((Group) component).getName()); for (ActionUrl action : mySelectedSchema.getActions()) { final ArrayList<String> groupPath = action.getGroupPath(); final int idx = Collections.indexOfSubList(groupPath, selectedGroupPath); if (idx > -1) { actions.add(action); } } } } } return actions; }