List of usage examples for com.google.gwt.core.client JsArrayString get
public final native String get(int index) ;
From source file:thothbot.parallax.core.client.gl2.arrays.JsArrayUtil.java
License:Apache License
/** * Converts a JsArrayString to a String[]. * /*ww w . jav a 2s.c o m*/ * @param jsArrayString * the array to unwrap. * @return the created String[]. */ public static String[] unwrapArray(JsArrayString jsArrayString) { if (GWT.isScript()) { return jsArrayAsArrayForProdMode(jsArrayString); } String[] result = new String[jsArrayString.length()]; for (int i = 0; i < jsArrayString.length(); i++) { result[i] = jsArrayString.get(i); } return result; }
From source file:thothbot.parallax.core.client.gl2.WebGLRenderingContext.java
License:Open Source License
/** * Returns an array of all the supported extension strings. Any string in * this list, when passed to getExtension must return a valid object. Any * other string passed to getExtension must return null. * //from w w w .j ava 2 s . c om * @return an array containing the names of the supported extensions. */ public String[] getSupportedExtensions() { JsArrayString supportedExts = getSupportedExtensionsAsJsArray(); String[] outSupportedExts = new String[supportedExts.length()]; for (int i = 0; i < outSupportedExts.length; i++) { outSupportedExts[i] = supportedExts.get(i); } return outSupportedExts; }
From source file:tigase.jaxmpp.gwt.client.GwtRosterStore.java
License:Open Source License
@Override public Object fromJSON(JsonSerializationHelper helper, JavaScriptObject obj) throws JaxmppException { String type = JsonSerializationHelper.getStringFromObject(obj, "type"); if (!getJsonType().equals(type)) { return null; }/* ww w . j a v a 2 s . co m*/ JavaScriptObject items = JsonSerializationHelper.getObjectFromObject(obj, "items"); JsArrayString jids = JsonSerializationHelper.getKeysFromObject(items); for (int i = 0; i < jids.length(); i++) { String key = jids.get(i); BareJID jid = BareJID.bareJIDInstance(key); JavaScriptObject item = JsonSerializationHelper.getObjectFromObject(items, key); RosterItem ri = new RosterItem(jid, helper.getSessionObject()); JsArrayString propNames = JsonSerializationHelper.getKeysFromObject(item); for (int j = 0; j < propNames.length(); j++) { String prop = propNames.get(j); if ("name".equals(prop)) { ri.setName(JsonSerializationHelper.getStringFromObject(item, prop)); } else if ("sub".equals(prop)) { ri.setSubscription( Subscription.valueOf(JsonSerializationHelper.getStringFromObject(item, prop))); } else if ("ask".equals(prop)) { ri.setAsk(true); } else if ("groups".equals(prop)) { JsArrayString groups = (JsArrayString) JsonSerializationHelper.getObjectFromObject(item, prop); for (int k = 0; k < groups.length(); k++) { String group = groups.get(k); ri.getGroups().add(group); } } this.addItem(ri); } } return this; }
From source file:tigase.jaxmpp.gwt.client.JsonSerializationHelper.java
License:Open Source License
public Object fromJSON(JavaScriptObject obj) throws JaxmppException { String type = getStringFromObject(obj, "type"); if ("bool".equals(type)) { return getBooleanFromObject(obj, "value"); } else if ("int".equals(type)) { return getIntegerFromObject(obj, "value"); } else if ("long".equals(type)) { long val = getIntegerFromObject(obj, "hi"); val = val * INT_SPLIT; val += getIntegerFromObject(obj, "lo"); return val; } else if ("string".equals(type)) { return getStringFromObject(obj, "value"); } else if ("element".equals(type)) { String data = getStringFromObject(obj, "value"); return GwtElement.parse(data); } else if ("map".equals(type)) { Map<String, Object> map = new HashMap<String, Object>(); JavaScriptObject val = getObjectFromObject(obj, "value"); JsArrayString jsKeys = getKeysFromObject(val); for (int i = 0; i < jsKeys.length(); i++) { String key = jsKeys.get(i); JavaScriptObject v = getObjectFromObject(val, key); //log("trying to decode for key = " + key, v); Object v1 = fromJSON(v); map.put(key, v1);/*from www. j a va2 s. co m*/ } return map; } else if ("set".equals(type)) { Set set = new HashSet(); JsArray<JavaScriptObject> array = (JsArray<JavaScriptObject>) getObjectFromObject(obj, "value"); for (int i = 0; i < array.length(); i++) { JavaScriptObject val = array.get(i); Object v = fromJSON(val); if (v != null) { set.add(v); } } return set; } else if ("list".equals(type)) { List list = new ArrayList(); JsArray<JavaScriptObject> array = (JsArray<JavaScriptObject>) getObjectFromObject(obj, "value"); for (int i = 0; i < array.length(); i++) { JavaScriptObject val = array.get(i); Object v = fromJSON(val); if (v != null) { list.add(v); } } return list; } else if ("entry".equals(type)) { AbstractSessionObject.Entry e = new AbstractSessionObject.Entry(); e.scope = SessionObject.Scope.valueOf(getStringFromObject(obj, "scope")); JavaScriptObject val = getObjectFromObject(obj, "value"); e.value = fromJSON(val); return e; } else if ("jid".equals(type)) { return JID.jidInstance(getStringFromObject(obj, "value")); } else if ("barejid".equals(type)) { return BareJID.bareJIDInstance(getStringFromObject(obj, "value")); } else if ("mutablelong".equals(type)) { long val = getIntegerFromObject(obj, "hi"); val = val * INT_SPLIT; val += getIntegerFromObject(obj, "lo"); StreamManagementModule.MutableLong v = new StreamManagementModule.MutableLong(); v.setValue(val); return v; } else { if (serializers != null) { Object val = null; for (Serializable it : serializers) { if (it.getJsonType().equals(type)) { val = it.fromJSON(this, obj); } } if (val != null) return val; } //log("Unknown type of serialized object", obj); return null; } }
From source file:us.softoption.infrastructure.GWTSymbolToolbar.java
License:Apache License
/** Method called to toggle the style in HTML-Mode **/ public void changeHtmlStyle(String startTag, String stopTag) { JsArrayString tx = getSelection(fRichText.getElement()); String txbuffer = fRichText.getText(); Integer startpos = Integer.parseInt(tx.get(1)); String selectedText = tx.get(0); fRichText.setText(txbuffer.substring(0, startpos) + startTag + selectedText + stopTag + txbuffer.substring(startpos + selectedText.length())); }
From source file:us.softoption.infrastructure.GWTSymbolToolbar.java
License:Apache License
public String getSelectionAsText() { // ! String outStr = ""; String htmlStr = ""; Element elem = fRichText.getElement(); try {/*www .j a va 2 s . c o m*/ JsArrayString txt = getSelection(elem); outStr = txt.get(0); } catch (Exception e) { } ; return outStr; }