net.refractions.udig.tools.edit
Interface EventBehaviour

All Known Subinterfaces:
LockingBehaviour
All Known Implementing Classes:
AcceptBehaviour, AcceptWhenOverFirstVertexBehaviour, AddVertexOnEdgeBehaviour, AddVertexWhileCreatingBehaviour, AdvancedFeaturesEventBehavior, CursorControlBehaviour, DoubleClickRunAcceptBehaviour, DrawCreateVertexSnapAreaBehaviour, ExtendLineBehaviour, FreeHandPolygonDrawBehaviour, MouseDownVertexSelectorBehaviour, MoveGeometryBehaviour, MoveVertexBehaviour, MoveVertexBehaviour.PositionTracker, MutualExclusiveEventBehavior, OrderedCompositeEventBehavior, RemoveVertexBehaviour, SelectGeometryBehaviour, SelectHoleBehaviour, SelectionBoxBehaviour, SetSnapSizeBehaviour, ShapeCreationBehaviour, StartEditingBehaviour, StartHoleCuttingBehaviour, VertexSelectorBehaviour

public interface EventBehaviour

This is a Stategy object for the (@link net.refractions.udig.tools.edit.latest.EditToolHandler} behaviour. Each EventBehavior is valid in a particular context and will be run by the (@link net.refractions.udig.tools.edit.latest.EditToolHandler} if the isValid method returns true.

An example is a SelectGeometryBehaviour.

Context: EditState is MODIFYING, EventType is RELEASED, mouse button is button 1 and no keys are pressed.

Action: If mouse is over a feature add the Geometry to the EditBlackBoard and set the EditToolHandler's current Geometry and Shape.

Error handling: If exception occurs reset the EditBlackBoard and current Geometry and shape

Since:
1.1.0
Author:
jones

Method Summary
 UndoableMapCommand getCommand(EditToolHandler handler, MapMouseEvent e, EventType eventType)
          The action to be performed by this EventBehaviour.
 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, MapMouseEvent e, EventType eventType)
          Called to determine whether this EventBehaviour is applicable and should be run.
 

Method Detail

isValid

boolean isValid(EditToolHandler handler,
                MapMouseEvent e,
                EventType eventType)
Called to determine whether this EventBehaviour is applicable and should be run.

Parameters:
handler - handler that calls this Behaviour
e - mouse event that just occurred.
eventType - the type of event that just occurred
Returns:
true if this mode is applicable and should be run.

getCommand

UndoableMapCommand getCommand(EditToolHandler handler,
                              MapMouseEvent e,
                              EventType eventType)
The action to be performed by this EventBehaviour. This action takes place in the event thread so it must perform VERY quickly.

Parameters:
handler - handler that calls this Behaviour
e - Event that occurred.
eventType - The type of event that has occurred
Returns:
Command that will be executed in order to perform the behaviour

handleError

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.

This method should

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

Parameters:
handler - handler that calls this Behaviour
error - Error that occurred
command - Command retrieved from getCommandMethod. May be null if exception occurred while executing getCommand();