BeeSoft®
Since 1992
 

Content

 Welcome
 Products
       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
      
  JavaGanttI®
© 2012 BeeSoft ®
 

About GanttModel

JavaGantt 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:

  • TimelineObject createObject (TimelineObject, int, UndoStep) - creates a new domain object and adds it as child to parent (you don't need to care about treetable nodes). Register all modified objects to undo before any change occurs.
  • boolean deleteObject (TimelineObject, UndoStep) - removes given object from its parent on domain objects level (you don't need to care about treetable nodes). Register object, its parent and all modified objects to undo before any change occurs.
  • boolean moveObject (TimelineObject, TimelineObject, int, UndoStep) - moves given object on domain objects level (you don't need to care about treetable nodes). Register all modified objects to undo before any change occurs.

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.