|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uic.model.UICSimpleAction uic.action.SwingAction uic.action.DocumentChangedAction
public class DocumentChangedAction
An event to respond to document change signals.
All swing components that use a document (JTextField being the most well known) can trigger this action,
it is generally preferred to react to document changes then it is to actions like key-events. Using
this action object will mean you will be notified of changes including paste actions and undo actions.
Notice that the default version uses the OnlyLastPolicy
.
Using this class is easy; just call:
new DocumentChangedAction(this, "changedSlot").add(childComponent);This has the result that when the childComponent has any change in its content 'changedSlot' on object 'this' will be called.
ARGUMENT_CHANGE_OFFSET
,
ARGUMENT_CHANGE_LENGTH
,
ARGUMENT_DOCUMENT
,
ARGUMENT_TEXT
,
ARGUMENT_CHANGED_TEXT
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 | |
---|---|
static String |
ARGUMENT_CHANGE_LENGTH
an int: the length of the change |
static String |
ARGUMENT_CHANGE_OFFSET
an int: the offset in the document of the start of the change |
static String |
ARGUMENT_CHANGED_TEXT
a String: the textual representation of the change in the document |
static String |
ARGUMENT_DOCUMENT
a Document: the document that changed |
static String |
ARGUMENT_TEXT
a String: the complete-textual representation of the document |
Fields inherited from class uic.action.SwingAction |
---|
updateUICommmand |
Fields inherited from class uic.model.UICSimpleAction |
---|
currentPolicy, target, targetObject |
Constructor Summary | |
---|---|
DocumentChangedAction(Object targetObject,
String targetMethod)
Create a new DocumentChangedAction. |
|
DocumentChangedAction(Object targetObject,
String targetMethod,
UICSimpleAction.Arguments arguments)
Create a new DocumentChangedAction. |
Method Summary | |
---|---|
DocumentChangedAction |
add(Document source)
Add an Document object to this action. |
DocumentChangedAction |
add(JComboBox source)
|
DocumentChangedAction |
add(JTextComponent source)
Add an TextComponent to this action |
void |
changedUpdate(DocumentEvent e)
|
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 |
insertUpdate(DocumentEvent e)
|
void |
removeUpdate(DocumentEvent e)
|
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 |
---|
public static final String ARGUMENT_CHANGE_OFFSET
public static final String ARGUMENT_CHANGE_LENGTH
public static final String ARGUMENT_DOCUMENT
public static final String ARGUMENT_TEXT
public static final String ARGUMENT_CHANGED_TEXT
Constructor Detail |
---|
public DocumentChangedAction(Object targetObject, String targetMethod)
targetObject
- on which object should the target method be invokedtargetMethod
- wich method on the targetObject should be invokedpublic DocumentChangedAction(Object targetObject, String targetMethod, UICSimpleAction.Arguments arguments)
targetObject
- on which object should the target method be invokedtargetMethod
- wich method on the targetObject should be invokedarguments
- to be used in finding the targetMethod signatureUICSimpleAction.setTarget(Object,String,uic.model.UICSimpleAction.Arguments)
Method Detail |
---|
public DocumentChangedAction add(Document source)
source
- the document that will be monitoredpublic DocumentChangedAction add(JTextComponent source)
source
- the component the holds the document we want to monitorpublic DocumentChangedAction add(JComboBox source)
protected List getTargetSignatures()
UICSimpleAction
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.
getTargetSignatures
in class UICSimpleAction
UICSimpleAction.getArgumentValue(java.util.EventObject, java.lang.String)
,
UICSimpleAction.getArgumentClass(java.lang.String)
protected Object getArgumentValue(EventObject source, String argumentType)
UICSimpleAction
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).
getArgumentValue
in class UICSimpleAction
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.
protected Class getArgumentClass(String argumentType)
UICSimpleAction
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.
getArgumentClass
in class UICSimpleAction
argumentType
- the uniquely defined name specifying the type of argument.
public void changedUpdate(DocumentEvent e)
changedUpdate
in interface DocumentListener
public void insertUpdate(DocumentEvent e)
insertUpdate
in interface DocumentListener
public void removeUpdate(DocumentEvent e)
removeUpdate
in interface DocumentListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |