ContentWelcomeProducts Abeona Gaia Hephaistos JavaGantt Features News Documentation Programming domain objects About JavaGantt model Undo / Redo support Localization support Building a treetable Painting a chart Working with the time scale JavaGantt actions License Download Purchase Services Promote your software Contact Us Links |
About GanttModelJavaGantt uses class GanttModel as its model. It is an abstract class derived from eu.beesoft.gaia.swing.TreeTableModel. Here are the methods required to implementation:
The methods above are designed to manipulate with objects on the domain objects level. You don't need to work with treetable nodes. Here is the implementation of these methods from our demo application: @Override public boolean moveObject (TimelineObject object, TimelineObject newContainer, int newIndex, UndoStep undo) { Task task = (Task) object; Task supertask = (Task) newContainer; undo.registerObject (task); undo.registerObject (supertask); Task oldSupertask = task.getSupertask (); if (supertask != oldSupertask) { if (oldSupertask != null) { undo.registerObject (oldSupertask); oldSupertask.removeSubtask (task); } supertask.addSubtask (task); } supertask.shiftSubtask (task, newIndex); return true; } @Override public boolean deleteObject (TimelineObject what, UndoStep undo) { Task task = (Task) what; Task parent = task.getSupertask (); undo.registerObject (parent); undo.registerObject (task); parent.removeSubtask (task); return true; } @Override public TimelineObject createObject (TimelineObject parent, int index, UndoStep undo) { undo.registerObject (parent); Task parentTask = (Task) parent; Task task = new Task (); String id = Gantt.getNextTaskId (); task.setTaskId (id); task.setName ("Task " + id); parentTask.addSubtask (task); parentTask.shiftSubtask (task, index); return task; } There is an UndoStep object used as argument in these methods. It supports undo / redo operations. You can read more about it in the next chapter.
|