java类javax.swing.tree.TreeModel的实例源码

ProjectTab.java 文件源码 项目:incubator-netbeans 阅读 24 收藏 0 点赞 0 评论 0
public void scrollToNode(final Node n) {
        // has to be delayed to be sure that events for Visualizers
        // were processed and TreeNodes are already in hierarchy
        SwingUtilities.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));
                Rectangle r = tree.getPathBounds(path);
                if (r != null) {
                    tree.scrollRectToVisible(r);
                }
            }
        });
}
DefaultOutlineModel.java 文件源码 项目:incubator-netbeans 阅读 21 收藏 0 点赞 0 评论 0
/** Creates a new instance of DefaultOutlineModel.  <strong><b>Note</b> 
 * Do not fire table structure changes from the wrapped TableModel (value
 * changes are okay).  Changes that affect the number of rows must come
 * from the TreeModel.
 * @param treeModel The tree model
 * @param tableModel The table model
 * @param largeModel <code>true</code> if it's a large model tree, <code>false</code> otherwise.
 * @param nodesColumnLabel Label of the node's column
 */
protected DefaultOutlineModel(TreeModel treeModel, TableModel tableModel, boolean largeModel, String nodesColumnLabel) {
    this.treeModel = treeModel;
    this.tableModel = tableModel;
    if (nodesColumnLabel != null) {
        this.nodesColumnLabel = nodesColumnLabel;
    }

    layout = largeModel ? (AbstractLayoutCache) new FixedHeightLayoutCache() 
        : (AbstractLayoutCache) new VariableHeightLayoutCache();

    broadcaster = new EventBroadcaster (this);

    layout.setRootVisible(true);
    layout.setModel(this);
    treePathSupport = new TreePathSupport(this, layout);
    treePathSupport.addTreeExpansionListener(broadcaster);
    treePathSupport.addTreeWillExpandListener(broadcaster);
    treeModel.addTreeModelListener(broadcaster);
    tableModel.addTableModelListener(broadcaster);
    if (tableModel instanceof ProxyTableModel) {
        ((ProxyTableModel) tableModel).setOutlineModel(this);
    }
}
ProfilerTreeTable.java 文件源码 项目:incubator-netbeans 阅读 23 收藏 0 点赞 0 评论 0
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);
    }
}
ProfilerTreeTable.java 文件源码 项目:incubator-netbeans 阅读 23 收藏 0 点赞 0 评论 0
public void collapseChildren(int row) {
    if (tree != null) try {
        markExpansionTransaction();

        TreePath tpath = tree.getPathForRow(row);
        if (tpath == null || tree.isCollapsed(tpath)) return;

        TreeModel tmodel = tree.getModel();
        Object selected = tpath.getLastPathComponent();

        int nchildren = tmodel.getChildCount(selected);
        for (int i = 0; i < nchildren; i++)
            tree.collapsePath(tpath.pathByAddingChild(tmodel.getChild(selected, i)));

    } finally {
        clearExpansionTransaction();
    }
}
ProfilerTreeTable.java 文件源码 项目:incubator-netbeans 阅读 25 收藏 0 点赞 0 评论 0
public void expandPlainPath(int row, int maxChildren) {
    if (tree != null) try {
        markExpansionTransaction();

        TreePath tpath = tree.getPathForRow(row);
        if (tpath == null) return;

        TreeModel tmodel = tree.getModel();            
        int childCount = tmodel.getChildCount(tpath.getLastPathComponent());

        while (childCount > 0 && childCount <= maxChildren) {
            tpath = tpath.pathByAddingChild(tmodel.getChild(tpath.getLastPathComponent(), 0));
            childCount = tmodel.getChildCount(tpath.getLastPathComponent());
        }

        tree.putClientProperty(UIUtils.PROP_AUTO_EXPANDING, Boolean.TRUE);
        try { tree.expandPath(tpath); selectPath(tpath, true); }
        finally { tree.putClientProperty(UIUtils.PROP_AUTO_EXPANDING, null); }

    } finally {
        clearExpansionTransaction();
    }
}
ProfilerTreeTable.java 文件源码 项目:incubator-netbeans 阅读 26 收藏 0 点赞 0 评论 0
public void expandFirstPath(int row) {
    if (tree != null) try {
        markExpansionTransaction();

        TreePath tpath = tree.getPathForRow(row);
        if (tpath == null) return;

        TreeModel tmodel = tree.getModel();    

        while (tmodel.getChildCount(tpath.getLastPathComponent()) > 0)
            tpath = tpath.pathByAddingChild(tmodel.getChild(tpath.getLastPathComponent(), 0));

        tree.putClientProperty(UIUtils.PROP_AUTO_EXPANDING, Boolean.TRUE);
        try { selectPath(tpath, true); }
        finally { tree.putClientProperty(UIUtils.PROP_AUTO_EXPANDING, null); }

    } finally {
        clearExpansionTransaction();
    }
}
DebuggingViewComponent.java 文件源码 项目:incubator-netbeans 阅读 30 收藏 0 点赞 0 评论 0
private void createTreeView() {
    synchronized (lock) {
        releaseTreeView();
        treeView = new DebugTreeView();
        treeView.setRootVisible(false);
        treeView.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        treeView.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
        treeView.getAccessibleContext().setAccessibleName(NbBundle.getMessage(DebuggingViewComponent.class, "DebuggingViewComponent.treeView.AccessibleContext.accessibleName")); // NOI18N
        treeView.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(DebuggingViewComponent.class, "DebuggingViewComponent.treeView.AccessibleContext.accessibleDescription")); // NOI18N
        treeView.getTree().addMouseWheelListener(this);
        treeView.addTreeExpansionListener(this);
        TreeModel model = treeView.getTree().getModel();
        model.addTreeModelListener(this);
        treeView.getViewport().addChangeListener(this);
        treeView.getTree().setScrollsOnExpand(false);
        mainPanel.add(treeView, BorderLayout.CENTER);
    }
}
Tab.java 文件源码 项目:incubator-netbeans 阅读 22 收藏 0 点赞 0 评论 0
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);
            }
        }
    });
}
PlotConfigurationTree.java 文件源码 项目:rapidminer 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Opens all paths in the given node and all nodes below that.
 *
 * @param path
 *            the tree path to the node to expand
 * @param treeModel
 *            the tree model
 * @see JTree#expandPath(TreePath)
 */
