Example usage for javax.swing.tree DefaultTreeModel DefaultTreeModel

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

Introduction

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

Prototype

@ConstructorProperties({ "root" })
public DefaultTreeModel(TreeNode root) 

Source Link

Document

Creates a tree in which any node can have children.

Usage

From source file:org.alfresco.repo.jive.impl.MockJiveService.java

private final TreeModel buildMockData1() {
    TreeModel result = null;/*from  w  w  w.j  a  v a  2s.c  o m*/

    /*
     * Build up a tree that looks like this:
     * 
     * root
     *   Child 1
     *     Child 1.1
     *       Child 1.1.1
     *       Child 1.1.2
     *       Child 1.1.3
     *         Child 1.1.3.1
     *           Child 1.1.3.1.1
     *             Child 1.1.3.1.1.1
     *               Child 1.1.3.1.1.1.1
     *                 Child 1.1.3.1.1.1.1.1
     *     Child 1.2
     *       Child 1.2.1
     *       Child 1.2.2
     *     Child 1.3
     *   Child 2
     *     Child 2.1
     *     Child 2.2
     *     Child 2.3
     *     Child 2.4
     *     ... 45 other children omitted for brevity ...
     *     Child 2.50
     *   Child 3
     *   Child 4 which has some punctuation characters: '";/?\[]{}
     *   Child 5 which has an extremely long name that is intended to test out how it'll appear in the Share UI
     *   Child 6 which has some Unicode characters: ?
     */

    // First up we create all the nodes
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(new JiveCommunity(0, "root"));
    DefaultMutableTreeNode child1 = new DefaultMutableTreeNode(new JiveCommunity(1, "Child 1"));
    DefaultMutableTreeNode child11 = new DefaultMutableTreeNode(new JiveCommunity(11, "Child 1.1"));
    DefaultMutableTreeNode child111 = new DefaultMutableTreeNode(new JiveCommunity(111, "Child 1.1.1"));
    DefaultMutableTreeNode child112 = new DefaultMutableTreeNode(new JiveCommunity(112, "Child 1.1.2"));
    DefaultMutableTreeNode child113 = new DefaultMutableTreeNode(new JiveCommunity(113, "Child 1.1.3"));
    DefaultMutableTreeNode child1131 = new DefaultMutableTreeNode(new JiveCommunity(1131, "Child 1.1.3.1"));
    DefaultMutableTreeNode child11311 = new DefaultMutableTreeNode(new JiveCommunity(11311, "Child 1.1.3.1.1"));
    DefaultMutableTreeNode child113111 = new DefaultMutableTreeNode(
            new JiveCommunity(113111, "Child 1.1.3.1.1.1"));
    DefaultMutableTreeNode child1131111 = new DefaultMutableTreeNode(
            new JiveCommunity(1131111, "Child 1.1.3.1.1.1.1"));
    DefaultMutableTreeNode child11311111 = new DefaultMutableTreeNode(
            new JiveCommunity(11311111, "Child 1.1.3.1.1.1.1.1"));
    DefaultMutableTreeNode child12 = new DefaultMutableTreeNode(new JiveCommunity(12, "Child 1.2"));
    DefaultMutableTreeNode child121 = new DefaultMutableTreeNode(new JiveCommunity(121, "Child 1.2.1"));
    DefaultMutableTreeNode child122 = new DefaultMutableTreeNode(new JiveCommunity(122, "Child 1.2.2"));
    DefaultMutableTreeNode child13 = new DefaultMutableTreeNode(new JiveCommunity(13, "Child 1.3"));
    DefaultMutableTreeNode child2 = new DefaultMutableTreeNode(new JiveCommunity(2, "Child 2"));
    DefaultMutableTreeNode child21 = new DefaultMutableTreeNode(new JiveCommunity(21, "Child 2.1"));
    DefaultMutableTreeNode child22 = new DefaultMutableTreeNode(new JiveCommunity(22, "Child 2.2"));
    DefaultMutableTreeNode child23 = new DefaultMutableTreeNode(new JiveCommunity(23, "Child 2.3"));
    DefaultMutableTreeNode child24 = new DefaultMutableTreeNode(new JiveCommunity(24, "Child 2.4"));
    DefaultMutableTreeNode child25 = new DefaultMutableTreeNode(new JiveCommunity(25, "Child 2.5"));
    DefaultMutableTreeNode child26 = new DefaultMutableTreeNode(new JiveCommunity(26, "Child 2.6"));
    DefaultMutableTreeNode child27 = new DefaultMutableTreeNode(new JiveCommunity(27, "Child 2.7"));
    DefaultMutableTreeNode child28 = new DefaultMutableTreeNode(new JiveCommunity(28, "Child 2.8"));
    DefaultMutableTreeNode child29 = new DefaultMutableTreeNode(new JiveCommunity(29, "Child 2.9"));
    DefaultMutableTreeNode child210 = new DefaultMutableTreeNode(new JiveCommunity(210, "Child 2.10"));
    DefaultMutableTreeNode child211 = new DefaultMutableTreeNode(new JiveCommunity(211, "Child 2.11"));
    DefaultMutableTreeNode child212 = new DefaultMutableTreeNode(new JiveCommunity(212, "Child 2.12"));
    DefaultMutableTreeNode child213 = new DefaultMutableTreeNode(new JiveCommunity(213, "Child 2.13"));
    DefaultMutableTreeNode child214 = new DefaultMutableTreeNode(new JiveCommunity(214, "Child 2.14"));
    DefaultMutableTreeNode child215 = new DefaultMutableTreeNode(new JiveCommunity(215, "Child 2.15"));
    DefaultMutableTreeNode child216 = new DefaultMutableTreeNode(new JiveCommunity(216, "Child 2.16"));
    DefaultMutableTreeNode child217 = new DefaultMutableTreeNode(new JiveCommunity(217, "Child 2.17"));
    DefaultMutableTreeNode child218 = new DefaultMutableTreeNode(new JiveCommunity(218, "Child 2.18"));
    DefaultMutableTreeNode child219 = new DefaultMutableTreeNode(new JiveCommunity(219, "Child 2.19"));
    DefaultMutableTreeNode child220 = new DefaultMutableTreeNode(new JiveCommunity(220, "Child 2.20"));
    DefaultMutableTreeNode child221 = new DefaultMutableTreeNode(new JiveCommunity(221, "Child 2.21"));
    DefaultMutableTreeNode child222 = new DefaultMutableTreeNode(new JiveCommunity(222, "Child 2.22"));
    DefaultMutableTreeNode child223 = new DefaultMutableTreeNode(new JiveCommunity(223, "Child 2.23"));
    DefaultMutableTreeNode child224 = new DefaultMutableTreeNode(new JiveCommunity(224, "Child 2.24"));
    DefaultMutableTreeNode child225 = new DefaultMutableTreeNode(new JiveCommunity(225, "Child 2.25"));
    DefaultMutableTreeNode child226 = new DefaultMutableTreeNode(new JiveCommunity(226, "Child 2.26"));
    DefaultMutableTreeNode child227 = new DefaultMutableTreeNode(new JiveCommunity(227, "Child 2.27"));
    DefaultMutableTreeNode child228 = new DefaultMutableTreeNode(new JiveCommunity(228, "Child 2.28"));
    DefaultMutableTreeNode child229 = new DefaultMutableTreeNode(new JiveCommunity(229, "Child 2.29"));
    DefaultMutableTreeNode child230 = new DefaultMutableTreeNode(new JiveCommunity(230, "Child 2.30"));
    DefaultMutableTreeNode child231 = new DefaultMutableTreeNode(new JiveCommunity(231, "Child 2.31"));
    DefaultMutableTreeNode child232 = new DefaultMutableTreeNode(new JiveCommunity(232, "Child 2.32"));
    DefaultMutableTreeNode child233 = new DefaultMutableTreeNode(new JiveCommunity(233, "Child 2.33"));
    DefaultMutableTreeNode child234 = new DefaultMutableTreeNode(new JiveCommunity(234, "Child 2.34"));
    DefaultMutableTreeNode child235 = new DefaultMutableTreeNode(new JiveCommunity(235, "Child 2.35"));
    DefaultMutableTreeNode child236 = new DefaultMutableTreeNode(new JiveCommunity(236, "Child 2.36"));
    DefaultMutableTreeNode child237 = new DefaultMutableTreeNode(new JiveCommunity(237, "Child 2.37"));
    DefaultMutableTreeNode child238 = new DefaultMutableTreeNode(new JiveCommunity(238, "Child 2.38"));
    DefaultMutableTreeNode child239 = new DefaultMutableTreeNode(new JiveCommunity(239, "Child 2.39"));
    DefaultMutableTreeNode child240 = new DefaultMutableTreeNode(new JiveCommunity(240, "Child 2.40"));
    DefaultMutableTreeNode child241 = new DefaultMutableTreeNode(new JiveCommunity(241, "Child 2.41"));
    DefaultMutableTreeNode child242 = new DefaultMutableTreeNode(new JiveCommunity(242, "Child 2.42"));
    DefaultMutableTreeNode child243 = new DefaultMutableTreeNode(new JiveCommunity(243, "Child 2.43"));
    DefaultMutableTreeNode child244 = new DefaultMutableTreeNode(new JiveCommunity(244, "Child 2.44"));
    DefaultMutableTreeNode child245 = new DefaultMutableTreeNode(new JiveCommunity(245, "Child 2.45"));
    DefaultMutableTreeNode child246 = new DefaultMutableTreeNode(new JiveCommunity(246, "Child 2.46"));
    DefaultMutableTreeNode child247 = new DefaultMutableTreeNode(new JiveCommunity(247, "Child 2.47"));
    DefaultMutableTreeNode child248 = new DefaultMutableTreeNode(new JiveCommunity(248, "Child 2.48"));
    DefaultMutableTreeNode child249 = new DefaultMutableTreeNode(new JiveCommunity(249, "Child 2.49"));
    DefaultMutableTreeNode child250 = new DefaultMutableTreeNode(new JiveCommunity(250, "Child 2.50"));
    DefaultMutableTreeNode child3 = new DefaultMutableTreeNode(new JiveCommunity(3, "Child 3"));
    DefaultMutableTreeNode child4 = new DefaultMutableTreeNode(
            new JiveCommunity(4, "Child 4 which has some punctuation characters: '\";/?\\[]{}"));
    DefaultMutableTreeNode child5 = new DefaultMutableTreeNode(new JiveCommunity(5,
            "Child 5 which has an extremely long name that is intended to test out how it'll appear in the Share UI"));
    DefaultMutableTreeNode child6 = new DefaultMutableTreeNode(new JiveCommunity(6,
            "Child 6 which has some Unicode characters: ?"));

    // Now link all of the nodes together to create the tree structure
    root.add(child1);
    root.add(child2);
    root.add(child3);
    root.add(child4);
    root.add(child5);
    root.add(child6);

    child1.add(child11);
    child1.add(child12);
    child1.add(child13);

    child11.add(child111);
    child11.add(child112);
    child11.add(child113);

    child113.add(child1131);
    child1131.add(child11311);
    child11311.add(child113111);
    child113111.add(child1131111);
    child1131111.add(child11311111);

    child12.add(child121);
    child12.add(child122);

    child2.add(child21);
    child2.add(child22);
    child2.add(child23);
    child2.add(child24);
    child2.add(child25);
    child2.add(child26);
    child2.add(child27);
    child2.add(child28);
    child2.add(child29);
    child2.add(child210);
    child2.add(child211);
    child2.add(child212);
    child2.add(child213);
    child2.add(child214);
    child2.add(child215);
    child2.add(child216);
    child2.add(child217);
    child2.add(child218);
    child2.add(child219);
    child2.add(child220);
    child2.add(child221);
    child2.add(child222);
    child2.add(child223);
    child2.add(child224);
    child2.add(child225);
    child2.add(child226);
    child2.add(child227);
    child2.add(child228);
    child2.add(child229);
    child2.add(child230);
    child2.add(child231);
    child2.add(child232);
    child2.add(child233);
    child2.add(child234);
    child2.add(child235);
    child2.add(child236);
    child2.add(child237);
    child2.add(child238);
    child2.add(child239);
    child2.add(child240);
    child2.add(child241);
    child2.add(child242);
    child2.add(child243);
    child2.add(child244);
    child2.add(child245);
    child2.add(child246);
    child2.add(child247);
    child2.add(child248);
    child2.add(child249);
    child2.add(child250);

    result = new DefaultTreeModel(root);
    return (result);
}

