net.refractions.udig.tools.edit
Class MutualExclusiveBehavior

java.lang.Object
  extended by net.refractions.udig.tools.edit.MutualExclusiveBehavior
All Implemented Interfaces:
Behaviour

public class MutualExclusiveBehavior
extends java.lang.Object
implements Behaviour

A Composite Mode (See GOF Composite Pattern) where contained modes are ordered by priority and only the mode with the highest priority and is valid for the current context is ran.

Since:
1.1.0
Author:
jones

Constructor Summary
MutualExclusiveBehavior()
          Create an empty behaviour.
MutualExclusiveBehavior(Behaviour behaviour)
           
MutualExclusiveBehavior(java.util.List<Behaviour> modes)
           
 
Method Summary
 java.util.List<Behaviour> getBehaviours()
           
 UndoableMapCommand getCommand(EditToolHandler handler)
          The action to be performed by this Behaviour.
 void handleError(EditToolHandler handler, java.lang.Throwable error, UndoableMapCommand command)
          This method is called if an exception occurs during the execution of the run method.
 boolean isValid(EditToolHandler handler)
          Called to determine whether this Behaviour is applicable and should be run.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MutualExclusiveBehavior

public MutualExclusiveBehavior(java.util.List<Behaviour> modes)

MutualExclusiveBehavior

public MutualExclusiveBehavior(Behaviour behaviour)
Parameters:
behaviour -

MutualExclusiveBehavior

public MutualExclusiveBehavior()
Create an empty behaviour. Behaviours must be added via the getBehaviours() method

Method Detail

isValid

public boolean isValid(EditToolHandler handler)
Description copied from interface: Behaviour
Called to determine whether this Behaviour is applicable and should be run.

Specified by:
isValid in interface Behaviour
Parameters:
handler - handler that calls this Behaviour
Returns:
true if this mode is applicable and should be run.

getCommand

public UndoableMapCommand getCommand(EditToolHandler handler)
Description copied from interface: Behaviour
The action to be performed by this Behaviour. This action takes place in the event thread so it must perform quickly.

Specified by:
getCommand in interface Behaviour
Parameters:
handler - handler that calls this Behaviour
Returns:
Command that will be executed in order to perform the behaviour

handleError

public void handleError(EditToolHandler handler,
                        java.lang.Throwable error,
                        UndoableMapCommand command)
Description copied from interface: Behaviour
This method is called if an exception occurs during the execution of the run method.

This method should:

  1. Rollback the changes made during the run method
  2. Log the error in the plugin's log

Specified by:
handleError in interface Behaviour
error - Error that occurred
command - Command retrieved from getCommandMethod. May be null if exception occurred while executing getCommand();

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getBehaviours

public java.util.List<Behaviour> getBehaviours()
Returns:
Returns the behaviours.