Example usage for javax.swing.tree DefaultMutableTreeNode DefaultMutableTreeNode

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

Introduction

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

Prototype

public DefaultMutableTreeNode(Object userObject) 

Source Link

Document

Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.

Usage

From source file:com.pironet.tda.TDA.java

private void addDumpStream(InputStream inputStream, String file, boolean withLogfile) {
    final InputStream parseFileStream = new ProgressMonitorInputStream(this, "Parsing " + file, inputStream);

    //Create the nodes.
    if (!runningAsJConsolePlugin || topNodes.size() == 0) {
        topNodes.add(new DefaultMutableTreeNode(new Logfile(file)));
    }//from w ww  .j a v  a 2s .  c  o  m
    final DefaultMutableTreeNode top = topNodes.get(topNodes.size() - 1);

    if ((!withLogfile && logFile == null) || isLogfileSizeOk(file)) {
        logFile = new DefaultMutableTreeNode(new LogFileContent(file));
        if (!runningAsVisualVMPlugin) {
            top.add(logFile);
        }
    }
    setFileOpen(true);

    final SwingWorker worker = new SwingWorker() {

        public Object construct() {
            synchronized (syncObject) {
                int divider = topSplitPane.getDividerLocation();
                addThreadDumps(top, parseFileStream);
                createTree();
                tree.expandRow(1);

                topSplitPane.setDividerLocation(divider);
            }

            return null;
        }
    };
    worker.start();
}

From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java

private DefaultMutableTreeNode getRegStatusNode(String nodeId, String regStatus, String contextIdseq,
        String csIdseq, TreeFunctions treeFunctions) throws Exception {

    DefaultMutableTreeNode regStatusNode = new DefaultMutableTreeNode(new WebNode(nodeId, regStatus,
            "javascript:" + treeFunctions.getFormJsFunctionName() + "('P_PARAM_TYPE=REGCS&P_IDSEQ=" + csIdseq
                    + "&P_CONTE_IDSEQ=" + contextIdseq //context idseq
                    + "&P_REGSTATUS=" + regStatus //classification idseq
                    + treeFunctions.getExtraURLParameters() + "')",
            regStatus)); //registration status
    return regStatusNode;
}

From source file:com.lp.client.frame.component.PanelDokumentenablage.java

private void addNotExistingNodes(DocPath pathToAdd, DefaultMutableTreeNode top) {
    if (pathToAdd == null || pathToAdd.size() == 0) {
        treeModel.insertNodeInto(new DefaultMutableTreeNode(MUST_LOAD_CHILDREN), top, 0);
        return;/*from   ww w .j a v a  2 s.c  o  m*/
    }
    boolean exists = false;
    DefaultMutableTreeNode node = null;
    for (int i = 0; i < top.getChildCount(); i++) {
        node = (DefaultMutableTreeNode) top.getChildAt(i);
        if (pathToAdd.asDocNodeList().get(0).toString().equals(node.getUserObject().toString())) {
            exists = true;
            break;
        }
    }
    if (!exists) {
        node = new DefaultMutableTreeNode(pathToAdd.asDocNodeList().get(0));
        treeModel.insertNodeInto(node, top, top.getChildCount());
    }
    DocPath subPath = pathToAdd.getDeepCopy();
    subPath.asDocNodeList().remove(0);
    addNotExistingNodes(subPath, node);
}

From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java

private DefaultMutableTreeNode getTemplateNode(String nodeId, Form template, ClassSchemeItem csi,
        Context currContext, TreeFunctions treeFunctions) throws Exception {
    String templateIdseq = template.getFormIdseq();

    String longName = template.getLongName();
    String prefferedDefinition = template.getPreferredDefinition();

    DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(new WebNode(nodeId, longName,
            "javascript:" + treeFunctions.getFormJsFunctionName() + "('P_PARAM_TYPE=TEMPLATE&P_IDSEQ="
                    + templateIdseq + "&P_CONTE_IDSEQ=" + currContext.getConteIdseq() + "&csName="
                    + URLEncoder.encode(csi.getClassSchemeLongName()) + "&diseaseName="
                    + URLEncoder.encode(csi.getClassSchemeItemName()) + "&templateType="
                    + URLEncoder.encode(template.getFormCategory()) + "&templateName="
                    + URLEncoder.encode(longName) + "&contextName=" + URLEncoder.encode(currContext.getName())
                    + treeFunctions.getExtraURLParameters() + "')",
            prefferedDefinition));//w  ww.ja  va 2 s . co  m

    return tmpNode;
}

