uic.model
Class UICSimpleAction

java.lang.Object
  extended byuic.model.UICSimpleAction
Direct Known Subclasses:
UICAction

public class UICSimpleAction
extends Object

This class represent the glue between a user event and a piece of controlling logic. Events based programming creates the need to execute certain pieces of logic based on the incoming event, conveniently grouped per action. An action can be something like 'print'. Notice that the default version uses the SimpleQueuedPolicy.

Since:
1.2

Nested Class Summary
static class UICSimpleAction.DirectPolicy
          This policy will execute the action in the calling thread.
static interface UICSimpleAction.ExecutePolicy
          Each action that is called 'execute()' on will be executed according to policy.
static class UICSimpleAction.OnlyLastPolicy
          This policy will enqueue the action; but will remove others that would call the same target method.
static class UICSimpleAction.QueuedPolicy
          This policy will queue each action to be executed serially, while disabling the action when running.
static class UICSimpleAction.SimpleQueuedPolicy
          This policy will queue each action to be executed serially.
 
Field Summary
protected  UICSimpleAction.ExecutePolicy currentPolicy
           
protected  Method target
           
protected  Object targetObject
           
 
Constructor Summary
UICSimpleAction()
          Empty constructor; don't forget to do a setTarget later!.
UICSimpleAction(Object targetObject, String targetMethod)
          Constructor with automatic setTarget.
 
Method Summary
protected  void doAction(Object source)
          Called to actually execute the action on the registered method.
 void execute()
          Convenience method.
 void execute(Object source)
          Execute the action.
 void setDirect(boolean direct)
          UIActions queue their work so actions will have to wait for all others to be finished; unless direct is true.
 void setEnabled(boolean enabled)
          Enable disable this action and all its registered components.
 void setExecutionPolity(UICSimpleAction.ExecutePolicy policy)
          Set a new policy for this action.
 void setTarget(Object object, String targetMethod)
          The target method that is to be called when the action is fired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

targetObject

protected Object targetObject

target

protected Method target

currentPolicy

protected UICSimpleAction.ExecutePolicy currentPolicy
Constructor Detail

UICSimpleAction

public UICSimpleAction()
Empty constructor; don't forget to do a setTarget later!.


UICSimpleAction

public UICSimpleAction(Object targetObject,
                       String targetMethod)
Constructor with automatic setTarget.

See Also:
setTarget(java.lang.Object, java.lang.String)
Method Detail

setTarget

public void setTarget(Object object,
                      String targetMethod)
               throws IllegalArgumentException
The target method that is to be called when the action is fired.

Parameters:
object - The object that contains the method we want to connect to.
targetMethod - the name of the method we want to connect to.
Throws:
IllegalArgumentException

setEnabled

public void setEnabled(boolean enabled)
Enable disable this action and all its registered components. Incoming events will not cause the action to be commited when the action is disabled.

Parameters:
enabled - the new state of the action.

doAction

protected void doAction(Object source)
Called to actually execute the action on the registered method.


execute

public void execute()
Convenience method.


execute

public void execute(Object source)
Execute the action. Calling execute will register the call and make sure the targetMethod is called. Notice that calling this method will do nothing if the action is not enabled.

Parameters:
source - an optional source object; this object will be passed as an argument to the target method.

setDirect

public void setDirect(boolean direct)
UIActions queue their work so actions will have to wait for all others to be finished; unless direct is true. In the case of stop/quit and other actions coming from UICActions that by definition should be executed directly; and not after all others, the action should be set to be 'direct'.

Parameters:
direct - if true the action will be executed directly, inside the calling thread.

setExecutionPolity

public void setExecutionPolity(UICSimpleAction.ExecutePolicy policy)
Set a new policy for this action.

Parameters:
policy - the new policy


Copyright © 2002,2003 Thomas Zander Available under the Free Apache licence