From source file:org.alfresco.repo.jive.impl.MockJiveService.java

/**
 * Alternative mock data that returns a tree of communities matched to the mocked up screen shots.
 * @return//from  ww  w .j  av  a  2s.c om
 */
private final TreeModel buildMockData2() {
    TreeModel result = null;

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(new JiveCommunity(0, "Alfresco Green Energy"));
    DefaultMutableTreeNode child1 = new DefaultMutableTreeNode(new JiveCommunity(1, "Engineering"));
    DefaultMutableTreeNode child2 = new DefaultMutableTreeNode(new JiveCommunity(2, "Finance"));
    DefaultMutableTreeNode child3 = new DefaultMutableTreeNode(new JiveCommunity(3, "Human Resources"));
    DefaultMutableTreeNode child31 = new DefaultMutableTreeNode(new JiveCommunity(31, "Archived Policies"));
    DefaultMutableTreeNode child32 = new DefaultMutableTreeNode(new JiveCommunity(32, "Company Policies"));
    DefaultMutableTreeNode child33 = new DefaultMutableTreeNode(
            new JiveCommunity(33, "Performance Appraisals"));
    DefaultMutableTreeNode child4 = new DefaultMutableTreeNode(new JiveCommunity(4, "Marketing"));

    // Now link all of the nodes together to create the tree structure
    root.add(child1);
    root.add(child2);
    root.add(child3);
    root.add(child4);

    child3.add(child31);
    child3.add(child32);
    child3.add(child33);

    result = new DefaultTreeModel(root);
    return (result);
}

