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:edu.ucla.stat.SOCR.chart.ChartTree.java

/**
 * Creates a tree node containing bar charts based on the 
 * {@link CategoryPlot} class./*from   w ww.  j a  va  2  s. co  m*/
 * 
 * @return The tree node.
 */
private MutableTreeNode createCategoryBarChartsNode() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("CategoryPlot");

    MutableTreeNode n1 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChartDemo1", "BarChartDemo1"));
    MutableTreeNode n2 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChartDemo2", "BarChartDemo2"));
    MutableTreeNode n3 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChartDemo3", "BarChartDemo3"));
    MutableTreeNode n4 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChartDemo4", "BarChartDemo4"));
    MutableTreeNode n5 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChartDemo5", "BarChartDemo5"));
    MutableTreeNode n6 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChartDemo6", "BarChartDemo6"));
    MutableTreeNode n7 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChartDemo7", "BarChartDemo7"));
    MutableTreeNode n8 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChartDemo8", "BarChartDemo8"));
    MutableTreeNode n9 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChartDemo9", "BarChartDemo9"));
    MutableTreeNode n10 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChartDemo10", "BarChartDemo10"));
    MutableTreeNode n11 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChart3DDemo1", "BarChart3DDemo1"));
    MutableTreeNode n12 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChart3DDemo2", "BarChart3DDemo2"));
    MutableTreeNode n13 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BarChart3DDemo3", "BarChart3DDemo3"));
    MutableTreeNode n14 = new DefaultMutableTreeNode(new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.IntervalBarChartDemo1", "IntervalBarChartDemo1"));
    MutableTreeNode n15 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.LayeredBarChartDemo1", "LayeredBarChartDemo1"));
    MutableTreeNode n16 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.LayeredBarChartDemo2", "LayeredBarChartDemo2"));
    MutableTreeNode n17 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.StackedBarChartDemo1", "StackedBarChartDemo1"));
    MutableTreeNode n18 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.StackedBarChartDemo2", "StackedBarChartDemo2"));
    MutableTreeNode n19 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.StackedBarChartDemo3", "StackedBarChartDemo3"));
    MutableTreeNode n20 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.StackedBarChartDemo4", "StackedBarChartDemo4"));
    MutableTreeNode n21 = new DefaultMutableTreeNode(new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.StatisticalBarChartDemo1", "StatisticalBarChartDemo1"));
    MutableTreeNode n22 = new DefaultMutableTreeNode(new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.StatisticalBarChartDemo2", "StatisticalBarChartDemo2"));

    MutableTreeNode n23 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.WaterfallChartDemo1", "WaterfallChartDemo1"));

    root.add(n1);
    root.add(n2);
    root.add(n3);
    root.add(n4);
    root.add(n5);
    // root.add(n6);
    root.add(n7);
    root.add(n8);
    root.add(n9);
    // root.add(n10);
    root.add(n11);
    root.add(n12);
    root.add(n13);
    // root.add(n14);
    root.add(n15);
    root.add(n16);
    root.add(n17);
    root.add(n18);
    root.add(n19);
    root.add(n20);
    root.add(n21);
    root.add(n22);
    root.add(n23);

    return root;
}

From source file:gov.nij.er.ui.RawDataFilteredTreeModel.java

/**
 * Determine which recordIds are filtered (displayed)
 * @param recordIds the list of ids for the records to display
 *//*from  ww  w.  j a  v a  2  s .  c  o  m*/
public void setFilteredRecordIds(Set<String> recordIds) {
    root = new DefaultMutableTreeNode(ROOT_NODE_LABEL);
    List<DefaultMutableTreeNode> nodes = rawDataTreeModel.getNodesForRecordIds(recordIds);
    for (DefaultMutableTreeNode node : nodes) {
        LOG.debug("Adding node " + node);
        root.add((MutableTreeNode) node.clone());

    }
    updateModel();
}

From source file:org.netxilia.server.rest.HomeResource.java

@GET
@Path("/treeview")
@Produces(MediaType.APPLICATION_JSON)/* w  w  w. j  a  va 2 s .  c  o m*/
public StringHolder treeview() throws NetxiliaResourceException, NetxiliaBusinessException {
    // TODO - here a light version if IWorkbook should be return to not be able to get around security exceptions

    // add workbooks
    List<Pair<WorkbookId, DataSourceConfigurationId>> workbooksAndConfigs = dataSourceConfigurationService
            .findAllWorkbooksConfigurations();

    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(null);

    for (Pair<WorkbookId, DataSourceConfigurationId> wkCfg : workbooksAndConfigs) {
        WorkbookId wkId = wkCfg.getFirst();
        IWorkbook workbook = null;
        Set<SheetFullName> sheetNames = new TreeSet<SheetFullName>();
        try {
            workbook = getWorkbookProcessor().getWorkbook(wkId);

            for (ISheet sheet : workbook.getSheets()) {
                if (sheet.getType() == SheetType.normal) {
                    try {
                        aclService.checkPermission(sheet.getFullName(), Permission.read);
                    } catch (AccessControlException e) {
                        continue;
                    }
                    sheetNames.add(sheet.getFullName());
                }
            }
        } catch (AccessControlException ex) {
            // user has not write to see the workbook
            continue;
        } catch (Exception ex) {
            log.error("Could not load workbook " + wkId + ":" + ex, ex);
            // add the workbook with error
            DefaultMutableTreeNode workbookNode = new DefaultMutableTreeNode(
                    new TreeViewData(wkId.getKey(), wkId.getKey(), "workbook error"));
            rootNode.add(workbookNode);
            continue;
        }

        ISheet foldersSheet = null;
        SheetFullName folderSheetName = new SheetFullName(workbook.getName(), FOLDERS_SHEET);
        try {
            foldersSheet = getWorkbookProcessor().getWorkbook(wkId).getSheet(FOLDERS_SHEET);
        } catch (NotFoundException ex) {
            // no folder sheet
        } catch (Exception ex) {
            log.error("Could not load folder sheet" + folderSheetName + ":" + ex, ex);
        }
        DefaultMutableTreeNode workbookNode = buildWorkbookTree(workbook, foldersSheet, sheetNames);
        rootNode.add(workbookNode);

    }

    // only for admins
    User currentUser = userService.getCurrentUser();
    if (currentUser != null && currentUser.isAdmin()) {
        // add admin
        DefaultMutableTreeNode adminNode = new DefaultMutableTreeNode(
                new TreeViewData("admin", "Administration", "admin", true));
        rootNode.add(adminNode);

        // add datasources nodes
        DefaultMutableTreeNode dsNode = new DefaultMutableTreeNode(
                new TreeViewData("ds", "Datasources", "datasources", true));
        adminNode.add(dsNode);
        for (DataSourceConfiguration dsConfig : dataSourceConfigurationService.findAll()) {
            dsNode.add(new DefaultMutableTreeNode(
                    new TreeViewData(dsConfig.getId().toString(), dsConfig.getName(), "datasource")));
        }

        // add modules nodes
        DefaultMutableTreeNode moduleNode = new DefaultMutableTreeNode(
                new TreeViewData("modules", "Modules", "modules", true));
        adminNode.add(moduleNode);

        // add build nodes
        DefaultMutableTreeNode buildNode = new DefaultMutableTreeNode(
                new TreeViewData("build", "Custom Modules", "build", true));
        adminNode.add(buildNode);
    }

    StringBuilder treeview = new StringBuilder();
    buildTreeView(rootNode, treeview);
    return new StringHolder(treeview.toString());
}

From source file:de.hsos.ecs.richwps.wpsmonitor.boundary.gui.controls.datasource.WpsDialog.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from   w  ww  . j a v  a 2  s  . c  o m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    JPanel jPanel1 = new JPanel();
    closeButton = new JButton();
    addToMonitorButton = new JButton();
    treeScrollPane = new JScrollPane();
    wpsTree = new JTree();
    JLabel jLabel1 = new JLabel();

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("List of WPS-Servers- and Processes");
    setIconImage(new ImageIcon(getClass().getResource("/icons/database.png")).getImage());
    setMinimumSize(null);
    setName("wpsDialog"); // NOI18N
    setResizable(false);

    jPanel1.setBorder(BorderFactory.createTitledBorder(""));

    closeButton.setIcon(new ImageIcon(getClass().getResource("/icons/apply.png"))); // NOI18N
    closeButton.setText("Close");
    closeButton.setName("closeButton"); // NOI18N
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            closeButtonActionPerformed(evt);
        }
    });

    addToMonitorButton.setIcon(new ImageIcon(getClass().getResource("/icons/add.png"))); // NOI18N
    addToMonitorButton.setText("Add WPS with Processes");
    addToMonitorButton.setName("addToMonitorButton"); // NOI18N
    addToMonitorButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            addToMonitorButtonActionPerformed(evt);
        }
    });

    DefaultMutableTreeNode treeNode1 = new DefaultMutableTreeNode("root");
    wpsTree.setModel(new DefaultTreeModel(treeNode1));
    wpsTree.setName("wpsTree"); // NOI18N
    treeScrollPane.setViewportView(wpsTree);

    jLabel1.setText(
            "<html><body>Here is a list of all registered data-sources. You can pick up processes and WPS and add your choice to the monitor through the \"Add WPS with Processes\"-Button. If you select only a WPS, all processes of this WPS will also  be added. The processes will  be saved, but they have no Jobs or a testrequest.</body></html>");

    GroupLayout jPanel1Layout = new GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                            .addComponent(addToMonitorButton)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(closeButton))
                    .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(treeScrollPane, GroupLayout.PREFERRED_SIZE, 630,
                                    GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE)))
                    .addContainerGap()));
    jPanel1Layout
            .setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
                            .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(treeScrollPane, GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(addToMonitorButton).addComponent(closeButton))
                            .addContainerGap()));

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap()
                    .addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap()
                    .addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));

    pack();
}

