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:gdt.jgui.entity.JEntityStructurePanel.java

/**
 * Create the context.//from   w ww . java2  s  . c  o m
 * @param console the main console.
 * @param locator$ the locator.
 * @return the structure panel.
 */
@Override
public JContext instantiate(JMainConsole console, String locator$) {
    this.console = console;
    this.locator$ = locator$;
    Properties locator = Locator.toProperties(locator$);
    entihome$ = locator.getProperty(Entigrator.ENTIHOME);
    entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
    entityLabel$ = locator.getProperty(EntityHandler.ENTITY_LABEL);
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(entityLabel$);
    locator = new Properties();
    locator.setProperty(Locator.LOCATOR_TITLE, STRUCTURE);
    String icon$ = Support.readHandlerIcon(null, getClass(), "tree.png");
    locator.setProperty(Locator.LOCATOR_ICON, icon$);
    root.setUserObject(Locator.toString(locator));
    DefaultMutableTreeNode parentNode = new DefaultMutableTreeNode(entityLabel$);
    root.add(parentNode);
    Entigrator entigrator = console.getEntigrator(entihome$);
    Sack parent = entigrator.getEntityAtKey(entityKey$);
    String parentLocator$ = EntityHandler.getEntityLocator(entigrator, parent);
    parentNode.setUserObject(parentLocator$);
    addChildren(parentNode);
    tree = new JTree(root);
    tree.addTreeSelectionListener(new SelectionListener());
    tree.setShowsRootHandles(true);
    tree.setCellRenderer(new NodeRenderer());
    tree.addMouseListener(new MousePopupListener());
    scrollPane.getViewport().add(tree);
    expandTree(tree, true);
    return this;
}

From source file:edu.ku.brc.specify.config.DebugLoggerDialog.java

protected void buildTree(final Logger logger, DefaultMutableTreeNode parent, final String[] names,
        final int level) {
    for (int i = 0; i < parent.getChildCount(); i++) {
        LoggerNode node = (LoggerNode) parent.getChildAt(i);
        //System.out.println("["+node.toString()+"]["+names[level]+"]");
        if (node.toString().equals(names[level])) {
            buildTree(logger, node, names, level + 1);
            return;
        }// w  w  w. ja v a 2s  .  c o  m
    }

    LoggerNode newNode = new LoggerNode(logger, names[level]);
    newNode.setSelected(logger.getLevel() == Level.DEBUG);
    parent.add(newNode);
    newNode.setParent(parent);
    if (level < names.length - 1) {
        buildTree(logger, newNode, names, level + 1);
    }
}

From source file:cloud.gui.CloudGUI.java

public void updateTree(ELBTable table) {
    elbTab.remove(elbTree);//ww  w. j av a 2s .  co m
    DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode("Elastic Load Balancer Table");
    for (ELBEntry entry : table.getEntries()) {
        DefaultMutableTreeNode replicas = new DefaultMutableTreeNode(
                "Replicas (" + entry.getNrOfReplicas() + ")");
        for (Node node : entry.getReplicas()) {
            DefaultMutableTreeNode replica = new DefaultMutableTreeNode(node);
            replicas.add(replica);
        }

        DefaultMutableTreeNode block;
        if (entry.isActive())
            block = new DefaultMutableTreeNode(entry.getName() + " (active)");
        else
            block = new DefaultMutableTreeNode(entry.getName());
        block.add(replicas);
        treeRoot.add(block);
    }
    elbTree = new JTree(treeRoot);
    elbTab.add(elbTree);
    elbTab.revalidate();
}

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

private MutableTreeNode createGanttChartsNode() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Gantt Charts");

    DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.GanttDemo1", "GanttDemo1"));
    DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.GanttDemo2", "GanttDemo2"));

    root.add(n1);
    root.add(n2);/*from   w  w  w .j  a  v a 2  s.co  m*/

    return root;
}

From source file:com.softeffect.primemovers.ui.ClientApplication.java

/**
 * @return application functions (ApplicationFunction objects), organized as
 *         a tree/*from  w w  w .  j  av  a 2  s .  co m*/
 */
