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:ai.aitia.meme.paramsweep.intellisweepPlugin.JgapGAPlugin.java

protected DefaultMutableTreeNode getAlteredParameterTreeRootNode(final IIntelliContext ctx) {
    genotype = generateInitialPopulation(ctx);

    final Population descendants = genotype.getPopulation();
    final DefaultMutableTreeNode root = new DefaultMutableTreeNode("Parameter file");

    paramList = ctx.getParameters();/*from   ww  w .  j  a va 2s .co m*/
    for (int i = 0; i < paramList.size(); ++i) {
        final ParameterInfo paramInfo = paramList.get(i);
        paramInfo.setRuns(1); // Run is always 1

        final List<Object> values = new ArrayList<Object>();

        final int genIdx = whichGene(paramInfo.getName());
        if (genIdx >= 0) {
            for (int j = 0; j < populationSize; ++j) {
                final String strValue = String
                        .valueOf(descendants.getChromosome(j).getGene(genIdx).getAllele());
                values.add(ParameterInfo.getValue(strValue, paramInfo.getJavaType()));
                paramInfo.setDefinitionType(ParameterInfo.LIST_DEF);
            }
        } else {
            values.add(paramInfo.getValue());
            paramInfo.setDefinitionType(ParameterInfo.CONST_DEF);
        }

        paramInfo.setValues(values);

        // add the node
        root.add(new DefaultMutableTreeNode(paramInfo));
    }

    return root;
}

From source file:eu.crisis_economics.abm.dashboard.GASearchHandler.java

protected DefaultMutableTreeNode getAlteredParameterTreeRootNode(final IIntelliContext ctx) {
    genotype = generateInitialPopulation(ctx);

    final Population descendants = genotype.getPopulation();
    final DefaultMutableTreeNode root = new DefaultMutableTreeNode("Parameter file");

    paramList = ctx.getParameters();/*from   w w  w. j a  v a 2s. c o m*/
    for (int i = 0; i < paramList.size(); ++i) {
        final ParameterInfo paramInfo = paramList.get(i);
        paramInfo.setRuns(1); // Run is always 1

        final List<Object> values = new ArrayList<Object>();

        final int genIdx = whichGene(calculateName(paramInfo));
        for (int j = 0; j < populationSize; ++j) {
            if (genIdx >= 0) {
                final String strValue = String
                        .valueOf(descendants.getChromosome(j).getGene(genIdx).getAllele());
                values.add(ParameterInfo.getValue(strValue, paramInfo.getType()));
                paramInfo.setDefinitionType(ParameterInfo.LIST_DEF);
            } else {
                values.add(paramInfo.getValue());
                paramInfo.setDefinitionType(ParameterInfo.CONST_DEF);
            }
        }

        paramInfo.setValues(values);

        // add and save the node
        root.add(new DefaultMutableTreeNode(paramInfo));
    }

    return root;
}

From source file:edu.ku.brc.specify.tasks.subpane.security.SecurityAdminPane.java

/**
 * @param session//from   ww  w  .  j av  a2s .co  m
 * @param node
 * @param scope
 */
private void addGroup(final DataProviderSessionIFace session, final DefaultMutableTreeNode node,
        final UserGroupScope scope) {
    String userPrin = UserPrincipal.class.getName();

    // sort groups
    Vector<SpPrincipal> groups = new Vector<SpPrincipal>();
    for (SpPrincipal group : scope.getUserGroups()) {
        String subClass = group.getGroupSubClass();
        if (group.getGroupType() == null && StringUtils.isNotEmpty(subClass) && subClass.equals(userPrin))
            continue;
        groups.add(group);
    }

    Collections.sort(groups, new Comparator<SpPrincipal>() {
        @Override
        public int compare(SpPrincipal obj1, SpPrincipal obj2) {
            if (obj1 != null && obj1.getPriority() != null && obj2 != null && obj2.getPriority() != null) {
                return obj2.getPriority().compareTo(obj1.getPriority());
            }
            return 100; // shouldn't happen
        }
    });

    for (SpPrincipal group : groups) {
        //log.debug(scope.getId()+"  "+scope.getTableId());
        //log.debug("      Group: "+group.getName()+"  "+ group.getGroupType()+"  "+ group.getGroupSubClass()+"  "+ group.getId());

        String subClass = group.getGroupSubClass();
        if (group.getGroupType() == null && StringUtils.isNotEmpty(subClass) && subClass.equals(userPrin))
            continue;

        //if (UserPrincipal.class.getCanonicalName().equals(group.getGroupSubClass())) continue;

        DefaultMutableTreeNode groupNode = new DefaultMutableTreeNode(new DataModelObjBaseWrapper(group));
        node.add(groupNode);

        // sort users
        TreeSet<SpecifyUser> users = new TreeSet<SpecifyUser>(group.getSpecifyUsers());
        for (SpecifyUser user : users) {
            // save user into user list
            spUsers.add(user);

            user.getSpPrincipals().size();
            DefaultMutableTreeNode userNode = new DefaultMutableTreeNode(new DataModelObjBaseWrapper(user));
            groupNode.add(userNode);
            //log.debug("        SpUser: "+user.getName());
        }
    }
}