From source file:edu.harvard.i2b2.query.QueryConceptTreePanel.java

private DefaultMutableTreeNode addNode(QueryConceptTreeNodeData node, DefaultMutableTreeNode parent) {
    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, parent, parent.getChildCount());
    if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) {
        treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount());
    }//www  .  j  a  v  a 2  s  .c o  m
    //Make sure the user can see the lovely new node.
    //jTree1.scrollPathToVisible(new TreePath(childNode.getPath()));

    return childNode;
}

From source file:it.cnr.icar.eric.client.ui.swing.BusinessQueryPanel.java

/**
 * Class Constructor.//  w  w w.j a  v  a  2 s. c  om
 */
public BusinessQueryPanel(final FindParamsPanel findParamsPanel, ConfigurationType uiConfigurationType)
        throws JAXRException {
    super(findParamsPanel, uiConfigurationType);

    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    objectTypeLabel = new JLabel(resourceBundle.getString("title.objectType"), SwingConstants.LEADING);

    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(objectTypeLabel, c);
    add(objectTypeLabel);

    //TODO: SwingBoost: Localize this
    TreeNode tempTreeNode = new DefaultMutableTreeNode("loading object types...");
    objectTypeCombo = new it.cnr.icar.eric.client.ui.swing.TreeCombo(new DefaultTreeModel(tempTreeNode));

    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(objectTypeCombo, c);
    add(objectTypeCombo);
    objectTypeCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            if (ev.getStateChange() == ItemEvent.DESELECTED) {
                return;
            }

            @SuppressWarnings("unused")
            String objectType = getObjectType().toString();
        }
    });

    //The caseSensitive CheckBox
    caseSensitiveCheckBox = new JCheckBox(resourceBundle.getString("title.caseSensitiveSearch"));
    caseSensitiveCheckBox.setSelected(false);
    caseSensitiveCheckBox.setEnabled(true);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(caseSensitiveCheckBox, c);
    add(caseSensitiveCheckBox);

    //The name Text
    nameLabel = new JLabel(resourceBundle.getString("title.name"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(nameLabel, c);
    add(nameLabel);

    nameText = new JTextField();
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(nameText, c);
    add(nameText);

    nameText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            findParamsPanel.find();
        }
    });

    //The description text
    descLabel = new JLabel(resourceBundle.getString("title.description"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(descLabel, c);
    add(descLabel);

    descText = new JTextField();
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(descText, c);
    add(descText);

    descText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            findParamsPanel.find();
        }
    });

    //Classifications
    classificationsLabel = new JLabel(resourceBundle.getString("title.classifications"),
            SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(classificationsLabel, c);
    add(classificationsLabel);

    classificationsList = new ClassificationsList();
    classificationsList.setEditable(true);
    classificationsList.setVisibleRowCount(3);

    JScrollPane classificationsListScrollPane = new JScrollPane(classificationsList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    classificationsListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 8;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(classificationsListScrollPane, c);
    add(classificationsListScrollPane);

    //Identifiers
    identifiersLabel = new JLabel(resourceBundle.getString("title.externalIdentifiers"),
            SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 9;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(identifiersLabel, c);
    add(identifiersLabel);

    extIdsList = new ExternalIdentifiersList();
    extIdsList.setEditable(true);
    extIdsList.setVisibleRowCount(3);

    JScrollPane extIdsListScrollPane = new JScrollPane(extIdsList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    extIdsListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 10;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(extIdsListScrollPane, c);
    add(extIdsListScrollPane);

    //External Links
    linksLabel = new JLabel(resourceBundle.getString("title.externalLinks"), SwingConstants.TRAILING);
    c.gridx = 0;
    c.gridy = 11;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(linksLabel, c);
    add(linksLabel);

    linksList = new ExternalLinksList();
    linksList.setEditable(true);
    linksList.setVisibleRowCount(3);

    JScrollPane linksListScrollPane = new JScrollPane(linksList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    linksListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 12;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(linksListScrollPane, c);
    add(linksListScrollPane);

    //add listener for 'locale' bound property
    RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_LOCALE, this);
}

From source file:jsonbrowse.JsonBrowse.java

/**
 * Builds a tree of TreeNode objects using the tree under the
 * given JsonNode./*w  w  w.  jav a 2 s.c  o  m*/
 * 
 * @param name Text to be associated with node
 * @param node
 * @return root TreeNode
 */
private DefaultMutableTreeNode buildTree(String name, JsonNode node) {
    DefaultMutableTreeNode treeNode = new DefaultMutableTreeNode(name);

    Iterator<Entry<String, JsonNode>> it = node.fields();
    while (it.hasNext()) {
        Entry<String, JsonNode> entry = it.next();
        treeNode.add(buildTree(entry.getKey(), entry.getValue()));
    }

    if (node.isArray()) {
        for (int i = 0; i < node.size(); i++) {
            JsonNode child = node.get(i);
            if (child.isValueNode())
                treeNode.add(new DefaultMutableTreeNode(child.asText()));
            else
                treeNode.add(buildTree(String.format("[%d]", i), child));
        }
    } else if (node.isValueNode()) {
        treeNode.add(new DefaultMutableTreeNode(node.asText()));
    }

    return treeNode;
}

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

public DefaultMutableTreeNode addNode(QueryConceptTreeNodeData node, DefaultMutableTreeNode parent) {
    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, parent, parent.getChildCount());
    if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) {
        treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount());
    }//from   www.j  a v  a2  s .  c o  m
    //Make sure the user can see the lovely new node.
    jTree1.scrollPathToVisible(new TreePath(childNode.getPath()));

    return childNode;
}

