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

Source Link

Document

Creates a tree node that has no parent and no children, but which allows children.

Usage

From source file:gdt.jgui.entity.phone.JPhoneFacetOpenItem.java

@Override
public DefaultMutableTreeNode[] getDigest() {
    try {/*from   w w  w . j a va 2 s .  c o m*/
        Entigrator entigrator = console.getEntigrator(entihome$);
        Sack entity = entigrator.getEntityAtKey(entityKey$);
        String phone$ = entity.getProperty("phone");
        String locator$ = getLocator();
        locator$ = Locator.append(locator$, Locator.LOCATOR_TITLE, phone$);
        DefaultMutableTreeNode phoneNode = new DefaultMutableTreeNode();
        phoneNode.setUserObject(locator$);
        return new DefaultMutableTreeNode[] { phoneNode };

    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
    return null;
}

From source file:gdt.jgui.entity.folder.JFolderFacetOpenItem.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  a2s . com
@Override
public DefaultMutableTreeNode[] getDigest() {
    try {
        //         System.out.println("JFolderFacetOpenItem:getDigest:locator="+locator$);
        Properties locator = Locator.toProperties(locator$);
        entihome$ = locator.getProperty(Entigrator.ENTIHOME);
        entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
        String folderPath$ = entihome$ + "/" + entityKey$;
        File folder = new File(folderPath$);
        DefaultMutableTreeNode fileNode;
        File[] fa = folder.listFiles();
        if (fa == null)
            return null;
        ArrayList<DefaultMutableTreeNode> fnl = new ArrayList<DefaultMutableTreeNode>();
        Properties fileLocator;
        String icon$;
        for (File f : fa) {
            fileLocator = new Properties();
            fileLocator.setProperty(Locator.LOCATOR_TITLE, f.getName());
            fileLocator.setProperty(Entigrator.ENTIHOME, entihome$);
            fileLocator.setProperty(EntityHandler.ENTITY_KEY, entityKey$);
            fileLocator.setProperty(BaseHandler.HANDLER_SCOPE, JConsoleHandler.CONSOLE_SCOPE);
            fileLocator.setProperty(JFolderPanel.FILE_NAME, f.getName());
            //               System.out.println("JFolderFacetOpenItem:getDigest:file="+f.getName());
            fileLocator.setProperty(JFolderPanel.FILE_PATH, f.getPath());
            fileLocator.setProperty(Locator.LOCATOR_TYPE, JFolderPanel.LOCATOR_TYPE_FILE);
            fileLocator.setProperty(Locator.LOCATOR_CHECKABLE, Locator.LOCATOR_TRUE);
            fileLocator.setProperty(JEntityDigestDisplay.NODE_TYPE, NODE_TYPE_FILE_NODE);
            icon$ = Support.readHandlerIcon(null, getClass(), "file.png");
            fileLocator.setProperty(Locator.LOCATOR_ICON, icon$);
            fileLocator.setProperty(BaseHandler.HANDLER_CLASS, getClass().getName());
            fileLocator.setProperty(BaseHandler.HANDLER_METHOD, "openFile");
            fileNode = new DefaultMutableTreeNode();
            fileNode.setUserObject(Locator.toString(fileLocator));
            fnl.add(fileNode);
        }
        return fnl.toArray(new DefaultMutableTreeNode[0]);

    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
    return null;
}

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

public DefaultTreeModel getChromosomeTree() {
    if (chromosomeTree == null)
        chromosomeTree = new DefaultTreeModel(new DefaultMutableTreeNode());
    return chromosomeTree;
}

From source file:gdt.jgui.entity.JEntityStructurePanel.java

private void addChildren(DefaultMutableTreeNode parentNode) {
    try {//  w w w. j a va  2  s  .co m
        String locator$ = (String) parentNode.getUserObject();
        Properties locator = Locator.toProperties(locator$);
        String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
        String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
        Entigrator entigrator = console.getEntigrator(entihome$);
        Sack parent = entigrator.getEntityAtKey(entityKey$);
        String[] sa = entigrator.ent_listComponents(parent);
        if (sa != null) {
            Sack child;
            String childLocator$;
            DefaultMutableTreeNode childNode;
            for (String aSa : sa) {
                child = entigrator.getEntityAtKey(aSa);
                childLocator$ = EntityHandler.getEntityLocator(entigrator, child);
                childNode = new DefaultMutableTreeNode();
                childNode.setUserObject(childLocator$);
                parentNode.add(childNode);
                addChildren(childNode);
            }
        }
    } catch (Exception e) {
        Logger.getLogger(JEntityStructurePanel.class.getName()).severe(e.toString());
    }
}

From source file:gdt.jgui.entity.JEntityDigestDisplay.java

private void instantiateFacetNode(DefaultMutableTreeNode facetNode) {
    try {/*from w  w w . j  ava2s .  c  o m*/
        String facetNodeLocator$ = (String) facetNode.getUserObject();
        Properties locator = Locator.toProperties(facetNodeLocator$);
        Entigrator entigrator = console.getEntigrator(entihome$);
        String facetClass$ = locator.getProperty(BaseHandler.HANDLER_CLASS);
        //      System.out.println("EntityDigestDisplay:instantiateFacetNode:facet class="+facetClass$);
        JFacetOpenItem facetOpenItem = (JFacetOpenItem) JConsoleHandler.getHandlerInstance(entigrator,
                facetClass$);
        FacetHandler facetHandler = facetOpenItem.getFacetHandler();
        //      System.out.println("EntityDigestDisplay:instantiateFacetNode:facet handler="+facetHandler.getClassName());
        Sack entity = entigrator.getEntityAtKey(entityKey$);
        String entityLocator$ = EntityHandler.getEntityLocator(entigrator, entity);
        //      System.out.println("EntityDigestDisplay:instantiateFacetNode:entity locator="+entityLocator$);
        DefaultMutableTreeNode facetComponentNode;
        if (facetHandler.isApplied(entigrator, entityLocator$)) {
            //      System.out.println("EntityDigestDisplay:instantiateFacetNode:entity locator="+entityLocator$);
            entityLocator$ = Locator.append(entityLocator$, Locator.LOCATOR_TYPE, LOCATOR_FACET_COMPONENT);
            entityLocator$ = Locator.append(entityLocator$, BaseHandler.HANDLER_CLASS, facetClass$);
            entityLocator$ = Locator.append(entityLocator$, NODE_TYPE, NODE_TYPE_FACET_OWNER);
            entityLocator$ = Locator.append(entityLocator$, NODE_NUMBER, String.valueOf(nodeNumber++));
            facetComponentNode = new DefaultMutableTreeNode();
            facetComponentNode.setUserObject(entityLocator$);
            instantiateComponentNode(facetComponentNode);
            facetNode.add(facetComponentNode);
        }
        String[] sa = entigrator.ent_listComponents(entity);
        if (sa != null) {
            Sack component;
            for (String aSa : sa) {
                component = entigrator.getEntityAtKey(aSa);
                if (component == null)
                    continue;
                entityLocator$ = EntityHandler.getEntityLocator(entigrator, component);
                if (facetHandler.isApplied(entigrator, entityLocator$)) {
                    entityLocator$ = Locator.append(entityLocator$, Locator.LOCATOR_TYPE,
                            LOCATOR_FACET_COMPONENT);
                    entityLocator$ = Locator.append(entityLocator$, BaseHandler.HANDLER_CLASS, facetClass$);
                    facetComponentNode = new DefaultMutableTreeNode();
                    facetComponentNode.setUserObject(entityLocator$);
                    instantiateComponentNode(facetComponentNode);
                    facetNode.add(facetComponentNode);
                }
            }
        }
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
}

From source file:ai.aitia.meme.paramsweep.intellisweepPlugin.JgapGAPlugin.java

private void addParameter(final ParameterOrGene parameterOrGene) {
    if (chromosomeTree == null) {
        chromosomeTree = new DefaultTreeModel(new DefaultMutableTreeNode());
        genes = null;//ww  w.  ja va2  s  .c o  m
    }

    final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(parameterOrGene);
    final DefaultMutableTreeNode root = (DefaultMutableTreeNode) chromosomeTree.getRoot();
    chromosomeTree.insertNodeInto(newNode, root, root.getChildCount());

    if (listeners != null) {
        for (final ModelListener listener : listeners)
            listener.parameterAdded();
    }
}

From source file:ai.aitia.meme.paramsweep.intellisweepPlugin.JgapGAPlugin.java

private void removeAllParameters() {
    if (chromosomeTree == null)
        chromosomeTree = new DefaultTreeModel(new DefaultMutableTreeNode());
    else//from   w  w w.jav  a2s .  c  o m
        chromosomeTree.setRoot(new DefaultMutableTreeNode());

    genes = null;

    if (listeners != null) {
        for (final ModelListener listener : listeners)
            listener.parametersRemoved();
    }
}

From source file:gdt.jgui.entity.JEntityDigestDisplay.java

private DefaultMutableTreeNode[] getFacetOpenItems() {
    String[] sa = listFacetOpenItems();
    if (sa == null)
        return null;
    DefaultMutableTreeNode facetNode;
    JFacetOpenItem facetOpenItem;/*w w  w.j  ava 2s.  c  om*/
    Properties locator;
    Entigrator entigrator = console.getEntigrator(entihome$);
    ArrayList<DefaultMutableTreeNode> nl = new ArrayList<DefaultMutableTreeNode>();
    for (String aSa : sa) {
        try {
            //   System.out.println("EntityDigestDisplay:getFacetOpenItems:foi="+aSa);
            facetOpenItem = (JFacetOpenItem) JConsoleHandler.getHandlerInstance(entigrator, aSa);
            locator = new Properties();
            locator.setProperty(Locator.LOCATOR_TYPE, LOCATOR_TYPE_FACET);
            locator.setProperty(BaseHandler.HANDLER_CLASS, aSa);
            locator.setProperty(BaseHandler.HANDLER_SCOPE, JConsoleHandler.CONSOLE_SCOPE);
            locator.setProperty(Locator.LOCATOR_ICON, facetOpenItem.getFacetIcon());
            locator.setProperty(Locator.LOCATOR_TITLE, facetOpenItem.getFacetName());
            locator.setProperty(NODE_TYPE, NODE_TYPE_FACET_HEADER);
            facetNode = new DefaultMutableTreeNode();
            facetNode.setUserObject(Locator.toString(locator));
            nl.add(facetNode);
            instantiateFacetNode(facetNode);
        } catch (Exception ee) {
            Logger.getLogger(getClass().getName()).info(ee.toString());
        }
    }
    Collections.sort(nl, new NodeComparator());
    return nl.toArray(new DefaultMutableTreeNode[0]);
}

From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java

/**
 * //w w w  .  ja v a  2 s  .c  o  m
 */
public void set(final Container rootCon, final CollectionObject rootCO) {
    this.rootContainer = rootCon;
    this.rootColObj = rootCO;

    colObjIdHash.clear();
    containerIdHash.clear();

    if (rootCon != null) {
        Integer rootParentId = getTopMostParentId(rootCon.getId());
        if (rootParentId != null) {
            this.rootContainer = getContainerFromDB(rootParentId);
            this.rootColObj = rootContainer.getCollectionObject();
        }
    } else if (rootCO == null) {

    }

    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
    rootNode.setUserObject(rootContainer != null ? rootContainer : rootColObj);

    if (rootContainer != null) {
        loadContainerTree(rootNode, rootContainer, null);

    } else if (rootColObj != null) {
        loadContainerTree(rootNode, null, rootColObj);
    } else {
        rootNode.setUserObject("New Container");
    }

    model = new DefaultTreeModel(rootNode);
    if (tree == null) {
        tree = new GhostActionableTree(this, model);
        tree.setRowHeight(ROW_HEIGHT);
        tree.setBackground(bgColor);
        tree.setEditable(false);
        tree.setVisibleRowCount(15);
        registerPrintContextMenu(tree);

    } else {
        tree.setModel(model);
    }
    model.reload();

    if (containerPanel != null) {
        containerPanel.getMultiView().setData(rootCon);
    }
}