org.eclipse.emf.transaction.util
Class TriggerCommand

java.lang.Object
  extended by org.eclipse.emf.common.command.AbstractCommand
      extended by org.eclipse.emf.common.command.CompoundCommand
          extended by org.eclipse.emf.transaction.util.ConditionalRedoCommand.Compound
              extended by org.eclipse.emf.transaction.util.TriggerCommand
All Implemented Interfaces:
Command, ConditionalRedoCommand

public class TriggerCommand
extends ConditionalRedoCommand.Compound

A specialized compound command that combines a "triggering" command with commands contributed by ResourceSetListeners as triggers. It takes care of the distinction between the triggering command and the others when executing, undoing, and redoing.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.emf.common.command.AbstractCommand
AbstractCommand.NonDirtying
 
Nested classes/interfaces inherited from interface org.eclipse.emf.transaction.util.ConditionalRedoCommand
ConditionalRedoCommand.Compound
 
Field Summary
 
Fields inherited from class org.eclipse.emf.common.command.CompoundCommand
commandList, LAST_COMMAND_ALL, MERGE_COMMAND_ALL, resultIndex
 
Fields inherited from class org.eclipse.emf.common.command.AbstractCommand
description, isExecutable, isPrepared, label
 
Constructor Summary
TriggerCommand(Command triggeringCommand, List<? extends Command> triggers)
          Initializes me with a list of commands triggered by the execution of some command on the command stack.
TriggerCommand(List<? extends Command> triggers)
          Initializes me with a list of commands triggered not by the execution of a command but by direct manipulation of the model during a read/write transaction.
 
Method Summary
 void dispose()
          Extends the inherited implementation by disposing my triggering command, also (if any).
 void execute()
          Executes all of my trigger commands, then prepends the original triggering command (if any) so that it will be undone/redone with the others.
 Command getTriggeringCommand()
          Retrieves the command that triggered the trigger commands.
 List<Command> getTriggers()
          Retrieves my trigger commands (not including the triggering command, if any).
protected  boolean prepare()
           
 
Methods inherited from class org.eclipse.emf.transaction.util.ConditionalRedoCommand.Compound
canRedo, chain
 
Methods inherited from class org.eclipse.emf.common.command.CompoundCommand
append, appendAndExecute, appendIfCanExecute, canUndo, getAffectedObjects, getCommandList, getDescription, getLabel, getMergedAffectedObjectsCollection, getMergedResultCollection, getResult, getResultIndex, isEmpty, redo, toString, undo, unwrap
 
Methods inherited from class org.eclipse.emf.common.command.AbstractCommand
canExecute, setDescription, setLabel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.emf.common.command.Command
canExecute, canUndo, getAffectedObjects, getDescription, getLabel, getResult, redo, undo
 

Constructor Detail

TriggerCommand

public TriggerCommand(List<? extends Command> triggers)
Initializes me with a list of commands triggered not by the execution of a command but by direct manipulation of the model during a read/write transaction. It is assumed, then, that the trigger command will not actually be used with a command stack where its label and description would matter for undo/redo menus.

Parameters:
triggers - the trigger commands that I encapsulate

TriggerCommand

public TriggerCommand(Command triggeringCommand,
                      List<? extends Command> triggers)
Initializes me with a list of commands triggered by the execution of some command on the command stack. My label and description are the same as the triggering command's

Parameters:
triggeringCommand - the command that triggered further commands
triggers - the trigger commands that I encapsulate
Method Detail

getTriggeringCommand

public final Command getTriggeringCommand()
Retrieves the command that triggered the trigger commands.

Returns:
the triggering command, or null if the triggers were not instigated by the execution of a command

getTriggers

public final List<Command> getTriggers()
Retrieves my trigger commands (not including the triggering command, if any).

Returns:
my triggers, as a list of Commands. Will not be empty

prepare

protected boolean prepare()
Overrides:
prepare in class CompoundCommand

execute

public void execute()
Executes all of my trigger commands, then prepends the original triggering command (if any) so that it will be undone/redone with the others.

Specified by:
execute in interface Command
Overrides:
execute in class CompoundCommand

dispose

public void dispose()
Extends the inherited implementation by disposing my triggering command, also (if any).

Specified by:
dispose in interface Command
Overrides:
dispose in class CompoundCommand

Copyright 2002, 2007 IBM Corporation and others.
All Rights Reserved.