kaapo.projectmanager.command
Class AbstractUndoableEdit

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by kaapo.projectmanager.command.AbstractUndoableEdit
All Implemented Interfaces:
Serializable, UndoableEdit
Direct Known Subclasses:
AddConnectionEdit, AddElementEdit, ChangeDiagramNameEdit, ChangeProjectNameEdit, ModifyDComponentAttributeEdit, MoveConnectionPointEdit, MoveDComponentEdit, MoveDiagramDownEdit, MoveDiagramUpEdit, NewDiagramEdit, RemoveDComponentEdit, RemoveDiagramEdit, ResizeElementEdit

public abstract class AbstractUndoableEdit
extends AbstractUndoableEdit

Abstract class that all the Edits extend.

Author:
hprajani
See Also:
Serialized Form

Field Summary
protected  ProjectManager pm
           
protected  DiagramWrapper visibleDiagram
           
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
AbstractUndoableEdit()
           
 
Method Summary
 boolean canRedo()
           
 boolean canUndo()
           
protected  void changeCorrectVisibleDiagram(ProjectManager pm, DiagramWrapper visibleDiagram)
          Changes the visible diagram into the correct given one if the current visible one is something else.
abstract  void execute(ProjectManager pm)
          Executes the created Edit inside the given environment.
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
addEdit, die, getPresentationName, getRedoPresentationName, getUndoPresentationName, isSignificant, redo, replaceEdit, toString, undo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pm

protected ProjectManager pm

visibleDiagram

protected DiagramWrapper visibleDiagram
Constructor Detail

AbstractUndoableEdit

public AbstractUndoableEdit()
Method Detail

execute

public abstract void execute(ProjectManager pm)
                      throws EditFailedException
Executes the created Edit inside the given environment.

Parameters:
pm - the enviroment where the Edit is executed in.
Throws:
EditFailedException - if the edit fails for some reason

changeCorrectVisibleDiagram

protected void changeCorrectVisibleDiagram(ProjectManager pm,
                                           DiagramWrapper visibleDiagram)
Changes the visible diagram into the correct given one if the current visible one is something else. This is mainly used when undoing or redoing stuff.

Parameters:
pm - the environment where the Edit's view is executed in. (This is done because if we use the field this.pm there can be a NullPointerException)
visibleDiagram - the latest visibleDiagram

canUndo

public boolean canUndo()
Specified by:
canUndo in interface UndoableEdit
Overrides:
canUndo in class AbstractUndoableEdit
See Also:
UndoableEdit.canUndo()

canRedo

public boolean canRedo()
Specified by:
canRedo in interface UndoableEdit
Overrides:
canRedo in class AbstractUndoableEdit
See Also:
UndoableEdit.canRedo()