Package javax.swing.tree

Examples of javax.swing.tree.DefaultMutableTreeNode


        if (debug)
            System.out.println("searchUserColor begin");
        loc.clear(); // clear the list

        for (Iterator it = lot.iterator(); it.hasNext();) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) it.next();
            if (!node.isRoot()) {
                GanttTask task = (GanttTask) (node.getUserObject());
                Color color = task.getColor();
                String hexaColor = getHexaColor(color);
            }
        }
        if (debug)
View Full Code Here


        int index = 0;

        // now add text and box objects to the tasks
        for (Iterator it = lot.iterator(); it.hasNext();) {
            DefaultMutableTreeNode node = ((DefaultMutableTreeNode) it.next());
            if (!node.isRoot()) {
                // get the task
                GanttTask task = (GanttTask) node.getUserObject();

                // get the text infos of the task
                TextObject textLabel = task2text(task, index, node.getLevel(),
                        (int) depthval);
                if (debug)
                    System.out.println("    add TEXT");
                atl.add(textLabel);

                // get the box object of the task
                BoxObject boxObject = task2box(task, (int) depthval, index,
                        node.isLeaf());
                if (debug)
                    System.out.println("    add BOX");
                abl.add(boxObject);

                index++;
View Full Code Here

                System.out.println("drawTasks begin");

            // loop on tasks
            int i = 0;
            for (Iterator it = lot.iterator(); it.hasNext();) {
                DefaultMutableTreeNode node = ((DefaultMutableTreeNode) it
                        .next());
                // get the task
                if (!node.isRoot()) {
                    GanttTask task = (GanttTask) (node.getUserObject());

                    TextObject txtObj = (TextObject) (atl.get(i));
                    BoxObject boxObject = (BoxObject) (abl.get(i));

                    // print the text of the task
View Full Code Here

    }
    /** add an object with the expand information */
    public DefaultMutableTreeNode addObjectWithExpand(Object child,
            DefaultMutableTreeNode parent) {

        DefaultMutableTreeNode childNode = new TaskNode((Task) child);

        if (parent == null)
            parent = rootNode;

        treeModel.insertNodeInto(childNode, parent, parent.getChildCount());
        //forwardScheduling();

        Task task = (Task) (childNode.getUserObject());

        boolean res = true;

        if (parent == null)
            res = false;

        // test for expantion
        while (parent != null) {
            Task taskFather = (Task) (parent.getUserObject());
            if (!taskFather.getExpand()) {
                res = false;
                break;
            }
            parent = (DefaultMutableTreeNode) (parent.getParent());
        }

        treetable.getTree().scrollPathToVisible(
                new TreePath(childNode.getPath()));
        if (!res && parent!=null) {
            treetable.getTree().collapsePath(new TreePath(parent.getPath()));
        }
//        else
//            task.setExpand(false);
View Full Code Here

        return childNode;
    }

    /** Return the selected task */
    private GanttTask getSelectedTask() {
        DefaultMutableTreeNode node = getSelectedTaskNode();
        if (node == null)
            return null;
        return (GanttTask) (node.getUserObject());
    }
View Full Code Here

    public DefaultMutableTreeNode getSelectedNode() {
        TreePath currentSelection = treetable.getTree().getSelectionPath();
        if (currentSelection == null) {
            return null;
        }
        DefaultMutableTreeNode dmtnselected = (DefaultMutableTreeNode) currentSelection
                .getLastPathComponent();
        return dmtnselected;
    }
View Full Code Here

        TreePath currentSelection = treetable.getTree().getSelectionPath();
        if (currentSelection == null
                || !(currentSelection.getLastPathComponent() instanceof TaskNode)) {
            return null;
        }
        DefaultMutableTreeNode dmtnselected = (DefaultMutableTreeNode) currentSelection
                .getLastPathComponent();
        return dmtnselected;
    }
View Full Code Here

    }

    private TaskNode[] getOnlyTaskNodes(DefaultMutableTreeNode[] array) {
        List resAsList = new ArrayList();
        for (int i = 0; i < array.length; i++) {
            DefaultMutableTreeNode next = array[i];
            if (next instanceof TaskNode)
                resAsList.add(next);
        }
        return (TaskNode[]) resAsList.toArray(new TaskNode[0]);
    }
View Full Code Here

        return (TaskNode[]) resAsList.toArray(new TaskNode[0]);
    }

    /** Return the DefaultMutableTreeNode with the name name. */
    public DefaultMutableTreeNode getNode(int id /* String name */) {
        DefaultMutableTreeNode res, base;
        base = (DefaultMutableTreeNode) treetable.getTreeTableModel().getRoot();
        Enumeration e = base.preorderEnumeration();
        while (e.hasMoreElements()) {
            res = ((DefaultMutableTreeNode) e.nextElement());
            if (res instanceof TaskNode)
                if (((Task) (res.getUserObject())).getTaskID() == id) {
                    return res;
                }
        }
        return null;
    }
View Full Code Here

    public List getAllVisibleNodes() {
        List res = new ArrayList();
        Enumeration enumeration = rootNode.preorderEnumeration();
        while (enumeration.hasMoreElements()) {
            DefaultMutableTreeNode o = (DefaultMutableTreeNode) enumeration
                    .nextElement();
            if (getTreeTable().getTree().isVisible(new TreePath(o.getPath())))
                res.add(o);
        }
        return res;
    }
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.