Author: rwhitcomb
Date: Sun Jan 16 03:03:30 2022
New Revision: 1897111
URL: http://svn.apache.org/viewvc?rev=1897111&view=rev
Log:
Further changes to Action to refine the Enum support and regularize the
parameter names.
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/Action.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Action.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Action.java?rev=1897111&r1=1897110&r2=1897111&view=diff
==
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Action.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Action.java Sun Jan 16 03:03:30
2022
@@ -43,41 +43,41 @@ public abstract class Action {
}
@Override
-public Action get(final String id) {
-return namedActions.get(id);
+public Action get(final String actionName) {
+return namedActions.get(actionName);
}
@Override
-public Action put(final String id, final Action action) {
+public Action put(final String actionName, final Action action) {
Utils.checkNull(action, "action");
-boolean update = containsKey(id);
-Action previousAction = namedActions.put(id, action);
+boolean update = containsKey(actionName);
+Action previousAction = namedActions.put(actionName, action);
if (update) {
-actionClassListeners.actionUpdated(id, previousAction);
+actionClassListeners.actionUpdated(actionName, previousAction);
} else {
-actionClassListeners.actionAdded(id);
+actionClassListeners.actionAdded(actionName);
}
return previousAction;
}
@Override
-public Action remove(final String id) {
+public Action remove(final String actionName) {
Action removedAction = null;
-if (containsKey(id)) {
-removedAction = namedActions.remove(id);
-actionClassListeners.actionRemoved(id, removedAction);
+if (containsKey(actionName)) {
+removedAction = namedActions.remove(actionName);
+actionClassListeners.actionRemoved(actionName, removedAction);
}
return removedAction;
}
@Override
-public boolean containsKey(final String id) {
-return namedActions.containsKey(id);
+public boolean containsKey(final String actionName) {
+return namedActions.containsKey(actionName);
}
@Override
@@ -136,7 +136,7 @@ public abstract class Action {
*/
private static HashMap namedActions = new HashMap<>();
/**
- * The global dictionary associating action ids with their implementations.
+ * The global dictionary associating action names with their
implementations.
*/
private static NamedActionDictionary namedActionDictionary = new
NamedActionDictionary();
@@ -205,12 +205,13 @@ public abstract class Action {
* This is the equivalent of
*
Action.getNamedActions().get(actionName).perform(comp).
*
+ * @param Enum type that gives the action name.
* @param actionName An enum value whose toString() value is
used as the action name.
* @param comp The component initiating the action.
* @throws IllegalArgumentException if the actionName is {@code null} or
if there is
* no action with that name.
*/
-public static void performAction(final Enum actionName,
final Component comp) {
+public static > void performAction(final E actionName,
final Component comp) {
Utils.checkNull(actionName, "action name");
performAction(actionName.toString(), comp);
}
@@ -247,52 +248,54 @@ public abstract class Action {
/**
* Add this action to the named action dictionary.
- * This is equivalent to getNamedActions().put(id,
action)
+ * This is equivalent to
getNamedActions().put(actionName, action)
*
- * @param id The name to store this action under (can be referenced
from button actions, etc.)
- * @param action The action to be performed under this name.
- * @return The previous action (if any) listed under this name.
+ * @param actionName The name to store this action under (can be
referenced from button actions, etc.)
+ * @param action The action to be performed under this name.
+ * @return The previous action (if any) listed under this name.
*/
-public static Action addNamedAction(final String id, final Action action) {
-return namedActionDictionary.put(id, action);
+public static Action addNamedAction(final String actionName, final Action
action) {
+return namedActionDictionary.put(actionName, action);
}
/**