Example usage for javax.swing.tree TreePath TreePath

List of usage examples for javax.swing.tree TreePath TreePath

Introduction

In this page you can find the example usage for javax.swing.tree TreePath TreePath.

Prototype

public TreePath(Object lastPathComponent) 

Source Link

Document

Creates a TreePath containing a single element.

Usage

From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java

public DefaultMutableTreeNode addNode(QueryMasterData node, DefaultMutableTreeNode parent) {
    DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node);

    QueryMasterData tmpData = new QueryMasterData();
    tmpData.name("working ......");
    tmpData.tooltip("A tmp node");
    tmpData.visualAttribute("LAO");
    DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(tmpData);

    treeModel.insertNodeInto(childNode, parent, parent.getChildCount());
    if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) {
        treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount());
    }/*from  w  ww . jav a 2s  . com*/
    //Make sure the user can see the lovely new node.
    jTree1.scrollPathToVisible(new TreePath(childNode.getPath()));

    return childNode;
}

From source file:edu.brown.gui.CatalogViewer.java

private void generateCatalogTree(Catalog catalog, String catalog_path) {
    this.catalogTreeModel = new CatalogTreeModel(catalog, catalog_path);
    this.catalogTree.setModel(this.catalogTreeModel);
    this.catalog = catalog;
    this.catalog_path = catalog_path;

    ///*  w ww.j  av  a2  s .c  o  m*/
    // Expand clusters and databases
    //
    this.catalogTree.expandPath(new TreePath(this.catalogTreeModel.getTablesNode().getPath()));
    this.catalogTree.expandPath(new TreePath(this.catalogTreeModel.getProceduresNode().getPath()));
}

From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java

public DefaultMutableTreeNode addNode(QueryInstanceData node, DefaultMutableTreeNode parent) {
    QueryMasterData logicdata = (QueryMasterData) parent.getUserObject();
    logicdata.runs.add(node);//from w w  w . j  a v  a2s .com

    DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node);

    QueryInstanceData tmpData = new QueryInstanceData();
    tmpData.name("working ......");
    tmpData.tooltip("A tmp node");
    tmpData.visualAttribute("LAO");
    DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(tmpData);

    treeModel.insertNodeInto(childNode, parent, parent.getChildCount());
    if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) {
        treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount());
    }
    //Make sure the user can see the lovely new node.
    jTree1.scrollPathToVisible(new TreePath(childNode.getPath()));

    DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) parent.getChildAt(0);
    QueryData tmpdata = (QueryData) tmpnode.getUserObject();
    if (tmpdata.name().equalsIgnoreCase("working ......")) {
        treeModel.removeNodeFromParent(tmpnode);
    }

    return childNode;
}

From source file:edu.harvard.i2b2.query.ui.ConceptTreePanel.java

public DefaultMutableTreeNode addNode(QueryConceptTreeNodeData node) {
    DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node);

    QueryConceptTreeNodeData tmpData = new QueryConceptTreeNodeData();
    tmpData.name("working ......");
    tmpData.tooltip("A tmp node");
    tmpData.visualAttribute("LAO");
    DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(tmpData);

    treeModel.insertNodeInto(childNode, top, top.getChildCount());
    treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount());
    // Make sure the user can see the lovely new node.
    jTree1.scrollPathToVisible(new TreePath(childNode.getPath()));

    return childNode;
}

From source file:de.tor.tribes.ui.views.DSWorkbenchSelectionFrame.java

public TreePath findByName(JTree tree, Village node) {
    TreeNode root = (TreeNode) tree.getModel().getRoot();
    return find2(tree, new TreePath(root), node, 0);
}

From source file:de.tbuchloh.kiskis.gui.treeview.TreeView.java

/**
 * Overridden!/*from  www  .  ja v  a  2  s .  com*/
 * 
 * @see de.tbuchloh.kiskis.gui.common.SearchListener#found(java.util.List)
 */
@Override
public void found(final List<ModelNode> nodes) {
    LOG.debug("found nodes.size()=" + nodes.size());
    if (nodes.isEmpty()) {
        resetSearch();
        return;
    }

    collapseAll();

    boolean first = true;
    final Set<ModelNode> nodesSet = new HashSet<ModelNode>(nodes);
    _treeNodeFilter.enableSearchFilter(nodes);

    expandTreeNodes(getRoot());

    for (final MyTreeNode node : getAllNodes()) {
        if (nodesSet.contains(node.getModelNode())) {
            node.setSearchResult(true);
            LOG.debug("displaying node=" + node);
            final TreeNode[] path = _treeModel.getPathToRoot(node);
            if (path != null) {
                final TreePath treePath = new TreePath(path);
                this.makeVisible(treePath);

                if (first) {
                    this.setSelectionPath(treePath);
                    first = false;
                }
            }
        } else {
            node.setSearchResult(false);
        }
    }

    _treeNodeFilter.disableSearchFilter();
}

From source file:com.openbravo.pos.admin.RolesViewTree.java

public void loadUserPermissionsIntoTree() throws BasicException {
    // Populate the tree with the selected users permissions
    uTree.clearChecking();// www . j  a  v a2s  .co  m
    if (!"".equals(m_jName.getText())) {
        getPermissions();
        for (String userPermission : m_apermissions) {
            uTree.addCheckingPath(new TreePath(nodePaths.get(userPermission).getPath()));
        }
        jRightsLevel.setValue(m_dlAdmin.getRightsLevel(m_jName.getText()));
        //    jRightsLevel.setText(m_dlAdmin.getRightsLevel(m_jName.getText()).toString());
    }
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopTree.java

@Override
public void collapseTree() {
    if (model == null) {
        return;/*ww  w .j  a v  a 2s.co  m*/
    }

    impl.collapsePath(new TreePath(model.getRoot()));
}

From source file:DynamicTreeDemo.java

public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent, Object child, boolean shouldBeVisible) {
    DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child);

    if (parent == null) {
        parent = rootNode;//from  www.  j  av  a 2 s. com
    }

    // It is key to invoke this on the TreeModel, and NOT DefaultMutableTreeNode
    treeModel.insertNodeInto(childNode, parent, parent.getChildCount());

    // Make sure the user can see the lovely new node.
    if (shouldBeVisible) {
        tree.scrollPathToVisible(new TreePath(childNode.getPath()));
    }
    return childNode;
}

From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java

public DefaultMutableTreeNode addNode(QueryResultData node, DefaultMutableTreeNode parent) {
    //QueryInstanceData rundata = (QueryInstanceData) parent.getUserObject();

    DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node);

    QueryInstanceData tmpData = new QueryInstanceData();
    tmpData.name("working ......");
    tmpData.tooltip("A tmp node");
    tmpData.visualAttribute("LAO");
    DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(tmpData);

    treeModel.insertNodeInto(childNode, parent, parent.getChildCount());
    if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) {
        treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount());
    }/*  ww w.  j  av  a2 s . c o m*/
    //Make sure the user can see the lovely new node.
    jTree1.scrollPathToVisible(new TreePath(childNode.getPath()));

    DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) parent.getChildAt(0);
    QueryData tmpdata = (QueryData) tmpnode.getUserObject();
    if (tmpdata.name().equalsIgnoreCase("working ......")) {
        treeModel.removeNodeFromParent(tmpnode);
    }

    return childNode;
}