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

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

Introduction

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

Prototype

public final native String join(String separator) ;

Source Link

Document

Convert each element of the array to a String and join them with a comma separator.

Usage

From source file:com.badlogic.gdx.backends.gwt.GwtMusic.java

License:Apache License

public GwtMusic(FileHandle file) {
    String url;/*w  w  w . jav  a2  s  .co m*/
    if (file.type() == Files.FileType.Internal && !(file instanceof AsyncFileHandle)) {
        url = ((GwtApplication) Gdx.app).getBaseUrl() + file.path();
    } else {
        byte[] data = file.readBytes();
        char[] encodedChars = Base64Coder.encode(data);

        //WTF, GWT?
        JsArrayString parts = (JsArrayString) JsArrayString.createArray();
        parts.push("data:audio/wav;base64,");
        for (int i = 0; i < encodedChars.length; i += 1024) {
            String part = new String(encodedChars, i, Math.min(1024, encodedChars.length - i));
            parts.push(part);
        }
        url = parts.join("");
    }
    sound = SoundManager.createSound(url);
    soundOptions = new SMSoundOptions();
    soundOptions.callback = this;
}

From source file:com.emitrom.ti4j.mobile.client.cloud.chats.ChatMessage.java

License:Apache License

/**
 * Comma separated user id(s) of the recipient(s). The current user id and
 * to_ids together determine which chat group a message belongs to.
 * <p>/*from ww  w. j a  v a2s  .  c  o m*/
 * Alternatively, you can use chat_group_id to identify a chat group
 * instead.
 * 
 * @param ids
 */
public void setToIds(String... ids) {
    JsArrayString toIds = JsArrayString.createArray().cast();
    for (String s : ids) {
        toIds.push(s);
    }
    setToIds(toIds.join(","));
}

From source file:com.emitrom.ti4j.mobile.client.cloud.core.Query.java

License:Apache License

/**
 * Comma separated user id(s) of the recipient(s). The current user id and
 * to_ids together determine which chat group a message belongs to.
 * <p>/*from  w  w w  . j a va2s  .  c o m*/
 * Alternatively, you can use chat_group_id to identify a chat group
 * instead.
 * 
 * @param ids
 */
public void setParticipateIds(String... ids) {
    JsArrayString toIds = JsArrayString.createArray().cast();
    for (String s : ids) {
        toIds.push(s);
    }
    setParticipateIds(toIds.join(","));
}

From source file:edu.caltech.ipac.firefly.fftools.FitsViewerJSInterface.java

public static void overlayRegionData(JsArrayString regionData, final String regionLayerId, final String title,
        final String plotId) {
    final String regText = "[" + regionData.join(StringUtils.STRING_SPLIT_TOKEN) + "]";
    final String[] plotIdArr = (plotId == null) ? null : new String[] { plotId };

    // load region data now if we have at least one loaded MiniPlotWidget with matching plot id
    for (MiniPlotWidget mpw : AllPlots.getInstance().getAll()) {
        if (plotId == null || plotId.equals(mpw.getPlotId())) {
            RegionLoader.loadRegion(title, regText, null, regionLayerId, plotIdArr);
            break;
        }/*from  ww  w.  j  av  a  2s  .  c o  m*/
    }
    // load region data later if we have loading MiniPlotWidgets
    for (MiniPlotWidget mpw : mpwMap.values()) {
        if (mpw.getPlotId() == null) {
            ArrayList<AsyncCallback<MiniPlotWidget>> callbacks = mpwCallbacks.get(mpw);
            if (callbacks == null) {
                callbacks = new ArrayList<AsyncCallback<MiniPlotWidget>>();
                mpwCallbacks.put(mpw, callbacks);
            }
            callbacks.add(new AsyncCallback<MiniPlotWidget>() {
                @Override
                public void onFailure(Throwable caught) {
                }

                @Override
                public void onSuccess(MiniPlotWidget result) {
                    if (plotId == null || plotId.equals(result.getPlotId())) {
                        RegionLoader.loadRegion(title, regText, null, regionLayerId, plotIdArr);
                    }
                }
            });
        }
    }
}

From source file:edu.caltech.ipac.firefly.fftools.FitsViewerJSInterface.java

public static void removeRegionData(JsArrayString regionData, String regionLayerId) {
    String regText = "[" + regionData.join(StringUtils.STRING_SPLIT_TOKEN) + "]";
    RegionLoader.removeFromRegion(regText, regionLayerId);
}

From source file:org.eclipse.che.ide.editor.codemirror.client.CodeMirrorEditorExtension.java

License:Open Source License