From source file:com.github.rholder.gradle.ui.DependencyViewerStandalone.java

public void updateView(GradleNode rootDependency, GradleNode selectedDependency) {
    // TODO replace this hack with something that populates the GradleNode graph

    DefaultMutableTreeNode fullRoot = new DefaultMutableTreeNode(new GradleNode("Project Dependencies"));
    if (rootDependency == null) {
        DefaultMutableTreeNode loading = new DefaultMutableTreeNode(new GradleNode("Loading..."));
        fullRoot.add(loading);/*  w  ww.j  a v a  2 s. c  o m*/
    } else {
        DefaultMutableTreeNode flattenedRoot = convertToSortedTreeNode(rootDependency);
        DefaultMutableTreeNode hierarchyRoot = convertToHierarchyTreeNode(rootDependency);
        fullRoot.add(flattenedRoot);
        fullRoot.add(hierarchyRoot);
    }

    TreeModel treeModel = new DefaultTreeModel(fullRoot);
    final JTree fullTree = new JTree(treeModel);
    fullTree.setCellRenderer(dependencyCellRenderer);

    // expand path for first level from root
    //fullTree.expandPath(new TreePath(hierarchyRoot.getNextNode().getPath()));

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            if (gradleBaseDir != null) {
                setTitle(TITLE + " - " + gradleBaseDir);
            }
            splitter.setLeftComponent(new JScrollPane(fullTree));
            splitter.setRightComponent(new JScrollPane(information));
            splitter.setDividerLocation(0.75);
        }
    });
}

