diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2015-03-31 15:41:46 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2015-04-07 15:21:50 +0300 |
commit | 8664c97c7bb6fb36b2ebbe3849b51ec00e052e24 (patch) | |
tree | 31451d8bf956cb2bfb686857f27f12e54703f67d /server/src/com/vaadin/ui/declarative | |
parent | 0f1dcd23a0bffae76fc312d95d7b64bf7861df88 (diff) | |
download | vaadin-framework-8664c97c7bb6fb36b2ebbe3849b51ec00e052e24.tar.gz vaadin-framework-8664c97c7bb6fb36b2ebbe3849b51ec00e052e24.zip |
Fix declarative support for Window (#17314)
Change-Id: If89a46a4c08ec1491eb00a2f2b8580fb3ef785fc
Diffstat (limited to 'server/src/com/vaadin/ui/declarative')
-rw-r--r-- | server/src/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/server/src/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java b/server/src/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java index e2b6ed8e14..d6f2f65938 100644 --- a/server/src/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java +++ b/server/src/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java @@ -126,32 +126,37 @@ public class DesignShortcutActionConverter implements if (value.length() == 0) { return null; } - String[] data = value.split(" ", 2); + String[] data = value.split(" ", 2); String[] parts = data[0].split("-"); - // handle keycode - String keyCodePart = parts[parts.length - 1]; - int keyCode = getKeycodeForString(keyCodePart); - if (keyCode < 0) { - throw new IllegalArgumentException("Invalid shortcut definition " - + value); - } - // handle modifiers - int[] modifiers = null; - if (parts.length > 1) { - modifiers = new int[parts.length - 1]; - } - for (int i = 0; i < parts.length - 1; i++) { - int modifier = getKeycodeForString(parts[i]); - if (modifier > 0) { - modifiers[i] = modifier; - } else { - throw new IllegalArgumentException( - "Invalid shortcut definition " + value); + + try { + // handle keycode + String keyCodePart = parts[parts.length - 1]; + int keyCode = getKeycodeForString(keyCodePart); + if (keyCode < 0) { + throw new IllegalArgumentException("Invalid key '" + + keyCodePart + "'"); + } + // handle modifiers + int[] modifiers = null; + if (parts.length > 1) { + modifiers = new int[parts.length - 1]; + } + for (int i = 0; i < parts.length - 1; i++) { + int modifier = getKeycodeForString(parts[i]); + if (modifier > 0) { + modifiers[i] = modifier; + } else { + throw new IllegalArgumentException("Invalid modifier '" + + parts[i] + "'"); + } } + return new ShortcutAction(data.length == 2 ? data[1] : null, + keyCode, modifiers); + } catch (Exception e) { + throw new ConversionException("Invalid shortcut '" + value + "'", e); } - return new ShortcutAction(data.length == 2 ? data[1] : null, keyCode, - modifiers); } @Override |