private void setupFullCodeMirror(final InitializerCallback callback) {
    /*//from w ww.j av  a  2 s  .  c  o m
     * This could be simplified and optimized with a all-in-one minified js from http://codemirror.net/doc/compress.html but at least
     * while debugging, unmodified source is necessary. Another option would be to include all-in-one minified along with a source map
     */
    final String[] scripts = new String[] {

            // base script
            codemirrorBase + "lib/codemirror",

            // library of modes
            codemirrorBase + "mode/meta",
            // mode autoloading
            codemirrorBase + "addon/mode/loadmode",

            /* We will preload modes that have extensions */
            // language modes
            codemirrorBase + "mode/xml/xml", codemirrorBase + "mode/htmlmixed/htmlmixed", // must be defined after xml

            codemirrorBase + "mode/javascript/javascript", codemirrorBase + "mode/coffeescript/coffeescript",

            codemirrorBase + "mode/css/css",

            codemirrorBase + "mode/sql/sql",

            codemirrorBase + "mode/clike/clike",

            codemirrorBase + "mode/markdown/markdown", codemirrorBase + "mode/gfm/gfm", // markdown extension for github

            // hints
            codemirrorBase + "addon/hint/show-hint", codemirrorBase + "addon/hint/xml-hint",
            codemirrorBase + "addon/hint/html-hint", codemirrorBase + "addon/hint/javascript-hint",
            codemirrorBase + "addon/hint/css-hint", codemirrorBase + "addon/hint/anyword-hint",
            codemirrorBase + "addon/hint/sql-hint",

            // pair matching
            codemirrorBase + "addon/edit/closebrackets", codemirrorBase + "addon/edit/closetag",
            codemirrorBase + "addon/edit/matchbrackets", codemirrorBase + "addon/edit/matchtags",
            // the two following are added to repair actual functionality in 'classic' editor
            codemirrorBase + "addon/selection/mark-selection", codemirrorBase + "addon/selection/active-line",

            // for search
            codemirrorBase + "addon/search/search", codemirrorBase + "addon/dialog/dialog",
            codemirrorBase + "addon/search/searchcursor", codemirrorBase + "addon/search/match-highlighter",
            // comment management
            codemirrorBase + "addon/comment/comment", codemirrorBase + "addon/comment/continuecomment",
            // folding
            codemirrorBase + "addon/fold/foldcode", codemirrorBase + "addon/fold/foldgutter",
            codemirrorBase + "addon/fold/brace-fold", codemirrorBase + "addon/fold/xml-fold", // also required by matchbrackets and closebrackets
            codemirrorBase + "addon/fold/comment-fold", codemirrorBase + "addon/fold/indent-fold",
            codemirrorBase + "addon/fold/markdown-fold",

            codemirrorBase + "addon/scroll/simplescrollbars", codemirrorBase + "addon/scroll/annotatescrollbar",
            codemirrorBase + "addon/scroll/scrollpastend",
            codemirrorBase + "addon/search/matchesonscrollbar", };

    this.requireJsLoader.require(new Callback<JavaScriptObject[], Throwable>() {
        @Override
        public void onSuccess(final JavaScriptObject[] result) {
            editorModule.setReady();
            callback.onSuccess();
        }

        @Override
        public void onFailure(final Throwable e) {
            if (e instanceof JavaScriptException) {
                final JavaScriptException jsException = (JavaScriptException) e;
                final Object nativeException = jsException.getThrown();
                if (nativeException instanceof RequireError) {
                    final RequireError requireError = (RequireError) nativeException;
                    final String errorType = requireError.getRequireType();
                    String message = "Codemirror injection failed: " + errorType + " ";
                    final JsArrayString modules = requireError.getRequireModules();
                    if (modules != null) {
                        message += modules.join(",");
                    }
                    Log.debug(CodeMirrorEditorExtension.class, message);
                }
            }
            initializationFailed(callback, "Unable to initialize CodeMirror", e);
        }
    }, scripts, new String[] { CODEMIRROR_MODULE_KEY });

}

From source file:org.eclipse.che.ide.editor.orion.client.EditorInitializePromiseHolder.java

License:Open Source License

private void injectOrion(final AsyncCallback<Void> callback) {
    loader.setMessage(waitEditorMessage);
    final String[] scripts = new String[] { "built-codeEdit/code_edit/built-codeEdit-amd",
            "orion/CheContentAssistMode" };

    requireJsLoader.require(new Callback<JavaScriptObject[], Throwable>() {
        @Override// ww  w  .ja v  a2s.  com
        public void onSuccess(final JavaScriptObject[] result) {
            requireOrion(callback);
        }

        @Override
        public void onFailure(final Throwable e) {
            if (e instanceof JavaScriptException) {
                final JavaScriptException jsException = (JavaScriptException) e;
                final Object nativeException = jsException.getThrown();
                if (nativeException instanceof RequireError) {
                    final RequireError requireError = (RequireError) nativeException;
                    final String errorType = requireError.getRequireType();
                    String message = "Orion injection failed: " + errorType;
                    final JsArrayString modules = requireError.getRequireModules();
                    if (modules != null) {
                        message += modules.join(",");
                    }
                    Log.debug(OrionEditorExtension.class, message);
                }
            }
            initializationFailed(callback, "Failed to inject Orion editor", e);
        }
    }, scripts, new String[0]);

    injectCssLink(GWT.getModuleBaseForStaticFiles() + "built-codeEdit/code_edit/built-codeEdit.css");
}

