Fluff the pillows.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@817 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Dave Hoover
2009-05-11 17:35:12 +00:00
parent 338d4eb567
commit 7656af30c7
@@ -27,6 +27,8 @@ import java.awt.event.ActionEvent;
import javax.swing.Icon; import javax.swing.Icon;
import com.google.common.collect.Maps;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.samskivert.swing.RadialMenu; import com.samskivert.swing.RadialMenu;
@@ -34,15 +36,14 @@ import com.samskivert.swing.RadialMenu;
import static com.threerings.miso.Log.log; import static com.threerings.miso.Log.log;
/** /**
* Objects in scenes can be configured to generate action events. Those * Objects in scenes can be configured to generate action events. Those events are grouped into
* events are grouped into types and an object action handler can be * types and an object action handler can be registered to handle all actions of a particular
* registered to handle all actions of a particular type. * type.
*/ */
public class ObjectActionHandler public class ObjectActionHandler
{ {
/** /**
* Returns true if we should allow this object action, false if we * Returns true if we should allow this object action, false if we should not.
* should not.
*/ */
public boolean actionAllowed (String action) public boolean actionAllowed (String action)
{ {
@@ -50,10 +51,9 @@ public class ObjectActionHandler
} }
/** /**
* Returns true if we should display the text for the action. By default * Returns true if we should display the text for the action. By default this returns whether
* this returns whether the action is allowed or not, but can be * the action is allowed or not, but can be overridden by subclasses. This is used to
* overridden by subclasses. This is used to completely hide actions that * completely hide actions that should not be visible without the proper privileges.
* should not be visible without the proper privileges.
*/ */
public boolean isVisible (String action) public boolean isVisible (String action)
{ {
@@ -69,8 +69,8 @@ public class ObjectActionHandler
} }
/** /**
* Returns the tooltip icon for the specified action or null if the * Returns the tooltip icon for the specified action or null if the action has no tooltip
* action has no tooltip icon. * icon.
*/ */
public Icon getTipIcon (String action) public Icon getTipIcon (String action)
{ {
@@ -90,14 +90,12 @@ public class ObjectActionHandler
*/ */
public void handleAction (SceneObject scobj, ActionEvent event) public void handleAction (SceneObject scobj, ActionEvent event)
{ {
log.warning("Unknown object action [scobj=" + scobj + log.warning("Unknown object action", "scobj", scobj, "action", event);
", action=" + event + "].");
} }
/** /**
* Returns the type associated with this action command (which is * Returns the type associated with this action command (which is mapped to a registered
* mapped to a registered object action handler) or the empty string * object action handler) or the empty string if it has no type.
* if it has no type.
*/ */
public static String getType (String command) public static String getType (String command)
{ {
@@ -106,8 +104,7 @@ public class ObjectActionHandler
} }
/** /**
* Returns the unqualified object action (minus the type, see {@link * Returns the unqualified object action (minus the type, see {@link #getType}).
* #getType}).
*/ */
public static String getAction (String command) public static String getAction (String command)
{ {
@@ -124,8 +121,7 @@ public class ObjectActionHandler
} }
/** /**
* Looks up the object action handler associated with the specified * Looks up the object action handler associated with the specified command.
* command.
*/ */
public static ObjectActionHandler lookup (String command) public static ObjectActionHandler lookup (String command)
{ {
@@ -133,17 +129,15 @@ public class ObjectActionHandler
} }
/** /**
* Registers an object action handler which will be called when a user * Registers an object action handler which will be called when a user clicks on an object in
* clicks on an object in a scene that has an associated action. * a scene that has an associated action.
*/ */
public static void register (String prefix, ObjectActionHandler handler) public static void register (String prefix, ObjectActionHandler handler)
{ {
// make sure we know about potential funny business // make sure we know about potential funny business
if (_oahandlers.containsKey(prefix)) { if (_oahandlers.containsKey(prefix)) {
log.warning("Warning! Overwriting previous object action " + log.warning("Warning! Overwriting previous object action handler registration, all " +
"handler registration, all hell could shortly " + "hell could shortly break loose", "prefix", prefix, "handler", handler);
"break loose [prefix=" + prefix +
", handler=" + handler + "].");
} }
_oahandlers.put(prefix, handler); _oahandlers.put(prefix, handler);
} }
@@ -157,6 +151,5 @@ public class ObjectActionHandler
} }
/** Our registered object action handlers. */ /** Our registered object action handlers. */
protected static HashMap<String, ObjectActionHandler> _oahandlers = protected static HashMap<String, ObjectActionHandler> _oahandlers = Maps.newHashMap();
new HashMap<String, ObjectActionHandler>();
} }