uic.action
Class JTreeDoubleClickAction

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

public class JTreeDoubleClickAction
extends SwingAction
implements MouseListener

When your users double click an item in a tree, a method of your choosing will be invoked. This only responds to double clicks which are on (within the bounds of) some tree node. Notice that the default version uses the OnlyLastPolicy. Using this class is easy; just call:

new JTreeDoubleClickAction(this, "selectedSlot").add(myTree); 
This has the result that when the user double clicks on the tree the method 'selectedSlot' on object 'this' will be called.
Default target signatures
(ARGUMENT_TREENODE)
(ARGUMENT_SOURCE)
(ARGUMENT_TREENODE)
(ARGUMENT_TREENODE, ARGUMENT_LOCATION)
All Targets
ARGUMENT_SOURCE
ARGUMENT_TREENODE
ARGUMENT_LOCATION


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_LOCATION
          a Point: the point where the click happened
static String ARGUMENT_SOURCE
          a JTree: the source object that threw the event
static String ARGUMENT_TREENODE
          a TreeNode: the tree node which was double clicked
 
Fields inherited from class uic.action.SwingAction
updateUICommmand
 
Fields inherited from class uic.model.UICSimpleAction
currentPolicy, target, targetObject
 
Constructor Summary
JTreeDoubleClickAction(Object targetObject, String targetMethod)
          Create a new JTreeDoubleClickAction.
JTreeDoubleClickAction(Object targetObject, String targetMethod, UICSimpleAction.Arguments arguments)
          Create a new JTreeDoubleClickAction.
 
Method Summary
 JTreeDoubleClickAction add(JTree tree)
          Add an JTree object to this action
protected  Class getArgumentClass(String argumentType)
          For the uniquely defined argumentType (as also used in UICSimpleAction.getTargetSignatures()) return the Class.
protected  Object getArgumentValue(EventObject event, String argumentType)
          For the uniquely defined argumentType (as also used in UICSimpleAction.getTargetSignatures()) return the value.
protected  List getTargetSignatures()
          Define standard target signatures
 void mouseClicked(MouseEvent e)
           
 void mouseEntered(MouseEvent event)
           
 void mouseExited(MouseEvent event)
           
 void mousePressed(MouseEvent event)
           
 void mouseReleased(MouseEvent event)
           
 JTreeDoubleClickAction setOnlyOnLeaves(boolean leafOnly)
          Change the action to respond to leaf nodes and 'folder' nodes or only to leaf nodes.
 
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_SOURCE

public static final String ARGUMENT_SOURCE
a JTree: the source object that threw the event

See Also:
Constant Field Values

ARGUMENT_TREENODE

public static final String ARGUMENT_TREENODE
a TreeNode: the tree node which was double clicked

See Also:
Constant Field Values

ARGUMENT_LOCATION

public static final String ARGUMENT_LOCATION
a Point: the point where the click happened

See Also:
Constant Field Values
Constructor Detail

JTreeDoubleClickAction

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

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

JTreeDoubleClickAction

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

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

getTargetSignatures

protected List getTargetSignatures()
Define standard target signatures

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)

add

public JTreeDoubleClickAction add(JTree tree)
Add an JTree object to this action

Parameters:
tree - the JTree that triggers this action
Returns:
this action (useful for command chaining)

setOnlyOnLeaves

public JTreeDoubleClickAction setOnlyOnLeaves(boolean leafOnly)
Change the action to respond to leaf nodes and 'folder' nodes or only to leaf nodes. The action normally responds to double-clicks on any node, calling this method with true will alter that behavior to leafs only.

Parameters:
leafOnly - if true only pay attention to double clicks on leaf nodes.

getArgumentValue

protected Object getArgumentValue(EventObject event,
                                  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:
event - 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

mouseEntered

public void mouseEntered(MouseEvent event)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent event)
Specified by:
mouseExited in interface MouseListener

mousePressed

public void mousePressed(MouseEvent event)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent event)
Specified by:
mouseReleased in interface MouseListener

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener


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