org.jupe.editors.classdiagram.model.commands
Class ConnectionCreateCommand

java.lang.Object
  extended by org.eclipse.gef.commands.Command
      extended by org.jupe.editors.classdiagram.model.commands.ConnectionCreateCommand

public class ConnectionCreateCommand
extends org.eclipse.gef.commands.Command

A command to create a connection between two NodeModelElement. The command can be undone or redone.

This command is designed to be used together with a GraphicalNodeEditPolicy. To use this command properly, following steps are necessary:

  1. Create a subclass of GraphicalNodeEditPolicy.
  2. Override the getConnectionCreateCommand(...) method, to create a new instance of this class and put it into the CreateConnectionRequest.
  3. Override the getConnectionCompleteCommand(...) method, to obtain the Command from the ConnectionRequest, call setTarget(...) to set the target endpoint of the connection and return this command instance.

Author:
Steffen Klüpfel, Michael Pradel

Constructor Summary
ConnectionCreateCommand(NodeModelElement sourceElement, java.lang.String typeName)
          Instantiate a command that can create a connection between two NodeModelElements.
 
Method Summary
 boolean canExecute()
           
 void execute()
           
 ConnectionElement getConnection()
           
 void redo()
          (non-Javadoc)
 void setTarget(NodeModelElement targetElement)
          Set the target endpoint for the connection.
 void undo()
          (non-Javadoc)
 
Methods inherited from class org.eclipse.gef.commands.Command
canUndo, chain, dispose, getDebugLabel, getLabel, setDebugLabel, setLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionCreateCommand

public ConnectionCreateCommand(NodeModelElement sourceElement,
                               java.lang.String typeName)
Instantiate a command that can create a connection between two NodeModelElements.

Parameters:
sourceElement - the source endpoint
typeName - The type of the connection. See IConstants.
Throws:
java.lang.IllegalArgumentException - if source is null
Method Detail

getConnection

public ConnectionElement getConnection()

canExecute

public boolean canExecute()
Overrides:
canExecute in class org.eclipse.gef.commands.Command

execute

public void execute()
Overrides:
execute in class org.eclipse.gef.commands.Command

redo

public void redo()
(non-Javadoc)

Overrides:
redo in class org.eclipse.gef.commands.Command
See Also:
Command.redo()

setTarget

public void setTarget(NodeModelElement targetElement)
Set the target endpoint for the connection.

Parameters:
targetElement - that target endpoint (a non-null Shape instance)
Throws:
java.lang.IllegalArgumentException - if target is null

undo

public void undo()
(non-Javadoc)

Overrides:
undo in class org.eclipse.gef.commands.Command
See Also:
Command.undo()