edu.stanford.hci.dtools.statechart.model.commands
Class ComponentConnectionCreateCommand

java.lang.Object
  extended by org.eclipse.gef.commands.Command
      extended by edu.stanford.hci.dtools.statechart.model.commands.ComponentConnectionCreateCommand

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

This software is distributed under the BSD License.

This code is partially based on code that is copyright (c) 2004 Elias Volanakis. See License.txt

Author:
Elias Volanakis, Michael Bernstein ( mbernst(AT)stanford.edu ), Bjoern Hartmann ( bjoern(AT)stanford.edu ) 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.
, Elias Volanakis
See Also:
for an example of the above procedure., GraphicalNodeEditPolicy

Constructor Summary
ComponentConnectionCreateCommand(IOModel source, int lineStyle)
          Instantiate a command that can create a connection between two shapes.
 
Method Summary
 boolean canExecute()
           
 void execute()
           
 void redo()
           
 void setTarget(IOModel target)
          Set the target endpoint for the connection.
 void undo()
           
 
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

ComponentConnectionCreateCommand

public ComponentConnectionCreateCommand(IOModel source,
                                        int lineStyle)
Instantiate a command that can create a connection between two shapes.

Parameters:
source - the source endpoint (a non-null ShapeModel instance)
lineStyle - the desired line style. See ConnectionModel#setLineStyle(int) for details
Throws:
java.lang.IllegalArgumentException - if source is null
See Also:
ConnectionModel.setLineStyle(int)
Method Detail

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()
Overrides:
redo in class org.eclipse.gef.commands.Command

setTarget

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

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

undo

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