Package javax.swing.tree

Examples of javax.swing.tree.MutableTreeNode


                      m_firstUserComponentOpp = false;
                    }

                    Vector toRemove = ((JTreeLeafDetails)userObject).getMetaBean();
                    DefaultTreeModel model = (DefaultTreeModel) m_componentTree.getModel();
                    MutableTreeNode userRoot = (MutableTreeNode)tNode.getParent(); // The "User" folder
                    model.removeNodeFromParent(tNode);
                    m_userComponents.remove(toRemove);

                    if (m_userComponents.size() == 0) {
                      model.removeNodeFromParent(userRoot);
View Full Code Here


   * Refresh all plugin nodes. This method should be called continuously to
   * remove expired programs from the tree.
   */
  public void update() {
    if (!mDisableUpdate) {
      MutableTreeNode rootNode = (MutableTreeNode) this.getRoot();
      @SuppressWarnings("unchecked")
      Enumeration<DefaultMutableTreeNode> e = rootNode.children();
      while (e.hasMoreElements() && !mDisableUpdate) {
        DefaultMutableTreeNode n = e.nextElement();

        Object o = n.getUserObject();
        if (o instanceof Plugin) {
View Full Code Here

    }
    addCustomNode(pluginRoot);
  }

  private void insertSorted(PluginTreeNode pluginRoot) {
    MutableTreeNode rootNode = (MutableTreeNode) this.getRoot();
    ArrayList<String> pluginNames = new ArrayList<String>();

    for (int i = 0; i < rootNode.getChildCount(); i++) {
      pluginNames.add(rootNode.getChildAt(i).toString());
    }

    Collections.sort(pluginNames);
    int index = pluginNames.indexOf(pluginRoot.getUserObject().toString());

    if(index == -1) {
      index = Collections.binarySearch(pluginNames, pluginRoot.getUserObject().toString());
    }
    else {
      index = -index-1;
    }

    rootNode.insert(pluginRoot.getMutableTreeNode(), -index-1);

    if(pluginRoot.getMutableTreeNode().getIcon() == null) {
      if(pluginRoot.getUserObject() instanceof Plugin) {
        pluginRoot.getMutableTreeNode().setIcon(PluginProxyManager.getInstance().getActivatedPluginForId(((Plugin)pluginRoot.getUserObject()).getId()).getPluginIcon());
      }
View Full Code Here

  /**
   * Removes all ChildNodes from this Tree
   */
  public void removeAllChildNodes() {
    MutableTreeNode rootNode = (MutableTreeNode) this.getRoot();
    while (rootNode.getChildCount() > 0) {
      rootNode.remove(0);
    }
  }
View Full Code Here

        projectsNode.insert(node, projectsNode.getChildCount());
        nodesWereInserted(projectsNode, new int[]{projectsNode.getIndex(node)});
    }

    public void pomRemoved(final PomManagerEvent pEvent) {
        final MutableTreeNode node = findPomNode(pEvent.getUrl());
        if (node != null) {
            final int index = projectsNode.getIndex(node);
            node.removeFromParent();
            nodesWereRemoved(projectsNode, new int[]{index}, new Object[]{node});
        }
    }
View Full Code Here

    public Task newTask() {

        getTabs().setSelectedIndex(UIFacade.GANTT_INDEX);

        int index = -1;
        MutableTreeNode selectedNode = getTree().getSelectedNode();
        if (selectedNode != null) {
            DefaultMutableTreeNode parent1 = (DefaultMutableTreeNode) selectedNode
                    .getParent();
            index = parent1.getIndex(selectedNode) + 1;
            tree.getTreeTable().getTree().setSelectionPath(
                    new TreePath(parent1.getPath()));
            tree.getTreeTable().getTreeTable().editingStopped(
View Full Code Here

     * nodesWereRemoved to create the appropriate event. This is the preferred
     * way to remove a node as it handles the event creation for you.
     */
    public void removeNodeFromParent(MutableTreeNode node) {
        if (node != null) {
            MutableTreeNode parent = (MutableTreeNode) node.getParent();

            if (parent == null)
                throw new IllegalArgumentException(
                        "node does not have a parent.");

            int[] childIndex = new int[1];
            Object[] removedArray = new Object[1];

            childIndex[0] = parent.getIndex(node);
            parent.remove(childIndex[0]);
            removedArray[0] = node;
            nodesWereRemoved(parent, childIndex, removedArray);
        }
    }
View Full Code Here

   * Message this to remove node from its parent. This will message
   * nodesWereRemoved to create the appropriate event. This is the preferred
   * way to remove a node as it handles the event creation for you.
   */
  public void removeNodeFromParent(MutableTreeNode node) {
    MutableTreeNode parent = (MutableTreeNode) node.getParent();

    if (parent == null)
      throw new IllegalArgumentException("node does not have a parent.");

    int[] childIndex = new int[1];
    Object[] removedArray = new Object[1];

    childIndex[0] = parent.getIndex(node);
    parent.remove(childIndex[0]);
    removedArray[0] = node;
    nodesWereRemoved(parent, childIndex, removedArray);
  }
View Full Code Here

                      m_firstUserComponentOpp = false;
                    }

                    Vector toRemove = ((JTreeLeafDetails)userObject).getMetaBean();
                    DefaultTreeModel model = (DefaultTreeModel) m_componentTree.getModel();
                    MutableTreeNode userRoot = (MutableTreeNode)tNode.getParent(); // The "User" folder
                    model.removeNodeFromParent(tNode);
                    m_userComponents.remove(toRemove);

                    if (m_userComponents.size() == 0) {
                      model.removeNodeFromParent(userRoot);
View Full Code Here

    }

    final TestTree tree = new TestTree(nodes());

    private static TreeModel nodes() {
      MutableTreeNode root = node("root",
          node("branch1", node("branch1.1", node("branch1.1.1"), node("branch1.1.2")), node("branch1.2")),
          node("branch2"), node("branch3"), node("branch4"), node("branch5", node("branch5.1")));
      return new DefaultTreeModel(root);
    }
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.