kaapo.projectmanager.command
Class AddConnectionEdit

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

public class AddConnectionEdit
extends AbstractUndoableEdit

An Edit that adds a Connection to a visible Diagram.

Author:
hprajani, hkovaska
See Also:
Serialized Form

Field Summary
 
Fields inherited from class kaapo.projectmanager.command.AbstractUndoableEdit
pm, visibleDiagram
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
AddConnectionEdit(Class componentType, Point2D point)
          constructs an edit that adds a connection with default form and no connected components.
AddConnectionEdit(Class componentType, Point2D startPoint, Point2D endPoint, DiagramComponentWrapper startComponent, DiagramComponentWrapper endComponent)
          constructs an edit that adds a connection with defined start- and endcomponents and the points user has clicked on when choosing them.
 
Method Summary
 boolean canRedo()
           
 boolean canUndo()
           
 void execute(ProjectManager pm)
          Creates a new Connection and adds it to both the Project and to the visible 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

AddConnectionEdit

public AddConnectionEdit(Class componentType,
                         Point2D startPoint,
                         Point2D endPoint,
                         DiagramComponentWrapper startComponent,
                         DiagramComponentWrapper endComponent)
constructs an edit that adds a connection with defined start- and endcomponents and the points user has clicked on when choosing them.

Parameters:
componentType - type of the connection
startPoint - first clicked point
endPoint - second clicked point
startComponent - component the connection comes out
endComponent - component the connection plugs into

AddConnectionEdit

public AddConnectionEdit(Class componentType,
                         Point2D point)
constructs an edit that adds a connection with default form and no connected components.

Parameters:
componentType - type of the connection
point - where the connection is created to
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 Connection and adds it to both the Project and to the visible Diagram.

Specified by:
execute in class AbstractUndoableEdit
Parameters:
pm - the enviroment where the Edit is executed in.
Throws:
EditFailedException - thrown when instantiating the connection fails
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()