Package javax.swing.tree

Examples of javax.swing.tree.DefaultMutableTreeNode


        protected DefaultMutableTreeNode getNodeForCodeStartingAt(
                                                                  DefaultMutableTreeNode node,
                                                                  String code) {
            Enumeration enumeration = node.children();
            while (enumeration.hasMoreElements()) {
                DefaultMutableTreeNode kid = (DefaultMutableTreeNode) enumeration.nextElement();
                SymbolPart ssp = (SymbolPart) kid.getUserObject();

                try {
                    if (code.charAt(ssp.getCodePosition().startIndex) == '-')
                        return node;
View Full Code Here


        for (Iterator it = trees.iterator(); it.hasNext();) {
            SymbolTreeHolder sth = (SymbolTreeHolder) it.next();

            if (sth != null) {
                DefaultMutableTreeNode node = sth.getNodeForCode(text);
                if (node != null) {
                    if (Debug.debugging("symbology")) {
                        Debug.output("SymbolChooser: Found node for " + text);
                    }
                    sth.getTree()
                            .setSelectionPath(new TreePath(node.getPath()));
                    sth.updateOptionsForCode(text);
                    setSelectedTreeHolder(sth);
                }
            }
        }
View Full Code Here

                String key = null;
                String filename = null;

                DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
               
                DefaultMutableTreeNode current;
                DefaultMutableTreeNode parent;
                DefaultMutableTreeNode previous;
                boolean exists = false;
               
                Collection<String> keys = DataFilters.isFilterActive(getModule()) ?
                              DataManager.getKeyList(DataFilters.getCurrent(getModule())) : null;
               
                while (rs.next() && !stop) {
                    int level = 0;
                    parent = top;
                   
                    id = rs.getString(1);
                    module = rs.getInt(2);
                    filename = rs.getString(3);
                   
                    if (keys != null && !keys.contains(id)) continue;
                   
                    StringTokenizer st = new StringTokenizer(filename, (filename.indexOf("/") > -1 ? "/" : "\\"));
                    while (st.hasMoreElements()) {
                      key = (String) st.nextElement();
                     
                        if (stop) break;
                       
                        // check the whole last leaf
                        top.getLastLeaf();
                       
                        previous = parent.getChildCount() == 0 ? null : ((DefaultMutableTreeNode) parent.getChildAt(parent.getChildCount() - 1));
                        exists = previous != null && ((NodeElementprevious.getUserObject()).getComparableKey().equals(key.toLowerCase());
                       
                        if (!exists) {
                            ne = new FileNodeElement(key, new File(filename));
                            ne.addItem(id, module);
                            current = new DcDefaultMutableTreeNode(ne);
                            model.insertNodeInto(current, parent, parent.getChildCount());
                            parent = current;
                          
                        } else { // exists
                            existingNe =( NodeElement) previous.getUserObject();
                            existingNe.addItem(id, module);
                            model.nodeChanged(previous);
                            parent = previous;   
                        }
                        level++;
View Full Code Here

                DcField field = null;
                int module;

                DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
               
                DefaultMutableTreeNode current;
                DefaultMutableTreeNode parent;
                DefaultMutableTreeNode previous;
                boolean exists = false;
               
                Map<String, Integer> items = DataManager.getKeys(DataFilters.getCurrent(getModule()));
               
                Collection<String> keys = null;
                if (DataFilters.isFilterActive(getModule())) {
                    keys = new ArrayList<String>(items.keySet());
                }
               
                while (rs.next() && !stop) {
                    int level = 0;
                    parent = top;
                   
                    for (int idx = 0; idx < fields.length; idx++) {
                     
                      field = DcModules.get(getModule()).getField(fields[idx]);
                      if (field.isUiOnly() &&
                          field.getIndex() != DcObject._SYS_MODULE &&
                          field.getValueType() != DcRepository.ValueTypes._DCOBJECTCOLLECTION &&
                          field.getFieldType() != ComponentFactory._REFERENCEFIELD)
                        continue;
                     
                       
                        if (stop) break;
                       
                        // for each level the field index is shifted to the end.
                        id = rs.getString(1);
                        module = rs.getInt(2);
                        key = field.getIndex() == DcObject._SYS_MODULE ? DcModules.get(module).getLabel() : rs.getObject((level * 3) + 3);
                        value =  field.getIndex() == DcObject._SYS_MODULE ? DcModules.get(module).getLabel() : rs.getString((level * 3) + 4);
                        iconBase64 = field.getIndex() != DcObject._SYS_MODULE ? rs.getString((level * 3) + 5) : null;
                       
                        icon = field.getIndex() == DcObject._SYS_MODULE ?
                                new DcImageIcon(DcModules.get(module).getIcon16().getImage()) :
                                iconBase64 != null ? DataManager.addIcon(String.valueOf(key), iconBase64) : null;
                       
                        if (keys != null && !keys.contains(id)) continue;
                       
                        previous = parent.getChildCount() == 0 ? null : ((DefaultMutableTreeNode) parent.getChildAt(parent.getChildCount() - 1));
                        exists = previous == null || (((NodeElementprevious.getUserObject()).getKey() == null && key != null) ? false :
                                ((NodeElementprevious.getUserObject()).getKey() == key || // empty key
                                ((NodeElementprevious.getUserObject()).getKey().equals(key);
                       
                        if (!exists) {
                            if (key == null) {
                                ne = new NodeElement(null, empty, null);
                            } else {
                                ne = new NodeElement(key, value, icon);
                            }
                           
                            ne.addItem(id, module);
                            current = new DcDefaultMutableTreeNode(ne);
                            parent.add(current);
                            parent = current;
                          
                        } else { // exists
                            existingNe =(NodeElement) previous.getUserObject();
                            existingNe.addItem(id, module);
                            model.nodeChanged(previous);
                            parent = previous;   
                        }
                       
View Full Code Here

    @SuppressWarnings("unchecked")
    private Collection<SettingsPanel> getPanels() {
        Collection<SettingsPanel> panels = new ArrayList<SettingsPanel>();

        DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot();
        for (Enumeration<DefaultMutableTreeNode> enumerator = root.children(); enumerator.hasMoreElements(); ) {
            DefaultMutableTreeNode oCurrent = enumerator.nextElement();
            SettingsPanel nodePanel = (SettingsPanel) oCurrent.getUserObject();
            panels.add(nodePanel);

            for (Enumeration<DefaultMutableTreeNode> enumChilds = oCurrent.children(); enumChilds.hasMoreElements(); ) {
                DefaultMutableTreeNode oChild = enumChilds.nextElement();
                SettingsPanel nodePanelChild = (SettingsPanel) oChild.getUserObject();
                panels.add(nodePanelChild);
            }
        }
        return panels;
    }
View Full Code Here

     * added as leafs of the parent in the tree.
     * The settings panels are instantiated here as well.
     * Each leaf contains a specific panel with the settings components.
     */
    private DefaultMutableTreeNode buildTreeModel() {
        DefaultMutableTreeNode topTreeNode = new DcDefaultMutableTreeNode(DcResources.getText("lblSettings"));
        topTreeNode.setUserObject(panelInfo);

       
        for (SettingsGroup group : settings.getSettingsGroups().values()) {
            JPanel panel = new SettingsPanel(group);
            DefaultMutableTreeNode treeNode = new DcDefaultMutableTreeNode(panel);

            topTreeNode.add(treeNode);

            panelBogus.setPreferredSize(new Dimension(700, 380));

            panel.setMinimumSize(new Dimension(700, 380));
            panel.setPreferredSize(new Dimension(700, 380));
            panel.setMaximumSize(new Dimension(700, 380));

            getContentPane().add(panel, Layout.getGBC( 1, 0, 1, 1, 1.0, 1.0
                                ,GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
                                 new Insets(5, 5, 5, 5), 0, 0));

            for (SettingsGroup childGroup : group.getChildren().values()) {
                JPanel childPanel = new SettingsPanel(childGroup);
                DefaultMutableTreeNode childTreeNode = new DcDefaultMutableTreeNode(childPanel);
                treeNode.add(childTreeNode);

                childPanel.setMinimumSize(new Dimension(700, 380));
                childPanel.setPreferredSize(new Dimension(700, 380));
                childPanel.setMaximumSize(new Dimension(700, 380));
View Full Code Here

    }   

    private class NodeSelectedAction implements TreeSelectionListener {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();

            if (node == null)
                return;

            Object nodeInfo = node.getUserObject();

            if (nodeInfo.equals(panelInfo)) {
                JPanel panel = (JPanel) nodeInfo;
                panel.setVisible(true);
                setPanelsVisible(false);
View Full Code Here

       
        setSelected(top);
       
        tree.removeTreeSelectionListener(this);
       
        DefaultMutableTreeNode child;
        for (int i = 0; i < size; i++) {
            try {
                child = (DefaultMutableTreeNode) parent.getChildAt(i);
                collapseChildren(child);
                tree.collapsePath(new TreePath(child.getPath()));
            } catch (Exception e) {
                logger.error("An error occurred while collapsing leafs of " + parent, e);
            }
           
            tree.addTreeSelectionListener(this);
View Full Code Here

       
        setSelected(top);
       
        tree.removeTreeSelectionListener(this);
       
        DefaultMutableTreeNode child;
        for (int i = 0; i < size; i++) {
            try {
                child = (DefaultMutableTreeNode) parent.getChildAt(i);
                expandChildren(child);
                tree.expandPath(new TreePath(child.getPath()));
            } catch (Exception e) {
                logger.error("An error occurred while expanding leafs of " + parent, e);
            }
        }
       
View Full Code Here

            return;

        if (top != null) {
            tree.removeTreeSelectionListener(this);
           
            DefaultMutableTreeNode pn;
            DefaultMutableTreeNode cn;
            DefaultMutableTreeNode cn2;
            for (int i = 0; i < top.getChildCount(); i++) {
                pn = (DefaultMutableTreeNode) top.getChildAt(i);
               
                if (pn.getUserObject() != null)
                    ((NodeElement) pn.getUserObject()).clear();
               
                for (int j = 0; j < pn.getChildCount(); j++) {
                    cn = (DefaultMutableTreeNode) pn.getChildAt(j);
                    if (cn.getUserObject() != null)
                        ((NodeElement) cn.getUserObject()).clear();
                   
                    for (int k = 0; k < cn.getChildCount(); k++) {
                        cn2 = (DefaultMutableTreeNode) cn.getChildAt(k);
                        if (cn2.getUserObject() != null)
                            ((NodeElement) cn2.getUserObject()).clear();
                        cn2.removeAllChildren();
                    }
                    cn.removeAllChildren();
                }
                pn.removeAllChildren();
            }
View Full Code Here

TOP

Related Classes of javax.swing.tree.DefaultMutableTreeNode

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.