com.pietschy.command
Class ParameterUtils

java.lang.Object
  extended by com.pietschy.command.ParameterUtils

public class ParameterUtils
extends java.lang.Object

Utility class for parameter operations that are shared across ActionCommands and ActionCommandDelegates.


Constructor Summary
ParameterUtils()
           
 
Method Summary
static java.awt.event.ActionEvent getActionEvent(java.util.Map<java.lang.Object,java.lang.Object> parameters)
          Convenience method for getHint(ActionCommand.PARAMETER_ACTION_EVENT).
static java.lang.Object getInvoker(java.util.Map<java.lang.Object,java.lang.Object> parameters)
          Convenience method to get the object that invoked the command.
static java.awt.Window getInvokerWindow(java.util.Map<java.lang.Object,java.lang.Object> parameters)
          Convenience method to get the Window ancestor of the object that invoked the command.
static int getModifiers(java.util.Map<java.lang.Object,java.lang.Object> parameters)
          Convenience method to get any modifiers that were specified.
static java.lang.Object getParameter(java.util.Map<java.lang.Object,java.lang.Object> parameters, java.lang.Object key, java.lang.Object defaultValue)
          Gets a parameter from a map.
static void prepareInvokerWindow(java.util.Map<java.lang.Object,java.lang.Object> parameters)
          Prepares the invoker window parameter from the invoker parameter contained within the parameter map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterUtils

public ParameterUtils()
Method Detail

getModifiers

public static int getModifiers(java.util.Map<java.lang.Object,java.lang.Object> parameters)
Convenience method to get any modifiers that were specified. Modifiers are always copied from any action event that triggers this command.


getInvoker

public static java.lang.Object getInvoker(java.util.Map<java.lang.Object,java.lang.Object> parameters)
Convenience method to get the object that invoked the command. If the command was invoked from from a button (or menu) then the invoker will be that button.

Returns:
the AbstractButton that invoked to command. If the command was manually invoked this will return null unless the hint ActionCommand.PARAMETER_INVOKER has been explicitly set.

getInvokerWindow

public static java.awt.Window getInvokerWindow(java.util.Map<java.lang.Object,java.lang.Object> parameters)
Convenience method to get the Window ancestor of the object that invoked the command. If the invoker is null, or doesn't decend from Component then null is returned. Otherwise, an attempt to find the Window ancestor is made using SwingUtilities.getWindowAncestor(java.awt.Component) or by traversing the ancestors and invokers of popup menus.

Returns:
null if the invoker is null, doesn't extend Component or doesn't have a Window ancestor. Otherwise the invokers Window ancestor is returned.
See Also:
getInvoker(java.util.Map)

getActionEvent

public static java.awt.event.ActionEvent getActionEvent(java.util.Map<java.lang.Object,java.lang.Object> parameters)
Convenience method for getHint(ActionCommand.PARAMETER_ACTION_EVENT).


getParameter

public static java.lang.Object getParameter(java.util.Map<java.lang.Object,java.lang.Object> parameters,
                                            java.lang.Object key,
                                            java.lang.Object defaultValue)
Gets a parameter from a map. Returns the default value if the pararmeter is null.

Parameters:
parameters - the parameter map.
key - the key
defaultValue - the default value to use if the parameter isn't defined.
Returns:
the parameter value, or the default value if the parameter is undefined.

prepareInvokerWindow

public static void prepareInvokerWindow(java.util.Map<java.lang.Object,java.lang.Object> parameters)
Prepares the invoker window parameter from the invoker parameter contained within the parameter map.

Parameters:
parameters - the parameter map.


Copyright © 2006 - 2007 Andrew Pietsch