Search in sources :

Example 6 with JsArrayInteger

use of com.google.gwt.core.client.JsArrayInteger in project playn by threerings.

the class ArrayUtils method toJsArrayUnsigned.

public static JsArrayInteger toJsArrayUnsigned(byte[] data) {
    JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray();
    int len = data.length;
    for (int i = len - 1; i >= 0; i--) {
        jsan.set(i, data[i] & 255);
    }
    return jsan;
}
Also used : JsArrayInteger(com.google.gwt.core.client.JsArrayInteger)

Example 7 with JsArrayInteger

use of com.google.gwt.core.client.JsArrayInteger in project playn by threerings.

the class ArrayUtils method toJsArray.

// TODO(jgw): Get rid of these conversions in web mode.
public static JsArrayInteger toJsArray(byte[] data) {
    JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray();
    int len = data.length;
    for (int i = len - 1; i >= 0; i--) {
        jsan.set(i, data[i]);
    }
    return jsan;
}
Also used : JsArrayInteger(com.google.gwt.core.client.JsArrayInteger)

Example 8 with JsArrayInteger

use of com.google.gwt.core.client.JsArrayInteger in project playn by threerings.

the class ArrayUtils method toJsArray.

public static JsArrayInteger toJsArray(short[] data) {
    JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray();
    int len = data.length;
    for (int i = len - 1; i >= 0; i--) {
        jsan.set(i, data[i]);
    }
    return jsan;
}
Also used : JsArrayInteger(com.google.gwt.core.client.JsArrayInteger)

Example 9 with JsArrayInteger

use of com.google.gwt.core.client.JsArrayInteger in project playn by threerings.

the class ArrayUtils method toJsArrayUnsigned.

public static JsArrayInteger toJsArrayUnsigned(short[] data) {
    JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray();
    int len = data.length;
    for (int i = len - 1; i >= 0; i--) {
        jsan.set(i, data[i] & 65535);
    }
    return jsan;
}
Also used : JsArrayInteger(com.google.gwt.core.client.JsArrayInteger)

Example 10 with JsArrayInteger

use of com.google.gwt.core.client.JsArrayInteger in project rstudio by rstudio.

the class SpellingService method checkSpelling.

public void checkSpelling(List<String> words, final ServerRequestCallback<SpellCheckerResult> callback) {
    // results to return
    final SpellCheckerResult spellCheckerResult = new SpellCheckerResult();
    // only send words to the server that aren't in the cache
    final ArrayList<String> wordsToCheck = new ArrayList<String>();
    for (int i = 0; i < words.size(); i++) {
        String word = words.get(i);
        Boolean isCorrect = previousResults_.get(word);
        if (isCorrect != null) {
            if (isCorrect)
                spellCheckerResult.getCorrect().add(word);
            else
                spellCheckerResult.getIncorrect().add(word);
        } else {
            wordsToCheck.add(word);
        }
    }
    // if there are no words to check then return
    if (wordsToCheck.size() == 0) {
        callback.onResponseReceived(spellCheckerResult);
        return;
    }
    // hit the server
    server_.checkSpelling(JsUtil.toJsArrayString(wordsToCheck), new ServerRequestCallback<JsArrayInteger>() {

        @Override
        public void onResponseReceived(JsArrayInteger result) {
            // get misspelled indexes
            ArrayList<Integer> misspelledIndexes = new ArrayList<Integer>();
            for (int i = 0; i < result.length(); i++) misspelledIndexes.add(result.get(i));
            // determine correct/incorrect status and populate result & cache
            for (int i = 0; i < wordsToCheck.size(); i++) {
                String word = wordsToCheck.get(i);
                if (misspelledIndexes.contains(i)) {
                    spellCheckerResult.getIncorrect().add(word);
                    previousResults_.put(word, false);
                } else {
                    spellCheckerResult.getCorrect().add(word);
                    previousResults_.put(word, true);
                }
            }
            // return result
            callback.onResponseReceived(spellCheckerResult);
        }

        @Override
        public void onError(ServerError error) {
            callback.onError(error);
        }
    });
}
Also used : JsArrayInteger(com.google.gwt.core.client.JsArrayInteger) ServerError(org.rstudio.studio.client.server.ServerError) SpellCheckerResult(org.rstudio.studio.client.common.spelling.model.SpellCheckerResult) JsArrayInteger(com.google.gwt.core.client.JsArrayInteger) ArrayList(java.util.ArrayList) JsArrayString(com.google.gwt.core.client.JsArrayString)

Aggregations

JsArrayInteger (com.google.gwt.core.client.JsArrayInteger)14 JsArrayString (com.google.gwt.core.client.JsArrayString)4 ArrayList (java.util.ArrayList)4 JsArrayBoolean (com.google.gwt.core.client.JsArrayBoolean)2 ServerError (org.rstudio.studio.client.server.ServerError)2 RnwOptionCompletionResult (org.rstudio.studio.client.workbench.views.source.model.RnwChunkOptions.RnwOptionCompletionResult)2 Jso (org.eclipse.che.ide.collections.Jso)1 Match (org.rstudio.core.client.regex.Match)1 Completions (org.rstudio.studio.client.common.codetools.Completions)1 SpellCheckerResult (org.rstudio.studio.client.common.spelling.model.SpellCheckerResult)1 Range (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range)1