protected void expandAllPaths(TreePath path, TreeModel treeModel) {
    expandPath(path);
    final Object node = path.getLastPathComponent();
    final int n = treeModel.getChildCount(node);
    for (int index = 0; index < n; index++) {
        final Object child = treeModel.getChild(node, index);
        expandAllPaths(path.pathByAddingChild(child));
    }
}
DatabasePane.java 文件源码 项目:jdbacl 阅读 15 收藏 0 点赞 0 评论 0
@Override
public void run() {
    try {
        Database database = JDBCMetaDataUtil.getMetaData(environment, true, true, true, true, 
                ".*", exclusionPatternProvider.getValue(), true, true);
        DatabasePane.this.importer = importer;
        final TreeModel model = new SwingTreeModelAdapter<DBObject>(new DatabaseTreeModel(database));
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                tree = new DatabaseTree(model);
                scrollPane.setViewportView(tree);
            }
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
XrayToolWindow.java 文件源码 项目:jfrog-idea-plugin 阅读 22 收藏 0 点赞 0 评论 0
private void populateTrees() {
    licenseFilterMenu.setLicenses();
    TreeModel issuesTreeModel = new DefaultTreeModel(new ScanTreeNode("SeveritiesTree"));
    TreeModel licensesTreeModel = new DefaultTreeModel(new ScanTreeNode("LicensesTree"));
    ScanManager scanManager = ScanManagerFactory.getScanManager(project);
    if (scanManager != null) {
        scanManager.filterAndSort(issuesTreeModel, licensesTreeModel);
    }

    ScanTreeNode root = (ScanTreeNode) issuesTreeModel.getRoot();
    issuesCount.setText("Issues (" + root.getIssueCount() + ") ");

    issuesComponentsTree.setModel(issuesTreeModel);
    issuesComponentsTree.validate();
    issuesComponentsTree.repaint();
    licensesComponentsTree.setModel(licensesTreeModel);
    licensesComponentsTree.validate();
    licensesComponentsTree.repaint();

    issuesTreeExpansionListener.setIssuesCountPanel();
}
LastNodeLowerHalfDrop.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
protected static TreeModel getTreeModel() {
    root = new DefaultMutableTreeNode("Root");

    a = new DefaultMutableTreeNode("A");
    root.add(a);
    a1 = new DefaultMutableTreeNode("a1");
    a.add(a1);

    b = new DefaultMutableTreeNode("B");
    root.add(b);
    b1 = new DefaultMutableTreeNode("b1");
    b.add(b1);
    b2 = new DefaultMutableTreeNode("b2");
    b.add(b2);

    c = new DefaultMutableTreeNode("C");
    root.add(c);
    c1 = new DefaultMutableTreeNode("c1");
    c.add(c1);
    return new DefaultTreeModel(root);
}
SelectionTreeItemListener.java 文件源码 项目:alevin-svn2 阅读 21 收藏 0 点赞 0 评论 0
public SelectionTreeItemListener(SelectionPanel owner) {
    if (owner == null)
        throw new IllegalArgumentException();
    this.owner = owner;

    TreeModel model = owner.getTree().getModel();
    Object root = owner.getTree().getModel().getRoot();

    ePath = new TreePath(new Object[] { root, model.getChild(root, 0) });
    vPath = new TreePath(new Object[] { root, model.getChild(root, 1) });
}
TreeModelCustomizer.java 文件源码 项目:incubator-netbeans 阅读 15 收藏 0 点赞 0 评论 0
/**
 * Updates the tree according to the textual representation of the tree
 * model in the text area.
 */
private void updateTree() {
    String txt = textArea.getText();
    int tabSize = textArea.getTabSize();
    StringBuilder sb = new StringBuilder(tabSize);
    for (int i=0; i<tabSize; i++) {
        sb.append(" "); // NOI18N
    }
    txt = txt.replace("\t", sb.toString()); // NOI18N
    TreeModel model = propEditor.createTreeModel(txt);
    tree.setModel(model);
    expandTree();
    propEditor.setValue(model);
}
TreeView.java 文件源码 项目:incubator-netbeans 阅读 25 收藏 0 点赞 0 评论 0
ExplorerTree(TreeModel model) {
    super(model);
    toggleClickCount = 0;

    // fix for #18292
    // default action map for JTree defines these shortcuts
    // but we use our own mechanism for handling them
    // following lines disable default L&F handling (if it is
    // defined on Ctrl-c, Ctrl-v and Ctrl-x)
    getInputMap().put(KeyStroke.getKeyStroke("control C"), "none"); // NOI18N
    getInputMap().put(KeyStroke.getKeyStroke("control V"), "none"); // NOI18N
    getInputMap().put(KeyStroke.getKeyStroke("control X"), "none"); // NOI18N
    getInputMap().put(KeyStroke.getKeyStroke("COPY"), "none"); // NOI18N
    getInputMap().put(KeyStroke.getKeyStroke("PASTE"), "none"); // NOI18N
    getInputMap().put(KeyStroke.getKeyStroke("CUT"), "none"); // NOI18N

    if (Utilities.isMac()) {
        getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.META_MASK), "none"); // NOI18N
        getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.META_MASK), "none"); // NOI18N
        getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.META_MASK), "none"); // NOI18N
    }

    setupSearch();

    if (!GraphicsEnvironment.isHeadless()) {
        setDragEnabled(true);
    }
}
DefaultOutlineCellRendererTest.java 文件源码 项目:incubator-netbeans 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Test of getTableCellRendererComponent method, of class
 * DefaultOutlineCellRenderer.
 */
