pl.edu.agh.cast.schema.editor.command
Class DeleteElementsCommand

java.lang.Object
  extended by org.eclipse.gef.commands.Command
      extended by pl.edu.agh.cast.schema.editor.command.DeleteElementsCommand

public class DeleteElementsCommand
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
DeleteElementsCommand(SchemaEditPart schemaEditPart)
          Creates new instance of command to delete model elements.
 
Method Summary
 void add(ISchemaConnection connection)
          Adds ISchemaConnection to remove.
 void add(ISchemaElement element)
          Adds ISchemaNode or ISchemaConnection to remove.
 void add(ISchemaNode node)
          Adds ISchemaNode to remove along with all its connections.
 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

DeleteElementsCommand

public DeleteElementsCommand(SchemaEditPart schemaEditPart)
Creates new instance of command to delete model elements.

Parameters:
schemaEditPart - schema edit part which controls diagram diagram to operate on
Method Detail

add

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

Parameters:
connection - connection to remove

add

public void add(ISchemaNode node)
Adds ISchemaNode to remove along with all its connections.

Parameters:
node - node to remove

add

public void add(ISchemaElement element)
Adds ISchemaNode or ISchemaConnection to remove.

Parameters:
element - element 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.