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 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); } } } } } }