Java 类javax.swing.tree.TreeNode 实例源码

项目:hml    文件:TreePanel.java   
private void expandAll(JTree tree, TreePath path, boolean expand) {
    TreeNode node = (TreeNode) path.getLastPathComponent();

    if (node.getChildCount() >= 0) {
        Enumeration enumeration = node.children();
        while (enumeration.hasMoreElements()) {
            TreeNode n = (TreeNode) enumeration.nextElement();
            TreePath p = path.pathByAddingChild(n);

            expandAll(tree, p, expand);
        }
    }

    if (expand) {
        tree.expandPath(path);
    } else {
        tree.collapsePath(path);
    }
}
项目:incubator-netbeans    文件:ASTBrowserTopComponent.java   
private void initChildren () {
    if (children != null) return;
    children = new ArrayList<TreeNode> ();
    map = new HashMap<ASTItem,TreeNode> ();
    if (astItem == null) return;
    List<ASTItem> chList = astItem.getChildren ();

    if (chList != null) {
        Iterator<ASTItem> it = chList.iterator ();
        while (it.hasNext ()) {
            ASTItem item = it.next ();
            TreeNode tn = new TNode (this, item);
            children.add (tn);
            map.put (item, tn);
        }
    }
}
项目:incubator-netbeans    文件:ProfilerTreeTable.java   
private Comparator getComparator() {
    SortOrder sortOrder = getSortOrder();
    if (SortOrder.UNSORTED.equals(sortOrder)) return null;

    final boolean ascending = SortOrder.ASCENDING.equals(sortOrder);
    final int sortColumn = getSortColumn();
    boolean sortingTree = JTree.class.equals(model.getColumnClass(sortColumn));
    final Comparator comparator = sortingTree ? null : getComparator(sortColumn);

    return new Comparator() {
        public int compare(Object o1, Object o2) {
            int result;
            if (comparator == null) {
                String s1 = o1.toString();
                String s2 = o2.toString();
                result = s1.compareTo(s2);
            } else {
                Object v1 = model.getValueAt((TreeNode)o1, sortColumn);
                Object v2 = model.getValueAt((TreeNode)o2, sortColumn);
                result = comparator.compare(v1, v2);
            }

            return ascending ? result : result * -1;
        }
    };
}
项目:incubator-netbeans    文件:ASTBrowserTopComponent.java   
public void caretUpdate (CaretEvent e) {
    if (rootNode == null) return;
    ASTPath path = rootNode.findPath (e.getDot ());
    if (path == null) return;
    TreeNode tNode = (TreeNode) tree.getModel ().getRoot ();
    List<TreeNode> treePath = new ArrayList<TreeNode> ();
    Iterator it = path.listIterator ();
    if (!it.hasNext ()) return;
    it.next ();
    treePath.add (tNode);
    while (tNode instanceof TNode && it.hasNext ()) {
        tNode = ((TNode) tNode).getTreeNode (it.next ());
        if (tNode == null) throw new NullPointerException ();
        treePath.add (tNode);
    }
    TreePath treePath2 = new TreePath (treePath.toArray ());
    DefaultTreeModel model = new DefaultTreeModel ((TreeNode) tree.getModel ().getRoot ());
    tree.setModel (model);
    tree.setSelectionPath (treePath2);
    tree.scrollPathToVisible (treePath2);
}
项目:openjdk-jdk10    文件:ElementTreePanel.java   
/**
 * Invoke this method after you've changed how node is to be
 * represented in the tree.
 */
