Example usage for com.google.gwt.core.client JsArrayString set

List of usage examples for com.google.gwt.core.client JsArrayString set

Introduction

In this page you can find the example usage for com.google.gwt.core.client JsArrayString set.

Prototype

public final native void set(int index, String value) ;

Source Link

Document

Sets the value value at a given index.

Usage

From source file:com.ait.toolkit.sencha.touch.client.ui.Slider.java

License:Open Source License

/**
 * Sets the value of value./*from   w  w w  . ja  v a 2 s  .c o m*/
 * 
 * @param value
 */
public void setSliderValues(String[] value) {
    JsArrayString values = JavaScriptObject.createArray().cast();
    for (int i = 0; i < value.length; i++) {
        values.set(i, value[i]);
    }
    setSliderValues(values);
}

From source file:com.edgenius.wiki.gwt.client.editor.MCEInsertTableDialog.java

License:Open Source License

@Override
protected void okEvent() {
    int row;//  ww  w  . j  a  v  a2 s.c om
    int col;
    String borderColor = "", bgColor = "", borderWidth = "", cellpadding = "", cellspacing = "", clz;
    StringBuilder styleBuf = new StringBuilder();
    String hasTitleB = "false";
    if (asGrid.getValue()) {
        row = NumberUtil.toInt(gridRows.getText(), -1);
        col = NumberUtil.toInt(gridCols.getText(), -1);
        if (row <= 0 || col <= 0) {
            Window.alert(Msg.consts.error_input_number_only());
            return;
        }
        styleBuf.append("border-width:0px;width:100%;");
        //!!!please note: this size has same value in MceInsertTableMacro.java, please keep consist.
        cellpadding = "5";
        cellspacing = "5";
        clz = "macroGrid";
    } else {
        clz = "macroTable";
        row = NumberUtil.toInt(rows.getText(), -1);
        col = NumberUtil.toInt(cols.getText(), -1);
        if (row <= 0 || col <= 0) {
            Window.alert(Msg.consts.error_input_number_only());
            return;
        }
        hasTitleB = Boolean.valueOf(hasTitle.getValue()).toString();
        int borderN = NumberUtil.toInt(border.getText(), -1);
        if (borderN == -1) {
            border.setText("0");
            borderN = 0;
        }
        //according to TinyMCE, style string is for creating table, hidden is for update use 
        //although style=border-color is useless as it must put into td/th level,but it is useful to 
        //get back this value when editing table properties
        if (!SharedConstants.TABLE_BORDER_DEFAULT_COLOR.equalsIgnoreCase(borderPicker.getColor())) {
            borderColor = borderPicker.getColor();
            styleBuf.append("border-color:").append(borderColor);
        }
        if (!SharedConstants.TABLE_BG_DEFAULT_COLOR.equalsIgnoreCase(bkPicker.getColor())) {
            //only background color is not white.
            if (styleBuf.length() > 0)
                styleBuf.append(";");

            bgColor = bkPicker.getColor();
            styleBuf.append("background-color:").append(bgColor);
        }
        if (!StringUtil.isBlank(width)) {
            if (styleBuf.length() > 0)
                styleBuf.append(";");
            styleBuf.append("width:").append(width);
        }
        if (!StringUtil.isBlank(height)) {
            if (styleBuf.length() > 0)
                styleBuf.append(";");
            styleBuf.append("height:").append(height);
        }

        //border also pass to client even it is default size, this makes "1px solid #121212" valid 
        borderWidth = borderN + "px";
        if (borderN != DEFAULT_BORDER_SIZE) {
            if (styleBuf.length() > 0)
                styleBuf.append(";");

            styleBuf.append("border-width:").append(borderWidth);
        }
    }
    //Original design is use form.elements['name'].value to retrieve values. But fuck IE, it does work:
    //http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/5144115ec715ce1a/78507fc52fab2429?lnk=gst&q=setName+ie#78507fc52fab2429
    //It means pure javascript can not get value by name. So I collect them into list then pass it to javascript. Fuck IE again.
    JsArrayString input = (JsArrayString) JavaScriptObject.createArray();
    input.set(0, String.valueOf(row));
    input.set(1, String.valueOf(col));
    input.set(2, bgColor);
    input.set(3, borderColor);
    input.set(4, hasTitleB);
    input.set(5, borderWidth);
    input.set(6, styleBuf.toString());
    input.set(7, cellpadding);
    input.set(8, cellspacing);
    input.set(9, clz);

    tiny.restoreEditorBookmark();
    if (update) {
        updateTable(input);
    } else {
        //insert table
        insertTable(input);
    }
    close();

}

