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

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

Introduction

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

Prototype

public final native String get(int index) ;

Source Link

Document

Gets the value at a given index.

Usage

From source file:com.emitrom.ti4j.mobile.client.ui.AlertDialog.java

License:Apache License

/**
 * @return Array of button names as strings
 *///from ww  w . ja va2s  . co  m
public ArrayList<String> getButtonNames() {
    JsArrayString strings = _getButtonNames();
    ArrayList<String> values = new ArrayList<String>();
    for (int i = 0; i < strings.length(); i++) {
        values.add(strings.get(i));
    }
    return values;
}

From source file:com.fujitsu.gwt.bewebapp.client.content.text.RichTextToolbar.java

License:Open Source License

private void changeHtml(String startTag, String stopTag) {
    styleTextFormatter.removeFormat();/*  w  w  w.  ja v a  2s. c om*/
    JsArrayString tx = getSelection(styleText.getElement());
    Integer startpos = Integer.parseInt(tx.get(1));
    String selectedText = startTag + tx.get(0) + stopTag;

    styleTextFormatter.insertHTML(selectedText);
}

From source file:com.fujitsu.gwt.bewebapp.client.content.text.RichTextToolbar.java

License:Open Source License

private void changeHtmlElement(String startTag, String stopTag) {
    JsArrayString tx = getSelection(styleText.getElement());
    if (tx.get(0).length() == 0) {
        Window.alert("Please select a text to change style before using this button.");
        return;//ww w  . j  a  va  2  s  .co  m
    }
    Integer startpos = Integer.parseInt(tx.get(1));
    String selectedText = startTag + tx.get(0) + stopTag;

    styleTextFormatter.insertHTML(selectedText);
}

From source file:com.fujitsu.gwt.bewebapp.client.content.text.RichTextToolbar.java

License:Open Source License

private void changeHtm(String startTag, String stopTag) {
    styleTextFormatter.removeFormat();/*w  w w . j  a  v a  2 s . co  m*/
    JsArrayString tx = getSelection(styleText.getElement());
    String txbuffer = styleText.getHTML();
    Window.alert("txbuffer:" + txbuffer);
    Integer startpos = Integer.parseInt(tx.get(1));
    String selectedText = tx.get(0);
    styleText.setHTML(txbuffer.substring(0, startpos) + startTag + selectedText + stopTag
            + txbuffer.substring(startpos + selectedText.length()));
}

From source file:com.github.ligangty.common.highconvert.BaseChart.java

License:Apache License

/**
 * Returns an array of all currently selected series in the chart. Series can be selected either programmatically by the
 * {@link Series#select(boolean)} method or by checking the checkbox next to the legend item if the
 * {@link SeriesPlotOptions#setShowCheckbox(boolean)} option is true.
 *
 * @return An array of the selected Series items, or an empty array if either no series are selected or the
 *         chart has not yet been rendered.
 * @since 1.1.0/*ww  w . j  av  a2  s. c om*/
 */
public Series[] getSelectedSeries() {
    ArrayList<Series> selectedSeries = new ArrayList<Series>();
    if (isRendered()) {
        JsArrayString selectedSeriesIds = nativeGetSelectedSeriesIds(chart);
        for (int i = 0; i < selectedSeriesIds.length(); i++) {
            String selectedSeriesId = selectedSeriesIds.get(i);
            for (Series series : seriesList) {
                if (series.getId().equals(selectedSeriesId)) {
                    selectedSeries.add(series);
                }
            }
        }
    }
    return selectedSeries.toArray(new Series[selectedSeries.size()]);
}

From source file:com.github.nmorel.gwtjackson.client.deser.array.cast.StringArrayJsonDeserializer.java

License:Apache License

@Override
public String[] doDeserializeArray(JsonReader reader, JsonDeserializationContext ctx,
        JsonDeserializerParameters params) {
    JsArrayString jsArray = JsArrayString.createArray().cast();
    reader.beginArray();/*from w  ww. jav  a2  s .  com*/
    while (JsonToken.END_ARRAY != reader.peek()) {
        if (JsonToken.NULL == reader.peek()) {
            reader.skipValue();
            jsArray.push(null);
        } else {
            jsArray.push(reader.nextString());
        }
    }
    reader.endArray();

    if (GWT.isScript()) {
        return reinterpretCast(jsArray);
    } else {
        int length = jsArray.length();
        String[] ret = new String[length];
        for (int i = 0; i < length; i++) {
            ret[i] = jsArray.get(i);
        }
        return ret;
    }
}

From source file:com.google.api.explorer.client.base.ApiResponse.java

License:Apache License

/**
 * Inspects the headers object of the given JS object and constructs a
 * {@link Map} of its keys and values./*from  w ww  . j  a  v a 2 s.  c  o  m*/
 */
private static Map<String, HeaderValue> createHeadersMap(DynamicJso data) {
    DynamicJso headers = data.get("headers");
    JsArrayString keys = headers.keys();
    Map<String, HeaderValue> headersMap = Maps.newHashMapWithExpectedSize(keys.length());

    for (int i = 0; i < keys.length(); i++) {
        String key = keys.get(i);
        String value = "";
        switch (headers.typeofKey(key)) {
        case STRING:
            value = headers.getString(key);
            break;

        case BOOLEAN:
            value = String.valueOf(headers.getBoolean(key));
            break;

        case NUMBER:
            value = String.valueOf(headers.getInteger(key));
            break;

        case INTEGER:
            value = String.valueOf(headers.getDouble(key));
            break;
        }
        headersMap.put(key.toLowerCase(), new HeaderValue(key, value));

    }
    return headersMap;
}

