com.threerings.miso.client
Class ObjectActionHandler

java.lang.Object
  extended by com.threerings.miso.client.ObjectActionHandler

public class ObjectActionHandler
extends Object

Objects in scenes can be configured to generate action events. Those events are grouped into types and an object action handler can be registered to handle all actions of a particular type.


Field Summary
protected static HashMap<String,ObjectActionHandler> _oahandlers
          Our registered object action handlers.
 
Constructor Summary
ObjectActionHandler()
           
 
Method Summary
 boolean actionAllowed(String action)
          Returns true if we should allow this object action, false if we should not.
 SceneObjectIndicator createIndicator(MisoScenePanel panel, String text, Icon icon)
          Creates an indicator for this type of object action.
static String getAction(String command)
          Returns the unqualified object action (minus the type, see getType(java.lang.String)).
 Icon getTipIcon(String action)
          Returns the tooltip icon for the specified action or null if the action has no tooltip icon.
 String getTipText(String action)
          Get the human readable object tip for the specified action.
static String getType(String command)
          Returns the type associated with this action command (which is mapped to a registered object action handler) or the empty string if it has no type.
 void handleAction(SceneObject scobj, ActionEvent event)
          Called when an action is generated for an object.
 RadialMenu handlePressed(SceneObject sourceObject)
          Return a RadialMenu or null if no menu needed.
 boolean isVisible(String action)
          Returns true if we should display the text for the action.
static ObjectActionHandler lookup(String command)
          Looks up the object action handler associated with the specified command.
static void register(String prefix, ObjectActionHandler handler)
          Registers an object action handler which will be called when a user clicks on an object in a scene that has an associated action.
static void unregister(String prefix)
          Removes an object action handler registration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_oahandlers

protected static HashMap<String,ObjectActionHandler> _oahandlers
Our registered object action handlers.

Constructor Detail

ObjectActionHandler

public ObjectActionHandler()
Method Detail

actionAllowed

public boolean actionAllowed(String action)
Returns true if we should allow this object action, false if we should not.


isVisible

public boolean isVisible(String action)
Returns true if we should display the text for the action. By default this returns whether the action is allowed or not, but can be overridden by subclasses. This is used to completely hide actions that should not be visible without the proper privileges.


getTipText

public String getTipText(String action)
Get the human readable object tip for the specified action.


getTipIcon

public Icon getTipIcon(String action)
Returns the tooltip icon for the specified action or null if the action has no tooltip icon.


handlePressed

public RadialMenu handlePressed(SceneObject sourceObject)
Return a RadialMenu or null if no menu needed.


handleAction

public void handleAction(SceneObject scobj,
                         ActionEvent event)
Called when an action is generated for an object.


getType

public static String getType(String command)
Returns the type associated with this action command (which is mapped to a registered object action handler) or the empty string if it has no type.


getAction

public static String getAction(String command)
Returns the unqualified object action (minus the type, see getType(java.lang.String)).


createIndicator

public SceneObjectIndicator createIndicator(MisoScenePanel panel,
                                            String text,
                                            Icon icon)
Creates an indicator for this type of object action.


lookup

public static ObjectActionHandler lookup(String command)
Looks up the object action handler associated with the specified command.


register

public static void register(String prefix,
                            ObjectActionHandler handler)
Registers an object action handler which will be called when a user clicks on an object in a scene that has an associated action.


unregister

public static void unregister(String prefix)
Removes an object action handler registration.