public void testGetTableCellRendererComponent() {
    System.out.println("getTableCellRendererComponent");
    UIManager.put("Table.alternateRowColor", Color.red);
    final DefaultMutableTreeNode node1 = new DefaultMutableTreeNode();
    final DefaultMutableTreeNode node2 = new DefaultMutableTreeNode();
    final Object[][] values = new Object[][]{{node1, "01"}, {node2, "11"}};
    final String[] names = new String[]{"col1", "col2"};
    TreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
    DefaultTableModel tableModel = new DefaultTableModel(values, names);
    OutlineModel model = new DefaultOutlineModel(treeModel, tableModel, false, "Col1") {
    };
    final Outline outline = new Outline(model);
    ColorRenderDataProvider rdp = new ColorRenderDataProvider();
    outline.setRenderDataProvider(rdp);
    DefaultOutlineCellRenderer instance = new DefaultOutlineCellRenderer();
    Component result = instance.getTableCellRendererComponent(outline, node1, false, false, 0, 0);
    assertEquals("First line backgroundColor defaults to", outline.getBackground(), result.getBackground());
    assertEquals("Foreground defaults to", outline.getForeground(), result.getForeground());
    result = instance.getTableCellRendererComponent(outline, node2, false, false, 1, 0);
    assertEquals("Second line backgroundColor defaults to", Color.red, result.getBackground());
    assertEquals("Foreground defaults to", outline.getForeground(), result.getForeground());

    rdp.backgroundColor = Color.BLUE; // Custom background color
    rdp.foregroundColor = Color.GREEN; // Custom foreground color

    result = instance.getTableCellRendererComponent(outline, node1, false, false, 0, 0);
    assertEquals("First line backgroundColor is set as", Color.BLUE, result.getBackground());
    assertEquals("Foreground is set as", Color.GREEN, result.getForeground());
    result = instance.getTableCellRendererComponent(outline, node2, false, false, 1, 0);
    assertEquals("Second line backgroundColor is set as", Color.BLUE, result.getBackground());
    assertEquals("Foreground is set as", Color.GREEN, result.getForeground());
}
PhadhailViews.java 文件源码 项目:incubator-netbeans 阅读 19 收藏 0 点赞 0 评论 0
/** use Phadhail directly in a JTree */
public static Component rawView(Phadhail root) {
    TreeModel model = new PhadhailTreeModel(root);
    JTree tree = new JTree(model) {
        // Could also use a custom TreeCellRenderer, but this is a bit simpler for now.
        public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            Phadhail ph = (Phadhail)value;
            return ph.getPath();
        }
    };
    tree.setLargeModel(true);
    return new JScrollPane(tree);
}
SearchTree.java 文件源码 项目:geomapapp 阅读 20 收藏 0 点赞 0 评论 0
public void closePaths(JTree tree, TreePath path) {
    Object node = path.getLastPathComponent();
    TreeModel model = tree.getModel();
    if (model.isLeaf(node))
        return;
    int num = model.getChildCount(node);
    for (int i = 0; i < num; i++)
        closePaths(tree, path.pathByAddingChild(model.getChild(node, i)));
    tree.collapsePath(path);
}
UIUtils.java 文件源码 项目:incubator-netbeans 阅读 21 收藏 0 点赞 0 评论 0
/** Checks give TreePath for the last node, and if it ends with a node with just one child,
 * it keeps expanding further.
 * Current implementation expands through the first child that is not leaf. To more correctly
 * fulfil expected semantics in case maxChildToExpand is > 1, it should expand all paths through
 * all children.
 *
 * @param tree
 * @param path
 * @param maxChildToExpand
 */
