jcreek.cke.command
Class CreekCommand

java.lang.Object
  extended byjcreek.cke.command.CreekCommand
All Implemented Interfaces:
javax.swing.undo.UndoableEdit
Direct Known Subclasses:
ActivateEntityCommand, ActivateRelationCommand, ChangeRelationCommand, CutCommand, DeActivateEntityCommand, DeactivateRelationCommand, DeleteEntityCommand, DeleteRelationCommand, EntityMoveCommand, NewEntityCommand, NewRelationCommand, OverviewCommand, PasteCommand, SubModelCommand, ZoomCommand

public abstract class CreekCommand
extends java.lang.Object
implements javax.swing.undo.UndoableEdit

Defines the abstract class to be extended by all command classes in Visualizer. Provides a way of executing commands and being able to undo/redo them later. This class defines an additional method for performing the command for the first time.

Version:
Author:

Field Summary
protected  boolean canUndoRedo
          Indicates if this command and be undone/redone.
protected  CreekDocument document
          The document this command is associated with.
 
Constructor Summary
CreekCommand(CreekDocument doc)
          Creates a new CreekCommand object associated with the given document object.
 
Method Summary
 boolean canRedo()
          True if it is still possible to redo this operation.
 boolean canUndo()
          True if it is still possible to undo this operation.
 CreekDocument getDocument()
          Returns the document this command was performed on.
abstract  boolean perform()
          Do the command for the first time.
 void replaced()
          Indicates this object has been replaced by another.
 void setDocument(CreekDocument doc)
          Our document has been changed on us.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.undo.UndoableEdit
addEdit, die, getPresentationName, getRedoPresentationName, getUndoPresentationName, isSignificant, redo, replaceEdit, undo
 

Field Detail

document

protected CreekDocument document
The document this command is associated with.


canUndoRedo

protected boolean canUndoRedo
Indicates if this command and be undone/redone.

Constructor Detail

CreekCommand

public CreekCommand(CreekDocument doc)
Creates a new CreekCommand object associated with the given document object.

Parameters:
doc - document we are performed on
Method Detail

canRedo

public boolean canRedo()
True if it is still possible to redo this operation.

Specified by:
canRedo in interface javax.swing.undo.UndoableEdit
Returns:
true if redo-able

canUndo

public boolean canUndo()
True if it is still possible to undo this operation.

Specified by:
canUndo in interface javax.swing.undo.UndoableEdit
Returns:
true if undo-able

getDocument

public CreekDocument getDocument()
Returns the document this command was performed on.

Returns:
document this command is associated with

perform

public abstract boolean perform()
Do the command for the first time. The arguments are given in the constructor for the particular implementation of the command.

Returns:
true if command executed, false if error

setDocument

public void setDocument(CreekDocument doc)
Our document has been changed on us. We must save this new document object reference.


replaced

public void replaced()
Indicates this object has been replaced by another. From now on this object can no longer undo/redo and should throw exceptions if asked to do so.



Created at IDI, NTNU by the Artificial Intelligence and Learning group