@Override
public void nodeChanged(TreeNode node) {
    if (listenerList != null && node != null) {
        TreeNode parent = node.getParent();

        if (parent == null && node != root) {
            parent = root;
        }
        if (parent != null) {
            int anIndex = getIndexOfChild(parent, node);

            if (anIndex != -1) {
                int[] cIndexs = new int[1];

                cIndexs[0] = anIndex;
                nodesChanged(parent, cIndexs);
            }
        }
    }
}
项目:marathonv5    文件:AssertionTreeNode.java   
@Override public TreeNode getChildAt(int index) {
    if (object instanceof List) {
        return getNodeForList((List<?>) object, index);
    }
    if (object instanceof Map) {
        return getNodeForMap((Map<?, ?>) object, index);
    }
    Method method;
    if (object instanceof RComponent) {
        Method o = ((RComponent) object).getMethods().get(index);
        method = o;
    } else {
        method = getMethods(object).get(index);
    }
    return getNodeForMethod(method);
}
项目:Luyten4Forge    文件:Model.java   
@Override
public void treeExpanded(final TreeExpansionEvent event) {
    final TreePath treePath = event.getPath();

    final Object expandedTreePathObject = treePath.getLastPathComponent();
    if (!(expandedTreePathObject instanceof TreeNode)) {
        return;
    }

    final TreeNode expandedTreeNode = (TreeNode) expandedTreePathObject;
    if (expandedTreeNode.getChildCount() == 1) {
        final TreeNode descendantTreeNode = expandedTreeNode.getChildAt(0);

        if (descendantTreeNode.isLeaf()) {
            return;
        }

        final TreePath nextTreePath = treePath.pathByAddingChild(descendantTreeNode);
        tree.expandPath(nextTreePath);
    }
}
项目:incubator-netbeans    文件:OutlineView152857Test.java   
public void testRemoveNodeInOutlineView () throws InterruptedException {
    StringKeys children = new StringKeys (true);
    children.doSetKeys (new String [] {"1", "3", "2"});
    Node root = new TestNode (children, "root");
    comp = new OutlineViewComponent (root);
    ETableColumnModel etcm = (ETableColumnModel) comp.getOutlineView ().getOutline ().getColumnModel ();
    ETableColumn etc = (ETableColumn) etcm.getColumn (0); // tree column
    etcm.setColumnSorted (etc, true, 1); // ascending order

    TreeNode ta = Visualizer.findVisualizer(root);

    DialogDescriptor dd = new DialogDescriptor (comp, "", false, null);
    Dialog d = DialogDisplayer.getDefault ().createDialog (dd);
    d.setVisible (true);

    Thread.sleep (1000);
    ((StringKeys) root.getChildren ()).doSetKeys (new String [] {"1", "2"});
    Thread.sleep (1000);

    assertEquals ("Node on 0nd position is '1'", "1", ta.getChildAt (0).toString ());
    assertEquals ("Node on 1st position is '2'", "2", ta.getChildAt (1).toString ());

    d.setVisible (false);
}
项目:incubator-netbeans    文件:TreeTableView152857Test.java   
public void testRemoveNodeInTTV () throws InterruptedException {
    StringKeys children = new StringKeys (true);
    children.doSetKeys (new String [] {"1", "3", "2"});
    Node root = new TestNode (children, "root");
    view = new TTV (root);
    TreeNode ta = Visualizer.findVisualizer(root);

    DialogDescriptor dd = new DialogDescriptor (view, "", false, null);
    Dialog d = DialogDisplayer.getDefault ().createDialog (dd);
    makeVisible(d);
    ((StringKeys) root.getChildren ()).doSetKeys (new String [] {"1", "2"});
    Thread.sleep (1000);

    assertEquals ("Node on 0nd position is '1'", "1", ta.getChildAt (0).toString ());
    assertEquals ("Node on 1st position is '2'", "2", ta.getChildAt (1).toString ());

    d.setVisible (false);
}
项目:Cognizant-Intelligent-Test-Scripter    文件:JCheckBoxTree.java   
/**
 * iterate through every child and do the action
 *
 * @param parent
 * @param expand
 */
private void expandAll(TreePath parent, boolean expand) {
    TreeNode node = (TreeNode) parent.getLastPathComponent();
    if (getChildCount(node) >= 0) {
        for (int i = 0; i < getChildCount(node); i++) {
            TreePath path = parent.pathByAddingChild(getChildAt(node, i));
            expandAll(path, expand);
        }
    }
    if (expand) {
        expandPath(parent);
    } else {
        collapsePath(parent);
    }

}
项目:JavaGraph    文件:StateTree.java   
/**
 * Retrieves the child of a given parent node that is
 * a numbered tree node with a given number, if any.
 * @return the correctly numbered child, or {@code null} if there
 * is none such
 */