From source file:org.apache.directory.fortress.web.panel.AuditAuthzListPanel.java

private DefaultTreeModel createTreeModel(List<AuthZ> authZs) {
    DefaultTreeModel model;//www  .  j av a2  s  .c  o m
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);
    if (authZs == null)
        LOG.debug("no Authorizations found");
    else {
        LOG.debug("AuthZ found:" + authZs.size());
        info("Loading " + authZs.size() + " objects into list panel");
        loadTree(authZs);
    }
    return model;
}

From source file:org.apache.directory.fortress.web.panel.AuditBindListPanel.java

private DefaultTreeModel createTreeModel(List<Bind> binds) {
    DefaultTreeModel model;//from   ww w .  ja  v  a  2s.c  o m
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);
    if (binds == null)
        LOG.debug("no Authentications found");
    else {
        LOG.debug("Binds found:" + binds.size());
        info("Loading " + binds.size() + " objects into list panel");
        loadTree(binds);
    }
    return model;
}

From source file:org.apache.directory.fortress.web.panel.AuditModListPanel.java

private DefaultTreeModel createTreeModel(List<Mod> mods) {
    DefaultTreeModel model;/*from  w w w  . j av a 2 s.  c o m*/
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);
    if (mods == null)
        LOG.debug("no Modifications found");
    else {
        LOG.debug("AuthZ found:" + mods.size());
        info("Loading " + mods.size() + " objects into list panel");
        loadTree(mods);
    }
    return model;
}

