diff options
author | Artur Signell <artur@vaadin.com> | 2012-10-01 18:53:43 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-10-01 18:53:43 +0300 |
commit | 6da74b9512c50ffe736160d697913552c70172ef (patch) | |
tree | 384874c6c99b30ba399091991adc27c2c7214942 | |
parent | 4934e0539f4d773dcecfabc0456746e7f6a26fb6 (diff) | |
download | vaadin-framework-6da74b9512c50ffe736160d697913552c70172ef.tar.gz vaadin-framework-6da74b9512c50ffe736160d697913552c70172ef.zip |
Moved ShortcutActionHandler constants to shared (#8484)
Change-Id: Ia75fa0ca8b7f563ccc412381e88abae7c630569e
-rw-r--r-- | client/src/com/vaadin/client/ui/ShortcutActionHandler.java | 32 | ||||
-rw-r--r-- | server/src/com/vaadin/event/ActionManager.java | 21 |
2 files changed, 24 insertions, 29 deletions
diff --git a/client/src/com/vaadin/client/ui/ShortcutActionHandler.java b/client/src/com/vaadin/client/ui/ShortcutActionHandler.java index 929de7a15d..cd14f14585 100644 --- a/client/src/com/vaadin/client/ui/ShortcutActionHandler.java +++ b/client/src/com/vaadin/client/ui/ShortcutActionHandler.java @@ -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); } } }); diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java index ad643863a7..50bb2f8dad 100644 --- a/server/src/com/vaadin/event/ActionManager.java +++ b/server/src/com/vaadin/event/ActionManager.java @@ -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); } |