From source file:org.eclipse.che.ide.editor.orion.client.OrionEditorExtension.java

License:Open Source License

private void injectOrion(final InitializerCallback callback) {
    final String[] scripts = new String[] { "built-codeEdit-11.0/code_edit/built-codeEdit-amd",
            "orion/CheContentAssistMode" };

    requireJsLoader.require(new Callback<JavaScriptObject[], Throwable>() {
        @Override/*from   w w  w. j a v a  2s.  c o  m*/
        public void onSuccess(final JavaScriptObject[] result) {
            requireOrion(callback);
        }

        @Override
        public void onFailure(final Throwable e) {
            if (e instanceof JavaScriptException) {
                final JavaScriptException jsException = (JavaScriptException) e;
                final Object nativeException = jsException.getThrown();
                if (nativeException instanceof RequireError) {
                    final RequireError requireError = (RequireError) nativeException;
                    final String errorType = requireError.getRequireType();
                    String message = "Orion injection failed: " + errorType;
                    final JsArrayString modules = requireError.getRequireModules();
                    if (modules != null) {
                        message += modules.join(",");
                    }
                    Log.debug(OrionEditorExtension.class, message);
                }
            }
            initializationFailed(callback, "Failed to inject Orion editor", e);
        }
    }, scripts, new String[0]);

    injectCssLink(GWT.getModuleBaseForStaticFiles() + "built-codeEdit-11.0/code_edit/built-codeEdit.css");
}

From source file:org.rstudio.studio.client.common.r.roxygen.RoxygenHelper.java

License:Open Source License

private void amendExistingRoxygenBlock(int row, String objectName, JsArrayString argNames,
        JsArrayString argTypes, String tagName, Pattern pattern) {
    // Get the range encompassing this Roxygen block.
    Range range = getRoxygenBlockRange(row);

    // Extract that block (as an array of strings)
    JsArrayString block = extractRoxygenBlock(editor_.getWidget().getEditor(), range);

    // If the block contains roxygen parameters that require
    // non-local information (e.g. @inheritParams), then
    // bail./*from ww w  . j  a  v  a  2  s  .co  m*/
    for (int i = 0; i < block.length(); i++) {
        if (RE_ROXYGEN_NONLOCAL.test(block.get(i))) {
            view_.showWarningBar(
                    "Cannot automatically update roxygen blocks " + "that are not self-contained.");
            return;
        }
    }

    String roxygenDelim = RE_ROXYGEN.match(block.get(0), 0).getGroup(1);

    // The replacement block (we build by munging parts of
    // the old block
    JsArrayString replacement = JsArray.createArray().cast();

    // Scan through the block to get the names of
    // pre-existing parameters.
    JsArrayString params = listParametersInRoxygenBlock(block, pattern);

    // Figure out what parameters need to be removed, and remove them.
    // Any parameter not mentioned in the current function's argument list
    // should be stripped out.
    JsArrayString paramsToRemove = setdiff(params, argNames);

    int blockLength = block.length();
    for (int i = 0; i < blockLength; i++) {
        // If we encounter a param we don't want to extract, then
        // move over it.
        Match match = pattern.match(block.get(i), 0);
        if (match != null && contains(paramsToRemove, match.getGroup(1))) {
            i++;
            while (i < blockLength && !RE_ROXYGEN_WITH_TAG.test(block.get(i)))
                i++;

            i--;
            continue;
        }

        replacement.push(block.get(i));
    }

    // Now, add example roxygen for any parameters that are
    // present in the function prototype, but not present
    // within the roxygen block.
    int insertionPosition = findParamsInsertionPosition(replacement, pattern);
    JsArrayInteger indices = setdiffIndices(argNames, params);

    // NOTE: modifies replacement
    insertNewTags(replacement, argNames, argTypes, indices, roxygenDelim, tagName, insertionPosition);

    // Ensure space between final param and next tag
    ensureSpaceBetweenFirstParamAndPreviousEntry(replacement, roxygenDelim, pattern);
    ensureSpaceBetweenFinalParamAndNextTag(replacement, roxygenDelim, pattern);

    // Apply the replacement.
    editor_.getSession().replace(range, replacement.join("\n") + "\n");
}

From source file:org.rstudio.studio.client.workbench.views.source.editors.text.rmd.display.SetupChunkOptionsPopupPanel.java

License:Open Source License

private String getChunkText() {
    int chunkStart = position_.getRow();
    int chunkEnd = findEndOfChunk();
    JsArrayString chunkText = display_.getLines(chunkStart + 1, chunkEnd - 1);
    return chunkText.join("\n");
}