Modelers

org.topcased.modeler.commands
Class ReconnectNodeToNodeCommand

java.lang.Object
  extended by org.eclipse.gef.commands.Command
      extended by org.topcased.modeler.commands.ReconnectGraphEdgeCommand
          extended by org.topcased.modeler.commands.ReconnectNodeToNodeCommand
Direct Known Subclasses:
ReconnectSourceToTargetCommand, ReconnectTargetToSourceCommand

public abstract class ReconnectNodeToNodeCommand
extends ReconnectGraphEdgeCommand

This abstract command may be used when the edge is not contained by any EObject. It means the edge virtually represents a reference from one node to another.


Field Summary
static int SOURCE
          This means the user is reconnecting the SOURCE.
static int TARGET
          This means the user is reconnecting the TARGET.
 
Constructor Summary
ReconnectNodeToNodeCommand(org.eclipse.gef.ConnectionEditPart connection, java.lang.String featureName, int reconnectedEnd)
          Constructor.
 
Method Summary
protected  void doDirectReference(EObject node, EObject newReference, EObject oldReference)
          Sets the new reference to the given node.
protected  void doInverseReference(EObject reference, EObject newNode, EObject oldNode)
          Adds the reference to the new node.
protected  EObject getFixedEnd()
          Retuns the model object corresponding to the fixed edge end
protected abstract  EObject getObjectToUpdate()
          Retuns the model object corresponding to the fixed edge end
protected  GraphElement getOldGraphElement(org.eclipse.gef.ConnectionEditPart connection)
           
protected  int getReconnectionEndType()
          Returns the type of reconnection
protected  void undoDirectReference(EObject valueToUnset, EObject newNode, EObject oldNode)
          Undo what was done before by the doDirectReference() method
protected  void undoInverseReference(EObject valueToUnset, EObject newNode, EObject oldNode)
          Undo what was done before by the doInverseReference() method.
 
Methods inherited from class org.topcased.modeler.commands.ReconnectGraphEdgeCommand
canExecute, execute, getEdge, getNewElement, getOldElement, initializeConnectors, redo, redoModel, setNewElement, undo, undoModel, updateConnectors
 
Methods inherited from class org.eclipse.gef.commands.Command
canUndo, chain, dispose, getDebugLabel, getLabel, setDebugLabel, setLabel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCE

public static int SOURCE
This means the user is reconnecting the SOURCE. Its value is 0


TARGET

public static int TARGET
This means the user is reconnecting the TARGET. Its value is 1

Constructor Detail

ReconnectNodeToNodeCommand

public ReconnectNodeToNodeCommand(org.eclipse.gef.ConnectionEditPart connection,
                                  java.lang.String featureName,
                                  int reconnectedEnd)
Constructor. User must specify the edge end he is reconnecting by using SOURCE to reconnect the source and TARGET to reconnect the target. Another value (a value higher than 1) will make the command to be ignored

Parameters:
domain -
connection -
featureName -
reconnectedEnd -
Method Detail

getOldGraphElement

protected GraphElement getOldGraphElement(org.eclipse.gef.ConnectionEditPart connection)
Specified by:
getOldGraphElement in class ReconnectGraphEdgeCommand
Returns:
Returns the current end element of the given edge
See Also:
ReconnectGraphEdgeCommand.getOldGraphElement(org.eclipse.gef.ConnectionEditPart)

doDirectReference

protected void doDirectReference(EObject node,
                                 EObject newReference,
                                 EObject oldReference)
Sets the new reference to the given node. The old reference will be removed from the node. This method memorizes the old container of the new reference to be set to the old reference. Bey this way ancient references will not be lost.

Parameters:
node - The node which sets the new reference
newReference - The new object to reference
oldReference - The old object referenced. It will be take the place of the newReference in the container.

undoDirectReference

protected void undoDirectReference(EObject valueToUnset,
                                   EObject newNode,
                                   EObject oldNode)
Undo what was done before by the doDirectReference() method

Parameters:
valueToUnset - The value to set its old features.
newNode - the new source which contained the value to unset
oldNode - the old source to restablish its value
See Also:
doDirectReference(EObject, EObject, EObject)

doInverseReference

protected void doInverseReference(EObject reference,
                                  EObject newNode,
                                  EObject oldNode)
Adds the reference to the new node. The reference is also removed from the oldNode to avoid conflicts between nodes.

Parameters:
reference - The value to be referenced by the new node
newNode - The node object which is going to reference the value
oldNode - The node that will not reference the given value any longer

undoInverseReference

protected void undoInverseReference(EObject valueToUnset,
                                    EObject newNode,
                                    EObject oldNode)
Undo what was done before by the doInverseReference() method.

Parameters:
valueToUnset - The value to set its old features.
newNode - the new source which contained the value to unset
oldNode - the old source to restablish its value
See Also:
doInverseReference(EObject, EObject, EObject)

getReconnectionEndType

protected int getReconnectionEndType()
Returns the type of reconnection

Returns:
the integer value of the end reconnection type.
See Also:
SOURCE, TARGET

getFixedEnd

protected EObject getFixedEnd()
Retuns the model object corresponding to the fixed edge end

Returns:
The EObject of the fixed node end

getObjectToUpdate

protected abstract EObject getObjectToUpdate()
Retuns the model object corresponding to the fixed edge end

Returns:
The EObject of the fixed node end

Modelers

Copyright (c) 2005 TOPCASED Contributors 2005 - 2007. All rights reserved.