-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't throw classcast exception for languages in virtualkeyboard that…
… don't have an ISO code (fixes #447)
- Loading branch information
1 parent
72e6b2c
commit 8e5c6d4
Showing
1 changed file
with
27 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,21 +23,29 @@ | |
import com.vaadin.shared.JavaScriptExtensionState; | ||
import com.vaadin.ui.JavaScriptFunction; | ||
import elemental.json.JsonArray; | ||
import elemental.json.impl.JreJsonNull; | ||
import org.json.JSONException; | ||
|
||
/** | ||
* | ||
* @author Thomas Krause <[email protected]> | ||
*/ | ||
@StyleSheet({"keyboard.css"}) | ||
@JavaScript({"vaadin://jquery.js","keyboard.js", "virtualkeyboard_codeeditor.js"}) | ||
@StyleSheet( | ||
{ | ||
"keyboard.css" | ||
}) | ||
@JavaScript( | ||
{ | ||
"vaadin://jquery.js", "keyboard.js", "virtualkeyboard_codeeditor.js" | ||
}) | ||
public class VirtualKeyboardCodeEditor extends AbstractJavaScriptExtension | ||
{ | ||
|
||
public VirtualKeyboardCodeEditor() | ||
{ | ||
addFunction("updateLang", new UpdateLangJSFunction()); | ||
} | ||
|
||
@Override | ||
protected Class<? extends ClientConnector> getSupportedParentType() | ||
{ | ||
|
@@ -47,27 +55,28 @@ protected Class<? extends ClientConnector> getSupportedParentType() | |
public void extend(AqlCodeEditor target) | ||
{ | ||
super.extend(target); | ||
|
||
} | ||
|
||
@Override | ||
protected VKState getState() | ||
{ | ||
return (VKState) super.getState(); | ||
} | ||
|
||
public void show() | ||
{ | ||
callFunction("show"); | ||
} | ||
|
||
public void setKeyboardLayout(String layout) | ||
{ | ||
getState().setKeyboardLayout(layout); | ||
} | ||
|
||
public static class VKState extends JavaScriptExtensionState | ||
{ | ||
|
||
private String keyboardLayout = ""; | ||
|
||
public String getKeyboardLayout() | ||
|
@@ -79,7 +88,7 @@ public void setKeyboardLayout(String keyboardLayout) | |
{ | ||
this.keyboardLayout = keyboardLayout; | ||
} | ||
|
||
} | ||
|
||
private class UpdateLangJSFunction implements JavaScriptFunction | ||
|
@@ -92,8 +101,15 @@ public UpdateLangJSFunction() | |
@Override | ||
public void call(JsonArray arguments) throws JSONException | ||
{ | ||
((VKState) getState()).setKeyboardLayout(arguments.getString(0)); | ||
if (arguments.length() > 0 && !(arguments.get(0) instanceof JreJsonNull)) | ||
{ | ||
((VKState) getState()).setKeyboardLayout(arguments.getString(0)); | ||
} | ||
else | ||
{ | ||
((VKState) getState()).setKeyboardLayout(null); | ||
} | ||
} | ||
} | ||
|
||
} |