public static void autoExpand(JTree tree, TreePath path, int maxLines, int maxChildToExpand, boolean dontExpandToLeafs) {
    TreeModel model = tree.getModel();
    Object node = path.getLastPathComponent();
    TreePath newPath = path;

    int currentLines = 0;

    while (currentLines++ < maxLines &&
            !model.isLeaf(node) &&
            (model.getChildCount(node) > 0) &&
            (model.getChildCount(node) <= maxChildToExpand)) {
        for (int i = 0; i < model.getChildCount(node); i++) {
            node = tree.getModel().getChild(node, i);

            if (!model.isLeaf(node)) {
                if (dontExpandToLeafs && hasOnlyLeafs(tree, node)) {
                    break;
                }

                newPath = newPath.pathByAddingChild(node); // if the leaf is added the path will not expand

                break; // from for
            }
        }
    }

    tree.expandPath(newPath);
}
UIUtils.java 文件源码 项目:incubator-netbeans 阅读 20 收藏 0 点赞 0 评论 0
public static boolean hasOnlyLeafs(JTree tree, Object node) {
    TreeModel model = tree.getModel();

    for (int i = 0; i < model.getChildCount(node); i++) {
        if (!model.isLeaf(model.getChild(node, i))) {
            return false;
        }
    }

    return true;
}
ProfilerTreeTable.java 文件源码 项目:incubator-netbeans 阅读 22 收藏 0 点赞 0 评论 0
private TreePath getSimilarPath(TreePath oldPath) {
    if (oldPath == null || oldPath.getPathCount() < 1) return null;

    TreeModel currentModel = getModel();
    Object currentRoot = currentModel.getRoot();
    if (!currentRoot.equals(oldPath.getPathComponent(0))) return null;

    TreePath p = new TreePath(currentRoot);
    Object[] op = oldPath.getPath();
    Object n = currentRoot;

    for (int i = 1; i < op.length; i++) {
        Object nn = null;

        for (int ii = 0; ii < currentModel.getChildCount(n); ii++) {
            Object c = currentModel.getChild(n, ii);
            if (c.equals(op[i])) {
                nn = c;
                break;
            }
        }

        if (nn == null) return null;

        n = nn;
        p = p.pathByAddingChild(n);
    }

    return p;
}
JTreeTable.java 文件源码 项目:incubator-netbeans 阅读 19 收藏 0 点赞 0 评论 0
public TreeTableCellRenderer(TreeModel model) {
    super(model);

    offsetX = 0;
    setOpaque(false);
    treeCellRenderer = new EnhancedTreeCellRenderer();
    setCellRenderer(treeCellRenderer);
    unselectedBackground = UIUtils.getProfilerResultsBackground();
    darkerUnselectedBackground = UIUtils.getDarker(unselectedBackground);
}
JCheckTree.java 文件源码 项目:incubator-netbeans 阅读 21 收藏 0 点赞 0 评论 0
protected static TreeModel getDefaultTreeModel() {
    CheckTreeNode root = new CheckTreeNode("JTree"); // NOI18N
    CheckTreeNode parent;

    parent = new CheckTreeNode("colors"); // NOI18N
    root.add(parent);
    parent.add(new CheckTreeNode("blue")); // NOI18N
    parent.add(new CheckTreeNode("violet")); // NOI18N
    parent.add(new CheckTreeNode("red")); // NOI18N
    parent.add(new CheckTreeNode("yellow")); // NOI18N

    parent = new CheckTreeNode("sports"); // NOI18N
    root.add(parent);
    parent.add(new CheckTreeNode("basketball")); // NOI18N
    parent.add(new CheckTreeNode("soccer")); // NOI18N
    parent.add(new CheckTreeNode("football")); // NOI18N
    parent.add(new CheckTreeNode("hockey")); // NOI18N

    parent = new CheckTreeNode("food"); // NOI18N
    root.add(parent);
    parent.add(new CheckTreeNode("hot dogs")); // NOI18N
    parent.add(new CheckTreeNode("pizza")); // NOI18N
    parent.add(new CheckTreeNode("ravioli")); // NOI18N
    parent.add(new CheckTreeNode("bananas")); // NOI18N

    return new DefaultTreeModel(root);
}
DebuggingViewComponent.java 文件源码 项目:incubator-netbeans 阅读 24 收藏 0 点赞 0 评论 0
private void releaseTreeView() {
    synchronized (lock) {
        if (treeView == null) {
            return ;
        }
        treeView.getTree().removeMouseWheelListener(this);
        treeView.removeTreeExpansionListener(this);
        TreeModel model = treeView.getTree().getModel();
        model.removeTreeModelListener(this);
        treeView.getViewport().removeChangeListener(this);
        treeView.resetSelection();
        mainPanel.remove(treeView);
        treeView = null;
    }
}
NavigatorContent.java 文件源码 项目:incubator-netbeans 阅读 23 收藏 0 点赞 0 评论 0
private TreeModel createTreeModel(DocumentModel dm) {
    DocumentElement rootElement = dm.getRootElement();
    DefaultTreeModel dtm = new DefaultTreeModel(null);
    TreeNodeAdapter rootTna = new TreeNodeAdapter(rootElement, dtm, tree, null);
    dtm.setRoot(rootTna);

    return dtm;
}
HintsPanel.java 文件源码 项目:incubator-netbeans 阅读 21 收藏 0 点赞 0 评论 0
HintsPanel() {        
        initComponents();

        descriptionTextArea.setContentType("text/html"); // NOI18N

//        if( "Windows".equals(UIManager.getLookAndFeel().getID()) ) //NOI18N
//            setOpaque( false );

        errorTree.setCellRenderer( this );
        errorTree.setRootVisible( false );
        errorTree.setShowsRootHandles( true );
        errorTree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );

        DefaultComboBoxModel model = new DefaultComboBoxModel();
        model.addElement( NbBundle.getMessage(HintsPanel.class, "CTL_AsError"));
        model.addElement( NbBundle.getMessage(HintsPanel.class, "CTL_AsWarning"));
        severityComboBox.setModel(model);

        toProblemCheckBox.setVisible(false);

        update();

        DefaultTreeModel mdl = new DefaultTreeModel(new DefaultMutableTreeNode());
        errorTree.setModel( mdl );
        RequestProcessor.getDefault().post(new Runnable() {
            @Override
            public void run() {
                final TreeModel m = RulesManager.getHintsTreeModel();
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        errorTree.setModel( m );
                    }
                });
            }
        });


    }