private NumberedTreeNode find(TreeNode parent, int number) {
    NumberedTreeNode result = null;
    int lower = 0;
    int upper = parent.getChildCount() - 1;
    boolean found = false;
    while (!found && lower <= upper) {
        int mid = (lower + upper) / 2;
        result = (NumberedTreeNode) parent.getChildAt(mid);
        int resultNumber = result.getNumber();
        if (result.contains(number)) {
            found = true;
        } else if (resultNumber < number) {
            lower = mid + 1;
        } else if (resultNumber > number) {
            upper = mid - 1;
        }
    }
    return found ? result : null;
}
项目:incubator-netbeans    文件:ManageInspectionsOperatot.java   
private TreeNode[] getPath(Object node, String deap, String item, boolean debug) {
    if (node instanceof DefaultMutableTreeNode) {
        DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) node;
        if (debug) {
            System.out.println(deap + dmtn.toString());
        }
        if (dmtn.toString().equals(item)) {
            if (debug) {
                System.out.println("EQUAL!!! <" + item + ">");
            }
            return dmtn.getPath();
        }
        TreeNode[] curPath;
        for (int i = 0; i < dmtn.getChildCount(); i++) {
            curPath = getPath(dmtn.getChildAt(i), deap + "__", item, debug);
            if (curPath != null) {
                return curPath;
            }
        }
    }
    return null;
}
项目:incubator-netbeans    文件:Tab.java   
private void scrollNodeToVisible( final Node n ) {
    EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            TreeNode tn = Visualizer.findVisualizer(n);
            if (tn == null) {
                return;
            }
            TreeModel model = tree.getModel();
            if (!(model instanceof DefaultTreeModel)) {
                return;
            }
            TreePath path = new TreePath(((DefaultTreeModel) model).getPathToRoot(tn));
            if( null == path )
                return;
            Rectangle r = tree.getPathBounds(path);
            if (r != null) {
                tree.scrollRectToVisible(r);
            }
        }
    });
}
项目:incubator-netbeans    文件:DirectoryChooserUI.java   
private void applyEdit(DirectoryNode node) {
    TreeNode[] nodes = model.getPathToRoot(node);
    TreePath editingPath = new TreePath(nodes);
    tree.setEditable(true);
    tree.makeVisible(editingPath);
    tree.scrollPathToVisible(editingPath);
    tree.setSelectionPath(editingPath);
    tree.startEditingAtPath(editingPath);

    JTextField editField = DirectoryCellEditor.getTextField();
    editField.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    editField.setRequestFocusEnabled(true);
    editField.requestFocus();
    editField.setSelectionStart(0);
    editField.setSelectionEnd(editField.getText().length());
}
项目:incubator-netbeans    文件:AllocTreeTableView.java   
protected SearchUtils.TreeHelper getSearchHelper() {
    return new SearchUtils.TreeHelper() {
        public int getNodeType(TreeNode tnode) {
            PresoObjAllocCCTNode node = (PresoObjAllocCCTNode)tnode;
            CCTNode parent = node.getParent();
            if (parent == null) return SearchUtils.TreeHelper.NODE_SKIP_DOWN; // invisible root

            if (parent.getParent() == null) {
                if (searchObjects) {
                    return searchAllocations ? SearchUtils.TreeHelper.NODE_SEARCH_DOWN :
                                               SearchUtils.TreeHelper.NODE_SEARCH_NEXT;
                } else {
                    return searchAllocations ? SearchUtils.TreeHelper.NODE_SKIP_DOWN :
                                               SearchUtils.TreeHelper.NODE_SKIP_NEXT;
                }
            }

            return searchAllocations ? SearchUtils.TreeHelper.NODE_SEARCH_DOWN :
                                       SearchUtils.TreeHelper.NODE_SKIP_NEXT;
        }
    };
}
项目:Cognizant-Intelligent-Test-Scripter    文件:JCheckBoxTree.java   
private void resetCheckingState() {
    nodesCheckingState = new HashMap<>();
    checkedPaths = new ArrayList<TreePath>() {
        @Override
        public boolean add(TreePath e) {
            if (!contains(e)) {
                return super.add(e);
            }
            return false;
        }

    };
    if (getModel() == null) {
        return;
    }
    TreeNode node = (TreeNode) getModel().getRoot();
    if (node == null) {
        return;
    }
    addSubtreeToCheckingStateTracking(node);
}
项目:incubator-netbeans    文件:LivenessTreeTableView.java   
protected SearchUtils.TreeHelper getSearchHelper() {
    return new SearchUtils.TreeHelper() {
        public int getNodeType(TreeNode tnode) {
            PresoObjAllocCCTNode node = (PresoObjAllocCCTNode)tnode;
            CCTNode parent = node.getParent();
            if (parent == null) return SearchUtils.TreeHelper.NODE_SKIP_DOWN; // invisible root

            if (parent.getParent() == null) {
                if (searchObjects) {
                    return searchAllocations ? SearchUtils.TreeHelper.NODE_SEARCH_DOWN :
                                               SearchUtils.TreeHelper.NODE_SEARCH_NEXT;
                } else {
                    return searchAllocations ? SearchUtils.TreeHelper.NODE_SKIP_DOWN :
                                               SearchUtils.TreeHelper.NODE_SKIP_NEXT;
                }
            }

            return searchAllocations ? SearchUtils.TreeHelper.NODE_SEARCH_DOWN :
                                       SearchUtils.TreeHelper.NODE_SKIP_NEXT;
        }
    };
}
项目:incubator-netbeans    文件:LivenessTreeTableView.java   
public Object getValueAt(TreeNode node, int columnIndex) {
    PresoObjLivenessCCTNode livenessNode = (PresoObjLivenessCCTNode)node;

    if (selection == null) columnIndex++;

    if (columnIndex == 1) {
        return livenessNode.getNodeName();
    } else if (columnIndex == 2) {
        return livenessNode.totalObjSize;
    } else if (columnIndex == 3) {
        return livenessNode.nLiveObjects;
    } else if (columnIndex == 4) {
        return livenessNode.nCalls;
    } else if (columnIndex == 5) {
        return livenessNode.avgObjectAge;
    } else if (columnIndex == 6) {
        return livenessNode.survGen;
    } else if (columnIndex == 7) {
        return livenessNode.nTotalAllocObjects;
    } else if (columnIndex == 0) {
        if (selection.isEmpty()) return Boolean.FALSE;
        return selection.contains(nodesMap.get(node));
    }

    return null;
}
项目:rapidminer    文件:PlotConfigurationTreeTransferHandler.java   
/**
 * @param container
 * @param comp
 * @param childIndex
 * @param container2
 */
