Package javax.swing.tree

Examples of javax.swing.tree.MutableTreeNode


            TreePath path;
            if (rows > 1) path = comp.getTreePathForRow(1);
            else path = comp.getTreePathForRow(0); // el root
            if (path != null)
            {
                MutableTreeNode dataNode = (MutableTreeNode)path.getLastPathComponent();
                if (dataNode.getParent() != null) // No es Root
                    dataModel.removeNodeFromParent(dataNode);
                else
                    dataModel.setRoot(null);
            }
        }
View Full Code Here


            {
                // Selection Model is in CONTIGUOUS_TREE_SELECTION mode
                TreePath[] paths = selModel.getSelectionPaths();
                for(int i = 0; i < paths.length; i++)
                {
                    MutableTreeNode node = (MutableTreeNode)paths[i].getLastPathComponent();
                    if (node == dataModel.getRoot())
                        dataModel.setRoot(null);
                    else if (isInTree(node,dataModel)) // If false is already removed (a previous removed node was the parent)
                        dataModel.removeNodeFromParent(node);
                }
            }
        }
        else if ((currentTarget == updateButton.getHTMLInputElement()) ||
                 (currentTarget == insertBeforeButton.getHTMLInputElement()) ||
                 (currentTarget == insertAfterButton.getHTMLInputElement()) ||
                 (currentTarget == insertChildButton.getHTMLInputElement()) )
        {
            String newItem = itemComp.getText();
            int row;
            try
            {
                row = Integer.parseInt(posComp.getText());
                DefaultTreeModel dataModel = (DefaultTreeModel)treeComp.getTreeModel();
                if (currentTarget == updateButton.getHTMLInputElement())
                {
                    TreePath path = treeComp.getTreePathForRow(row);
                    if (path != null)
                    {
                        DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
                        node.setUserObject(newItem);
                        dataModel.nodeChanged(node);
                    }
                    else getItsNatDocument().addCodeToSend("alert('Bad Position');");
                }
                else if ((currentTarget == insertBeforeButton.getHTMLInputElement()) ||
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

            if (document == null) { return; }

            // iterate over children of this node
            NodeList nodes = document.getChildNodes();
            int len = (nodes != null) ? nodes.getLength() : 0;
            MutableTreeNode root = (MutableTreeNode)getRoot();
            for (int i = 0; i < len; i++) {
                Node node = nodes.item(i);
                switch (node.getNodeType()) {
                    case Node.DOCUMENT_NODE: {
                        root = insertDocumentNode(node, root);
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 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

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.