uic.action
Class PropertyChangedAction

java.lang.Object
  extended by uic.model.UICSimpleAction
      extended by uic.action.SwingAction
          extended by uic.action.PropertyChangedAction
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class PropertyChangedAction
extends SwingAction
implements PropertyChangeListener

An event to respond to firePropertyChange signals. Notice that the default version uses the OnlyLastPolicy. Using this class is easy; just call:

new PropertyChangedAction(this, "firedSlot").add(childPanel); 
This has the result that when the childPanel does a firePropertyChange() the 'firedSlot' on object 'this' will be called.
Default target signatures
(ARGUMENT_NEWVALUE)
()
All Targets
ARGUMENT_NEWVALUE
ARGUMENT_OLDVALUE
ARGUMENT_SOURCE

Since:
2.0

Nested Class Summary
static interface PropertyChangedAction.PropertyChangeCreator
           
 
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
static String ARGUMENT_NEWVALUE
          an Object: the new value from the event.
static String ARGUMENT_NEWVALUE_BOOLEAN
          an Object: the new value from the event.
static String ARGUMENT_NEWVALUE_BYTE
          an Object: the new value from the event.
static String ARGUMENT_NEWVALUE_CHAR
          an Object: the new value from the event.
static String ARGUMENT_NEWVALUE_DOUBLE
          an Object: the new value from the event.
static String ARGUMENT_NEWVALUE_FLOAT
          an Object: the new value from the event.
static String ARGUMENT_NEWVALUE_INT
          an Object: the new value from the event.
static String ARGUMENT_NEWVALUE_LONG
          an Object: the new value from the event.
static String ARGUMENT_NEWVALUE_SHORT
          an Object: the new value from the event.
static String ARGUMENT_OLDVALUE
          an Object: the old from the event.
static String ARGUMENT_OLDVALUE_BOOLEAN
          an Object: the old from the event.
static String ARGUMENT_OLDVALUE_BYTE
          an Object: the old from the event.
static String ARGUMENT_OLDVALUE_CHAR
          an Object: the old from the event.
static String ARGUMENT_OLDVALUE_DOUBLE
          an Object: the old from the event.
static String ARGUMENT_OLDVALUE_FLOAT
          an Object: the old from the event.
static String ARGUMENT_OLDVALUE_INT
          an Object: the old from the event.
static String ARGUMENT_OLDVALUE_LONG
          an Object: the old from the event.
static String ARGUMENT_OLDVALUE_SHORT
          an Object: the old from the event.
static String ARGUMENT_SOURCE
          an Object: the source object that registered the source.
 
Fields inherited from class uic.action.SwingAction
updateUICommmand
 
Fields inherited from class uic.model.UICSimpleAction
currentPolicy, target, targetObject
 
Constructor Summary
PropertyChangedAction(Object targetObject, String targetMethod)
          Create a new PropertyChangedAction.
PropertyChangedAction(Object targetObject, String targetMethod, UICSimpleAction.Arguments arguments)
          Create a new PropertyChangedAction.
 
Method Summary
 PropertyChangedAction add(Component source)
          Add an Component object to this action.
 PropertyChangedAction add(Component source, String propertyName)
           
 PropertyChangedAction add(PropertyChangedAction.PropertyChangeCreator source)
           
 PropertyChangedAction add(PropertyChangedAction.PropertyChangeCreator source, String propertyName)
           
protected  Class getArgumentClass(String argumentType)
          For the uniquely defined argumentType (as also used in UICSimpleAction.getTargetSignatures()) return the Class.
protected  Object getArgumentValue(EventObject source, String argumentType)
          For the uniquely defined argumentType (as also used in UICSimpleAction.getTargetSignatures()) return the value.
protected  List getTargetSignatures()
          Return a List object with instances of the Arguments class.
 void propertyChange(PropertyChangeEvent evt)
           
 
Methods inherited from class uic.action.SwingAction
doAction, getComponentsIterator, registerComponent, setEnabled, setUIUpdateCommand, setUIUpdateCommand
 
Methods inherited from class uic.model.UICSimpleAction
createArguments, equals, execute, execute, execute, execute, isEnabled, setDirect, setExecutionPolicy, setTarget, setTarget
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARGUMENT_NEWVALUE_INT

public static final String ARGUMENT_NEWVALUE_INT
an Object: the new value from the event.

See Also:
Constant Field Values

ARGUMENT_OLDVALUE_INT

public static final String ARGUMENT_OLDVALUE_INT
an Object: the old from the event.

See Also:
Constant Field Values

ARGUMENT_NEWVALUE_SHORT

public static final String ARGUMENT_NEWVALUE_SHORT
an Object: the new value from the event.

See Also:
Constant Field Values

ARGUMENT_OLDVALUE_SHORT

public static final String ARGUMENT_OLDVALUE_SHORT
an Object: the old from the event.

See Also:
Constant Field Values

ARGUMENT_NEWVALUE_BOOLEAN

public static final String ARGUMENT_NEWVALUE_BOOLEAN
an Object: the new value from the event.

See Also:
Constant Field Values

ARGUMENT_OLDVALUE_BOOLEAN

public static final String ARGUMENT_OLDVALUE_BOOLEAN
an Object: the old from the event.

See Also:
Constant Field Values

ARGUMENT_NEWVALUE_BYTE

public static final String ARGUMENT_NEWVALUE_BYTE
an Object: the new value from the event.

See Also:
Constant Field Values

ARGUMENT_OLDVALUE_BYTE

public static final String ARGUMENT_OLDVALUE_BYTE
an Object: the old from the event.

See Also:
Constant Field Values

ARGUMENT_NEWVALUE_CHAR