private String canImportRangeAxis(Component container, TreeNode treeNode, int childIndex, Component container2) {
    String importAction = I18N.getGUILabel("plotter.drag_and_drop.axis_drop.move_axis");

    // RangeAxisConfigTreeNode can only be dropped on PlotConfigTreeNodes
    if (!(treeNode instanceof PlotConfigurationTreeNode)) {
        updateToolTip(container, I18N.getGUILabel("plotter.drag_and_drop.axis_drop.cant_drop_axis_config"));
        return null;
    }
    // can only be dropped below static dimension configs
    if (childIndex > -1 && childIndex < PlotConfigurationTreeModel.NUMBER_OF_PERMANENT_DIMENSIONS) {
        updateToolTip(container, I18N.getGUILabel("plotter.drag_and_drop.axis_drop.only_below_dims"));
        return null;
    }

    if (childIndex == -1) {
        return I18N.getGUILabel("plotter.drag_and_drop.axis_drop.move_to_end");
    }

    return importAction;
}
项目:OpenJSharp    文件:ElementTreePanel.java   
/**
 * Invoke this method after you've changed how node is to be
 * represented in the tree.
 */
@Override
public void nodeChanged(TreeNode node) {
    if (listenerList != null && node != null) {
        TreeNode parent = node.getParent();

        if (parent == null && node != root) {
            parent = root;
        }
        if (parent != null) {
            int anIndex = getIndexOfChild(parent, node);

            if (anIndex != -1) {
                int[] cIndexs = new int[1];

                cIndexs[0] = anIndex;
                nodesChanged(parent, cIndexs);
            }
        }
    }
}
项目:JavaGraph    文件:DisplayTreeNode.java   
@Override
public int compare(TreeNode o1, TreeNode o2) {
    int result = compare(o1 instanceof RecipeTreeNode, o2 instanceof RecipeTreeNode);
    if (result != 0) {
        return result;
    }
    result = compare(o1 instanceof ActionTreeNode, o2 instanceof ActionTreeNode);
    if (result != 0) {
        return result;
    }
    if (o1 instanceof ActionTreeNode) {
        result =
            compare(((ActionTreeNode) o2).isProperty(), ((ActionTreeNode) o1).isProperty());
        if (result != 0) {
            return result;
        }
    }
    return stringComparator.compare(o1.toString(), o2.toString());
}
项目:Cognizant-Intelligent-Test-Scripter    文件:JCheckBoxTree.java   
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
        boolean selected, boolean expanded, boolean leaf, int row,
        boolean hasFocus) {
    TreeNode node = (TreeNode) value;
    TreePath tp = new TreePath(getPath(node));
    CheckedNode cn = nodesCheckingState.get(tp);
    checkBox.setIcon(getIcon(value));
    if (cn == null) {
        return this;
    }
    checkBox.setSelected(cn.isSelected);
    checkBox.setText(node.toString());
    checkBox.setOpaque(cn.isSelected && cn.hasChildren && !cn.allChildrenSelected);
    return this;
}
项目:incubator-netbeans    文件:ProfilerTreeTable.java   
TreePath getNextPath(TreePath path, boolean down) {
    TreeModel _model = model.treeModel;
    TreeNode node = (TreeNode)path.getLastPathComponent();
    if (down && _model.getChildCount(node) > 0)
        return path.pathByAddingChild(_model.getChild(node, 0));

    TreePath parentPath = path.getParentPath();
    if (!down && parentPath == null)
        return path.pathByAddingChild(_model.getChild(node, 0));

    TreeNode parent = (TreeNode)parentPath.getLastPathComponent();
    int idx = _model.getIndexOfChild(parent, node) + 1;

    if (_model.getChildCount(parent) > idx)
        return parentPath.pathByAddingChild(_model.getChild(parent, idx));

    if (!down && parentPath.getParentPath() == null) {
        return parentPath.pathByAddingChild(_model.getChild(parent, 0));
    } else {
        return getNextPath(parentPath, false);
    }
}
项目:alevin-svn2    文件:DefaultSelectionTreeModel.java   
@Override
public Object getChild(Object parent, int index) {
    if (parent instanceof IProxy)
        return ((IProxy) parent).getChildAt(index);
    else if (parent instanceof TreeNode)
        return ((TreeNode) parent).getChildAt(index);
    else
        return null;
}
项目:alevin-svn2    文件:DefaultSelectionTreeModel.java   
@Override
public int getChildCount(Object parent) {
    if (parent instanceof IProxy)
        return ((IProxy) parent).getChildCount();
    else if (parent instanceof TreeNode)
        return ((TreeNode) parent).getChildCount();
    else
        return 0;
}
项目:JavaGraph    文件:ResourceTree.java   
@Override
public void mouseReleased(MouseEvent evt) {

    // find the node that belongs to this event
    TreeNode selected = getMousedNode(evt);

    // show popup menu
    if (evt.isPopupTrigger()) {
        showPopupMenu(selected, evt);
    }
}
项目:incubator-netbeans    文件:ProfilerTreeTable.java   
public final boolean equals(Object o) {
    if (o == this) return true;
    if (!(o instanceof TreePathKey)) return false;

    TreeNode[] _pathToRoot = ((TreePathKey)o).pathToRoot;
    if (pathToRoot.length != _pathToRoot.length) return false;
    for (int i = pathToRoot.length - 1; i >= 0 ; i--)
        if (!pathToRoot[i].equals(_pathToRoot[i])) return false;

    return true;
}
项目:incubator-netbeans    文件:TreeView.java   
/** Expands all paths.
*/
public void expandAll() {
    try {
        tree.setUI(null);
        TreeNode root = (TreeNode) tree.getModel().getRoot();
        expandOrCollapseAll(new TreePath(root), true);
    } finally {
        tree.updateUI();
    }
}
项目:marathonv5    文件:AssertionTreeNode.java   
private TreeNode getNodeForMethod(Method method) {
    Object r = null;
    try {
        method.setAccessible(true);
        r = method.invoke(object, new Object[] {});
    } catch (Throwable t) {
    }
    String p = getPropertyName(method.getName());
    return getNewNode(r, p);
}
项目:incubator-netbeans    文件:VisualizerSpeed95364Test.java   
private void doTest() {
    TreeNode tn = null;
    for (int i = 0; i < 100000; i++) {
        tn = toCheck.getChildAt(size/2);
    }
    assertEquals("One node created + 50 at begining", 51, chK.cnt);
}
项目:JavaGraph    文件:StateTree.java   
private void maybeShowPopup(MouseEvent evt) {
    if (evt.isPopupTrigger()) {
        TreePath selectedPath = getPathForLocation(evt.getX(), evt.getY());
        TreeNode selectedNode =
            selectedPath == null ? null : (TreeNode) selectedPath.getLastPathComponent();
        StateTree.this.requestFocus();
        createPopupMenu(selectedNode).show(evt.getComponent(), evt.getX(), evt.getY());
    }
}
项目:Logisim    文件:ComponentSelector.java   
@Override
public int getIndex(TreeNode n) {
    for (int i = 0; i < opts.length; i++) {
        if (opts[i] == n)
            return i;
    }
    return -1;
}
项目:incubator-netbeans    文件:VisualizerNodeTest.java   
public void testIndexOfProvidesResultsEvenIfTheVisualizerIsComputedViaDifferentMeans() throws Exception {
    AbstractNode a = new AbstractNode(new Children.Array());
    AbstractNode m = new AbstractNode(Children.LEAF);
    a.getChildren().add(new Node[] { Node.EMPTY.cloneNode(), m, Node.EMPTY.cloneNode() });

    TreeNode ta = Visualizer.findVisualizer(a);
    TreeNode tm = Visualizer.findVisualizer(m);

    assertEquals("Index is 1", 1, ta.getIndex(tm));
}
项目:sbc-qsystem    文件:FAdmin.java   
/**
 * Из привязок к услугам всех юзеров убрать привязку к данной услуге и всех ее вложенных.
 *
 * @param service удаляемая услуга
 */
