List of usage examples for com.google.gwt.core.client JavaScriptObject createArray
public static native JavaScriptObject createArray() ;
From source file:com.floreysoft.gwt.picker.client.utils.JavaScriptUtils.java
License:Apache License
/** * Converts a string array to a javascript array * * @param javaArray The array to convert * @return The converted javascript string array *//* w w w .j a va 2 s . c o m*/ public static JsArrayString convert(String[] javaArray) { JsArrayString result = JavaScriptObject.createArray().cast(); for (int i = 0; i < javaArray.length; i++) { result.set(i, javaArray[i]); } return result; }
From source file:com.github.ligangty.common.highconvert.XAxis.java
License:Apache License
/** * Sets category names to use for the xAxis (instead of using numbers), explicitly controlling whether * or not the axis will be redrawn in the case that the chart has already been rendered to the DOM. * If categories are present for the xAxis, names are used instead of numbers for that axis. * Example: setCategories("Apples", "Bananas", "Oranges"). Defaults to an empty array, which will * use numbers for the categories instead of names when categories are present. * <p/>/* w w w . ja va 2s . c o m*/ * * @param redraw Whether to redraw the axis or wait for an explicit call to {@link com.github.ligangty.common.highconvert.BaseChart#redraw()} * @param categories An array of category names to use for the axis. * @return A reference to this {@link XAxis} instance for convenient method chaining. * @since 1.1.1 */ public XAxis setCategories(boolean redraw, String... categories) { final JavaScriptObject nativeAxis = getNativeAxis(); if (nativeAxis != null) { JsArrayString jsArray = JavaScriptObject.createArray().<JsArrayString>cast(); for (int i = 0; i < categories.length; i++) { String category = categories[i]; jsArray.set(i, category); } nativeSetCategories(nativeAxis, jsArray, redraw); return this; } else { return this.setOption("categories", categories); } }
From source file:com.goodow.realtime.json.js.JsJsonArray.java
License:Apache License
public static JsonArray create() { return (JsJsonArray) JavaScriptObject.createArray(); }
From source file:com.google.collide.client.code.autocomplete.css.CssPartialParser.java
License:Open Source License
/** * Checks whether the passed-in string matches the format of the special value * type in question. If it does, it returns a list of proposals that should be * shown to the user for this query.// w w w . j a va 2 s . c o m * * @param maybeSpecialValue * @param specialValueType a special value type, e.g., <integer>. This method * can be called with a specialValueType value that is not one of those * special values, in which case the method returns an empty array. * @return an array of strings corresponding to the proposals that should be * shown for the special value type */ @VisibleForTesting public JsArrayString checkIfSpecialValueAndGetSpecialValueProposals(String maybeSpecialValue, String specialValueType) { JsArrayString specialValues = getSpecialValues(maybeSpecialValue); for (int i = 0; i < specialValues.length(); i++) { if (specialValues.get(i).equals(specialValueType)) { return specialValueProposals.<Jso>cast().getJsObjectField(specialValueType).cast(); } } return JavaScriptObject.createArray().cast(); }
From source file:com.google.gerrit.client.diff.Unified.java
License:Apache License
@Override CodeMirror newCm(DiffInfo.FileMeta meta, String contents, Element parent) { JsArrayString gutters = JavaScriptObject.createArray().cast(); gutters.push(UnifiedTable.style.lineNumbersLeft()); gutters.push(UnifiedTable.style.lineNumbersRight()); return CodeMirror.create(parent, Configuration.create().set("cursorBlinkRate", prefs.cursorBlinkRate()).set("cursorHeight", 0.85) .set("gutters", gutters).set("inputStyle", "textarea").set("keyMap", "vim_ro") .set("lineNumbers", false).set("lineWrapping", prefs.lineWrapping()) .set("matchBrackets", prefs.matchBrackets()) .set("mode", getFileSize() == FileSize.SMALL ? getContentType(meta) : null) .set("readOnly", true).set("scrollbarStyle", "overlay").set("styleSelectedText", true) .set("showTrailingSpace", prefs.showWhitespaceErrors()).set("tabSize", prefs.tabSize()) .set("theme", prefs.theme().name().toLowerCase()).set("value", meta != null ? contents : "") .set("viewportMargin", renderEntireFile() ? POSITIVE_INFINITY : 10)); }
From source file:com.google.gerrit.client.rpc.Natives.java
License:Apache License
public static <T extends JavaScriptObject> JsArray<T> arrayOf(T element) { JsArray<T> arr = JavaScriptObject.createArray().cast(); arr.push(element);// w w w . j a va 2s . c o m return arr; }
From source file:com.google.mobile.trippy.web.client.db.JsoTrip.java
License:Apache License
public final void setContributorIds(HashSet<String> contributorIds) { JsArrayString stringArr = (JsArrayString) JavaScriptObject.createArray(); for (String s : contributorIds) { stringArr.push(s);/*from w w w.ja v a2s. co m*/ } setContributorIds(stringArr); }
From source file:com.google.mobile.trippy.web.client.db.JsoTrip.java
License:Apache License
public final void setViewerIds(HashSet<String> viewerIds) { JsArrayString stringArr = (JsArrayString) JavaScriptObject.createArray(); for (String s : viewerIds) { stringArr.push(s);/*from ww w .ja va 2 s .co m*/ } setViewerIds(stringArr); }
From source file:com.google.mobile.trippy.web.client.db.JsoTrip.java
License:Apache License
@SuppressWarnings("unchecked") public final void setTripItemIds(final IdDayDateTupleList idDateTupleList) { JsArray<JsoIdDayDateTuple> idArr = (JsArray<JsoIdDayDateTuple>) JavaScriptObject.createArray(); for (IdDayDateTuple s : idDateTupleList.getTuples()) { JsoIdDayDateTuple idTup = (JsoIdDayDateTuple) JavaScriptObject.createObject(); idTup.setId(s.getId());/*from ww w. j av a 2s .c o m*/ idTup.setDay(s.getDay() + ""); idTup.setDate(s.getLastModified().getTime() + ""); idArr.push(idTup); } setTripItemIds_(idArr); }
From source file:com.google.mobile.trippy.web.client.db.JsoTrip.java
License:Apache License
@SuppressWarnings("unchecked") public final void setCommentIds(final IdDateTupleList idDateTupleList) { JsArray<JsoIdDateTuple> idArr = (JsArray<JsoIdDateTuple>) JavaScriptObject.createArray(); for (IdDateTuple s : idDateTupleList.getTuples()) { JsoIdDateTuple idTup = (JsoIdDateTuple) JavaScriptObject.createObject(); idTup.setId(s.getId());/*from w w w .j a v a2 s. c o m*/ idTup.setDate(s.getLastModified().getTime() + ""); idArr.push(idTup); } setCommentIds_(idArr); }