svn commit: r1897111 - /pivot/trunk/wtk/src/org/apache/pivot/wtk/Action.java

2022-01-15 Thread rwhitcomb
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);
 }
 
 /**

svn commit: r1897109 - /pivot/trunk/wtk/src/org/apache/pivot/wtk/Action.java

2022-01-15 Thread rwhitcomb
Author: rwhitcomb
Date: Sun Jan 16 01:36:47 2022
New Revision: 1897109

URL: http://svn.apache.org/viewvc?rev=1897109&view=rev
Log:
Enhance "Action" to add overrides to facilitate actions that are Enum values.

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=1897109&r1=1897108&r2=1897109&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 01:36:47 
2022
@@ -201,6 +201,21 @@ public abstract class Action {
 }
 
 /**
+ * Perform the named action, unless the action is disabled.
+ *  This is the equivalent of
+ * 
Action.getNamedActions().get(actionName).perform(comp).
+ *
+ * @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) {
+Utils.checkNull(actionName, "action name");
+performAction(actionName.toString(), comp);
+}
+
+/**
  * Check if this action is currently enabled.
  *
  * @return Whether or not this action is currently enabled.
@@ -243,6 +258,20 @@ public abstract class Action {
 }
 
 /**
+ * Add this action to the named action dictionary.
+ *  This is equivalent to getNamedActions().put(id, 
action)
+ *
+ * @param actionName An enum whose toString() value is used 
as the ID for the action.
+ * @param action The action to be performed under this name.
+ * @return   The previous action (if any) listed under this name.
+ * @throws IllegalArgumentException if the actionName is {@code null}.
+ */
+public static Action addNamedAction(final Enum actionName, 
final Action action) {
+Utils.checkNull(actionName, "action name");
+return addNamedAction(actionName.toString(), action);
+}
+
+/**
  * Get the named action from the dictionary.
  *  This is the equivalent of 
getNamedActions().get(id)
  *
@@ -255,6 +284,20 @@ public abstract class Action {
 }
 
 /**
+ * Get the named action from the dictionary.
+ *  This is the equivalent of 
getNamedActions().get(id)
+ *
+ * @param actionName An enum whose toString() method is used 
as the ID for the action.
+ * @return   The action currently associated with this id (or 
{@code null} if
+ *   there is no saved action with that id value).
+ * @throws IllegalArgumentException if the actionName is {@code null}.
+ */
+public static Action getNamedAction(final Enum actionName) 
{
+Utils.checkNull(actionName, "action name");
+return getNamedAction(actionName.toString());
+}
+
+/**
  * @return The global named action dictionary.
  */
 public static NamedActionDictionary getNamedActions() {