Package net.sourceforge.ganttproject

Examples of net.sourceforge.ganttproject.GanttTask


        }
    }

    private void loadTask(Attributes attrs) {
        String taskIdAsString = attrs.getValue("id");
        GanttTask task = null;
        if (taskIdAsString == null) {
            task = getManager().createTask();
        } else {
            int taskId;
            try {
                taskId = Integer.parseInt(taskIdAsString);
            } catch (NumberFormatException e) {
                throw new RuntimeException("Failed to parse the value '"
                        + taskIdAsString + "' of attribute 'id' of tag <task>",
                        e);
            }
            task = getManager().createTask(taskId);
        }
        //
        String taskName = attrs.getValue("name");
        if (taskName != null) {
            task.setName(taskName);
        }

        String meeting = attrs.getValue("meeting");
        if (meeting != null) {
            task.setMilestone(meeting.equals("true"));
        }
   
    String project = attrs.getValue("project");
    if (project != null)
      task.setProjectTask(true);
   
        String start = attrs.getValue("start");
        if (start != null) {
            task.setStart(GanttCalendar.parseXMLDate(start));
        }

        String duration = attrs.getValue("duration");
        if (duration != null) {
            try {
                int length = Integer.parseInt(duration);
                if (length == 0) {
                    length = 1;
                }
                task.setLength(length);
            } catch (NumberFormatException e) {
                throw new RuntimeException("Failed to parse the value '"
                        + duration + "' of attribute 'duration' of tag <task>",
                        e);
            }
        }

        String complete = attrs.getValue("complete");
        if (complete != null) {
            try {
                task.setCompletionPercentage(Integer.parseInt(complete));
            } catch (NumberFormatException e) {
                throw new RuntimeException("Failed to parse the value '"
                        + complete + "' of attribute 'complete' of tag <task>",
                        e);
            }
        }

        String priority = attrs.getValue("priority");
        if (priority != null) {
            try {
                task.setPriority(Integer.parseInt(priority));
            } catch (NumberFormatException e) {
                throw new RuntimeException("Failed to parse the value '"
                        + priority + "' of attribute 'priority' of tag <task>",
                        e);
            }
        }

        String color = attrs.getValue("color");
        if (color != null) {
            task.setColor(ColorValueParser.parseString(color));
        }

        String fixedStart = attrs.getValue("fixed-start");
        if ("true".equals(fixedStart)) {
            myContext.addTaskWithLegacyFixedStart(task);
        }

//        String fixedFinish = attrs.getValue("fixed-finish");
//        if ("true".equals(fixedFinish)) {
//            task.setFinishFixed(true);
//        }

        String third = attrs.getValue("thirdDate");
        if (third != null) {
            task.setThirdDate(GanttCalendar.parseXMLDate(third));
        }
        String thirdConstraint = attrs.getValue("thirdDate-constraint");
        if (thirdConstraint != null) {
            try {
                task.setThirdDateConstraint(Integer.parseInt(thirdConstraint));
            } catch (NumberFormatException e) {
                throw new RuntimeException(
                        "Failed to parse the value '"
                                + thirdConstraint
                                + "' of attribute 'thirdDate-constraint' of tag <task>",
                        e);
            }
        }

        String webLink_enc = attrs.getValue("webLink");
        String webLink = webLink_enc;
        if (webLink_enc != null)
            try {
                webLink = URLDecoder.decode(webLink_enc, "ISO-8859-1");
            } catch (UnsupportedEncodingException e) {
              if (!GPLogger.log(e)) {
                e.printStackTrace(System.err);
              }
            }
        if (webLink != null) {
            task.setWebLink(webLink);
        }

        String expand = attrs.getValue("expand");
        if (expand != null) {
            task.setExpand("true".equals(expand));
        }

        String shape = attrs.getValue("shape");
        if (shape != null) {
            java.util.StringTokenizer st1 = new java.util.StringTokenizer(
                    shape, ",");
            int[] array = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            String token = "";
            int count = 0;
            while (st1.hasMoreTokens()) {
                token = st1.nextToken();
                array[count] = (new Integer(token)).intValue();
                count++;
            }
            task.setShape(new ShapePaint(4, 4, array, Color.white, task
                    .getColor()));
        }

        getManager().registerTask(task);
        TaskContainmentHierarchyFacade taskHierarchy = getManager()
                .getTaskHierarchy();
        myContext.setTaskID(task.getTaskID());
        Task lastTask = myStack.isEmpty() ? taskHierarchy.getRootTask()
                : (Task) myStack.peek();
        taskHierarchy.move(task, lastTask);
        myStack.push(task);
    }
View Full Code Here


        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)
            System.out.println("searchUserColor end");
View Full Code Here

        // 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)