public DefaultTreeModel getApplicationFunctions() {
    DefaultMutableTreeNode root = new OpenSwingTreeNode("Insurance Certicate Database");
    DefaultTreeModel model = new DefaultTreeModel(root);
    ApplicationFunction n1 = new ApplicationFunction("Administration", null);
    ApplicationFunction n10 = new ApplicationFunction("Configuration", "", null, "getConfigurationFunction");
    n1.add(n10);

    ApplicationFunction n2 = new ApplicationFunction("Tasks", null);
    ApplicationFunction n20 = new ApplicationFunction("Add Records", "", null, "getAddRecordsFunction");
    ApplicationFunction n21 = new ApplicationFunction("List Records", "", null, "getListRecordsFunction");
    ApplicationFunction n22 = new ApplicationFunction("Reports", "", null, "getReportsFunction");
    n2.add(n20);
    n2.add(n21);
    n2.add(n22);
    root.add(n1);
    root.add(n2);
    return model;
}

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

private MutableTreeNode createOrientationNode() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Plot Orientation");

    DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.PlotOrientationDemo1", "PlotOrientationDemo1"));
    DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.PlotOrientationDemo2", "PlotOrientationDemo2"));

    root.add(n1);
    root.add(n2);// w  w w. j  a v a  2  s.co m

    return root;
}

From source file:de.erdesignerng.visual.common.OutlineComponent.java

private void buildViewsChildren(Model aModel, DefaultMutableTreeNode aParent, List<View> aViews) {
    DefaultMutableTreeNode theViewsNode = new DefaultMutableTreeNode(TreeGroupingElement.VIEWS);
    aViews.stream().filter(theView -> isVisible(theView)).forEach(theView -> {
        DefaultMutableTreeNode theViewNode = new DefaultMutableTreeNode(theView);
        theViewsNode.add(theViewNode);

        registerUserObject(theView, theViewNode);

        updateViewTreeNode(aModel, theView, theViewNode);
    });/* w  ww  .  j  av a2 s . c  o  m*/
    aParent.add(theViewsNode);
}

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

private MutableTreeNode createBarChartsNode() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Bar Charts");
    defaultmutabletreenode.add(createCategoryBarChartsNode());
    defaultmutabletreenode.add(createXYBarChartsNode());
    return defaultmutabletreenode;
}

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

/**
 * Creates the tree node and its subnods
 * /*from w  w  w  . jav a  2  s .c  o  m*/
 * @return A populated tree node.
 */
private MutableTreeNode createChartsNode(String name) {
    //System.out.println("adding-"+name+"-");

    BufferedReader rder = startReaderBuffer();

    DefaultMutableTreeNode node_root = new DefaultMutableTreeNode(name);
    String line, className, chartName;
    StringBuffer sb = new StringBuffer();

    while ((line = readLine(rder)) != null) {
        if (line.toLowerCase().equalsIgnoreCase("[" + name + "]")) {
            while ((line = readLine(rder)) != null) {

                if (line.toLowerCase().startsWith("item")) {
                    line = line.substring(line.indexOf("=") + 1);
                    StringTokenizer tk = new StringTokenizer(line, "=,; ");

                    chartName = tk.nextToken().trim();
                    className = tk.nextToken().trim();
                    //   System.out.println("className =["+className+"]");
                    DefaultMutableTreeNode n = new DefaultMutableTreeNode(
                            new DemoDescription(className, chartName));
                    node_root.add(n);
                } //item

                else if (line.toLowerCase().startsWith("subcategory")) {
                    line = line.substring(line.indexOf("=") + 1);
                    try {
                        rder.mark(100);
                        node_root.add(createChartsNode(line.trim()));
                        rder.reset();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                } //subCategory

                else if (line.toLowerCase().startsWith("[")) {
                    //System.out.println("end of "+name);
                    return node_root;
                }

            }
        }

    }
    return node_root;
}

From source file:de.erdesignerng.visual.common.OutlineComponent.java

private void buildTablesChildren(Model aModel, DefaultMutableTreeNode aParentNode, List<Table> aTableList) {
    DefaultMutableTreeNode theTablesNode = new DefaultMutableTreeNode(TreeGroupingElement.TABLES);
    aTableList.stream().filter(theTable -> isVisible(theTable)).forEach(theTable -> {
        DefaultMutableTreeNode theTableNode = new DefaultMutableTreeNode(theTable);
        theTablesNode.add(theTableNode);

        registerUserObject(theTable, theTableNode);

        updateTableTreeNode(aModel, theTable, theTableNode);
    });//from   w w w.j  a  v a2  s .  c o m
    aParentNode.add(theTablesNode);
}