HintsPanel.java 文件源码 项目:incubator-netbeans 阅读 21 收藏 0 点赞 0 评论 0
void setCurrentSubcategory(String subpath) {
    TreeModel mdl = errorTree.getModel();
    for (int i = 0; i < mdl.getChildCount(mdl.getRoot()); i++) {
        Object child = mdl.getChild(mdl.getRoot(), i);
        Object data = ((DefaultMutableTreeNode) child).getUserObject();
        if (data instanceof POMErrorFixBase) {
            POMErrorFixBase rule = (POMErrorFixBase) data;
            if (rule.getConfiguration().getId().equals(subpath)) {
                errorTree.setSelectionRow(i);
                break;
            }
        }
    }
}
OptionsFilter.java 文件源码 项目:incubator-netbeans 阅读 22 收藏 0 点赞 0 评论 0
public FilteringTreeModel(TreeModel delegate, Document filter, Acceptor acceptor, boolean delegatingTreeModelListeners) {
    this.delegate = delegate;
    this.filter = filter;
    this.acceptor = acceptor;
    this.delegatingTreeModelListener = delegatingTreeModelListeners;

    this.delegate.addTreeModelListener(this);
    this.filter.addDocumentListener(this);

    filter();
}
NewProjectTest.java 文件源码 项目:incubator-netbeans 阅读 18 收藏 0 点赞 0 评论 0
private ArrayList<String> getChildren(TreeModel tree, Object root, String spaces) {
    int categoriesCount = tree.getChildCount(root);
    ArrayList<String> returnList = new ArrayList<String>();
    for (int i = 0; i <= categoriesCount - 1; i++) {
        Object actualChild = tree.getChild(root, i);
        returnList.add(spaces + actualChild.toString());

        if (!tree.isLeaf(actualChild)) {
            spaces = "+-" + spaces;
            returnList.addAll(getChildren(tree, actualChild, spaces));
            spaces = spaces.substring(2);
        }
    }
    return returnList;
}
PlotConfigurationTree.java 文件源码 项目:rapidminer 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Expands all paths in the tree.
 *
 * @see JTree#expandPath(TreePath)
 */
public void expandAll() {
    cancelEditing();
    final TreeModel tm = getModel();
    final Object root = tm.getRoot();

    /* nothing to expand, if no root */
    if (root != null) {
        expandAllPaths(new TreePath(root), tm);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号