uic.action
Class SwingAction

java.lang.Object
  extended by uic.model.UICSimpleAction
      extended by uic.action.SwingAction
Direct Known Subclasses:
AbstractButtonAction, ComponentEscapeAction, ComponentFocusLostAction, ComponentKeyboardAction, ComponentMouseClickedAction, ComponentResizedAction, ComponentShownAction, DocumentChangedAction, ItemSelectableAction, JCheckBoxMenuItemAction, JRadioButtonMenuItemAction, JSpinnerChangeAction, JTextComponentEnterAction, JTreeDoubleClickAction, ListDeselectionAction, ListDoubleClickAction, ListSelectionAction, PropertyChangedAction, WindowRepresenterToolBarAddedAction

public abstract class SwingAction
extends UICSimpleAction


Nested Class Summary
 
Nested classes/interfaces inherited from class uic.model.UICSimpleAction
UICSimpleAction.Arguments, UICSimpleAction.DirectMultiThreadingPolicy, UICSimpleAction.DirectPolicy, UICSimpleAction.ExecutePolicy, UICSimpleAction.OnlyLastPolicy, UICSimpleAction.QueuedPolicy, UICSimpleAction.SimpleQueuedPolicy
 
Field Summary
protected  UICSimpleAction updateUICommmand
           
 
Fields inherited from class uic.model.UICSimpleAction
currentPolicy, target, targetObject
 
Constructor Summary
SwingAction(Object targetObject, String targetMethod)
           
SwingAction(Object targetObject, String targetMethod, UICSimpleAction.Arguments args)
           
 
Method Summary
protected  void doAction(Object[] args)
          Called to actually execute the action on the registered method.
 Iterator getComponentsIterator()
          Returns an iterator over all added components.
protected  void registerComponent(Component comp)
          Add a component to be managed and listened to by this action.
 void setEnabled(boolean enabled)
          Enable disable this action and all its registered components.
 void setUIUpdateCommand(Object object, String targetMethod)
          Set an additional target for this action which will be in the AWT Thread.
 void setUIUpdateCommand(Object object, String targetMethod, UICSimpleAction.Arguments arguments)
          Set an additional target for this action which will be in the AWT Thread.
 
Methods inherited from class uic.model.UICSimpleAction
createArguments, equals, execute, execute, execute, execute, getArgumentClass, getArgumentValue, getTargetSignatures, isEnabled, setDirect, setExecutionPolicy, setTarget, setTarget
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

updateUICommmand

protected UICSimpleAction updateUICommmand
Constructor Detail

SwingAction

public SwingAction(Object targetObject,
                   String targetMethod)

SwingAction

public SwingAction(Object targetObject,
                   String targetMethod,
                   UICSimpleAction.Arguments args)
Method Detail

registerComponent

protected void registerComponent(Component comp)
Add a component to be managed and listened to by this action. Extending classes are expected to call this method after subscribing themselves to the appropriate listeners. After adding the component the action will manage the component's enabled state correctly.

Parameters:
comp - the component to be managed

getComponentsIterator

public Iterator getComponentsIterator()
Returns an iterator over all added components.

Returns:
an iterator over all added components.
See Also:
registerComponent(java.awt.Component)

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.

Overrides:
setEnabled in class UICSimpleAction
Parameters:
enabled - the new state of the action.

doAction

protected void doAction(Object[] args)
Description copied from class: UICSimpleAction
Called to actually execute the action on the registered method. Notice that this method will never throw any Throwables due to bad implementations in the target method since they are all cought (and ignored) here. That said; exceptions made in the target method will be printed using a simple printStackTrace() call on the throwable.

Overrides:
doAction in class UICSimpleAction

setUIUpdateCommand

public void setUIUpdateCommand(Object object,
                               String targetMethod)
                        throws IllegalArgumentException
Set an additional target for this action which will be in the AWT Thread. After the action executed the target method for this action another target method will be executed as soon as possible, in the AWT Event thread.

In Swing many changes to model and widgets are not safe to do from any thread but the event-handling thread that Swing starts itself. This event-handling thread is called the AWT Event Thread and handles button clicks and any other user event, as well as repaints.

It is wise to move updates to various widgets to an extra UIUpdateCommand and register it using this method.

For the arguments see: setTarget

Throws:
IllegalArgumentException

setUIUpdateCommand

public void setUIUpdateCommand(Object object,
                               String targetMethod,
                               UICSimpleAction.Arguments arguments)
                        throws IllegalArgumentException
Set an additional target for this action which will be in the AWT Thread. After the action executed the target method for this action another target method will be executed as soon as possible, in the AWT Event thread.

In Swing many changes to model and widgets are not safe to do from any thread but the event-handling thread that Swing starts itself. This event-handling thread is called the AWT Event Thread and handles button clicks and any other user event, as well as repaints.

It is wise to move updates to various widgets to an extra UIUpdateCommand and register it using this method.

For the arguments see: setTarget

Throws:
IllegalArgumentException


Copyright © 2002-2004 Thomas Zander Available under the Free Apache licence