From source file:Creator.WidgetPanel.java

public void loadTree() {

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Widget Links");
    treeModel = new DefaultTreeModel(root, true);

    Map<String, DefaultMutableTreeNode> treeMap = new TreeMap<>();

    for (Entry<String, WidgetLink> entry : ws.getWidgetLinkEntrySet()) {

        String[] entryString = entry.getKey().split("-");

        if (!treeMap.containsKey(entryString[0])) {
            DefaultMutableTreeNode folder = new DefaultMutableTreeNode(entryString[0], true);
            treeMap.put(entryString[0], folder);
        }/* www .  j a v a 2  s . c o  m*/

        DefaultMutableTreeNode child = new DefaultMutableTreeNode(entryString[1], true);

        // Add the fields of the widget link
        for (String s : entry.getValue().getTreeStrings()) {
            MutableTreeNode childStats = new DefaultMutableTreeNode(s, false);
            child.add(childStats);
        }

        //MutableTreeNode child = new DefaultMutableTreeNode(entry.getValue().getTreeStrings(entryString[1]), false);
        treeMap.get(entryString[0]).add(child);
    }

    for (Entry<String, DefaultMutableTreeNode> entry : treeMap.entrySet()) {
        root.add(entry.getValue());
    }

    _JTree_WidgetLinks.setModel(treeModel);

}

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

