List of usage examples for com.google.gwt.core.client JsArrayString get
public final native String get(int index) ;
From source file:org.eclipse.che.requirejs.RequireJsLoader.java
License:Open Source License
protected static void configureGlobalErrorCallback() { Requirejs.get().setOnError(new RequirejsErrorHandler() { @Override/*from w ww . ja v a 2 s . c o m*/ public void onError(final RequireError err) { final String type = err.getRequireType(); if ("scripterror".equals(type)) { // leave the module as-is final JsArrayString modules = err.getRequireModules(); if (modules != null && modules.length() > 0) { final String failed = modules.get(0); String formattedMsg = ""; if (err.getMessage() != null) { formattedMsg = formattedMsg.replace("\n", "\n\t\t"); } consoleWarn( "Required module '%s' load failed with script error " + "(nonexistant script or error in the loaded script)\n" + "\t- error message = '%s'\n" + "\t- original error = %o", failed, formattedMsg, err); } else { consoleWarn( "Unexpected requirejs of type 'scripterror' without requireModules property: %o", err); throw new RuntimeException(err.toString()); } } else if ("timeout".equals(type)) { // we'll retry next time final JsArrayString modules = err.getRequireModules(); if (modules != null && modules.length() > 0) { final String failed = modules.get(0); consoleWarn("Required module '%s' load failed on timeout.", failed); Requirejs.get().undef(failed); } else { consoleWarn("Unexpected requirejs of type 'timeout' without requireModules property: %o", err); throw new RuntimeException(err.toString()); } } else { throw new RuntimeException(err.toString()); } } }); }
From source file:org.geowe.client.local.main.map.Projections.java
License:Open Source License
private static List<String> getProj4jsProjections() { List<String> projections = new ArrayList<String>(); JsArrayString projDefs = getProjDefs(); for (int i = 0; i < projDefs.length(); i++) { projections.add(projDefs.get(i).trim()); }/*from w ww. j a v a 2s. c o m*/ return projections; }
From source file:org.gk.engine.client.utils.ComLibrary.java
License:Open Source License
/** * ?(${...})//from ww w .j av a2 s . com * * @param nodeName * @return JavaScriptObject */ public static JavaScriptObject getLibraryAttributes(String nodeName) { String gul = getContent(nodeName); JsArrayString list = (JsArrayString) findReplaceAttributes(gul); Set libAttr = new FastSet(); for (int i = 0; i < list.length(); i++) { String el = replaceToEL(list.get(i)); if (matchELPattern(el)) { String key = retriveELParameter(el).trim(); libAttr.add(key); } else { libAttr.add(el); } } return JsUtil.toJavaScriptArray(libAttr.toArray()); }
From source file:org.gk.engine.client.utils.ComLibrary.java
License:Open Source License
/** * ?/* ww w . jav a 2 s. c om*/ * * @param node * @param gul * @return Map */ private static Map createMappingTable(Node node, String gul) { Map<String, String> nodeAttr = new FastMap(); // node?Map NamedNodeMap map = node.getAttributes(); for (int index = 0; index < map.getLength(); index++) { Node attrNode = map.item(index); nodeAttr.put("${" + attrNode.getNodeName() + "}", attrNode.getNodeValue()); } gul = replaceExtraBackslash(gul); // ?Map JsArrayString list = (JsArrayString) findReplaceAttributes(gul); Map<String, String> libAttr = new FastMap(); for (int i = 0; i < list.length(); i++) { String attr = list.get(i); if (!libAttr.containsKey(attr)) { String el = replaceToEL(attr); if (matchELPattern(el)) { String key = retriveELParameter(el).trim(); String value = nodeAttr.get("${" + key + "}"); libAttr.put(attr, execEL(el, key, value == null ? "" : value)); } else { if (!nodeAttr.containsKey(attr)) { libAttr.put(attr, XDOM.getUniqueId()); } } } } nodeAttr.putAll(libAttr); return nodeAttr; }
From source file:org.gk.engine.client.utils.ComLibrary.java
License:Open Source License
/** * id${xxx}??uniqueId/*from ww w .ja va 2 s . c o m*/ * * @param gul * @return String */ public static String replaceAnonymousId(String gul) { JsArrayString list = (JsArrayString) findReplaceAttributes(gul); for (int i = 0; i < list.length(); i++) { gul = gul.replace(list.get(i), XDOM.getUniqueId()); } return gul; }
From source file:org.gwtbootstrap3.extras.select.client.ui.MultipleSelect.java
License:Apache License
@Override public List<String> getValue() { if (isAttached()) { JsArrayString arr = getValue(getElement()); List<String> result = new ArrayList<>(arr.length()); for (int i = 0; i < arr.length(); i++) { result.add(arr.get(i)); }/*from w ww. j a v a2 s . c o m*/ return result; } return getSelectedValues(); }
From source file:org.gwtbootstrap3.extras.slider.client.ui.base.SliderBase.java
License:Apache License
private List<String> getStringArrayAttribute(SliderOption option, List<String> defaultValue) { // Get array attribute JsArrayString array = null; if (isAttached()) { array = getStringArrayAttribute(getElement(), option.getName()); } else {/*from www .j a va2 s .c o m*/ String value = attributeMixin.getAttribute(option.getDataAttribute()); if (value != null && !value.isEmpty()) { array = JsonUtils.safeEval(value); } } // Attribute not set if (array == null) { return defaultValue; } // Put array to list List<String> list = new ArrayList<String>(array.length()); for (int i = 0; i < array.length(); i++) { list.add(array.get(i)); } return list; }
From source file:org.gwtbootstrap3.extras.tagsinput.client.ui.base.TagsInputBase.java
License:Apache License
protected static List<String> toMultiValue(JavaScriptObject js_multi_value) { List<String> retValue = new ArrayList<String>(); JsArrayString js_string_array = js_multi_value.cast(); for (int i = 0; i < js_string_array.length(); i++) { retValue.add(js_string_array.get(i)); }/*from w w w . j a v a 2 s .c o m*/ return retValue; }
From source file:org.gwtnode.core.GwtNodeBootstrap.java
License:Apache License
@Override public final void onModuleLoad() { //unhandled errors GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override//w ww. ja v a2 s .c o m public void onUncaughtException(Throwable e) { GwtNodeBootstrap.this.onUncaughtException(e); } }); Process.get().onUncaughtException(new ErrorEventHandler() { @Override public void onEvent(NodeJsError exception) { JavaScriptException e = new JavaScriptException(exception); if (e.getStackTrace().length == 0) { e.fillInStackTrace(); } onUncaughtException(e); } }); Process.get().nextTick(new ParameterlessEventHandler() { @Override public void onEvent() { try { //grab the arguments JsArrayString nativeArgs = Process.get().argv(); //well, the best I can do right now is find the arguments // after the .js argument //TODO: be smarter than this int jsArgIndex; for (jsArgIndex = 0; jsArgIndex < nativeArgs.length(); jsArgIndex++) { if (nativeArgs.get(jsArgIndex).endsWith(".js")) { break; } } //make the final native string array String[] args; if (jsArgIndex == nativeArgs.length()) { Util.get().log("Unable to find argument ending with .js"); args = new String[0]; } else { args = new String[nativeArgs.length() - jsArgIndex - 1]; for (int i = 0; i < args.length; i++) { args[i] = nativeArgs.get(jsArgIndex + i + 1); } } //call the main method Runner runner = GWT.create(Runner.class); runner.run(GwtNodeBootstrap.this, new Closure<Integer>() { @Override public void call(Integer result) { if (result != null) { Process.get().exit(result); } } }, args); } catch (Throwable e) { onUncaughtException(e); } } }); }
From source file:org.jboss.bpm.console.client.model.JSOModel.java
License:Open Source License
@Deprecated public final Set<String> keySet() { JsArrayString array = keys(); Set<String> set = new HashSet<String>(); for (int i = 0; i < array.length(); i++) { set.add(array.get(i)); }//w ww. j a v a 2 s . co m return set; }