private void deleteServicesFromUsers(QService service) {

    QServiceTree.sailToStorm(service, (TreeNode service1) -> {
        deleteServiceFromUsers((QService) service1);
    });
}
项目:Logisim    文件:SimulationTreeModel.java   
@Override
public int getChildCount(Object parent) {
    if (parent instanceof TreeNode) {
        return ((TreeNode) parent).getChildCount();
    } else {
        return 0;
    }
}
项目:Cognizant-Intelligent-Test-Scripter    文件:JCheckBoxTree.java   
protected void updatePredecessorsWithCheckMode(TreePath tp, boolean check) {
    TreePath parentPath = tp.getParentPath();
    // If it is the root, stop the recursive calls and return
    if (parentPath == null) {
        return;
    }
    CheckedNode parentCheckedNode = nodesCheckingState.get(parentPath);
    TreeNode parentNode = (TreeNode) parentPath.getLastPathComponent();
    parentCheckedNode.allChildrenSelected = true;
    parentCheckedNode.isSelected = false;
    for (int i = 0; i < getChildCount(parentNode); i++) {
        TreePath childPath = parentPath.pathByAddingChild(getChildAt(parentNode, i));
        CheckedNode childCheckedNode = nodesCheckingState.get(childPath);
        // It is enough that even one subtree is not fully selected
        // to determine that the parent is not fully selected
        if (!childCheckedNode.allChildrenSelected) {
            parentCheckedNode.allChildrenSelected = false;
        }
        // If at least one child is selected, selecting also the parent
        if (childCheckedNode.isSelected) {
            parentCheckedNode.isSelected = true;
        }
    }
    if (parentCheckedNode.isSelected) {
        checkedPaths.add(parentPath);
    } else {
        checkedPaths.remove(parentPath);
    }
    // Go to upper predecessor
    updatePredecessorsWithCheckMode(parentPath, check);
}
项目:fuck_zookeeper    文件:ZooInspectorTreeViewer.java   
public TreeNode getChildAt(int childIndex) {
    String child = zooInspectorManager.getNodeChild(this.nodePath,
            childIndex);
    if (child != null) {
        return new ZooInspectorTreeNode((this.nodePath.equals("/") ? ""
                : this.nodePath)
                + "/" + child, this);
    }
    return null;
}
项目:incubator-netbeans    文件:ExcludeDependencyPanel.java   
private TreeNode createTransitiveDependenciesList() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(null, true);
    Set<Artifact> artifacts = project.getArtifacts();
    Icon icn = ImageUtilities.image2Icon(ImageUtilities.loadImage(IconResources.TRANSITIVE_DEPENDENCY_ICON, true)); //NOI18N
    for (Artifact a : artifacts) {
        if (a.getDependencyTrail().size() > 2) {
            String label = a.getGroupId() + ":" + a.getArtifactId();
            root.add(new CheckNode(a, label, icn));
        }
    }
    return root;
}
项目:Cognizant-Intelligent-Test-Scripter    文件:XpathGenerator.java   
private static String getPosition(AndroidTreeNode node) {
    int count = 0;
    TreeNode parent = node.getParent();
    String nodeName = node.getClassName();
    for (int i = 0; i < parent.getChildCount(); i++) {
        AndroidTreeNode currNode = (AndroidTreeNode) parent.getChildAt(i);
        if (currNode.getClassName().equals(nodeName)) {
            count++;
            if (currNode.equals(node)) {
                return nodeName + "[" + count + "]";
            }
        }
    }
    return nodeName;
}
项目:Logisim    文件:ComponentSelector.java   
public CircuitNode(CircuitNode parent, CircuitState circuitState, Component subcircComp) {
    this.parent = parent;
    this.circuitState = circuitState;
    this.subcircComp = subcircComp;
    this.children = new ArrayList<TreeNode>();
    circuitState.getCircuit().addCircuitListener(this);
    computeChildren();
}