Package net.sourceforge.ganttproject

Examples of net.sourceforge.ganttproject.GanttCalendar


     * @return A list of the last-ended tasks.
     */
    private List getLastTasks() {
        List res = new ArrayList();
        Enumeration en = this.root.preorderEnumeration();
        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


        public void commit() {
            try {
                boolean fireChanges = false;
                if (myStartChange != null) {
                    GanttCalendar start = getStart();
                    TaskImpl.this.setStart(start);
                }
                if (myDurationChange != null) {
                    TaskLength duration = getDuration();
                    TaskImpl.this.setDuration(duration);
                    myEndChange = null;
                }
                if (myCompletionPercentageChange != null) {
                    int newValue = getCompletionPercentage();
                    TaskImpl.this.setCompletionPercentage(newValue);
                }
                if (myEndChange != null) {
                    GanttCalendar end = getEnd();
                    if (end.getTime().compareTo(TaskImpl.this.getStart().getTime())>0) {
                      TaskImpl.this.setEnd(end);
                    }
                }
                if (myThirdChange != null) {
                    GanttCalendar third = getThird();
                    TaskImpl.this.setThirdDate(third);
                }
                for (int i = 0; i < myCommands.size(); i++) {
                    Runnable next = (Runnable) myCommands.get(i);
                    next.run();
                }
                myCommands.clear();
                myPropertiesEventSender.fireEvent();
                myProgressEventSender.fireEvent();
            } finally {
                TaskImpl.this.myMutator = null;
            }
            if (myStartChange!=null && TaskImpl.this.isSupertask()) {
                TaskImpl.this.adjustNestedTasks();
            }
            if ((myStartChange!=null || myEndChange!=null || myDurationChange!=null) && areEventsEnabled()) {
              GanttCalendar oldStart = (GanttCalendar) (myStartChange==null ? TaskImpl.this.getStart() : myStartChange.myOldValue);
              GanttCalendar oldEnd = (GanttCalendar) (myEndChange==null ? TaskImpl.this.getEnd() : myEndChange.myOldValue);
                myManager.fireTaskScheduleChanged(TaskImpl.this, oldStart, oldEnd);
            }

        }
View Full Code Here

            });
        }

        public void setStart(final GanttCalendar start) {
          assert start!=null;
          GanttCalendar currentStart = getStart();
          if (currentStart!=null && start.equals(currentStart)) {
            return;
          }
            if (myStartChange == null) {
                myStartChange = new FieldChange();
View Full Code Here

            // Date prevEnd =
            // myDurationChange.getCachedDate((int)prevLength.getLength());
            Date prevEnd = null;
            // System.err.println("previously cached shift="+prevEnd);
            myDurationChange.setValue(length);
            GanttCalendar newEnd;
            Date shifted;
            if (prevEnd == null) {
                // System.err.println("no prev, length="+length.getLength());
                shifted = TaskImpl.this.shiftDate(getStart().getTime(), length);
            } else {
                // System.err.println("yes prev,
                // length="+(length.getLength()-prevLength.getLength()));
                shifted = TaskImpl.this.shiftDate(
                    prevEnd,
                    getManager().createLength(
                        length.getTimeUnit(),
                        length.getLength() - prevLength.getLength()));
            }
            // System.err.println("caching shift="+shifted+" for
            // duration="+length);
            // myDurationChange.cacheDate(shifted, (int)length.getLength());
            newEnd = new GanttCalendar(shifted);
            setEnd(newEnd);
            myActivities = null;
        }
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

     * (non-Javadoc)
     *
     * @see net.sourceforge.ganttproject.task.TaskManager#createTask(int)
     */
    public GanttTask createTask(int taskID) {
        GanttTask result = new GanttTask("", new GanttCalendar(), 1, this,
                taskID);
        if (result.getTaskID() >= getMaxID()) {
            setMaxID(result.getTaskID() + 1);
        }
        // result.setTaskID(taskID);
View Full Code Here

                    else if (GregorianCalendar.class.isAssignableFrom(cc
                            .getType())) {
                      try {
                        Date dateValue =
                          DateUtils.parseDate(newDefaultValue.toString());
                        cc.setDefaultValue(new GanttCalendar(dateValue));
                      }
                      catch (ParseException e) {
                        cc.setDefaultValue(null);
                      }
                    }
View Full Code Here

            final TaskContainmentHierarchyFacade containmentFacade) {
        Task[] nested = containmentFacade.getNestedTasks(supertask);
        if (nested.length == 0) {
            return;
        }
        GanttCalendar maxEnd = null;
        GanttCalendar minStart = null;
        for (int i = 0; i < nested.length; i++) {
            Task nextNested = nested[i];
            GanttCalendar nextStart = nextNested.getStart();
            if (minStart == null || nextStart.compareTo(minStart) < 0) {
                minStart = nextStart;
            }
            GanttCalendar nextEnd = nextNested.getEnd();
            if (maxEnd == null || nextEnd.compareTo(maxEnd) > 0) {
                maxEnd = nextEnd;
            }
        }
        TaskMutator mutator = supertask.createMutator();
        if (minStart.compareTo(supertask.getStart()) != 0) {
View Full Code Here

TOP

Related Classes of net.sourceforge.ganttproject.GanttCalendar

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.