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
*/
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
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));
}
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);
}
}
});
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;
/**
}
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];
}
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());
}
}
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);
}