From source file:com.edgenius.wiki.gwt.client.editor.MCEMergeCellsDialog.java

License:Open Source License

@Override
protected void okEvent() {
    int row = NumberUtil.toInt(rowBox.getText(), -1);
    int col = NumberUtil.toInt(colBox.getText(), -1);
    if (row <= 0 || col <= 0) {
        Window.alert(Msg.consts.error_input_number_only());
        return;//from w w w.java  2 s  .  c  o  m
    }

    JsArrayString input = (JsArrayString) JavaScriptObject.createArray();
    input.set(0, rowBox.getText());
    input.set(1, colBox.getText());

    mergeCells(input);
    close();

}

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
 *///  www .ja  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 ww  .  jav  a2  s . 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.google.code.gwt.database.client.SQLTransaction.java

License:Apache License

/**
 * Converts a java array to a JsArrayString.
 * //from w  w  w . j  a  va 2  s  .com
 * <p>
 * JSNI requires a JsArray of uniform type. All array values are converted to
 * string using the toString() method before being added to the JsArrayString.
 * </p>
 * 
 * <p>
 * Note that the database takes care of converting the strings back to the
 * datatype required by the table column.
 * </p>
 * 
 * @param array to load into a JsArrayString
 * @return a JsArrayString array that can be passed to JSNI
 */
private JsArrayString toJsniArray(Object[] array) {
    if (array == null) {
        return null;
    }
    JsArrayString jsArray = (JsArrayString) JsArrayString.createArray();
    for (int i = 0; i < array.length; i++) {
        Object value = array[i];
        jsArray.set(i, value == null ? null : value.toString());
    }
    return jsArray;
}

From source file:com.googlecode.gflot.client.options.GridOptions.java

License:Open Source License

/**
 * Set the background color inside the grid area as a gradient.
 */// w  ww  .  j a  v a2s .  c o m
public final GridOptions setBackgroundColor(String fromColor, String toColor) {
    JsArrayString array = getBackgroundColorAsArray();
    if (null == array) {
        JsonObject jsonObject = JavaScriptObject.createObject().cast();
        array = JavaScriptObject.createArray().cast();
        jsonObject.put(BACKGROUND_COLORS_KEY, array);
        put(BACKGROUND_COLOR_KEY, jsonObject);
    }
    array.set(0, fromColor);
    array.set(1, toColor);
    return this;
}

From source file:com.googlecode.gwt.charts.client.ajaxloader.ArrayHelper.java

License:Apache License

/**
 * Converts an array of Java strings to an array of JavaScript strings.
 * //from   w  ww  .j a v  a2  s. co  m
 * @param strings array of strings to convert
 */
public static JsArrayString toJsArrayString(String... strings) {
    JsArrayString result = JsArrayString.createArray().cast();
    for (int i = 0; i < strings.length; i++) {
        result.set(i, strings[i]);
    }
    nativePatchConstructorForSafari(result);
    return result;
}

From source file:com.gwtmobile.persistence.client.EntityInternal.java

License:Apache License

public void index(String[] columns, boolean unique) {
    JsArrayString jsArray = (JsArrayString) JavaScriptObject.createArray();
    for (int i = 0; i < columns.length; i++) {
        String col = columns[i];/* w  w  w .j  a v a 2s.c  om*/
        jsArray.set(i, col);
    }
    index(jsArray, false, getNativeObject());
}

From source file:com.parabay.client.gears.Utils.java

License:Apache License

/**
 * Converts a Java array of strings to a JavaScript array of strings.
 *///from  w ww.j av a2 s  .c o m
public static JsArrayString toJavaScriptArray(String[] elements) {
    JsArrayString array = JavaScriptObject.createArray().cast();
    if (null != elements) {
        for (int i = 0; i < elements.length; ++i) {
            array.set(i, elements[i]);
        }
    }
    return array;
}