Package javax.swing.tree

Examples of javax.swing.tree.DefaultMutableTreeNode$PathBetweenNodesEnumeration


    /** Return all sub task for the tree node base */
    public ArrayList getAllChildTask(Task task) {
        ArrayList res = new ArrayList();
        if (task == null)
            return null;
        DefaultMutableTreeNode base = (DefaultMutableTreeNode) getNode(task
                .getTaskID());
        if (base == null)
            return res;
        Enumeration e = base.children();
        while (e.hasMoreElements()) {
            res.add(e.nextElement());
        }
        return res;
    }
View Full Code Here


    }

    /** Remove the current node.
     * @param current */
    void removeCurrentNode(DefaultMutableTreeNode currentNode) {
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) (currentNode
                    .getParent());
            getTaskManager().deleteTask((Task) currentNode.getUserObject());
            if (parent != null) {
                ((GanttTreeTableModel) treeModel)
                        .removeNodeFromParent(currentNode);
View Full Code Here

        while (it.hasNext())
            selectTask((Task) it.next(), true);
    }

    public void selectTask(Task task, boolean multipleSelection) {
        DefaultMutableTreeNode taskNode = null;
        for (Enumeration nodes = rootNode.preorderEnumeration(); nodes
                .hasMoreElements();) {
            DefaultMutableTreeNode nextNode = (DefaultMutableTreeNode) nodes
                    .nextElement();
            if (!(nextNode instanceof TaskNode))
                continue;
            if (nextNode.getUserObject().equals(task)) {
                taskNode = nextNode;
                break;
            }
        }
        if (taskNode != null) {
View Full Code Here

    /** Returne the mother task. */
    public DefaultMutableTreeNode getFatherNode(Task node) {
        if (node == null) {
            return null;
        }
        DefaultMutableTreeNode tmp = (DefaultMutableTreeNode) getNode(node
                .getTaskID());
        if (tmp == null) {
            return null;
        }

        return (DefaultMutableTreeNode) tmp.getParent();
    }
View Full Code Here

     * Hides the selected tasks.
     */
    public void hideSelectedNodes() {
        DefaultMutableTreeNode[] t = getSelectedNodes();
        for (int i = 0; i < t.length; i++) {
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) t[i]
                    .getParent();
            hiddenTask.add(new HiddenTask(t[i], parent, parent.getIndex(t[i])));
        }

        for (int i = 0; i < hiddenTask.size(); i++) {
            HiddenTask ht = (HiddenTask) hiddenTask.get(i);
            TreeNode parent = ht.node.getParent();
View Full Code Here

     */
    public void displayHiddenTasks() {
        for (int i = 0; i < hiddenTask.size(); i++) {
            HiddenTask ht = (HiddenTask) hiddenTask.get(i);

            DefaultMutableTreeNode node = ht.getNode();
            DefaultMutableTreeNode parent = ht.getParent();
            node.setParent(parent);
        }
        Collections.sort(hiddenTask);
        for (int i = 0; i < hiddenTask.size(); i++) {
            HiddenTask ht = (HiddenTask) hiddenTask.get(i);

            DefaultMutableTreeNode node = ht.getNode();
            DefaultMutableTreeNode parent = ht.getParent();
            int index = ht.getIndex();
            node.setParent(null);
            ((GanttTreeTableModel) getTreeTable().getTreeTableModel())
                    .insertNodeInto(node, parent, index);

View Full Code Here

        appli.getUndoManager().undoableEdit("Up", new Runnable() {
            public void run()
            {
                for (int i = 0; i < cdmtn.length; i++)
                {
                    DefaultMutableTreeNode father = gt2.getFatherNode(cdmtn[i]);
                    int index = father.getIndex((TreeNode) cdmtn[i]);

                    index--;

                    Task task = (Task) cdmtn[i].getUserObject();

                    if (index >= 0)
                    {
                      DefaultMutableTreeNode [] child = new DefaultMutableTreeNode[cdmtn[i].getChildCount()];

                      if(task.getExpand())
                      {
                        for(int j=0; j<cdmtn[i].getChildCount(); j++)
                        {
                          child[j] = (DefaultMutableTreeNode)cdmtn[i].getChildAt(j);
                        }

                        for(int j=0; j<child.length; j++)
                        {
                          child[j].removeFromParent();
                          treeModel.nodesWereRemoved(cdmtn[i],
                              new int[] { 0 },
                              new Object[] { child });
                        }
                      }

                      cdmtn[i].removeFromParent();
                        treeModel.nodesWereRemoved(father,
                                        new int[] { index + 1 },
                                        new Object[] { cdmtn });

                        father.insert(cdmtn[i], index);
                        treeModel.nodesWereInserted(father, new int[] {index});

                        if(task.getExpand())
                        {
                          for(int j=0; j<child.length; j++)
View Full Code Here

        appli.getUndoManager().undoableEdit("Down", new Runnable(){
            public void run()
            {
                for (int i = cdmtn.length - 1; i >= 0; i--)
                {
                    DefaultMutableTreeNode father = gt2.getFatherNode(cdmtn[i]);
                    int index = father.getIndex((TreeNode) cdmtn[i]);
                    index++;

                    Task task = (Task) cdmtn[i].getUserObject();

                    // New position
                    if ((index < father.getChildCount()))
                    {
                      DefaultMutableTreeNode [] child = new DefaultMutableTreeNode[cdmtn[i].getChildCount()];

                      if(task.getExpand())
                      {
                        for(int j=0; j<cdmtn[i].getChildCount(); j++)
                        {
                          child[j] = (DefaultMutableTreeNode)cdmtn[i].getChildAt(j);
                        }

                        for(int j=0; j<child.length; j++)
                        {
                          child[j].removeFromParent();
                          treeModel.nodesWereRemoved(cdmtn[i],
                              new int[] { 0 },
                              new Object[] { child });
                        }
                      }

                      cdmtn[i].removeFromParent();
                        treeModel.nodesWereRemoved(father,
                                        new int[] { index - 1 },
                                        new Object[] { cdmtn });

                        father.insert(cdmtn[i], index);
                        treeModel.nodesWereInserted(father, new int[] {index});

                        if(task.getExpand())
                        {
                          for(int j=0; j<child.length; j++)
View Full Code Here

        area.repaint();
    }

    public DefaultMutableTreeNode removeChild(DefaultMutableTreeNode node)
    {
      DefaultMutableTreeNode nodeCopy = new DefaultMutableTreeNode(node.getUserObject());
      Enumeration children = node.children();
      while(children.hasMoreElements())
      {
        DefaultMutableTreeNode child = (DefaultMutableTreeNode)children.nextElement();

        DefaultMutableTreeNode childCopy = this.removeChild(child);
        nodeCopy.add(childCopy);

        child.removeFromParent();
        treeModel.nodesWereRemoved(node,
                    new int[] { 0 },
View Full Code Here

      Enumeration children = copy.children();

      int index = 0;
      while(children.hasMoreElements())
      {
        DefaultMutableTreeNode childCopy = (DefaultMutableTreeNode)children.nextElement();
        DefaultMutableTreeNode child = new DefaultMutableTreeNode(childCopy.getUserObject());
        node.insert(child, index);
        treeModel.nodesWereInserted(node, new int[] {index});
        this.insertChild(child, childCopy);
        index++;
      }
View Full Code Here

TOP

Related Classes of javax.swing.tree.DefaultMutableTreeNode$PathBetweenNodesEnumeration

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.