|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uic.model.UICSimpleAction uic.model.UICAction
public class UICAction
This action class contains all the information to provide high quality widgets and an action. The idea behind an action is that one object wraps a certain functionality and provdes various ways to access that functionality. A good example is a print action.
Creating an action and using it with the ActionFactory creates widgets like buttons
or menu entries. When your users click the button or select the menu item the action
will be informed and a method of your choosing will be invoked.
Notice that the default version uses the QueuedPolicy
.
ActionFactory
,
UICToggleAction
Nested Class Summary | |
---|---|
class |
UICAction.StatusBarUpdater
Helper class. |
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_SOURCE
an Object: the source object that threw the event. |
protected UICSimpleAction |
updateUICommmand
|
Fields inherited from class uic.model.UICSimpleAction |
---|
currentPolicy, target, targetObject |
Constructor Summary | |
---|---|
UICAction(String name)
Base constructor. |
|
UICAction(String name,
Object targetObject,
String targetMethod,
String title)
|
|
UICAction(String name,
Object targetObject,
String targetMethod,
String title,
ActionFactory actions)
|
|
UICAction(String name,
Object targetObject,
String targetMethod,
String title,
String iconBaseName)
|
|
UICAction(String name,
Object targetObject,
String targetMethod,
String title,
String iconBaseName,
ActionFactory actions)
|
|
UICAction(String name,
Object targetObject,
String targetMethod,
String title,
String iconBaseName,
String keyStroke)
|
|
UICAction(String name,
Object targetObject,
String targetMethod,
String title,
String iconBaseName,
String keyStroke,
ActionFactory actions)
|
|
UICAction(String name,
Object targetObject,
String targetMethod,
String title,
String iconBaseName,
String keyStroke,
String toolTipText,
String whatIsThis)
|
|
UICAction(String name,
Object targetObject,
String targetMethod,
String title,
String iconBaseName,
String keyStroke,
String toolTipText,
String whatIsThis,
ActionFactory actions)
Create new action. |
Method Summary | |
---|---|
void |
actionPerformed(ActionEvent e)
|
void |
addComponent(AbstractButton c)
A button component that represents this action the the users user interface can be registered here. |
protected void |
addIcon(AbstractButton button,
IconFactory iconFactory)
|
protected void |
addKeyStroke(JMenuItem button)
|
JMenuItem |
createMenuItem(IconFactory iconFactory)
|
JMenuItem |
createPopupMenuItem(IconFactory iconFactory)
|
AbstractButton |
createToolBarButton(IconFactory iconFactory)
|
protected void |
decorateButton(AbstractButton button,
IconFactory iconFactory)
|
protected void |
doAction(Object[] args)
Called to actually execute the action on the registered method. |
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. |
Iterator |
getComponentsIterator()
|
String |
getIconBaseName()
The name of the icon that will be used on buttons. |
KeyStroke |
getKeyStroke()
|
String |
getName()
Return the name key. |
protected List |
getTargetSignatures()
Return a List object with instances of the Arguments class. |
String |
getTitle()
return the title of this action, this is mostly the name on screen. |
String |
getToolTipText()
|
String |
getWhatIsThis()
The text used in the popup for whatIs help. |
void |
setEnabled(boolean enabled)
Enable disable this action and all its registered components. |
void |
setIconBaseName(String iconBaseName)
The name of the icon that will be used on buttons. |
void |
setKeyStroke(KeyStroke keyStroke)
|
void |
setName(String name)
Set the unique key that is the name of this action. |
void |
setStatusBar(StatusBar statusBar)
Register a statusbar that will be used to show whatIs texts on on mouseOver of the menuitems. |
protected void |
setTexts(AbstractButton button)
|
void |
setTitle(String title)
Set the title of this action, this is mostly the name on screen. |
void |
setToolTipText(String toolTipText)
|
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. |
void |
setWhatIsThis(String whatIsThis)
The text used in the popup for whatIs help. |
String |
toString()
returns the title. |
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, wait, wait, wait |
Field Detail |
---|
protected UICSimpleAction updateUICommmand
public static final String ARGUMENT_SOURCE
Constructor Detail |
---|
public UICAction(String name)
public UICAction(String name, Object targetObject, String targetMethod, String title, ActionFactory actions)
public UICAction(String name, Object targetObject, String targetMethod, String title, String iconBaseName, ActionFactory actions)
public UICAction(String name, Object targetObject, String targetMethod, String title, String iconBaseName, String keyStroke, ActionFactory actions)
public UICAction(String name, Object targetObject, String targetMethod, String title)
public UICAction(String name, Object targetObject, String targetMethod, String title, String iconBaseName)
public UICAction(String name, Object targetObject, String targetMethod, String title, String iconBaseName, String keyStroke)
public UICAction(String name, Object targetObject, String targetMethod, String title, String iconBaseName, String keyStroke, String toolTipText, String whatIsThis)
public UICAction(String name, Object targetObject, String targetMethod, String title, String iconBaseName, String keyStroke, String toolTipText, String whatIsThis, ActionFactory actions)
name
- The identifying name of the action, must be unique.targetObject
- The object that contains the method we want to connect to.targetMethod
- the name of the method we want to connect to.title
- the name used on buttons or in a menu entry.iconBaseName
- the basename the new widgets can use to fetch the correct icon, or null if nonekeyStroke
- the keyStroke in the format accepted by javax.swing.KeyStroke.getKeyStroke(String)toolTipText
- the text for tooltips, or null for nonewhatIsThis
- the text for the statusBar.actions
- the actionFactory this action belongs to.KeyStroke.getKeyStroke(String)
Method Detail |
---|
public void addComponent(AbstractButton c)
public String getName()
public void setName(String name)
public void setEnabled(boolean enabled)
setEnabled
in class UICSimpleAction
enabled
- the new state of the action.public String getTitle()
public void setTitle(String title)
Setting the title on an action will not change created buttons/menu items.
public String getIconBaseName()
public void setIconBaseName(String iconBaseName)
public String getToolTipText()
public void setToolTipText(String toolTipText)
public String getWhatIsThis()
MainWindow
public void setWhatIsThis(String whatIsThis)
MainWindow
public Iterator getComponentsIterator()
public KeyStroke getKeyStroke()
public void setKeyStroke(KeyStroke keyStroke)
public void setStatusBar(StatusBar statusBar)
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
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.
protected void doAction(Object[] args)
UICSimpleAction
doAction
in class UICSimpleAction
public void setUIUpdateCommand(Object object, String targetMethod) throws IllegalArgumentException
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
IllegalArgumentException
public void setUIUpdateCommand(Object object, String targetMethod, UICSimpleAction.Arguments arguments) throws IllegalArgumentException
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
IllegalArgumentException
public String toString()
toString
in class Object
public AbstractButton createToolBarButton(IconFactory iconFactory)
protected void decorateButton(AbstractButton button, IconFactory iconFactory)
protected void setTexts(AbstractButton button)
protected void addKeyStroke(JMenuItem button)
protected void addIcon(AbstractButton button, IconFactory iconFactory)
public JMenuItem createMenuItem(IconFactory iconFactory)
public JMenuItem createPopupMenuItem(IconFactory iconFactory)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |