Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Mueller2019-02-26 03:08:11 -0500
committerMarvin Mueller2019-02-26 03:08:11 -0500
commit81162f0541c7fc5f3985d1cfbc0ccdb74b7879a3 (patch)
tree5a8d305d0cc1cd9408801393a9197f8f7f4a68e3
parenta3f51d55c2b8662dd0a25457d8313835d9c2cf39 (diff)
downloadorg.eclipse.jubula.core-81162f0541c7fc5f3985d1cfbc0ccdb74b7879a3.tar.gz
org.eclipse.jubula.core-81162f0541c7fc5f3985d1cfbc0ccdb74b7879a3.tar.xz
org.eclipse.jubula.core-81162f0541c7fc5f3985d1cfbc0ccdb74b7879a3.zip
Fix for Bug 544379
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/RCPKeyboardRegistry.java55
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/commands/GetKeyboardLayoutNameResponseCommand.java26
2 files changed, 73 insertions, 8 deletions
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/RCPKeyboardRegistry.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/RCPKeyboardRegistry.java
new file mode 100644
index 000000000..7d4313695
--- /dev/null
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/RCPKeyboardRegistry.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2019 BREDEX GmbH. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: BREDEX GmbH - initial API and implementation and/or initial
+ * documentation
+ *******************************************************************************/
+
+package org.eclipse.jubula.client;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * @author BREDEX GmbH
+ *
+ */
+public enum RCPKeyboardRegistry {
+ /** */
+ INSTANCE;
+
+ /** */
+ private Map<String, Properties> m_nameToKeyBinding =
+ new HashMap<String, Properties>();
+
+ /**
+ *
+ * @return the {@link Map} from local to the keybinding properties
+ */
+ public Map<String, Properties> getNameToKeyBinding() {
+ return m_nameToKeyBinding;
+ }
+
+ /**
+ * adds the keyboard mapping to the map with the localNameCode as the key
+ * @param localNameCode the localCode
+ * @param keyBinding the keybinding Properties
+ */
+ public void addKeyboardMapping(String localNameCode,
+ Properties keyBinding) {
+ m_nameToKeyBinding.put(localNameCode, keyBinding);
+ }
+
+ /**
+ *
+ * @param localNameCode the local code like EN_US
+ * @return the keybinding properties for the local
+ */
+ public Properties getPropertiesForLocalCode(String localNameCode) {
+ return m_nameToKeyBinding.get(localNameCode);
+ }
+}
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/commands/GetKeyboardLayoutNameResponseCommand.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/commands/GetKeyboardLayoutNameResponseCommand.java
index cdc0f039c..5debde284 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/commands/GetKeyboardLayoutNameResponseCommand.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/commands/GetKeyboardLayoutNameResponseCommand.java
@@ -14,6 +14,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
+import org.eclipse.jubula.client.RCPKeyboardRegistry;
import org.eclipse.jubula.client.internal.BaseConnection;
import org.eclipse.jubula.client.internal.exceptions.ConnectionException;
import org.eclipse.jubula.communication.internal.APICommand;
@@ -66,15 +67,24 @@ public class GetKeyboardLayoutNameResponseCommand implements APICommand {
public Message execute() {
String layoutName = m_message.getKeyboardLayoutName();
if (layoutName != null && layoutName.length() > 0) {
- String filename = SwtToolkitConstants.KEYBOARD_MAPPING_FILE_PREFIX
- + layoutName
- + SwtToolkitConstants.KEYBOARD_MAPPING_FILE_POSTFIX;
- final InputStream stream = getClass().getClassLoader()
- .getResourceAsStream(filename);
+ Properties prop = RCPKeyboardRegistry.INSTANCE
+ .getPropertiesForLocalCode(layoutName);
+ InputStream stream = null;
try {
- if (stream != null) {
- Properties prop = new Properties();
- prop.load(stream);
+ if (prop == null) {
+ String filename =
+ SwtToolkitConstants.KEYBOARD_MAPPING_FILE_PREFIX
+ + layoutName
+ + SwtToolkitConstants
+ .KEYBOARD_MAPPING_FILE_POSTFIX;
+ stream = getClass().getClassLoader()
+ .getResourceAsStream(filename);
+ if (stream != null) {
+ prop = new Properties();
+ prop.load(stream);
+ }
+ }
+ if (prop != null) {
m_connection.send(new SetKeyboardLayoutMessage(prop));
} else {
LOG.error("Mapping for '" + layoutName + "' could not be found."); //$NON-NLS-1$//$NON-NLS-2$

Back to the top