]> source.dussan.org Git - vaadin-framework.git/commitdiff
Moved ShortcutActionHandler constants to shared (#8484)
authorArtur Signell <artur@vaadin.com>
Mon, 1 Oct 2012 15:53:43 +0000 (18:53 +0300)
committerArtur Signell <artur@vaadin.com>
Mon, 1 Oct 2012 15:53:43 +0000 (18:53 +0300)
Change-Id: Ia75fa0ca8b7f563ccc412381e88abae7c630569e

client/src/com/vaadin/client/ui/ShortcutActionHandler.java
server/src/com/vaadin/event/ActionManager.java

index 929de7a15ddd66a46cf4f32538f1336f4c60916f..cd14f145855eb715b63e96a44c9fec013f3fa4af 100644 (file)
@@ -35,6 +35,7 @@ import com.vaadin.client.UIDL;
 import com.vaadin.client.Util;
 import com.vaadin.client.ui.richtextarea.VRichTextArea;
 import com.vaadin.shared.Connector;
+import com.vaadin.shared.ui.ShortCutConstants;
 
 /**
  * A helper class to implement keyboard shorcut handling. Keeps a list of owners
@@ -45,15 +46,6 @@ import com.vaadin.shared.Connector;
  */
 public class ShortcutActionHandler {
 
-    public static final String ACTION_TARGET_ATTRIBUTE = "sat";
-    public static final String ACTION_TARGET_ACTION_ATTRIBUTE = "sata";
-    public static final String ACTION_CAPTION_ATTRIBUTE = "caption";
-    public static final String ACTION_KEY_ATTRIBUTE = "key";
-    public static final String ACTION_SHORTCUT_KEY_ATTRIBUTE = "kc";
-    public static final String ACTION_MODIFIER_KEYS_ATTRIBUTE = "mk";
-    public static final String ACTION_TARGET_VARIABLE = "actiontarget";
-    public static final String ACTION_TARGET_ACTION_VARIABLE = "action";
-
     /**
      * An interface implemented by those users of this helper class that want to
      * support special components like {@link VRichTextArea} that don't properly
@@ -119,21 +111,23 @@ public class ShortcutActionHandler {
             final UIDL action = (UIDL) it.next();
 
             int[] modifiers = null;
-            if (action.hasAttribute(ACTION_MODIFIER_KEYS_ATTRIBUTE)) {
+            if (action
+                    .hasAttribute(ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE)) {
                 modifiers = action
-                        .getIntArrayAttribute(ACTION_MODIFIER_KEYS_ATTRIBUTE);
+                        .getIntArrayAttribute(ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE);
             }
 
             final ShortcutKeyCombination kc = new ShortcutKeyCombination(
-                    action.getIntAttribute(ACTION_SHORTCUT_KEY_ATTRIBUTE),
+                    action.getIntAttribute(ShortCutConstants.ACTION_SHORTCUT_KEY_ATTRIBUTE),
                     modifiers);
-            final String key = action.getStringAttribute(ACTION_KEY_ATTRIBUTE);
+            final String key = action
+                    .getStringAttribute(ShortCutConstants.ACTION_KEY_ATTRIBUTE);
             final String caption = action
-                    .getStringAttribute(ACTION_CAPTION_ATTRIBUTE);
+                    .getStringAttribute(ShortCutConstants.ACTION_CAPTION_ATTRIBUTE);
             final String targetPID = action
-                    .getStringAttribute(ACTION_TARGET_ATTRIBUTE);
+                    .getStringAttribute(ShortCutConstants.ACTION_TARGET_ATTRIBUTE);
             final String targetAction = action
-                    .getStringAttribute(ACTION_TARGET_ACTION_ATTRIBUTE);
+                    .getStringAttribute(ShortCutConstants.ACTION_TARGET_ACTION_ATTRIBUTE);
             actions.add(new ShortcutAction(key, kc, caption, targetPID,
                     targetAction));
         }
@@ -201,10 +195,12 @@ public class ShortcutActionHandler {
                 if (!handledClientSide) {
                     if (finalTarget != null) {
                         client.updateVariable(paintableId,
-                                ACTION_TARGET_VARIABLE, finalTarget, false);
+                                ShortCutConstants.ACTION_TARGET_VARIABLE,
+                                finalTarget, false);
                     }
                     client.updateVariable(paintableId,
-                            ACTION_TARGET_ACTION_VARIABLE, a.getKey(), true);
+                            ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE,
+                            a.getKey(), true);
                 }
             }
         });
index ad643863a700a29ef31d47f7c7e1d506cc466b53..50bb2f8dad515341f2c4abc44a9792974ef496d1 100644 (file)
@@ -18,13 +18,13 @@ package com.vaadin.event;
 import java.util.HashSet;
 import java.util.Map;
 
-import com.vaadin.client.ui.ShortcutActionHandler;
 import com.vaadin.event.Action.Container;
 import com.vaadin.event.Action.Handler;
 import com.vaadin.server.KeyMapper;
 import com.vaadin.server.PaintException;
 import com.vaadin.server.PaintTarget;
 import com.vaadin.server.VariableOwner;
+import com.vaadin.shared.ui.ShortCutConstants;
 import com.vaadin.ui.Component;
 
 /**
@@ -188,10 +188,9 @@ public class ActionManager implements Action.Container, Action.Handler,
                 }
                 if (a instanceof ShortcutAction) {
                     final ShortcutAction sa = (ShortcutAction) a;
-                    paintTarget
-                            .addAttribute(
-                                    ShortcutActionHandler.ACTION_SHORTCUT_KEY_ATTRIBUTE,
-                                    sa.getKeyCode());
+                    paintTarget.addAttribute(
+                            ShortCutConstants.ACTION_SHORTCUT_KEY_ATTRIBUTE,
+                            sa.getKeyCode());
                     final int[] modifiers = sa.getModifiers();
                     if (modifiers != null) {
                         final String[] smodifiers = new String[modifiers.length];
@@ -200,16 +199,16 @@ public class ActionManager implements Action.Container, Action.Handler,
                         }
                         paintTarget
                                 .addAttribute(
-                                        ShortcutActionHandler.ACTION_MODIFIER_KEYS_ATTRIBUTE,
+                                        ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE,
                                         smodifiers);
                     }
                     if (sa.getTarget() != null) {
                         paintTarget.addAttribute(
-                                ShortcutActionHandler.ACTION_TARGET_ATTRIBUTE,
+                                ShortCutConstants.ACTION_TARGET_ATTRIBUTE,
                                 sa.getTarget());
                         paintTarget
                                 .addAttribute(
-                                        ShortcutActionHandler.ACTION_TARGET_ACTION_ATTRIBUTE,
+                                        ShortCutConstants.ACTION_TARGET_ACTION_ATTRIBUTE,
                                         sa.getTargetAction());
                     }
                 }
@@ -229,13 +228,13 @@ public class ActionManager implements Action.Container, Action.Handler,
 
     public void handleActions(Map<String, Object> variables, Container sender) {
         if (variables
-                .containsKey(ShortcutActionHandler.ACTION_TARGET_ACTION_VARIABLE)
+                .containsKey(ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE)
                 && actionMapper != null) {
             final String key = (String) variables
-                    .get(ShortcutActionHandler.ACTION_TARGET_ACTION_VARIABLE);
+                    .get(ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE);
             final Action action = actionMapper.get(key);
             final Object target = variables
-                    .get(ShortcutActionHandler.ACTION_TARGET_VARIABLE);
+                    .get(ShortCutConstants.ACTION_TARGET_VARIABLE);
             if (action != null) {
                 handleAction(action, sender, target);
             }