Class ProjectModel

java.lang.Object
com.codename1.scheduling.ProjectModel

public class ProjectModel extends Object

A project: a tree of tasks, the links between them, the resources they use and the calendar their durations are measured in.

Building or editing a project is two steps. The methods that change it (addTask, link, a setter on a task) only change it; update then schedules the whole project and tells the listeners, so a hundred edits cost one pass:

ProjectModel p = new ProjectModel();
GanttTask design = new GanttTask("design", "Design", 3 * p.getCalendar().getMillisPerDay());
GanttTask build = new GanttTask("build", "Build", 5 * p.getCalendar().getMillisPerDay());
p.addTask(design).addTask(build);
p.link(design, build);
p.update();
  • Constructor Details

    • ProjectModel

      public ProjectModel()
      A project that starts today, on the default working week.
    • ProjectModel

      public ProjectModel(WorkCalendar calendar, long start)
  • Method Details

    • getCalendar

      public WorkCalendar getCalendar()
    • setCalendar

      public ProjectModel setCalendar(WorkCalendar v)
    • getStart

      public long getStart()
      The earliest any task is scheduled.
    • setStart

      public ProjectModel setStart(long millis)
    • getFinish

      public long getFinish()
      When the last task finishes, from the last scheduling pass.
    • getCriticalSlack

      public long getCriticalSlack()
      A task with this much total slack or less is critical. Zero by default; a day makes the tasks that are nearly critical stand out too.
    • setCriticalSlack

      public ProjectModel setCriticalSlack(long millis)
    • addTask

      public ProjectModel addTask(GanttTask task)
      Adds a top level task.
    • addTask

      public ProjectModel addTask(GanttTask parent, GanttTask task)
      Adds a task under parent, which becomes a summary.
    • addTask

      public ProjectModel addTask(GanttTask parent, int index, GanttTask task)

      Adds a task at a position among parent's children; -1 is the end, and a null parent is the top level. A task that is in the project already is moved. A task belongs to one project: one that is a task of another is to be removed from that project first, with removeTask, which also drops the links that project has to it.

      Throws
      • IllegalArgumentException: when the task would go under itself, when the parent is not in this project, or when its links would then run in a loop through the summary
    • contains

      public boolean contains(GanttTask task)
      Whether a task is in this project's tree.
    • moveTask

      public boolean moveTask(GanttTask task, GanttTask newParent, int index)

      Moves a task, with everything under it, to another place in the tree.

      Returns

      false when the move would put the task under itself, under a task that is not in this project, or would close a loop of links through a summary

    • removeTask

      public ProjectModel removeTask(GanttTask task)
      Removes a task, everything under it, and every link to any of them.
    • getRootTasks

      public List<GanttTask> getRootTasks()
    • getTasks

      public List<GanttTask> getTasks()
      Every task, a parent before its children, in the order of the outline.
    • getTask

      public GanttTask getTask(String id)
    • link

      public TaskDependency link(GanttTask predecessor, GanttTask successor)
      Links two tasks finish to start.
    • link

      public TaskDependency link(GanttTask predecessor, GanttTask successor, TaskDependency.Type type, long lag)

      Links two tasks.

      A link whose successor is a summary holds the start of every task under it, whatever its type: a summary's finish is the result of its children and cannot be held by itself.

      Throws
      • IllegalArgumentException: when canLink says no
    • canLink

      public boolean canLink(GanttTask predecessor, GanttTask successor)
      Whether a link from predecessor to successor is possible: they are two tasks of this project, neither is inside the other, they are not linked already, and the link would not close a loop.
    • unlink

      public ProjectModel unlink(TaskDependency d)
    • getDependencies

      public List<TaskDependency> getDependencies()
    • getDependency

      public TaskDependency getDependency(GanttTask predecessor, GanttTask successor)
      The link from one task to another, or null.
    • getPredecessors

      public List<TaskDependency> getPredecessors(GanttTask task)
      The links that end at task.
    • getSuccessors

      public List<TaskDependency> getSuccessors(GanttTask task)
      The links that start at task.
    • addResource

      public ProjectModel addResource(ScheduleResource r)
    • removeResource

      public ProjectModel removeResource(ScheduleResource r)
    • getResources

      public List<ScheduleResource> getResources()
    • getResource

      public ScheduleResource getResource(String id)
    • captureBaseline

      public ProjectModel captureBaseline()
      Records every task's current dates as its baseline.
    • clearLeveling

      public ProjectModel clearLeveling()
      Removes every leveling delay. Call update after it.
    • update

      public void update()
      Schedules the project and tells the listeners. Call it after a change, or after a group of them.
    • addChangeListener

      public void addChangeListener(ProjectChangeListener l)
    • removeChangeListener

      public void removeChangeListener(ProjectChangeListener l)
    • fireChanged

      public void fireChanged()
      Tells the listeners without scheduling, for a change that moves no date, such as a name.