kaapo.projectmanager.command
Class AddElementEdit

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by kaapo.projectmanager.command.AbstractUndoableEdit
          extended by kaapo.projectmanager.command.AddElementEdit
All Implemented Interfaces:
Serializable, UndoableEdit

public class AddElementEdit
extends AbstractUndoableEdit

This UndoableEdit adds a new Element into a Diagram. This happens by adding the Element into the Project that contains the Diagram and add an <@link kaapo.project.ElementWrapper> that holds the Element into the Diagram.

Author:
hprajani
See Also:
Serialized Form

Field Summary
 
Fields inherited from class kaapo.projectmanager.command.AbstractUndoableEdit
visibleDiagram
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
AddElementEdit(Class componentType)
          Constructs an edit without an user defined location for the new Element
AddElementEdit(Class componentType, Point2D point)
          Constructs an edit with an user defined location for the new Element
 
Method Summary
 boolean canRedo()
           
 boolean canUndo()
           
 void execute(ProjectManager pm)
          Creates a new Element and adds it to both the project and to the diagram.
 void redo()
          Redos the edit.
 void undo()
          Undos the Edit.
 
Methods inherited from class kaapo.projectmanager.command.AbstractUndoableEdit
changeCorrectVisibleDiagram
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
addEdit, die, getPresentationName, getRedoPresentationName, getUndoPresentationName, isSignificant, replaceEdit, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AddElementEdit

public AddElementEdit(Class componentType)
Constructs an edit without an user defined location for the new Element

Parameters:
componentType - type of the new DComponent

AddElementEdit

public AddElementEdit(Class componentType,
                      Point2D point)
Constructs an edit with an user defined location for the new Element

Parameters:
componentType - type of the new DComponent
Method Detail

undo

public void undo()
Undos the Edit.

Specified by:
undo in interface UndoableEdit
Overrides:
undo in class AbstractUndoableEdit
See Also:
UndoableEdit.undo()

redo

public void redo()
Redos the edit.

Specified by:
redo in interface UndoableEdit
Overrides:
redo in class AbstractUndoableEdit
See Also:
UndoableEdit.redo()

execute

public void execute(ProjectManager pm)
             throws EditFailedException
Creates a new Element and adds it to both the project and to the diagram.

Specified by:
execute in class AbstractUndoableEdit
Parameters:
pm - the enviroment where the Edit is executed in.
Throws:
EditFailedException
See Also:
AbstractUndoableEdit.execute(ProjectManager)

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()