From source file:org.apache.directory.fortress.web.panel.GroupListPanel.java

private DefaultTreeModel createTreeModel(List<Group> groups) {
    DefaultTreeModel model;/*from w w  w.ja  va 2  s  . c  o m*/
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);
    if (groups == null)
        log.debug("no Groups found");
    else {
        log.debug(".createTreeModel Groups found:" + groups.size());
        for (Group group : groups)
            rootNode.add(new DefaultMutableTreeNode(group));
    }
    return model;
}

From source file:org.apache.directory.fortress.web.panel.ObjectListPanel.java

private DefaultTreeModel createTreeModel(List<PermObj> permObjs) {
    DefaultTreeModel model;//from   w  ww .  j  a  v  a2  s .  c om
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);
    if (permObjs == null)
        log.debug("no Permission Objects found");
    else {
        log.debug(".createTreeModel Permission Objects found:" + permObjs.size());
        for (PermObj permObj : permObjs)
            rootNode.add(new DefaultMutableTreeNode(permObj));
    }
    return model;
}

From source file:org.apache.directory.fortress.web.panel.OUListPanel.java

private DefaultTreeModel createTreeModel(List<OrgUnit> orgUnits) {
    DefaultTreeModel model;//from  ww  w .j  av a2s.  c o m
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);
    if (orgUnits == null) {
        log.debug("no OrgUnits found");
    } else {
        log.debug("OrgUnits found:" + orgUnits.size());
        for (OrgUnit orgUnit : orgUnits) {
            rootNode.add(new DefaultMutableTreeNode(orgUnit));
        }
    }
    return model;
}

From source file:org.apache.directory.fortress.web.panel.PermListPanel.java

private DefaultTreeModel createTreeModel(List<Permission> perms) {
    DefaultTreeModel model;//from   w w  w .ja  v a2s.co  m
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);

    if (perms == null) {
        log.debug(".createTreeModel no Perms found");
    } else {
        log.debug(".createTreeModel Perms found:" + perms.size());

        for (Permission perm : perms) {
            rootNode.add(new DefaultMutableTreeNode(perm));
        }
    }

    return model;
}

From source file:org.apache.directory.fortress.web.panel.PwPolicyListPanel.java

private DefaultTreeModel createTreeModel(List<PwPolicy> policies) {
    DefaultTreeModel model;/* w ww  .j  ava  2 s . c  o  m*/
    rootNode = new DefaultMutableTreeNode(null);
    model = new DefaultTreeModel(rootNode);
    if (policies == null)
        log.debug("no Policies found");
    else {
        log.debug("Policies found:" + policies.size());
        for (PwPolicy policy : policies)
            rootNode.add(new DefaultMutableTreeNode(policy));
    }
    return model;
}