public static final String ARGUMENT_NEWVALUE_CHAR
an Object: the new value from the event.

See Also:
Constant Field Values

ARGUMENT_OLDVALUE_CHAR

public static final String ARGUMENT_OLDVALUE_CHAR
an Object: the old from the event.

See Also:
Constant Field Values

ARGUMENT_NEWVALUE_DOUBLE

public static final String ARGUMENT_NEWVALUE_DOUBLE
an Object: the new value from the event.

See Also:
Constant Field Values

ARGUMENT_OLDVALUE_DOUBLE

public static final String ARGUMENT_OLDVALUE_DOUBLE
an Object: the old from the event.

See Also:
Constant Field Values

ARGUMENT_NEWVALUE_FLOAT

public static final String ARGUMENT_NEWVALUE_FLOAT
an Object: the new value from the event.

See Also:
Constant Field Values

ARGUMENT_OLDVALUE_FLOAT

public static final String ARGUMENT_OLDVALUE_FLOAT
an Object: the old from the event.

See Also:
Constant Field Values

ARGUMENT_NEWVALUE_LONG

public static final String ARGUMENT_NEWVALUE_LONG
an Object: the new value from the event.

See Also:
Constant Field Values

ARGUMENT_OLDVALUE_LONG

public static final String ARGUMENT_OLDVALUE_LONG
an Object: the old from the event.

See Also:
Constant Field Values

ARGUMENT_NEWVALUE

public static final String ARGUMENT_NEWVALUE
an Object: the new value from the event.

See Also:
Constant Field Values

ARGUMENT_OLDVALUE

public static final String ARGUMENT_OLDVALUE
an Object: the old from the event.

See Also:
Constant Field Values

ARGUMENT_SOURCE

public static final String ARGUMENT_SOURCE
an Object: the source object that registered the source.

See Also:
Constant Field Values
Constructor Detail

PropertyChangedAction

public PropertyChangedAction(Object targetObject,
                             String targetMethod)
Create a new PropertyChangedAction.

Parameters:
targetObject - on which object should the target method be invoked
targetMethod - wich method on the targetObject should be invoked

PropertyChangedAction

public PropertyChangedAction(Object targetObject,
                             String targetMethod,
                             UICSimpleAction.Arguments arguments)
Create a new PropertyChangedAction.

Parameters:
targetObject - on which object should the target method be invoked
targetMethod - wich method on the targetObject should be invoked
arguments - to be used in finding the targetMethod signature
See Also:
UICSimpleAction.setTarget(Object,String,uic.model.UICSimpleAction.Arguments)
Method Detail

add

public PropertyChangedAction add(Component source)
Add an Component object to this action.

Parameters:
source - the component that does a firePropertyChange

add

public PropertyChangedAction add(Component source,
                                 String propertyName)

add

public PropertyChangedAction add(PropertyChangedAction.PropertyChangeCreator source)

add

public PropertyChangedAction add(PropertyChangedAction.PropertyChangeCreator source,
                                 String propertyName)

getTargetSignatures

protected List getTargetSignatures()
Description copied from class: UICSimpleAction
Return a List object with instances of the Arguments class. Extending classes should implement this to return all the target method signatures that are searched for should the user create an action without an Arguments instance.

An example implementation could be this:

  List result = new ArrayList(1);
  result.add( new Arguments().addArgument("Source") );
  return result;
This will result in a call to UICSimpleAction.getArgumentClass(java.lang.String) with the string "Source" which returns a Class instance. In our example that would be java.lang.Object.

The result of this would be that a call to setTarget will try to find a method with an argument of type Object, and will search again if that is not found without any arguments.

Overrides:
getTargetSignatures in class UICSimpleAction
Returns:
a List object with instances of the Arguments class.
See Also:
UICSimpleAction.getArgumentValue(java.util.EventObject, java.lang.String), UICSimpleAction.getArgumentClass(java.lang.String)

getArgumentValue

protected Object getArgumentValue(EventObject source,
                                  String argumentType)
Description copied from class: UICSimpleAction
For the uniquely defined argumentType (as also used in UICSimpleAction.getTargetSignatures()) return the value. This method will always return 'null'; Extending actions can define various argumentType strings that can be used as an argument in the call to the target method of this action. The user decides on construction of the action which argumentTypes are to be used, if a certain value is requested to be sent to the targetMethod a call is made to this method to find its value based on the source event.

Note that base types can not be returned, since they are instances of object; you should wrap these in their object re-presentation (an Integer object for an int).

Overrides:
getArgumentValue in class UICSimpleAction
Parameters:
source - the event that caused the action to be fired. This is the event that the extending class passed to the execute method; so casting is fine.
argumentType - the uniquely defined name specifying the type of argument.
Returns:
the value to be passed to the taget method.

getArgumentClass

protected Class getArgumentClass(String argumentType)
Description copied from class: UICSimpleAction
For the uniquely defined argumentType (as also used in UICSimpleAction.getTargetSignatures()) return the Class. This method will always return 'null'; Extending actions can define various argumentType strings that can be used as an argument in the call to the target method of this action. The user decides on construction of the action which argumentTypes are to be used, if a certain value is requested to be sent to the targetMethod a call is made to this method to find the Class of the type.

Note that basetypes have a class of their own and you should return the correct one you expect the targetMethod to implement. returning Integer.class will search for an Integer; returing int.class will search for an int. This is important to note since the UICSimpleAction.getArgumentValue(java.util.EventObject, java.lang.String) method should return an Integer object in both cases.

Overrides:
getArgumentClass in class UICSimpleAction
Parameters:
argumentType - the uniquely defined name specifying the type of argument.
Returns:
the class of this argument to be found on the target method

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener


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