pl.edu.agh.cast.backward.command
Class DeleteModelElementsCommand

java.lang.Object
  extended by org.eclipse.gef.commands.Command
      extended by pl.edu.agh.cast.backward.command.DeleteModelElementsCommand

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

This command will be created multiple times because of the way delete requests work on edit parts. The exact same command is returned for all requests - GEF fires a single request for each model element to delete, and they're all aggregated into a single command. It should execute only once, deleting all elements at once, and undo only once, restoring them at once as well. That's what the _executed and _undone flags are for. GEF calls execute for a command created for each model element to be deleted - that's why this command's execute() will be called multiple times, and we have to guard against that.

Author:
AGH CAST Team

Field Summary
static Object ID
          Id of the command.
 
Constructor Summary
DeleteModelElementsCommand(IDiagram diagram)
          Creates new instance of command to delete model elements.
 
Method Summary
 void add(Connection connection)
          Adds Connection to remove.
 void add(ConnectionGroup group)
          Adds ConnectionGroup to remove.
 void add(Node node)
          Adds Node to remove.
 void execute()
          
 void redo()
          
 void undo()
          
 
Methods inherited from class org.eclipse.gef.commands.Command
canExecute, 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

ID

public static final Object ID
Id of the command.

Constructor Detail

DeleteModelElementsCommand

public DeleteModelElementsCommand(IDiagram diagram)
Creates new instance of command to delete model elements.

Parameters:
diagram - the diagram to operate on
Method Detail

add

public void add(Connection connection)
Adds Connection to remove.

Parameters:
connection - connection to remove

add

public void add(ConnectionGroup group)
Adds ConnectionGroup to remove.

Parameters:
group - connection group to remove

add

public void add(Node node)
Adds Node to remove.

Parameters:
node - node to remove

execute

public void execute()

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

undo

public void undo()

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

redo

public void redo()

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


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.