summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/event/ShortcutAction.java
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-09-04 15:05:27 +0300
committerArtur Signell <artur@vaadin.com>2015-09-04 15:05:27 +0300
commitf46be1b2792755cb7d9b111068dd6cf202398c4a (patch)
tree74f7098faee688cc1f1ca1b6ffe9e912338bbcaf /server/src/com/vaadin/event/ShortcutAction.java
parente603ea3cf91e5dd0893b766f27d400947527fba9 (diff)
parentebceef4d44bcd61605fa92fcf7be8d3678537599 (diff)
downloadvaadin-framework-f46be1b2792755cb7d9b111068dd6cf202398c4a.tar.gz
vaadin-framework-f46be1b2792755cb7d9b111068dd6cf202398c4a.zip
Merge remote-tracking branch 'origin/master' into reconnect-dialog
Change-Id: Ie622160a83116c83b255a26bec297f73f3223ac7
Diffstat (limited to 'server/src/com/vaadin/event/ShortcutAction.java')
-rw-r--r--server/src/com/vaadin/event/ShortcutAction.java30
1 files changed, 24 insertions, 6 deletions
diff --git a/server/src/com/vaadin/event/ShortcutAction.java b/server/src/com/vaadin/event/ShortcutAction.java
index 09accae1c7..dd511c23c0 100644
--- a/server/src/com/vaadin/event/ShortcutAction.java
+++ b/server/src/com/vaadin/event/ShortcutAction.java
@@ -17,6 +17,7 @@
package com.vaadin.event;
import java.io.Serializable;
+import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -55,7 +56,7 @@ public class ShortcutAction extends Action {
private final int keyCode;
- private final int[] modifiers;
+ private int[] modifiers;
/**
* Creates a shortcut that reacts to the given {@link KeyCode} and
@@ -73,7 +74,7 @@ public class ShortcutAction extends Action {
public ShortcutAction(String caption, int kc, int... m) {
super(caption);
keyCode = kc;
- modifiers = m;
+ setModifiers(m);
}
/**
@@ -94,7 +95,7 @@ public class ShortcutAction extends Action {
public ShortcutAction(String caption, Resource icon, int kc, int... m) {
super(caption, icon);
keyCode = kc;
- modifiers = m;
+ setModifiers(m);
}
/**
@@ -190,7 +191,7 @@ public class ShortcutAction extends Action {
// Given modifiers override this indicated in the caption
if (modifierKeys != null) {
- modifiers = modifierKeys;
+ setModifiers(modifierKeys);
} else {
// Read modifiers from caption
int[] mod = new int[match.length() - 1];
@@ -208,13 +209,30 @@ public class ShortcutAction extends Action {
break;
}
}
- modifiers = mod;
+ setModifiers(mod);
}
} else {
keyCode = -1;
- modifiers = modifierKeys;
+ setModifiers(modifierKeys);
}
+
+ }
+
+ /**
+ * When setting modifiers, make sure that modifiers is a valid array AND
+ * that it's sorted.
+ *
+ * @param modifiers
+ * the modifier keys for this shortcut
+ */
+ private void setModifiers(int... modifiers) {
+ if (modifiers == null) {
+ this.modifiers = new int[0];
+ } else {
+ this.modifiers = modifiers;
+ }
+ Arrays.sort(this.modifiers);
}
/**