Package net.sourceforge.ganttproject.task

Examples of net.sourceforge.ganttproject.task.TaskNode


        treetable.getTree().addTreeSelectionListener(
                new TreeSelectionListener() {

                    public void valueChanged(TreeSelectionEvent e) {
                        Mediator.getTaskSelectionManager().clear();
                        TaskNode tn[] = (TaskNode[]) getSelectedTaskNodes();
                        if (tn != null)
                            for (int i = 0; i < tn.length; i++)
                                Mediator.getTaskSelectionManager().addTask(
                                        (Task) tn[i].getUserObject());
                    }
View Full Code Here


        //this.treetable.changeLanguage(language);
    }

    private void initRootNode() {
        getTaskManager().getRootTask().setName("root");
        rootNode = new TaskNode(getTaskManager().getRootTask());
    }
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

    }

    /** Add a sub task. */
    public TaskNode addObject(Object child, MutableTreeNode parent, int index) {
        TaskNode childNode = new TaskNode((Task) child);

        if (parent == null)
            parent = rootNode;

        // GanttTask tmpTask = (GanttTask)(childNode.getUserObject());
        // tmpTask.indentID((String)(((GanttTask)(parent.getUserObject())).getID()));

        treeModel.insertNodeInto(childNode, parent, index == -1 ? parent
                .getChildCount() : index);

        treetable.getTree().scrollPathToVisible(
                new TreePath(childNode.getPath()));

        nbTasks++;
        appli.refreshProjectInfos();

        return childNode;
View Full Code Here

        TreePath paths[] = treetable.getTree().getSelectionModel()
                .getSelectionPaths();
        Mediator.getTaskSelectionManager().clear();
        if (paths != null)
            for (int i = 0; i < paths.length; i++) {
                TaskNode tn = (TaskNode) paths[i].getLastPathComponent();
                if (!tn.isRoot())
                    Mediator.getTaskSelectionManager().addTask(
                            (Task) tn.getUserObject());
            }
    }
View Full Code Here

    public void pasteNode() {
        if (cpNodesArrayList != null) {
            final GanttTree2 gt2 = this;
            getUndoManager().undoableEdit("Paste", new Runnable() {
                public void run() {
                    TaskNode current = (TaskNode) treetable.getTree()
                            .getLastSelectedPathComponent();
                    List tasksList = new ArrayList();
                    if (current == null) {
                        current = rootNode;
                    }

                    boolean isAProjectTaskChild = false;
                    DefaultMutableTreeNode father = (DefaultMutableTreeNode) current
                            .getParent();
                    // if the task as a projectTask parent
                    while (father != null) {
                        if (((Task) father.getUserObject()).isProjectTask()) {
                            isAProjectTaskChild = true;
                        }
                        father = (DefaultMutableTreeNode) father.getParent();
                    }
                    mapOriginalIDCopyID = new HashMap();
                    // copyID = new ArrayList ();
                    // pasteID = new ArrayList ();

                    TaskManagerImpl tmi = (TaskManagerImpl) getTaskManager();
                    int MaxID = tmi.getMaxID();
                    // for(int i=0; i < cpNodesArrayList.size(); i++) {
                    for (int i = cpNodesArrayList.size() - 1; i >= 0; i--) {

                        if (isAProjectTaskChild)
                            ((Task) ((TaskNode) cpNodesArrayList.get(i))
                                    .getUserObject()).setProjectTask(false);
                        /*
                         * this will add new custom columns to the newly
                         * created task.
                         */
                        TreeNode sel = getSelectedTaskNode();
                        TreeNode parent = null;
                        if (sel != null) {
                            parent = sel.getParent();
                            if (parent != null)
                                where = parent.getIndex(sel);
                        }
                        tasksList.add((Task) insertClonedNode(
                                current == rootNode ? current
                                        : (DefaultMutableTreeNode) current
                                                .getParent(),
                                (DefaultMutableTreeNode) cpNodesArrayList
                                        .get(i), where + 1, true)
                                .getUserObject());
                        nbTasks++;
View Full Code Here

            assignment[i].delete();
        }

        getTaskManager().registerTask(newTask);

        DefaultMutableTreeNode cloneChildNode = new TaskNode(newTask);

        for (int i = 0; i < child.getChildCount(); i++) {
            insertClonedNode(cloneChildNode, (DefaultMutableTreeNode) child
                    .getChildAt(i), i, false);
        }
        // if(child.getParent() != null)
        // if(!child.getParent().equals(parent))
        // parent = (DefaultMutableTreeNode)parent.getParent();
        //
        //
        if (parent == null)
            location = 0;
        if (parent.getChildCount() < location)
            location = parent.getChildCount();

        ((GanttTreeTableModel) treeModel).insertNodeInto(cloneChildNode,
                parent, location);

        treetable.getTree().scrollPathToVisible(
                new TreePath(cloneChildNode.getPath()));

        // Remove the node from the expand list
        /*
         * int index = expand.indexOf(new
         * Integer(newTask.getTaskID())cloneChildNode.toString()); if (index >=
View Full Code Here

    }

    public void setDelay(final Task task, final Delay delay) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                TaskNode taskNode = (TaskNode) getNode(task.getTaskID());
                if (taskNode != null)
                    treetable.setDelay(taskNode, delay);
            }
        });
    }
View Full Code Here

        // task.setColor(current.getColor());
        // }
        // if (current.shapeDefined())
        // task.setShape(current.getShape());
        // }
        TaskNode taskNode = tree.addObject(task, node, index);

        /*
         * this will add new custom columns to the newly created task.
         */
        getCustomColumnsStorage().processNewTask(task);
View Full Code Here

        GanttCalendar end = null;
        while (en.hasMoreElements()) {
            Object next = en.nextElement();
            if(!(next instanceof TaskNode))
                continue;
            TaskNode tn = (TaskNode) next;
            if (tn.isRoot())
                continue;
            GanttCalendar tnEnd = tn.getEnd();
            if (end == null || end.before(tnEnd)) {
                res.clear();
                end = tnEnd.Clone();
                res.add(tn.getUserObject());
            } else if (end.compareTo(tnEnd) == 0)
                res.add(tn.getUserObject());
        }
        return res;
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.ganttproject.task.TaskNode

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.