Examples of DefaultMutableTreeNode


Examples of javax.swing.tree.DefaultMutableTreeNode

            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

Examples of javax.swing.tree.DefaultMutableTreeNode

    private void removeNode(DefaultMutableTreeNode child) {
       DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
       model.removeNodeFromParent(child);
   
       // remove empty branches above (needed for the file tree panel)
       DefaultMutableTreeNode parent = (DefaultMutableTreeNode) child.getParent();
       NodeElement ne;
       while (parent != null) {
         ne = ((NodeElement) child.getUserObject());
         if (ne.getCount() == 0 && parent.getChildCount() == 0) {
           DefaultMutableTreeNode newParent = null;

           try {
             newParent = (DefaultMutableTreeNode) parent.getParent();
           } catch (Exception e) {}
            
View Full Code Here

Examples of javax.swing.tree.DefaultMutableTreeNode

         }
       }
    }


    DefaultMutableTreeNode node = null;
    for (int i=0; i<vSubNodes.size(); i++) {
      BasicNode bNode = new BasicNode(null, (String) vSubNodes.elementAt(i));
//TODO      bNode.setClassName(nodes[i].getClassName());
      bNode.setExpandedIcon(loadIcon("question.gif"));
      bNode.setNormalIcon(loadIcon("question.gif"));
      node = new DefaultMutableTreeNode(bNode);
      parent.add(node);
    }
  }
View Full Code Here

Examples of javax.swing.tree.DefaultMutableTreeNode

  public DefaultMutableTreeNode addServerNodes() throws Exception {
      Object[] nodes = new Object[5];
      BasicNode rootNode = new BasicNode(null, "xmlBlaster");
      rootNode.setExpandedIcon(loadIcon("globe.gif"));
      rootNode.setNormalIcon(loadIcon("globe.gif"));
      top = new DefaultMutableTreeNode(rootNode);

      parent = top;
      nodes[0] = top;
      DefaultMutableTreeNode node = null;
     
      ConnectorFactory connectorFactory = ConnectorFactory.getInstance(this.glob);
      connectorFactory.getMBeanServer("127.0.0.1");
      String[] servers = connectorFactory.getMBeanServerList();
     
      if (servers == null) throw new Exception("could not connect to any host! ");
      for (int i=0; i<servers.length; i++) {
        BasicNode bNode = new BasicNode(null, servers[i]);
        bNode.setExpandedIcon(loadIcon("node.gif"));
        bNode.setNormalIcon(loadIcon("node.gif"));
        node = new DefaultMutableTreeNode(bNode);
        parent.add(node);
      }
      parent = node;
      nodes[1] = parent;
View Full Code Here

Examples of javax.swing.tree.DefaultMutableTreeNode

   
  /**
   *
   */
  public Component3DTree() {
    DefaultMutableTreeNode root=new DefaultMutableTreeNode();
    model= new DefaultTreeModel(root, true);
    setModel(model);
    setCellRenderer(new SceneGraphTreeRenderer());
    setRootVisible(false);
  }
View Full Code Here

Examples of javax.swing.tree.DefaultMutableTreeNode

      return;
    }
    for (Enumeration e = rootNode.depthFirstEnumeration(); e.hasMoreElements();) {
      Object elt = e.nextElement();
      if (!(elt instanceof DefaultMutableTreeNode)) continue;
      DefaultMutableTreeNode node = (DefaultMutableTreeNode)elt;
      Object u = node.getUserObject();
      if ((u!=null) && (u.equals(o))) {
        TreePath path = new TreePath(node.getPath());
        scrollPathToVisible(path);
        setSelectionPath(path);
        return;
      }
    }
View Full Code Here

Examples of javax.swing.tree.DefaultMutableTreeNode

  public void setSelectedValueById(String id) {
    if (id==null) return;
    for (Enumeration e = rootNode.depthFirstEnumeration(); e.hasMoreElements();) {
      Object elt = e.nextElement();
      if (!(elt instanceof DefaultMutableTreeNode)) continue;
      DefaultMutableTreeNode node = (DefaultMutableTreeNode)elt;
      if (id.equals(DataInfo.getId(node.getUserObject()))) {
        TreePath path = new TreePath(node.getPath());
        scrollPathToVisible(path);
        setSelectionPath(path);
        return;
      }
    }
View Full Code Here

Examples of javax.swing.tree.DefaultMutableTreeNode

    // Don't remove the nodes while iterating, safer to do it after?
    // May be useless, a pity I'm too lazy to investigate...
    Vector nodes = new Vector();
    for (Enumeration e = rootNode.children(); e.hasMoreElements();) {
      DefaultMutableTreeNode child = (DefaultMutableTreeNode)e.nextElement();
      if (child.getUserObject()==o) nodes.add(child);
    }
    for (Iterator it = nodes.iterator(); it.hasNext();)
      rootNode.remove((MutableTreeNode)it.next());
   
   
View Full Code Here

Examples of javax.swing.tree.DefaultMutableTreeNode

    setFilterValidity(true);
  }

  protected void changeSource(DataSource ds, DataSource old) {
    for (Enumeration e = rootNode.children(); e.hasMoreElements();) {
      DefaultMutableTreeNode child = (DefaultMutableTreeNode)e.nextElement();
      if (child.getUserObject()==old) ((DataSourceNode)child).changeSource(ds);
    }
  }
View Full Code Here

Examples of javax.swing.tree.DefaultMutableTreeNode

    }
  }

  protected void changeCollection(DataSourceCollection dsc, DataSourceCollection old) {
    for (Enumeration e = rootNode.children(); e.hasMoreElements();) {
      DefaultMutableTreeNode child = (DefaultMutableTreeNode)e.nextElement();
      if (child.getUserObject()==old) ((CollectionNode)child).changeCollection(dsc);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.