View Full Code Here

            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

        }

        //
        // Create the new task object
        //
        GanttTask gtask = tm.createTask();
        // gtask.setChecked();
        // gtask.setColor();
        gtask.setCompletionPercentage((int) task.getPercentageCompleteValue());
        // gtask.setExpand()
        // gtask.setLength();
        gtask.setMilestone(milestone);
        gtask.setName(task.getName() == null ? "-" : task.getName());
        gtask.setNotes(task.getNotes());
        Priority prio = task.getPriority();
        if (prio != null) {
            int priority = prio.getValue();
            int p;
            switch (priority) {
            case Priority.HIGHEST:
            case Priority.HIGHER:
            case Priority.VERY_HIGH:
                p = 2;
                break;
            case Priority.LOWEST:
            case Priority.LOWER:
            case Priority.VERY_LOW:
                p = 0;
                break;
            default:
                p = 1;
            }

            gtask.setPriority(p);
        }
        // gtask.setShape();
        // gtask.setStartFixed()
        // gtask.setTaskID()
        gtask.setWebLink(task.getHyperlink());
        Date taskStart = task.getStart();
        assert taskStart!=null : "Task="+task+" has null start";
        gtask.setStart(new GanttCalendar(taskStart));
//        gtask.setDuration(tm.createLength((long) duration.getDuration()));
        long longDuration = (long) Math.ceil(duration.convertUnits(TimeUnit.DAYS).getDuration());
        if (longDuration > 0) {
          gtask.setDuration(tm.createLength(longDuration));
        }
        else {
          System.err.println("Task "+task.getName()+" has duration="+duration+" which is 0 as long integer. This duration has been ignored, task has got the default duration");
        }
        // gtask.setEnd(new GanttCalendar(task.getFinish()));

        //
        // Add the task and process any child tasks
        //
        tm.registerTask(gtask);

        m_tasks.addObject(gtask, (TaskNode) node, -1);

        m_taskMap.put(task.getID(), new Integer(gtask.getTaskID()));

        LinkedList children = task.getChildTasks();

        if (children.size() != 0) {
            node = m_tasks.getNode(gtask.getTaskID());

            Iterator iter = children.iterator();

            while (iter.hasNext() == true) {
                processTask(tm, defaultCalendar, (Task) iter.next(), node);
View Full Code Here

        Task task;
        RelationList rels;
        Iterator relIter;
        Relation rel;

        GanttTask gTask1;
        int gTaskNumber1;
        GanttTask gTask2;
        int gTaskNumber2;
        TaskDependency gTaskDependency;
        int gConstraintType;
        while (taskIter.hasNext() == true) {
            task = (Task) taskIter.next();
View Full Code Here

        LinkedList assignments = mpx.getAllResourceAssignments();
        Iterator iter = assignments.iterator();
        com.tapsterrock.mpx.ResourceAssignment assignment;
        int gTaskID;
        int gResourceID;
        GanttTask gTask;
        ProjectResource gResource;
        ResourceAssignment gAssignment;

        while (iter.hasNext() == true) {
            assignment = (com.tapsterrock.mpx.ResourceAssignment) iter.next();
            gTaskID = mapTaskNumber(assignment.getTask().getID());
            gResourceID = mapResourceNumber(assignment.getResource().getID());

            if ((gTaskID != -1) && (gResourceID != -1)) {
                gTask = tm.getTask(gTaskID);
                gResource = hrm.getById(gResourceID);

                gAssignment = gTask.getAssignmentCollection().addAssignment(
                        gResource);
                gAssignment.setLoad((float) assignment.getUnitsValue());
                gAssignment.setCoordinator(false);
                if (gResource instanceof HumanResource)
                    gAssignment
View Full Code Here

                String sTaskName = br.readLine();

                // The test is used to skip the white line (with no text)
                if (!sTaskName.equals("")) {
                    // Create the task
                    GanttTask task = myTaskManager.createTask();
                    task.setColor(area.getTaskColor());
                    task.setName(sTaskName);
                    task.setLength(1);
                    myTaskManager.registerTask(task);
                    treePanel.addObject(task, null, -1);
                }
            }
View Full Code Here

                : containmentFacadeFactory;
        // clear();
        {
            Calendar c = CalendarFactory.newCalendar();
            Date today = c.getTime();
            myRoot = new GanttTask(null, new GanttCalendar(today), 1, this, -1);
            myRoot.setStart(new GanttCalendar(today));
            myRoot.setDuration(createLength(getConfig().getTimeUnitStack()
                    .getDefaultTimeUnit(), 1));
            myRoot.setExpand(true);
View Full Code Here

        setMaxID(-1);
        myDependencyCollection.clear();
        {
            Calendar c = CalendarFactory.newCalendar();
            Date today = c.getTime();
            myRoot = new GanttTask(null, new GanttCalendar(today), 1, this, -1);
            myRoot.setStart(new GanttCalendar(today));
            myRoot.setDuration(createLength(getConfig().getTimeUnitStack()
                    .getDefaultTimeUnit(), 1));
            myRoot.setExpand(true);
View Full Code Here

TOP

Related Classes of net.sourceforge.ganttproject.GanttTask

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.