@Override
 protected Object[] getAllElements() {
   if (myCanExpand) {
     final Object root = myComponent.getModel().getRoot();
     if (root instanceof DefaultMutableTreeNode || root instanceof PathAwareTreeNode) {
       final List<TreePath> paths = new ArrayList<TreePath>();
       TreeUtil.traverseDepth(
           (TreeNode) root,
           new TreeUtil.Traverse() {
             @Override
             public boolean accept(Object node) {
               if (node instanceof DefaultMutableTreeNode) {
                 paths.add(new TreePath(((DefaultMutableTreeNode) node).getPath()));
               } else if (node instanceof PathAwareTreeNode) {
                 paths.add(((PathAwareTreeNode) node).getPath());
               }
               return true;
             }
           });
       return paths.toArray(new TreePath[paths.size()]);
     }
   }
   TreePath[] paths = new TreePath[myComponent.getRowCount()];
   for (int i = 0; i < paths.length; i++) {
     paths[i] = myComponent.getPathForRow(i);
   }
   return paths;
 }
 public void selectFirstBreakpoint() {
   TreeUtil.traverseDepth(
       myRootNode,
       new TreeUtil.Traverse() {
         public boolean accept(Object node) {
           final CheckedTreeNode treeNode = (CheckedTreeNode) node;
           final TreeDescriptor descriptor = (TreeDescriptor) treeNode.getUserObject();
           if (descriptor instanceof BreakpointDescriptor) {
             TreeUtil.selectNode(BreakpointTree.this, treeNode);
             return false;
           }
           return true;
         }
       });
 }
Ejemplo n.º 3
0
 protected static MyNode findNodeByCondition(
     final TreeNode root, final Condition<NamedConfigurable> condition) {
   final MyNode[] nodeToSelect = new MyNode[1];
   TreeUtil.traverseDepth(
       root,
       new TreeUtil.Traverse() {
         public boolean accept(Object node) {
           if (condition.value(((MyNode) node).getConfigurable())) {
             nodeToSelect[0] = (MyNode) node;
             return false;
           }
           return true;
         }
       });
   return nodeToSelect[0];
 }
Ejemplo n.º 4
0
 protected void clearChildren() {
   TreeUtil.traverseDepth(
       myRoot,
       new TreeUtil.Traverse() {
         public boolean accept(Object node) {
           if (node instanceof MyNode) {
             final MyNode treeNode = ((MyNode) node);
             treeNode.getConfigurable().disposeUIResources();
             if (!(treeNode instanceof MyRootNode)) {
               treeNode.setUserObject(null);
             }
           }
           return true;
         }
       });
   myRoot.removeAllChildren();
 }
Ejemplo n.º 5
0
 public boolean isModified() {
   if (myHasDeletedItems) return true;
   final boolean[] modified = new boolean[1];
   TreeUtil.traverseDepth(
       myRoot,
       new TreeUtil.Traverse() {
         public boolean accept(Object node) {
           if (node instanceof MyNode) {
             final NamedConfigurable configurable = ((MyNode) node).getConfigurable();
             if (isInitialized(configurable) && configurable.isModified()) {
               modified[0] = true;
               return false;
             }
           }
           return true;
         }
       });
   return modified[0];
 }
Ejemplo n.º 6
0
 public List<PackagingElementNode<?>> findNodes(
     final Collection<? extends PackagingElement<?>> elements) {
   final List<PackagingElementNode<?>> nodes = new ArrayList<PackagingElementNode<?>>();
   TreeUtil.traverseDepth(
       getRootNode(),
       new TreeUtil.Traverse() {
         public boolean accept(Object node) {
           final Object userObject = ((DefaultMutableTreeNode) node).getUserObject();
           if (userObject instanceof PackagingElementNode) {
             final PackagingElementNode<?> packagingNode = (PackagingElementNode<?>) userObject;
             final List<? extends PackagingElement<?>> nodeElements =
                 packagingNode.getPackagingElements();
             if (ContainerUtil.intersects(nodeElements, elements)) {
               nodes.add(packagingNode);
             }
           }
           return true;
         }
       });
   return nodes;
 }
 public Breakpoint[] getSelectedBreakpoints() {
   final TreePath[] selectionPaths = getSelectionPaths();
   if (selectionPaths == null || selectionPaths.length == 0) {
     return Breakpoint.EMPTY_ARRAY;
   }
   final List<Breakpoint> breakpoints = new ArrayList<Breakpoint>(selectionPaths.length);
   for (TreePath path : selectionPaths) {
     final CheckedTreeNode node = (CheckedTreeNode) path.getLastPathComponent();
     TreeUtil.traverseDepth(
         node,
         new TreeUtil.Traverse() {
           public boolean accept(Object _node) {
             final CheckedTreeNode node = (CheckedTreeNode) _node;
             final TreeDescriptor descriptor = (TreeDescriptor) node.getUserObject();
             if (descriptor instanceof BreakpointDescriptor) {
               breakpoints.add(((BreakpointDescriptor) descriptor).getBreakpoint());
             }
             return true;
           }
         });
   }
   return breakpoints.toArray(new Breakpoint[breakpoints.size()]);
 }
 protected void doOKAction() {
   final ActionManager actionManager = ActionManager.getInstance();
   TreeUtil.traverseDepth(
       (TreeNode) myTree.getModel().getRoot(),
       new TreeUtil.Traverse() {
         public boolean accept(Object node) {
           if (node instanceof DefaultMutableTreeNode) {
             final DefaultMutableTreeNode mutableNode = (DefaultMutableTreeNode) node;
             final Object userObject = mutableNode.getUserObject();
             if (userObject instanceof Pair) {
               String actionId = (String) ((Pair) userObject).first;
               final AnAction action = actionManager.getAction(actionId);
               Icon icon = (Icon) ((Pair) userObject).second;
               action.getTemplatePresentation().setIcon(icon);
               action.setDefaultIcon(icon == null);
               editToolbarIcon(actionId, mutableNode);
             }
           }
           return true;
         }
       });
   super.doOKAction();
   setCustomizationSchemaForCurrentProjects();
 }