Modelers

org.topcased.modeler.commands
Class CreateGraphNodeCommand

java.lang.Object
  extended by org.eclipse.gef.commands.Command
      extended by org.topcased.modeler.commands.CreateGraphNodeCommand

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

Node creation
This command just add a graphNode into another. It also add the contained element to the element of the parentNode graph node if needed.
creation : 30 nov. 2004


Constructor Summary
CreateGraphNodeCommand(org.eclipse.gef.EditDomain domain, GraphNode newObject, GraphNode newParent, EObject newContainerParent, org.eclipse.draw2d.geometry.Point location, org.eclipse.draw2d.geometry.Dimension dimension, int attach, java.util.List featuresList, boolean needModelUpdate)
          Constructor
CreateGraphNodeCommand(org.eclipse.gef.EditDomain domain, GraphNode newObject, GraphNode newParent, org.eclipse.draw2d.geometry.Point location, org.eclipse.draw2d.geometry.Dimension dimension, int attach)
          Constructor - Add simply a graphNode to its container Node without updating the model
CreateGraphNodeCommand(org.eclipse.gef.EditDomain domain, GraphNode newObject, GraphNode newParent, org.eclipse.draw2d.geometry.Point location, org.eclipse.draw2d.geometry.Dimension dimension, java.util.List featuresList, boolean needModelUpdate)
          Constructor
 
Method Summary
 boolean canExecute()
          Check if the object that we try to add to the model is not already set (because the cardinality is 1)
 void execute()
           
protected  EObject getChildEObject()
          Return the childNode EObject to create
protected  GraphNode getChildNode()
          Return the childNode to create
protected  org.eclipse.gef.EditDomain getEditDomain()
          Return the EditDomain associated with the command
protected  EObject getParentEObject()
          Return the parentNode EObject that will contain the childEObject
protected  GraphNode getParentNode()
          Return the parentNode that will contain the childNode
protected  EStructuralFeature getSelectedFeature()
          Return the EStructuralFeature where to add the childNode
protected  boolean isUpdateModel()
          Return a boolean value used to update or not the model
 void redo()
           
protected  void redoModel()
          Update the model after at the end of the redo() method.
 void undo()
           
protected  void undoModel()
          Update the model at the end of the undo() method.
 
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
 

Constructor Detail

CreateGraphNodeCommand

public CreateGraphNodeCommand(org.eclipse.gef.EditDomain domain,
                              GraphNode newObject,
                              GraphNode newParent,
                              org.eclipse.draw2d.geometry.Point location,
                              org.eclipse.draw2d.geometry.Dimension dimension,
                              java.util.List featuresList,
                              boolean needModelUpdate)
Constructor

Parameters:
domain - the EditDomain (used to init the name)
newObject - the node to create
newParent - the parentNode node
location - the location of the created node
dimension - the size of the created node
featuresList - the avalaible model element feature of the parentNode node where the model element of the childNode node can be added
needModelUpdate - true if the model must be modified during this command, false if objects already exist in the mode.

CreateGraphNodeCommand

public CreateGraphNodeCommand(org.eclipse.gef.EditDomain domain,
                              GraphNode newObject,
                              GraphNode newParent,
                              EObject newContainerParent,
                              org.eclipse.draw2d.geometry.Point location,
                              org.eclipse.draw2d.geometry.Dimension dimension,
                              int attach,
                              java.util.List featuresList,
                              boolean needModelUpdate)
Constructor

Parameters:
domain - the EditDomain (used to init the name)
newObject - the node to create
newParent - the parentNode node
newContainerParent - the model object that should contain the new childNode object
location - the location of the created node
dimension - the size of the created node
attach - the newAttachment of the created node
featuresList - the avalaible model element feature of the parentNode node where the model element of the childNode node can be added
needModelUpdate - true if the model must be modified during this command, false if objects already exist in the mode.

CreateGraphNodeCommand

public CreateGraphNodeCommand(org.eclipse.gef.EditDomain domain,
                              GraphNode newObject,
                              GraphNode newParent,
                              org.eclipse.draw2d.geometry.Point location,
                              org.eclipse.draw2d.geometry.Dimension dimension,
                              int attach)
Constructor - Add simply a graphNode to its container Node without updating the model

Parameters:
domain - the EditDomain (used to init the name)
newObject - the node to create
newParent - the parentNode node
location - the location of the created node
dimension - the size of the created node
attach - the newAttachment of the created node
Method Detail

canExecute

public boolean canExecute()
Check if the object that we try to add to the model is not already set (because the cardinality is 1)

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

execute

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

redoModel

protected void redoModel()
Update the model after at the end of the redo() method. This method should be overriden by subclasses when additionnal model changes are needed.


redo

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

undoModel

protected void undoModel()
Update the model at the end of the undo() method. This method should be overriden by subclasses.


undo

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

getEditDomain

protected org.eclipse.gef.EditDomain getEditDomain()
Return the EditDomain associated with the command

Returns:
the EditDomain

getChildEObject

protected EObject getChildEObject()
Return the childNode EObject to create

Returns:
the childNode EObject

getChildNode

protected GraphNode getChildNode()
Return the childNode to create

Returns:
the childNode

getParentEObject

protected EObject getParentEObject()
Return the parentNode EObject that will contain the childEObject

Returns:
the parentNode EObject

getParentNode

protected GraphNode getParentNode()
Return the parentNode that will contain the childNode

Returns:
the parentNode

getSelectedFeature

protected EStructuralFeature getSelectedFeature()
Return the EStructuralFeature where to add the childNode

Returns:
the EStructuralFeature

isUpdateModel

protected boolean isUpdateModel()
Return a boolean value used to update or not the model

Returns:
false if the command is coming from a DND request

Modelers

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