net.refractions.udig.project.command
Class UndoableComposite

java.lang.Object
  extended by net.refractions.udig.project.command.CompositeCommand
      extended by net.refractions.udig.project.command.UndoableComposite
All Implemented Interfaces:
Command, MapCommand, PostDeterminedEffectCommand, UndoableCommand, UndoableMapCommand

public class UndoableComposite
extends CompositeCommand
implements UndoableMapCommand, PostDeterminedEffectCommand

A UndoableCommand composed of multiple UndoableCommands. Executes and rollsback as a atomic command. See Composite Pattern.

Since:
0.3
Author:
jeichar
See Also:
CompositeCommand, UndoableCommand

Field Summary
 
Fields inherited from class net.refractions.udig.project.command.CompositeCommand
commands, finalizerCommands
 
Constructor Summary
UndoableComposite()
          Creates a new instance of UndoableComposite
UndoableComposite(java.util.List undoableCommands)
          Creates a new instance of UndoableComposite API List
 
Method Summary
 boolean execute(IProgressMonitor monitor)
          This method should return true if the method has changed state and will do something when undone.
 void rollback(IProgressMonitor monitor)
          Rollback the effects of the command
 void run(IProgressMonitor monitor)
          The method that performs the work of the command.
 
Methods inherited from class net.refractions.udig.project.command.CompositeCommand
copy, getCommands, getFinalizerCommands, getMap, getName, setMap, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.refractions.udig.project.command.Command
copy, getName
 
Methods inherited from interface net.refractions.udig.project.command.Command
copy, getName
 
Methods inherited from interface net.refractions.udig.project.command.Command
copy, getName
 
Methods inherited from interface net.refractions.udig.project.command.Command
copy, getName
 

Constructor Detail

UndoableComposite

public UndoableComposite()
Creates a new instance of UndoableComposite

Parameters:
undoableCommands - an ordered list of UndoableCommands

UndoableComposite

public UndoableComposite(java.util.List undoableCommands)
Creates a new instance of UndoableComposite API List

Parameters:
undoableCommands - an ordered list of UndoableCommands
Method Detail

run

public void run(IProgressMonitor monitor)
         throws java.lang.Exception
Description copied from interface: Command
The method that performs the work of the command.

Run is called by UDIG when the command is received. Commands are run in a seperate thread.

Specified by:
run in interface Command
Specified by:
run in interface PostDeterminedEffectCommand
Overrides:
run in class CompositeCommand
Parameters:
monitor - A progress monitor used by the command to report on its internal state. API how is this associated with a Thread? is it a Thread?
Throws:
java.lang.Exception
See Also:
net.refractions.udig.project.internal.command.MapCommand#run()

rollback

public void rollback(IProgressMonitor monitor)
              throws java.lang.Exception
Description copied from interface: UndoableCommand
Rollback the effects of the command

Specified by:
rollback in interface UndoableCommand
Throws:
java.lang.Exception
See Also:
net.refractions.udig.project.internal.command.UndoableCommand#rollback()

execute

public boolean execute(IProgressMonitor monitor)
                throws java.lang.Exception
Description copied from interface: PostDeterminedEffectCommand
This method should return true if the method has changed state and will do something when undone.

Specified by:
execute in interface PostDeterminedEffectCommand
Parameters:
monitor - used to indicate the progress of the monitor.
Returns:
true if the method has changed global state and command should be put on the undo stack.
Throws:
java.lang.Exception