private void createAttributeTreeNodes(DefaultMutableTreeNode top) {
    DefaultMutableTreeNode standardTree = new DefaultMutableTreeNode("Standard Attributes");
    DefaultMutableTreeNode vsaTree = new DefaultMutableTreeNode("Vendor Specific Attributes");
    addAttributesToTable(standardTree, AttributeFactory.getAttributeNameMap(), true);
    top.add(standardTree);

    Map<Long, VendorValue> vendors = AttributeFactory.getVendorValueMap();
    LinkedHashMap<String, Map<String, Class<?>>> dictList = new LinkedHashMap<String, Map<String, Class<?>>>();
    for (Iterator<VendorValue> i = vendors.values().iterator(); i.hasNext();) {
        VendorValue vendor = i.next();//  w w w .j  a  va 2  s.c  o  m
        try {
            VSADictionary dict = (VSADictionary) vendor.getDictClass().newInstance();
            String vendorName = dict.getVendorName();
            Map<String, Class<?>> map = vendor.getAttributeNameMap();
            System.out.println("Loading vendor " + vendorName + " with " + map.size() + " attributes.");
            dictList.put(vendorName, map);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    LinkedList<String> list = new LinkedList<String>(dictList.keySet());
    Collections.sort(list);
    for (Iterator<String> i = list.iterator(); i.hasNext();) {
        String vendorName = i.next();
        DefaultMutableTreeNode vsaNode = new DefaultMutableTreeNode(vendorName);
        addAttributesToTable(vsaNode, dictList.get(vendorName), false);
        vsaTree.add(vsaNode);
    }
    top.add(vsaTree);
}

From source file:com.yosanai.java.aws.console.panel.InstancesPanel.java

public void loadInstances() {
    new Thread(new Runnable() {

        @Override/*from w  w  w .ja va2 s.  c  om*/
        public void run() {
            DefaultTreeModel treeModel = (DefaultTreeModel) trInstances.getModel();
            DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) treeModel.getRoot();
            tblInstances.clearSelection();
            trInstances.clearSelection();
            rootNode.removeAllChildren();
            treeModel.reload();
            tblInstances.setModel(instancesTableModel);
            DescribeInstancesResult result = awsConnectionProvider.getConnection().describeInstances();
            while (0 < instancesTableModel.getRowCount()) {
                instancesTableModel.removeRow(0);
            }
            for (Reservation reservation : result.getReservations()) {
                for (Instance instance : reservation.getInstances()) {
                    String name = null;
                    StringBuilder tags = new StringBuilder();
                    for (Tag tag : instance.getTags()) {
                        tags.append(tag.getKey());
                        tags.append("=");
                        tags.append(tag.getValue());
                        if (StringUtils.equalsIgnoreCase(nameTag, tag.getKey())) {
                            name = tag.getValue();
                        }
                    }
                    try {
                        boolean apiTermination = awsConnectionProvider
                                .getApiTermination(instance.getInstanceId());
                        instancesTableModel.addRow(new Object[] { instance.getInstanceId(),
                                instance.getPublicDnsName(), instance.getPublicIpAddress(),
                                instance.getPrivateDnsName(), instance.getPrivateIpAddress(),
                                apiTermination ? "Yes" : "No", instance.getState().getName(),
                                instance.getInstanceType(), instance.getKeyName(),
                                StringUtils.join(reservation.getGroupNames(), ","),
                                instance.getPlacement().getAvailabilityZone(),
                                DATE_FORMAT.format(instance.getLaunchTime()), tags.toString() });
                        DefaultMutableTreeNode instanceNode = new DefaultMutableTreeNode(
                                new InstanceObjectWrapper(instance, name), false);
                        rootNode.add(instanceNode);
                        treeModel.reload();
                    } catch (Exception ex) {
                        Logger.getLogger(InstancesPanel.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    }).start();
}

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

private MutableTreeNode createXYChartsNode() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("XY Charts");
    DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(
            new DemoDescription("ScatterPlotDemo1", "ScatterPlotDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode(
            new DemoDescription("ScatterPlotDemo2", "ScatterPlotDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode(
            new DemoDescription("ScatterPlotDemo3", "ScatterPlotDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode(
            new DemoDescription("XYBlockChartDemo1", "XYBlockChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode5 = new DefaultMutableTreeNode(
            new DemoDescription("XYBlockChartDemo2", "XYBlockChartDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode6 = new DefaultMutableTreeNode(
            new DemoDescription("XYBlockChartDemo3", "XYBlockChartDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode7 = new DefaultMutableTreeNode(
            new DemoDescription("XYLineAndShapeRendererDemo1", "XYLineAndShapeRendererDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode8 = new DefaultMutableTreeNode(
            new DemoDescription("XYSeriesDemo1", "XYSeriesDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode9 = new DefaultMutableTreeNode(
            new DemoDescription("XYSeriesDemo2", "XYSeriesDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode10 = new DefaultMutableTreeNode(
            new DemoDescription("XYSeriesDemo3", "XYSeriesDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode11 = new DefaultMutableTreeNode(
            new DemoDescription("experimental.VectorPlotDemo1", "VectorPlotDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode12 = new DefaultMutableTreeNode(
            new DemoDescription("WindChartDemo1", "WindChartDemo1.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);
    return defaultmutabletreenode;
}

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

private void addThreadDumps(DefaultMutableTreeNode top, InputStream dumpFileStream) {
    DumpParser dp = null;// ww w  .j  a  va2 s.  c o m
    try {
        String fileName = top.getUserObject().toString();
        Map<String, Map<String, String>> dumpMap = null;
        if (runningAsJConsolePlugin || runningAsVisualVMPlugin) {
            dumpMap = dumpStore.getFromDumpFiles(fileName);
        }

        if (dumpMap == null) {
            dumpMap = new HashMap<>();
            dumpStore.addFileToDumpFiles(fileName, dumpMap);
        }
        dp = DumpParserFactory.get().getDumpParserForLogfile(dumpFileStream, dumpMap, runningAsJConsolePlugin,
                dumpCounter);
        ((Logfile) top.getUserObject()).setUsedParser(dp);

        while ((dp != null) && dp.hasMoreDumps()) {
            top.add(dp.parseNext());
            if (!isFoundClassHistogram) {
                isFoundClassHistogram = dp.isFoundClassHistograms();
            }
        }
    } finally {
        if (dp != null) {
            try {
                dp.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
}

From source file:gdt.jgui.entity.fields.JFieldsFacetOpenItem.java

/**
 * Get children nodes of the facet node for the digest view.
 * @return the children nodes of the facet node.
 */// ww  w  .  j a  v  a  2s. c om
@Override
public DefaultMutableTreeNode[] getDigest() {
    try {
        //System.out.println("JFieldsFacetOpenItem: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("field");
        if (ca == null)
            return null;
        DefaultMutableTreeNode nameNode;
        DefaultMutableTreeNode valueNode;
        String locator$ = getLocator();
        String nameLocator$;
        String valueLocator$;
        String nameIcon$ = icon$ = Support.readHandlerIcon(null, 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.name);
            nameLocator$ = Locator.append(nameLocator$, Locator.LOCATOR_TYPE, FIELD_NAME);
            nameLocator$ = Locator.append(nameLocator$, FIELD_NAME, aCa.name);
            nameLocator$ = Locator.append(nameLocator$, Locator.LOCATOR_ICON, nameIcon$);
            nameLocator$ = Locator.append(nameLocator$, JEntityDigestDisplay.NODE_TYPE, NODE_TYPE_FIELD_NAME);
            if (entihome$ != null)
                nameLocator$ = Locator.append(nameLocator$, Entigrator.ENTIHOME, entihome$);
            nameLocator$ = Locator.append(nameLocator$, JEntityDigestDisplay.NODE_TYPE, NODE_TYPE_FIELD_VALUE);
            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$, FIELD_NAME, aCa.name);
            valueLocator$ = Locator.append(valueLocator$, FIELD_VALUE, aCa.value);
            valueLocator$ = Locator.append(valueLocator$, Locator.LOCATOR_TYPE, FIELD_VALUE);
            valueLocator$ = Locator.append(valueLocator$, Locator.LOCATOR_ICON, valueIcon$);
            valueLocator$ = Locator.append(valueLocator$, JEntityDigestDisplay.NODE_TYPE,
                    NODE_TYPE_FIELD_VALUE);
            if (entihome$ != null)
                valueLocator$ = Locator.append(valueLocator$, Entigrator.ENTIHOME, entihome$);
            valueLocator$ = Locator.append(valueLocator$, JEntityDigestDisplay.NODE_TYPE,
                    NODE_TYPE_FIELD_VALUE);
            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 a tree node containing line chart items.
 * //from ww w . j  a  va2 s . c  om
 * @return A tree node.
 */
private MutableTreeNode createLineChartsNode() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Line Charts");

    DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.AnnotationDemo1", "AnnotationDemo1"));
    DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.LineChartDemo1", "LineChartDemo1"));
    DefaultMutableTreeNode n3 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.LineChartDemo2", "LineChartDemo2"));
    DefaultMutableTreeNode n3a = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.ScatterChartDemo1", "ScatterChartDemo1"));
    DefaultMutableTreeNode n3b = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.QQNormalPlotDemo", "QQNormalPlotDemo"));
    DefaultMutableTreeNode n3c = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.QQData2DataDemo", "QQData2DataDemo"));
    DefaultMutableTreeNode n4 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.LineChartDemo3", "LineChartDemo3"));

    DefaultMutableTreeNode n5 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.LineChartDemo4", "LineChartDemo4"));
    DefaultMutableTreeNode n6 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.LineChartDemo5", "LineChartDemo5"));
    DefaultMutableTreeNode n7 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.LineChartDemo6", "LineChartDemo6"));
    DefaultMutableTreeNode n8 = new DefaultMutableTreeNode(new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.NormalDistributionDemo", "NormalDistributionDemo"));
    DefaultMutableTreeNode n9 = new DefaultMutableTreeNode(new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.StatisticalLineChartDemo1", "StatisticalLineChartDemo1"));
    DefaultMutableTreeNode n10 = new DefaultMutableTreeNode(new DemoDescription(
            "edu.ucla.stat.SOCR.chart.demo.StatisticalLineChartDemo2", "StatisticalLineChartDemo2"));

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

    //  root.add(n1);
    root.add(n2);
    root.add(n3);
    root.add(n4);

    // root.add(n5);
    root.add(n6);
    //  root.add(n7);//same as n3
    root.add(n3a);
    root.add(n3b);// qqnormaldemo
    root.add(n3c); // qqdddemo
    root.add(n8);
    root.add(n9);
    root.add(n10);
    root.add(n11);

    return root;
}