From source file:com.google.code.gwt.database.client.GenericRow.java

License:Apache License

/**
 * @return a {@link List} of all attribute names in this Row.
 *///from   w w w. ja  v  a  2s  .  c o  m
public final List<String> getAttributeNames() {
    JsArrayString jas = getAttributeNames0();
    List<String> attributeNames = new ArrayList<String>(jas.length());
    for (int i = 0; i < jas.length(); i++) {
        attributeNames.add(jas.get(i));
    }
    return attributeNames;
}

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.//from  w  ww . jav  a2  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.collide.client.code.autocomplete.css.CssPartialParser.java

License:Open Source License

public JsoArray<AutocompleteProposal> getAutocompletions(String property, JsArrayString valuesBefore,
        String incomplete, JsArrayString valuesAfter) {
    incomplete = incomplete.toLowerCase();
    boolean isRepeatingProperty = repeatingProperties.hasKey(property);
    JsArrayString valuesAndSpecialValuesAfter = getValuesAndSpecialValues(valuesAfter);
    JsArrayString valuesAndSpecialValuesBefore = getValuesAndSpecialValues(valuesBefore);

    JsoArray<AutocompleteProposal> proposals = JsoArray.create();
    JsArray<JavaScriptObject> valuesForAllSlots = getPropertyValues(property);
    if (valuesForAllSlots == null) {
        return proposals;
    }// w w  w  . j  av  a 2  s .c  om
    int numSlots = valuesForAllSlots.length();

    if (numSlots == 0) {
        return proposals;
    }
    int slot = valuesBefore.length(); // slots use 0-based counting

    if (slot >= numSlots) {
        // before giving up, see if the last entry is +, in which case we just
        // adjust the slot number
        JavaScriptObject lastSlotValues = valuesForAllSlots.get(numSlots - 1);
        JsArrayString keySet = getKeySet(lastSlotValues);
        if ((keySet.length() == 1) && (keySet.get(0).equals("+"))) {
            slot = numSlots - 1;
        } else {
            return proposals;
        }
    }
    JavaScriptObject valuesForSlotInQuestion = valuesForAllSlots.get(slot);

    JsArrayString keySet = getKeySet(valuesForSlotInQuestion);
    if ((keySet.length() == 1) && (keySet.get(0).equals("+"))) {
        valuesForSlotInQuestion = valuesForAllSlots.get(slot - 1);
        keySet = getKeySet(valuesForSlotInQuestion);
    }

    if (valuesForSlotInQuestion != null) {
        if (keySet.length() == 0) {
            return proposals;
        }

        for (int keyCt = 0; keyCt < keySet.length(); keyCt++) {
            String currentValue = keySet.get(keyCt);
            Boolean shouldBeIncluded = false;
            // TODO: Avoid using untyped native collections.
            JavaScriptObject triggers = valuesForSlotInQuestion.<Jso>cast().getJsObjectField(currentValue)
                    .cast();
            JsArrayString keyTriggerSet = getKeySet(triggers);
            if (keyTriggerSet.length() == 0) {
                if (currentValue.charAt(0) == '<') {
                    JsArrayString valueProposals = specialValueProposals.<Jso>cast()
                            .getJsObjectField(currentValue).cast();
                    if (valueProposals != null && valueProposals.length() != 0) {
                        shouldBeIncluded = false;
                        for (int i = 0; i < valueProposals.length(); i++) {
                            if (valueProposals.get(i).startsWith(incomplete)
                                    && (isRepeatingProperty || !inExistingValues(currentValue,
                                            valuesAndSpecialValuesBefore, valuesAndSpecialValuesAfter))) {
                                proposals.add(new AutocompleteProposal(valueProposals.get(i)));
                            }
                        }
                    }
                } else {
                    shouldBeIncluded = true;
                }
            } else {
                for (int keyTriggerCt = 0; keyTriggerCt < keyTriggerSet.length(); keyTriggerCt++) {
                    String triggerValue = keyTriggerSet.get(keyTriggerCt);
                    int triggerSlot = triggers.<Jso>cast().getIntField(triggerValue);
                    if (triggerValue.charAt(0) == '<') {
                        JsArrayString specialValueProposalsAfterCheck = checkIfSpecialValueAndGetSpecialValueProposals(
                                valuesBefore.get(triggerSlot), triggerValue);
                        if (specialValueProposalsAfterCheck.length() != 0) {
                            shouldBeIncluded = false;
                            for (int i = 0; i < specialValueProposalsAfterCheck.length(); i++) {
                                if (specialValueProposalsAfterCheck.get(i).startsWith(incomplete)
                                        && (isRepeatingProperty || !inExistingValues(triggerValue,
                                                valuesAndSpecialValuesBefore, valuesAndSpecialValuesAfter))) {
                                    proposals.add(
                                            new AutocompleteProposal(specialValueProposalsAfterCheck.get(i)));
                                }
                            }
                        }
                    } else if (valuesBefore.get(triggerSlot).compareTo(triggerValue) == 0) {
                        shouldBeIncluded = true;
                    }
                }
            }
            if (shouldBeIncluded) {
                if (currentValue.startsWith(incomplete)
                        && (isRepeatingProperty || !inExistingValues(currentValue, valuesAndSpecialValuesBefore,
                                valuesAndSpecialValuesAfter))) {
                    proposals.add(new AutocompleteProposal(currentValue));
                }
            }
        }
    }
    return proposals;
}