From source file:hr.fer.zemris.vhdllab.view.explorer.ProjectExplorerView.java

@Override
protected JComponent createControl() {
    CommandManager commandManager = getActiveWindow().getCommandManager();
    commandManager.createCommandGroup("hierarchyMenu", new String[] { hierarchyXUsesYCommand.getId(),
            hierarchyXUsedByYCommand.getId(), hierarchyFlatCommand.getId() });
    CommandGroup commandGroup = commandManager.createCommandGroup("treePopupMenu",
            new String[] { "newMenu", "separator", openCommand.getId(), "separator", compileCommand.getId(),
                    simulateCommand.getId(), viewVhdlCommand.getId(), "separator", deleteCommand.getId(),
                    "separator", "hierarchyMenu" });
    popupMenu = commandGroup.createPopupMenu();

    root = new DefaultMutableTreeNode("vhdllab-root");
    model = new DefaultTreeModel(root);
    model.addTreeModelListener(new TreeModelAdapter() {
        @Override//from www .j  a v  a 2s  .c  om
        public void treeNodesInserted(TreeModelEvent e) {
            Object[] children = e.getChildren();
            if (children.length > 0) {
                Object child = children[children.length - 1];
                TreePath path = e.getTreePath().pathByAddingChild(child);
                tree.setSelectionPath(path);
            }
        }
    });
    tree = new JTree(model);
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    // tree is expanded manually in OpenFileOrShowPopupMenuListener
    tree.setToggleClickCount(0);
    tree.setCellRenderer(new WorkspaceCellRenderer());
    tree.addMouseListener(new OpenFileOrShowPopupMenuListener());
    tree.addTreeSelectionListener(new CommandGuard());
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    JPanel hierarchyPanel = new JPanel();
    hierarchyPanel.add(createHierarchyButton(hierarchyXUsesYCommand));
    hierarchyPanel.add(createHierarchyButton(hierarchyXUsedByYCommand));
    hierarchyPanel.add(createHierarchyButton(hierarchyFlatCommand));
    JPanel borderHierarchyPanel = new JPanel(new BorderLayout());
    borderHierarchyPanel.add(hierarchyPanel, BorderLayout.WEST);

    JPanel control = new JPanel(new BorderLayout());
    control.add(borderHierarchyPanel, BorderLayout.NORTH);
    control.add(new JScrollPane(tree), BorderLayout.CENTER);

    return control;
}