Package javax.swing.tree

Examples of javax.swing.tree.MutableTreeNode


            } // insertNode(Node,MutableTreeNode):MutableTreeNode
           
        /** Inserts the document node. */
        private MutableTreeNode insertDocumentNode(Node what, MutableTreeNode where) {
            MutableTreeNode treeNode = insertNode("<"+what.getNodeName()+'>', where);
            nodeMap.put(treeNode, what);
            return treeNode;
            }
View Full Code Here


                }
            name.append('>');

            // insert element node
           
            MutableTreeNode element = insertNode(name.toString(), where);
            nodeMap.put(element, what);
           
            // gather up attributes and children nodes
            NodeList children = what.getChildNodes();
            int len = (children != null) ? children.getLength() : 0;
View Full Code Here

        /** Inserts a text node. */
        private MutableTreeNode insertTextNode(Node what, MutableTreeNode where) {
            String value = what.getNodeValue().trim();
            if (value.length() > 0) {
                MutableTreeNode treeNode = insertNode(value, where);
                nodeMap.put(treeNode, what);           
                return treeNode;
                }
            return null;
            }
View Full Code Here

         StringBuffer CSectionBfr = new StringBuffer();        
         //--- optional --- CSectionBfr.append( "<![CDATA[" );
         CSectionBfr.append( what.getNodeValue() );
         //--- optional --- CSectionBfr.append( "]]>" );
         if (CSectionBfr.length() > 0) {
            MutableTreeNode treeNode = insertNode(CSectionBfr.toString(), where);
            nodeMap.put(treeNode, what);           
            return treeNode;
            }
         return null;
         }
View Full Code Here

        private void buildTree(Node node, MutableTreeNode where) {
           
            // is there anything to do?
            if (node == null) { return; }

            MutableTreeNode treeNode = insertNode(node, where);

            // iterate over children of this node
            NodeList nodes = node.getChildNodes();
            int len = (nodes != null) ? nodes.getLength() : 0;
            for (int i = 0; i < len; i++) {
View Full Code Here

        } // buildTree()

        /** Inserts a node and returns a reference to the new node. */
        private MutableTreeNode insertNode(String what, MutableTreeNode where) {

            MutableTreeNode node = new DefaultMutableTreeNode(what);
            insertNodeInto(node, where, where.getChildCount());
            return node;

            } // insertNode(Node,MutableTreeNode):MutableTreeNode
View Full Code Here

            } // insertNode(Node,MutableTreeNode):MutableTreeNode
           

        /** Inserts a text node. */
        public MutableTreeNode insertNode(Node what, MutableTreeNode where) {
                MutableTreeNode treeNode = insertNode(DOMTreeFull.toString(what), where);
                nodeMap.put(treeNode, what);
                treeNodeMap.put(what, treeNode);
                return treeNode;
            }
View Full Code Here

            throw new RuntimeException(t.getMessage());
        }

        is.close();

        final MutableTreeNode parentNode = getNode(d.path, filename, rootNode);
        final MutableTreeNode nameNode = new DefaultMutableTreeNode(d.name);
        parentNode.insert(nameNode, 0);
        final MutableTreeNode dNode = new DefaultMutableTreeNode(d);
        nameNode.insert(dNode, 0);
    }
View Full Code Here

     */
    private MutableTreeNode getNode(final POIFSDocumentPath path,
                                    final String fsName,
                                    final MutableTreeNode root)
    {
        MutableTreeNode n = (MutableTreeNode) pathToNode.get(path);
        if (n != null)
            /* Node found in map, just return it. */
            return n;
        if (path.length() == 0)
        {
            /* This is the root path of the POI filesystem. Its tree
             * node is resp. must be located below the tree node of
             * the POI filesystem itself. This is a tree node with the
             * POI filesystem's name (this the operating system file's
             * name) as its key it the path-to-node map. */
            n = (MutableTreeNode) pathToNode.get(fsName);
            if (n == null)
            {
                /* A tree node for the POI filesystem does not yet
                 * exist. */
                n = new DefaultMutableTreeNode(fsName);
                pathToNode.put(fsName, n);
                root.insert(n, 0);
            }
            return n;
        }
        /* else - The path is somewhere down in the POI filesystem's
         * hierarchy. We need the tree node of this path's parent
         * and attach our new node to it. */
        final String name = path.getComponent(path.length() - 1);
        final POIFSDocumentPath parentPath = path.getParent();
        final MutableTreeNode parentNode =
            getNode(parentPath, fsName, root);
        n = new DefaultMutableTreeNode(name);
        pathToNode.put(path, n);
        parentNode.insert(n, 0);
        return n;
    }
View Full Code Here

    tree.insert(new DefaultMutableTreeNode(new Node("Movies", "movies")), 0);
    DefaultMutableTreeNode music = new DefaultMutableTreeNode(
        new Node("Music", "music"));
    tree.insert(music, 0);
    tree.insert(new DefaultMutableTreeNode(new Node("Games", "games")), 0);
    MutableTreeNode temp = new DefaultMutableTreeNode(
        new Node("Science", "science"));
    temp.insert(
        new DefaultMutableTreeNode(new Node("Geography", "geography")), 0);
    temp.insert(
        new DefaultMutableTreeNode(new Node("Mathematics", "math")), 0);
    DefaultMutableTreeNode temp2 = new DefaultMutableTreeNode(
        new Node("Astronomy", "astro"));
    temp2.insert(new DefaultMutableTreeNode(new Node("Education", "edu")), 0);
    temp2.insert(new DefaultMutableTreeNode(new Node("Pictures", "pic")), 0);
    temp.insert(temp2, 2);
    tree.insert(temp, 2);
    treeState = new TreeState();
    treeState.addExpandState(tree);
    treeState.addSelection(temp2);
    treeState.setMarker(music);
View Full Code Here

TOP

Related Classes of javax.swing.tree.MutableTreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.