From source file:com.pironet.tda.TDA.java

protected void createTree() {
    //Create a tree that allows multiple selection at a time.
    if (topNodes.size() == 1) {
        treeModel = new DefaultTreeModel((DefaultMutableTreeNode) topNodes.get(0));
        tree = new JTree(treeModel);
        tree.setRootVisible(!runningAsJConsolePlugin && !runningAsVisualVMPlugin);
        addTreeListener(tree);//from   w ww .  j  a v  a 2 s  .  co m
        if (!runningAsJConsolePlugin && !runningAsVisualVMPlugin) {
            frame.setTitle("TDA - Thread Dumps of " + dumpFile);
        }
    } else {
        DefaultMutableTreeNode root = new DefaultMutableTreeNode("Thread Dump Nodes");
        treeModel = new DefaultTreeModel(root);
        for (Object topNode : topNodes) {
            root.add((DefaultMutableTreeNode) topNode);
        }
        tree = new JTree(root);
        tree.setRootVisible(false);
        addTreeListener(tree);
        if (!runningAsJConsolePlugin && !runningAsVisualVMPlugin) {
            if (!frame.getTitle().endsWith("...")) {
                frame.setTitle(frame.getTitle() + " ...");
            }
        }
    }

    tree.setShowsRootHandles(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

    tree.setCellRenderer(new TreeRenderer());

    //Create the scroll pane and add the tree to it.
    ViewScrollPane treeView = new ViewScrollPane(tree, runningAsVisualVMPlugin);

    topSplitPane.setLeftComponent(treeView);

    Dimension minimumSize = new Dimension(200, 50);
    treeView.setMinimumSize(minimumSize);

    //Listen for when the selection changes.
    tree.addTreeSelectionListener(this);

    if (!runningAsJConsolePlugin && !runningAsVisualVMPlugin) {
        dt = new DropTarget(tree, new FileDropTargetListener());
    }

    createPopupMenu();

}

From source file:org.jfree.chart.demo.SuperDemo.java

private MutableTreeNode createTimeSeriesChartsNode() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Time Series Charts");
    DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(
            new DemoDescription("PeriodAxisDemo1", "PeriodAxisDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode(
            new DemoDescription("PeriodAxisDemo2", "PeriodAxisDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode(
            new DemoDescription("RelativeDateFormatDemo1", "RelativeDateFormatDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo1", "TimeSeriesDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode5 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo2", "TimeSeriesDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode6 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo3", "TimeSeriesDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode7 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo4", "TimeSeriesDemo4.java"));
    DefaultMutableTreeNode defaultmutabletreenode8 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo5", "TimeSeriesDemo5.java"));
    DefaultMutableTreeNode defaultmutabletreenode9 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo6", "TimeSeriesDemo6.java"));
    DefaultMutableTreeNode defaultmutabletreenode10 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo7", "TimeSeriesDemo7.java"));
    DefaultMutableTreeNode defaultmutabletreenode11 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo8", "TimeSeriesDemo8.java"));
    DefaultMutableTreeNode defaultmutabletreenode12 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo9", "TimeSeriesDemo9.java"));
    DefaultMutableTreeNode defaultmutabletreenode13 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo10", "TimeSeriesDemo10.java"));
    DefaultMutableTreeNode defaultmutabletreenode14 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo11", "TimeSeriesDemo11.java"));
    DefaultMutableTreeNode defaultmutabletreenode15 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo12", "TimeSeriesDemo12.java"));
    DefaultMutableTreeNode defaultmutabletreenode16 = new DefaultMutableTreeNode(
            new DemoDescription("TimeSeriesDemo13", "TimeSeriesDemo13.java"));
    DefaultMutableTreeNode defaultmutabletreenode17 = new DefaultMutableTreeNode(
            new DemoDescription("DeviationRendererDemo1", "DeviationRendererDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode18 = new DefaultMutableTreeNode(
            new DemoDescription("DeviationRendererDemo2", "DeviationRendererDemo2.java"));
    defaultmutabletreenode.add(defaultmutabletreenode1);
    defaultmutabletreenode.add(defaultmutabletreenode2);
    defaultmutabletreenode.add(defaultmutabletreenode3);
    defaultmutabletreenode.add(defaultmutabletreenode4);
    defaultmutabletreenode.add(defaultmutabletreenode5);
    defaultmutabletreenode.add(defaultmutabletreenode6);
    defaultmutabletreenode.add(defaultmutabletreenode7);
    defaultmutabletreenode.add(defaultmutabletreenode8);
    defaultmutabletreenode.add(defaultmutabletreenode9);
    defaultmutabletreenode.add(defaultmutabletreenode10);
    defaultmutabletreenode.add(defaultmutabletreenode11);
    defaultmutabletreenode.add(defaultmutabletreenode12);
    defaultmutabletreenode.add(defaultmutabletreenode13);
    defaultmutabletreenode.add(defaultmutabletreenode14);
    defaultmutabletreenode.add(defaultmutabletreenode15);
    defaultmutabletreenode.add(defaultmutabletreenode16);
    defaultmutabletreenode.add(defaultmutabletreenode17);
    defaultmutabletreenode.add(defaultmutabletreenode18);
    return defaultmutabletreenode;
}

From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java

private DefaultMutableTreeNode getProtocolNode(String nodeId, Protocol protocol, String currContextId,
        TreeFunctions treeFunctions) throws Exception {
    String protoIdseq = protocol.getProtoIdseq();

    String longName = protocol.getLongName();
    String preferred_definition = protocol.getPreferredDefinition();

    DefaultMutableTreeNode protocolNode = new DefaultMutableTreeNode(new WebNode(nodeId, longName,
            "javascript:" + treeFunctions.getJsFunctionName() + "('P_PARAM_TYPE=PROTOCOL&P_IDSEQ=" + protoIdseq
                    + "&P_CONTE_IDSEQ=" + currContextId + "&protocolLongName=" + longName
                    + treeFunctions.getExtraURLParameters() + "')",
            preferred_definition));//from w  w w. j  a  v a2 s. com
    return protocolNode;
}

From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java

private DefaultMutableTreeNode getWebNode(String name, String id) {
    return new DefaultMutableTreeNode(new WebNode(id, name));
}

From source file:jeplus.JEPlusProject.java

/**
 * Add a list of parameter items as a branch at the given root node
 * @param root Root where the new branch is attached
 * @param list The list of parameter items
 *//*from  w  w w  .  jav  a  2 s  . co  m*/
public void addParameterListAsBranch(DefaultMutableTreeNode root, List<ParameterItem> list) {
    if (list != null && list.size() > 0) {
        if (root == null) { // replace current tree
            ParamTree = new DefaultMutableTreeNode(list.get(0));
            DefaultMutableTreeNode current = ParamTree;
            for (int i = 1; i < list.size(); i++) {
                DefaultMutableTreeNode newnode = new DefaultMutableTreeNode(list.get(i));
                current.add(newnode);
                current = newnode;
            }
        } else {
            DefaultMutableTreeNode current = root;
            for (ParameterItem item : list) {
                DefaultMutableTreeNode newnode = new DefaultMutableTreeNode(item);
                current.add(newnode);
                current = newnode;
            }
        }
    }
}

From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java

/**
 * This method is called from within the constructor to initialize the form.
 *//*from w  w w. j ava  2  s  . co m*/
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;
    System.setProperty("PQSortByTimeCheckBox", "true");
    System.setProperty("QueryToolMaxQueryNumber", "20");
    System.setProperty("PQMaxPatientsNumber", "200");
    System.setProperty("PQSortByNameCheckBox", "false");

    jPanel1 = new javax.swing.JPanel();
    jContainComboBox = new javax.swing.JComboBox();
    jCategoryComboBox = new javax.swing.JComboBox();
    jSearchStringTextField = new javax.swing.JTextField();
    jFindButton = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTree1 = new javax.swing.JTree();
    jPanel2 = new javax.swing.JPanel();
    jStartTimeTextField = new javax.swing.JTextField();
    jBackwardButton = new javax.swing.JButton();
    jForwardButton = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();

    //setLayout(new java.awt.BorderLayout());
    setLayout(new java.awt.BorderLayout(20, 4));

    jPanel1.setLayout(new java.awt.GridBagLayout());

    jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Search By Name"));
    jPanel1.setMinimumSize(new java.awt.Dimension(0, 50));
    jPanel1.setPreferredSize(new java.awt.Dimension(400, 80));
    jContainComboBox.setModel(new javax.swing.DefaultComboBoxModel(
            new String[] { "Containing", "Start With", "End With", "Exact" }));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.ipadx = 32;
    gridBagConstraints.ipady = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.01;
    gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 2);
    jPanel1.add(jContainComboBox, gridBagConstraints);

    jCategoryComboBox.setModel(new javax.swing.DefaultComboBoxModel(
            new String[] { "Any Category", "Previous Query", "Previous Query Result", "Patient" }));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    gridBagConstraints.ipadx = 14;
    gridBagConstraints.ipady = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.6;
    gridBagConstraints.insets = new java.awt.Insets(4, 2, 0, 2);
    jPanel1.add(jCategoryComboBox, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipadx = 11;
    gridBagConstraints.ipady = 3;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.9;
    gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2);
    jPanel1.add(jSearchStringTextField, gridBagConstraints);

    jFindButton.setText("Find");
    jFindButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jFindButtonActionPerformed(evt);
        }
    });

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.ipadx = 19;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.01;
    gridBagConstraints.insets = new java.awt.Insets(4, 4, 2, 2);
    jPanel1.add(jFindButton, gridBagConstraints);

    add(jPanel1, java.awt.BorderLayout.NORTH);

    QueryMasterData tmpData = new QueryMasterData();
    tmpData.name("Queries by " + UserInfoBean.getInstance().getUserName());
    tmpData.tooltip("Previous query runs");
    tmpData.visualAttribute("CA");
    top = new DefaultMutableTreeNode(tmpData);
    // top = new DefaultMutableTreeNode("Root Node");
    treeModel = new DefaultTreeModel(top);
    // treeModel.addTreeModelListener(new MyTreeModelListener());

    jTree1 = new JTree(treeModel);
    jTree1.setEditable(false);

    // jTree1.getSelectionModel().setSelectionMode
    // (TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree1.setShowsRootHandles(true);
    // JScrollPane treeView = new JScrollPane(jTree1);
    jTree1.setRootVisible(false);
    jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree1.setCellRenderer(new MyRenderer());
    ToolTipManager.sharedInstance().registerComponent(jTree1);

    if (cellStatus.equalsIgnoreCase("CellDown")) {
        DefaultMutableTreeNode childNode = new DefaultMutableTreeNode("Data Repository Cell is unavailable");
        treeModel.insertNodeInto(childNode, top, top.getChildCount());
        // Make sure the user can see the lovely new node.
        jTree1.expandPath(new TreePath(top.getPath()));
    }

    ArrayList<QueryMasterData> queries = previousQueries;
    if (queries != null) {
        for (int i = 0; i < queries.size(); i++) {
            addNode(queries.get(i));
        }
    }

    jScrollPane1.setViewportView(jTree1);
    add(jScrollPane1, java.awt.BorderLayout.CENTER);

    jTree1.setTransferHandler(new NodeCopyTransferHandler());
    jTree1.addTreeExpansionListener(this);
    jTree1.addTreeWillExpandListener(this);

    jPanel2.setLayout(new java.awt.GridBagLayout());

    jPanel2.setMinimumSize(new java.awt.Dimension(92, 20));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipadx = 244;
    gridBagConstraints.ipady = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.9;
    gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0);
    jPanel2.add(jStartTimeTextField, gridBagConstraints);

    jBackwardButton.setText("<");
    jBackwardButton.setMaximumSize(new java.awt.Dimension(43, 22));
    jBackwardButton.setMinimumSize(new java.awt.Dimension(43, 22));
    jBackwardButton.setPreferredSize(new java.awt.Dimension(43, 22));
    jBackwardButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jBackwardButtonActionPerformed(evt);
        }
    });

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.01;
    gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 2);
    jPanel2.add(jBackwardButton, gridBagConstraints);

    jForwardButton.setText(">");
    jForwardButton.setMaximumSize(new java.awt.Dimension(43, 22));
    jForwardButton.setMinimumSize(new java.awt.Dimension(43, 22));
    jForwardButton.setPreferredSize(new java.awt.Dimension(43, 22));
    jForwardButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jForwardButtonActionPerformed(evt);
        }
    });

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.01;
    gridBagConstraints.insets = new java.awt.Insets(0, 43, 0, 3);
    jPanel2.add(jForwardButton, gridBagConstraints);

    jLabel2.setText("Begin:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.01;
    gridBagConstraints.insets = new java.awt.Insets(3, 7, 0, 2);
    jPanel2.add(jLabel2, gridBagConstraints);

    add(jPanel2, java.awt.BorderLayout.SOUTH);
}