Example usage for javax.swing.tree DefaultMutableTreeNode add

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

Introduction

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

Prototype

public void add(MutableTreeNode newChild) 

Source Link

Document

Removes newChild from its parent and makes it a child of this node by adding it to the end of this node's child array.

Usage

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

private MutableTreeNode createPieChartsNode() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Pie Charts");
    DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(
            new DemoDescription("PieChartDemo1", "PieChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode(
            new DemoDescription("PieChartDemo2", "PieChartDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode(
            new DemoDescription("PieChartDemo3", "PieChartDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode(
            new DemoDescription("PieChartDemo4", "PieChartDemo4.java"));
    DefaultMutableTreeNode defaultmutabletreenode5 = new DefaultMutableTreeNode(
            new DemoDescription("PieChartDemo5", "PieChartDemo5.java"));
    DefaultMutableTreeNode defaultmutabletreenode6 = new DefaultMutableTreeNode(
            new DemoDescription("PieChartDemo6", "PieChartDemo6.java"));
    DefaultMutableTreeNode defaultmutabletreenode7 = new DefaultMutableTreeNode(
            new DemoDescription("PieChartDemo7", "PieChartDemo7.java"));
    DefaultMutableTreeNode defaultmutabletreenode8 = new DefaultMutableTreeNode(
            new DemoDescription("PieChartDemo8", "PieChartDemo8.java"));
    DefaultMutableTreeNode defaultmutabletreenode9 = new DefaultMutableTreeNode(
            new DemoDescription("PieChart3DDemo1", "PieChart3DDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode10 = new DefaultMutableTreeNode(
            new DemoDescription("PieChart3DDemo2", "PieChart3DDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode11 = new DefaultMutableTreeNode(
            new DemoDescription("PieChart3DDemo3", "PieChart3DDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode12 = new DefaultMutableTreeNode(
            new DemoDescription("MultiplePieChartDemo1", "MultiplePieChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode13 = new DefaultMutableTreeNode(
            new DemoDescription("RingChartDemo1", "RingChartDemo1.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);
    return defaultmutabletreenode;
}

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

private MutableTreeNode createLineChartsNode() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Line Charts");
    DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(
            new DemoDescription("AnnotationDemo1", "AnnotationDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode(
            new DemoDescription("LineChartDemo1", "LineChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode(
            new DemoDescription("LineChartDemo2", "LineChartDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode(
            new DemoDescription("LineChartDemo3", "LineChartDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode5 = new DefaultMutableTreeNode(
            new DemoDescription("LineChartDemo4", "LineChartDemo4.java"));
    DefaultMutableTreeNode defaultmutabletreenode6 = new DefaultMutableTreeNode(
            new DemoDescription("LineChartDemo5", "LineChartDemo5.java"));
    DefaultMutableTreeNode defaultmutabletreenode7 = new DefaultMutableTreeNode(
            new DemoDescription("LineChartDemo6", "LineChartDemo6.java"));
    DefaultMutableTreeNode defaultmutabletreenode8 = new DefaultMutableTreeNode(
            new DemoDescription("LineChartDemo7", "LineChartDemo7.java"));
    DefaultMutableTreeNode defaultmutabletreenode9 = new DefaultMutableTreeNode(
            new DemoDescription("LineChartDemo8", "LineChartDemo8.java"));
    DefaultMutableTreeNode defaultmutabletreenode10 = new DefaultMutableTreeNode(
            new DemoDescription("LineChart3DDemo1", "LineChart3DDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode11 = new DefaultMutableTreeNode(
            new DemoDescription("StatisticalLineChartDemo1", "StatisticalLineChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode12 = new DefaultMutableTreeNode(
            new DemoDescription("XYStepRendererDemo1", "XYStepRendererDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode13 = new DefaultMutableTreeNode(
            new DemoDescription("XYStepRendererDemo2", "XYStepRendererDemo2.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);
    return defaultmutabletreenode;
}

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

private MutableTreeNode createXYBarChartsNode() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("XYPlot");
    DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(
            new DemoDescription("XYBarChartDemo1", "XYBarChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode(
            new DemoDescription("XYBarChartDemo2", "XYBarChartDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode(
            new DemoDescription("XYBarChartDemo3", "XYBarChartDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode(
            new DemoDescription("XYBarChartDemo4", "XYBarChartDemo4.java"));
    DefaultMutableTreeNode defaultmutabletreenode5 = new DefaultMutableTreeNode(
            new DemoDescription("XYBarChartDemo5", "XYBarChartDemo5.java"));
    DefaultMutableTreeNode defaultmutabletreenode6 = new DefaultMutableTreeNode(
            new DemoDescription("XYBarChartDemo6", "XYBarChartDemo6.java"));
    DefaultMutableTreeNode defaultmutabletreenode7 = new DefaultMutableTreeNode(
            new DemoDescription("XYBarChartDemo7", "XYBarChartDemo7.java"));
    DefaultMutableTreeNode defaultmutabletreenode8 = new DefaultMutableTreeNode(
            new DemoDescription("ClusteredXYBarRendererDemo1", "ClusteredXYBarRendererDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode9 = new DefaultMutableTreeNode(
            new DemoDescription("StackedXYBarChartDemo1", "StackedXYBarChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode10 = new DefaultMutableTreeNode(
            new DemoDescription("StackedXYBarChartDemo2", "StackedXYBarChartDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode11 = new DefaultMutableTreeNode(
            new DemoDescription("StackedXYBarChartDemo3", "StackedXYBarChartDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode12 = new DefaultMutableTreeNode(
            new DemoDescription("RelativeDateFormatDemo1", "RelativeDateFormatDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode13 = new DefaultMutableTreeNode(
            new DemoDescription("RelativeDateFormatDemo2", "RelativeDateFormatDemo2.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);
    return defaultmutabletreenode;
}

From source file:gdt.jgui.entity.webset.JWebsetFacetOpenItem.java

/**
 * Get children nodes of the facet node for the digest view.
 * @return the children nodes of the facet node.
 *///from  w w w  .j av  a  2  s  .  c  o  m
@Override
public DefaultMutableTreeNode[] getDigest() {
    try {
        //      System.out.println("JWebsetFacetOpenItem:getDigest:locator="+locator$);
        Properties locator = Locator.toProperties(locator$);
        entihome$ = locator.getProperty(Entigrator.ENTIHOME);
        entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
        Entigrator entigrator = console.getEntigrator(entihome$);
        Sack entity = entigrator.getEntityAtKey(entityKey$);
        Core[] ca = entity.elementGet("web");
        if (ca == null)
            return null;
        DefaultMutableTreeNode nameNode;
        DefaultMutableTreeNode valueNode;
        String locator$ = getLocator();
        String nameLocator$;
        String valueLocator$;
        String nameIcon$;//=icon$=Support.readHandlerIcon(JEntitiesPanel.class, "text.png");
        String valueIcon$ = Support.readHandlerIcon(null, JEntitiesPanel.class, "equal.png");
        ArrayList<DefaultMutableTreeNode> nl = new ArrayList<DefaultMutableTreeNode>();
        for (Core aCa : ca) {
            nameNode = new DefaultMutableTreeNode();
            nameLocator$ = Locator.append(locator$, Locator.LOCATOR_TITLE, aCa.type);
            nameLocator$ = Locator.append(nameLocator$, Locator.LOCATOR_TYPE, JWeblinksPanel.WEB_LINK_NAME);
            nameLocator$ = Locator.append(nameLocator$, JWeblinksPanel.WEB_LINK_NAME, aCa.type);
            nameLocator$ = Locator.append(nameLocator$, JWeblinksPanel.WEB_LINK_KEY, aCa.name);
            nameIcon$ = entity.getElementItemAt("web.icon", aCa.name);
            if (nameIcon$ != null)
                nameLocator$ = Locator.append(nameLocator$, Locator.LOCATOR_ICON, nameIcon$);
            nameLocator$ = Locator.append(nameLocator$, JEntityDigestDisplay.NODE_TYPE, NODE_TYPE_WEB_NAME);
            if (entihome$ != null)
                nameLocator$ = Locator.append(nameLocator$, Entigrator.ENTIHOME, entihome$);
            nameLocator$ = Locator.append(nameLocator$, JEntityDigestDisplay.NODE_TYPE, NODE_TYPE_WEB_ADDRESS);
            if (entityKey$ != null)
                nameLocator$ = Locator.append(nameLocator$, EntityHandler.ENTITY_KEY, entityKey$);

            nameNode.setUserObject(nameLocator$);
            valueNode = new DefaultMutableTreeNode();
            valueLocator$ = Locator.append(locator$, Locator.LOCATOR_TITLE, aCa.value);
            valueLocator$ = Locator.append(valueLocator$, JWeblinksPanel.WEB_LINK_NAME, aCa.type);
            valueLocator$ = Locator.append(valueLocator$, JWeblinksPanel.WEB_LINK_URL, aCa.value);
            valueLocator$ = Locator.append(valueLocator$, JWeblinksPanel.WEB_LINK_KEY, aCa.name);
            valueLocator$ = Locator.append(valueLocator$, Locator.LOCATOR_TYPE, LOCATOR_TYPE_WEB_ADDRESS);
            valueLocator$ = Locator.append(valueLocator$, Locator.LOCATOR_ICON, valueIcon$);
            valueLocator$ = Locator.append(valueLocator$, JEntityDigestDisplay.NODE_TYPE,
                    NODE_TYPE_WEB_ADDRESS);
            if (entihome$ != null)
                valueLocator$ = Locator.append(valueLocator$, Entigrator.ENTIHOME, entihome$);
            valueLocator$ = Locator.append(valueLocator$, JEntityDigestDisplay.NODE_TYPE,
                    NODE_TYPE_WEB_ADDRESS);
            if (entityKey$ != null)
                valueLocator$ = Locator.append(valueLocator$, EntityHandler.ENTITY_KEY, entityKey$);

            valueNode.setUserObject(valueLocator$);
            //            System.out.println("JFieldsFacetOpenItem:getDigest:VALUE locator="+valueLocator$);
            nameNode.add(valueNode);
            nl.add(nameNode);
        }
        return nl.toArray(new DefaultMutableTreeNode[0]);
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
    return null;
}

From source file:edu.ucla.stat.SOCR.chart.ChartTree.java

/**
 * Creates the subtree containing the miscellaneous chart types.
 * /*from w w w.  ja v a2s  . c  o m*/
 * @return A subtree.
 */
private MutableTreeNode createMiscellaneousChartsNode() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Miscellaneous");

    DefaultMutableTreeNode n0 = new DefaultMutableTreeNode(new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo1", "BoxAndWhiskerChartDemo1"));

    DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.BubbleChartDemo1", "BubbleChartDemo1"));
    DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.CategoryStepChartDemo1", "CategoryStepChartDemo1"));
    DefaultMutableTreeNode n3 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.CompassDemo1", "CompassDemo1"));
    DefaultMutableTreeNode n4 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.CompassFormatDemo1", "CompassFormatDemo1"));
    DefaultMutableTreeNode n5 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.CompassFormatDemo2", "CompassFormatDemo2"));
    DefaultMutableTreeNode n6 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.DifferenceChartDemo1", "DifferenceChartDemo1"));
    DefaultMutableTreeNode n7 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.DifferenceChartDemo2", "DifferenceChartDemo2"));
    DefaultMutableTreeNode n8 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.EventFrequencyDemo1", "EventFrequencyDemo1"));

    DefaultMutableTreeNode n9 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.HideSeriesDemo1", "HideSeriesDemo1"));

    DefaultMutableTreeNode n10 = new DefaultMutableTreeNode(new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.OverlaidBarChartDemo1", "OverlaidBarChartDemo1"));

    DefaultMutableTreeNode n11 = new DefaultMutableTreeNode(new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.OverlaidBarChartDemo2", "OverlaidBarChartDemo2"));

    DefaultMutableTreeNode n12 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.SpiderWebChartDemo1", "SpiderWebChartDemo1"));
    DefaultMutableTreeNode n13 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.SymbolAxisDemo1", "SymbolAxisDemo1"));
    DefaultMutableTreeNode n14 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.PolarChartDemo1", "PolarChartDemo1"));
    DefaultMutableTreeNode n15 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.YIntervalChartDemo1", "YIntervalChartDemo1"));

    root.add(createCrosshairChartsNode());
    //  root.add(createItemLabelsNode());
    //  root.add(createLegendNode());
    //  root.add(createMarkersNode());
    // root.add(createOrientationNode());
    root.add(n0);
    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);

    return root;
}

From source file:edu.ucla.stat.SOCR.chart.ChartTree.java

/**
 * Creates a sub-tree for the time series charts.
 * /*  www  .  j  av  a  2  s .  c  o  m*/
 * @return The root node for the subtree.
 */
private MutableTreeNode createTimeSeriesChartsNode() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Time Series Charts");

    DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo1", "TimeSeriesDemo1"));
    DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo2", "TimeSeriesDemo2"));
    DefaultMutableTreeNode n3 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo3", "TimeSeriesDemo3"));
    DefaultMutableTreeNode n4 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo4", "TimeSeriesDemo4"));
    DefaultMutableTreeNode n5 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo5", "TimeSeriesDemo5"));
    DefaultMutableTreeNode n6 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo6", "TimeSeriesDemo6"));
    DefaultMutableTreeNode n7 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo7", "TimeSeriesDemo7"));
    DefaultMutableTreeNode n8 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo8", "TimeSeriesDemo8"));
    DefaultMutableTreeNode n9 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo9", "TimeSeriesDemo9"));
    DefaultMutableTreeNode n10 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo10", "TimeSeriesDemo10"));
    DefaultMutableTreeNode n11 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo11", "TimeSeriesDemo11"));
    DefaultMutableTreeNode n12 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo12", "TimeSeriesDemo12"));
    DefaultMutableTreeNode n13 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.TimeSeriesDemo13", "TimeSeriesDemo13"));
    DefaultMutableTreeNode n14 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.PeriodAxisDemo1", "PeriodAxisDemo1"));
    DefaultMutableTreeNode n15 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.PeriodAxisDemo2", "PeriodAxisDemo2"));
    DefaultMutableTreeNode n16 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.DynamicDataDemo1", "DynamicDataDemo1"));
    DefaultMutableTreeNode n17 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.DynamicDataDemo2", "DynamicDataDemo2"));
    DefaultMutableTreeNode n18 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.DynamicDataDemo3", "DynamicDataDemo3"));

    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);

    return root;
}

From source file:net.jradius.client.gui.JRadiusSimulator.java

private void addAttributesToTable(DefaultMutableTreeNode node, Map<String, Class<?>> map, boolean skipVSA) {
    LinkedHashMap<String, String> attributeList = new LinkedHashMap<String, String>();
    for (Iterator<Map.Entry<String, Class<?>>> i = map.entrySet().iterator(); i.hasNext();) {
        Map.Entry<String, Class<?>> entry = i.next();
        String type = entry.getKey();
        Class<?> clazz = entry.getValue();
        try {/*from  w w  w.j  a v a2 s  .  c  o m*/
            RadiusAttribute attribute = (RadiusAttribute) clazz.newInstance();
            if (!skipVSA || (!(attribute instanceof VSAttribute) && attribute.getType() <= 255)) {
                String attributeName = attribute.getAttributeName();
                if (attributeName.equals("Vendor-Specific"))
                    continue;
                if (attributeName.startsWith("X-Ascend-"))
                    continue;
                attributeList.put(type, attributeName);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    LinkedList<String> list = new LinkedList<String>(attributeList.keySet());
    Collections.sort(list);
    for (Iterator<String> i = list.iterator(); i.hasNext();) {
        node.add(new DefaultMutableTreeNode(attributeList.get(i.next())));
    }
}

From source file:GUI.MainWindow.java

private void AddToPersonalVulnsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddToPersonalVulnsActionPerformed

    System.out.println("Add to personal vulns section");

    DefaultTreeModel dtm = (DefaultTreeModel) VulnTree.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) dtm.getRoot();
    TreePath[] paths = VulnTree.getSelectionPaths();

    // If there are no paths then no nodes have been selected, ignore the request
    if (paths == null) {
        return;//w  ww.  jav  a  2s  .com
    }

    DefaultTreeModel personaldtm = (DefaultTreeModel) this.personal_vulns_window.PersonalVulnsTree.getModel();
    DefaultMutableTreeNode personalroot = (DefaultMutableTreeNode) personaldtm.getRoot();

    // For each selected node
    for (int i = 0; i < paths.length; i++) {
        TreePath path = paths[i]; // Get the node
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
        Object obj = node.getUserObject();
        // Make sure it has an object of type Vulnerability
        if (obj != null && obj instanceof Vulnerability) {
            Vulnerability vuln = (Vulnerability) obj;
            if (vuln.containsIdentifier("24d459a81449d721c8f9a86c2913034", "ReportCompiler")) {
                JOptionPane.showMessageDialog(null,
                        "Attempting to add a personal vuln with the title 'NEW' has a dangerous identifier, please change the title first\n"
                                + vuln.getTitle());
                return;
            }
            // Clone that vulnerability so it isn't the same object that is in the main tree
            Vulnerability newvuln = new Vulnerability();
            newvuln.setTitle(vuln.getTitle());
            newvuln.setRecommendation(vuln.getRecommendation());
            newvuln.setDescription(vuln.getDescription());
            newvuln.cloneReferences(vuln);
            newvuln.cloneRisk(vuln);
            newvuln.cloneIdentifiers(vuln);
            // Add the clone to the personal vulns database
            // TODO do something clever where a vuln exists that has an ID in this one.
            if (new TreeUtils().OkToaddToPersonalVulns(personalroot, newvuln)) {
                personalroot.add(new DefaultMutableTreeNode(newvuln));
                System.out.println("Added to personal vulns: " + newvuln);
                System.out.println("Hosts: " + newvuln.getAffectedHosts().size());
            } else {
                JOptionPane.showMessageDialog(null, "A personal vuln exists that may match that already");
            }

        }
    }

    // Sort the tree
    personalroot = new TreeUtils().sortVulns(personalroot);
    // Update the model
    personaldtm.setRoot(personalroot);

    try {

        // Save the tree again
        new SaveFileExporter().save(this.personal_vulns_window.person_vulns_file, personalroot);
        System.out.println(
                "Personal Vulns Saved: " + this.personal_vulns_window.person_vulns_file.getAbsolutePath());
    } catch (Exception ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
    }

}

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

public Map getAllPublishingNode(TreeFunctions treeFunctions, TreeIdGenerator idGen,
        boolean showFormsAlphebetically) throws Exception {
    CSITransferObject publishFormCSI = null, publishTemplateCSI = null;

    DefaultMutableTreeNode publishNode = null;
    Map formPublishCSCSIMap = new HashMap();
    Map templatePublishCSCSIMap = new HashMap();
    Map publishNodeByContextMap = new HashMap();

    Map formCSMap = getFormClassificationNodes(treeFunctions, idGen, CaDSRConstants.FORM_CS_TYPE,
            CaDSRConstants.FORM_CSI_TYPE);
    Map templateCSMap = getFormClassificationNodes(treeFunctions, idGen, CaDSRConstants.TEMPLATE_CS_TYPE,
            CaDSRConstants.TEMPLATE_CSI_TYPE);

    FormDAO dao = daoFactory.getFormDAO();
    List formCSIs = dao.getAllPublishingCSCSIsForForm();

    Iterator formIter = formCSIs.iterator();

    while (formIter.hasNext()) {
        publishFormCSI = (CSITransferObject) formIter.next();

        formPublishCSCSIMap.put(publishFormCSI.getCsConteIdseq(), publishFormCSI);
    }/* ww  w  .j av  a2  s  .  co m*/

    List templateCSIs = dao.getAllPublishingCSCSIsForTemplate();

    Iterator templateIter = templateCSIs.iterator();

    while (templateIter.hasNext()) {
        publishTemplateCSI = (CSITransferObject) templateIter.next();

        templatePublishCSCSIMap.put(publishTemplateCSI.getCsConteIdseq(), publishTemplateCSI);
    }

    // get all form publishing context
    Collection formPublishingContexts = formPublishCSCSIMap.keySet();
    Iterator contextIter = formPublishingContexts.iterator();
    Map treeNodeMap = new HashMap();

    while (contextIter.hasNext()) {
        String currContextId = (String) contextIter.next();
        treeNodeMap.clear();

        publishFormCSI = (CSITransferObject) formPublishCSCSIMap.get(currContextId);
        publishNode = new DefaultMutableTreeNode(
                new WebNode(idGen.getNewId(), publishFormCSI.getClassSchemeLongName()));
        publishNodeByContextMap.put(currContextId, publishNode);

        List publishedProtocols = null;
        List publishedForms = null;

        publishedProtocols = dao.getAllProtocolsForPublishedForms(currContextId);

        publishedForms = new ArrayList();

        if (showFormsAlphebetically)
            publishedForms = dao.getAllPublishedForms(currContextId);

        if (!publishedProtocols.isEmpty() || !publishedForms.isEmpty()) {
            DefaultMutableTreeNode publishFormNode = new DefaultMutableTreeNode(
                    new WebNode(idGen.getNewId(), publishFormCSI.getClassSchemeItemName()));

            publishNode.add(publishFormNode);

            if (!publishedForms.isEmpty() && showFormsAlphebetically) {
                DefaultMutableTreeNode listedAlphabetically = new DefaultMutableTreeNode(
                        new WebNode(idGen.getNewId(), "Listed Alphabetically"));

                Iterator formsIt = publishedForms.iterator();

                while (formsIt.hasNext()) {
                    Form currForm = (Form) formsIt.next();

                    listedAlphabetically.add(getFormNode(idGen.getNewId(), currForm, treeFunctions, true));
                }

                publishFormNode.add(listedAlphabetically);
            }

            //starting here
            if (!publishedProtocols.isEmpty()) {
                DefaultMutableTreeNode listedByProtocol = new DefaultMutableTreeNode(
                        new WebNode(idGen.getNewId(), "Listed by Protocol"));

                Iterator protocolIt = publishedProtocols.iterator();

                while (protocolIt.hasNext()) {
                    Protocol currProto = (Protocol) protocolIt.next();

                    // first create protocol node for each protocol
                    DefaultMutableTreeNode currProtoNode = getProtocolNode(idGen.getNewId(), currProto,
                            currContextId, treeFunctions);

                    // then add all form nodes
                    List formsForProtocol = dao.getAllPublishedFormsForProtocol(currProto.getIdseq());

                    Iterator protocolFormsIt = formsForProtocol.iterator();

                    while (protocolFormsIt.hasNext()) {
                        Form currProtocolForm = (Form) protocolFormsIt.next();

                        //TODO - tree for multiple form/protocols
                        //currProtocolForm.setProtocol(currProto);

                        Collection formCSes = currProtocolForm.getClassifications();

                        if (formCSes == null || formCSes.size() == 0) {
                            currProtoNode.add(
                                    this.getFormNode(idGen.getNewId(), currProtocolForm, treeFunctions, true));
                        } else {
                            //add formNode to csTree
                            Iterator csIter = formCSes.iterator();
                            while (csIter.hasNext()) {
                                ClassSchemeItem currCSI = (ClassSchemeItem) csIter.next();

                                Map currCSMap = (Map) formCSMap.get(currCSI.getCsConteIdseq());
                                this.copyCSTree(currProtocolForm, currCSMap, treeNodeMap,
                                        getFormNode(idGen.getNewId(), currProtocolForm, treeFunctions, true),
                                        currProtoNode, idGen);
                            }
                        }

                        listedByProtocol.add(currProtoNode);
                    }

                    publishFormNode.add(listedByProtocol);
                }
            }
        }
    }
    // get all publishing template context
    Collection templatePublishingContexts = templatePublishCSCSIMap.keySet();
    contextIter = templatePublishingContexts.iterator();

    while (contextIter.hasNext()) {
        List publishedTemplates = null;
        treeNodeMap.clear();

        String currContextId = (String) contextIter.next();
        publishTemplateCSI = (CSITransferObject) templatePublishCSCSIMap.get(currContextId);
        publishNode = (DefaultMutableTreeNode) publishNodeByContextMap.get(currContextId);

        if (publishNode == null) {
            publishNode = new DefaultMutableTreeNode(
                    new WebNode(idGen.getNewId(), publishTemplateCSI.getClassSchemeLongName()));

            publishNodeByContextMap.put(currContextId, publishNode);
        }

        publishedTemplates = dao.getAllPublishedTemplates(currContextId);

        if (publishedTemplates != null && !publishedTemplates.isEmpty()) {
            DefaultMutableTreeNode publishTemplateNode = new DefaultMutableTreeNode(
                    new WebNode(idGen.getNewId(), publishTemplateCSI.getClassSchemeItemName()));

            Iterator templateIt = publishedTemplates.iterator();

            while (templateIt.hasNext()) {
                Form currTemplate = (Form) templateIt.next();

                if (currTemplate.getClassifications() == null
                        || currTemplate.getClassifications().size() == 0) {
                    publishTemplateNode.add(getTemplateNode(idGen.getNewId(), currTemplate, treeFunctions));
                } else {
                    //add template node to csTree(s)
                    Iterator csIter = currTemplate.getClassifications().iterator();
                    while (csIter.hasNext()) {
                        ClassSchemeItem currCSI = (ClassSchemeItem) csIter.next();

                        Map currCSMap = (Map) templateCSMap.get(currCSI.getCsConteIdseq());
                        this.copyCSTree(currTemplate, currCSMap, treeNodeMap,
                                getTemplateNode(idGen.getNewId(), currTemplate, treeFunctions),
                                publishTemplateNode, idGen);
                    }

                }

            }

            publishNode.add(publishTemplateNode);
        }
    }

    return publishNodeByContextMap;
}