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:org.daxplore.presenter.client.json.shared.JsonTools.java

License:Open Source License

/**
 * Convert a {@link JsArrayString} to a List<String>.
 * //from  w  w w.  j  a  va2s . c o m
 * @param jsArray
 *            the js array
 * @return the list
 */
public static List<String> jsArrayAsList(JsArrayString jsArray) {
    List<String> list = new LinkedList<String>();
    for (int i = 0; i < jsArray.length(); i++) {
        list.add(jsArray.get(i));
    }
    return list;
}

From source file:org.ducktools.tutorial.gwt.architecture.photoalbum.client.commons.dispatcher.AlbumListDispatchAsync.java

License:Open Source License

public AlbumListDispatchAsync() {

    JsArrayString initialAlbums = initFromPage();

    currentAlbumList = new ArrayList<Album>(initialAlbums.length());

    for (int i = 0; i < initialAlbums.length(); i++) {

        Album album = new Album();
        album.setName(initialAlbums.get(i));
        currentAlbumList.add(album);//from w  w  w .  java2s  .  c  o  m

    }

}

From source file:org.ebayopensource.turmeric.monitoring.client.model.MetricsMetaDataResponse.java

License:Open Source License

/**
 * Gets the ordered resource entity response names.
 *
 * @return the ordered resource entity response names
 *///from  w  w w.  j  av  a2  s  .  c  o  m
public final Set<String> getOrderedResourceEntityResponseNames() {
    JsArrayString array = getResourceEntityResponseNames();
    Set<String> set = new TreeSet<String>();
    if (array != null) {
        for (int i = 0; i < array.length(); i++) {
            set.add(array.get(i));
        }
    }
    return set;
}

From source file:org.ebayopensource.turmeric.policy.adminui.client.model.policy.CreateSubjectGroupsResponseJS.java

License:Open Source License

/**
* Gets the subject group ids./*from   w  w  w. ja  v a  2  s. c o  m*/
* 
* @return the subject group ids
* @see org.ebayopensource.turmeric.policy.adminui.client.model.policy.PolicyQueryService.CreateSubjectGroupsResponse#getSubjectGroupIds()
*/
public final List<Long> getSubjectGroupIds() {
    JsArrayString idsAsStrings = getSubjectGroupIdsAsStrings();
    List<Long> results = new ArrayList<Long>();
    if (idsAsStrings != null) {
        for (int i = 0; i < idsAsStrings.length(); i++) {
            String s = idsAsStrings.get(i);
            results.add(Long.valueOf(s));
        }
    }
    return results;
}

From source file:org.ebayopensource.turmeric.policy.adminui.client.model.policy.CreateSubjectsResponseJS.java

License:Open Source License

/**
 * Gets the subject ids./* w  ww. j av a 2 s .  c  om*/
 * 
 * @return the subject ids
 * @see org.ebayopensource.turmeric.policy.adminui.client.model.policy.PolicyQueryService.CreateSubjectsResponse#getSubjectIds()
 */
public final List<Long> getSubjectIds() {
    JsArrayString idsAsStrings = getSubjectIdsAsStrings();
    List<Long> results = new ArrayList<Long>();
    if (idsAsStrings != null) {
        for (int i = 0; i < idsAsStrings.length(); i++) {
            String s = idsAsStrings.get(i);
            results.add(Long.valueOf(s));
        }
    }
    return results;
}

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

License:Open Source License

private boolean modePresent(final String modeName) {
    if (modeName == null) {
        return false;
    }//  w ww . j a  va 2s.com
    final JsArrayString modeNames = this.codeMirror.modeNames();
    for (int i = 0; i < modeNames.length(); i++) {
        if (modeName.equals(modeNames.get(i))) {
            return true;
        }
    }
    return false;
}

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

License:Open Source License

public static final String translateKeyBinding(final Keybinding keybinding,
        final CodeMirrorOverlay codemirror) {
    final StringBuilder sb = new StringBuilder();

    /*//  w w  w.ja v  a 2  s .  com
     * From CodeMirror doc at https://codemirror.net/doc/manual.html#keymaps
     *
     * Keys are identified either by name or by character. The CodeMirror.keyNames object defines names
     * for common keys and associates them with their key codes. Examples of names defined here are
     * Enter, F5, and Q. These can be prefixed with Shift-, Cmd-, Ctrl-, and Alt- (in that order!) to
     * specify a modifier. So for example, Shift-Ctrl-Space would be a valid key identifier.
     */

    // handle modifiers
    if (keybinding.isShift()) {
        sb.append(SHIFT).append("-");
    }
    if (keybinding.isCmd()) {
        sb.append(CMD).append("-");
    }
    if (keybinding.isControl()) {
        sb.append(CTRL).append("-");
    }
    if (keybinding.isAlt()) {
        sb.append(ALT).append("-");
    }
    // now add the key
    final JsArrayString keyNames = codemirror.keyNames();
    final String keyname = keyNames.get(keybinding.getKeyCode());
    if (keyname == null) {
        return null;
    }
    sb.append(keyname);

    return sb.toString();
}

From source file:org.eclipse.che.ide.editor.codemirrorjso.client.CMKeymapOverlay.java

License:Open Source License

public final List<String> getKeys() {
    final JsArrayString jsObject = keys(this);
    final List<String> result = new ArrayList<>();
    for (int i = 0; i < jsObject.length(); i++) {
        result.add(jsObject.get(i));
    }//from ww  w  . j ava  2  s. co  m
    return result;
}

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

License:Open Source License

public void registerFileType(final OrionContentTypeOverlay contentType,
        final OrionHighlightingConfigurationOverlay config) {
    // register content type and configure orion
    JsArrayString extensions = contentType.getExtensions();
    for (int i = 0; i < extensions.length(); i++) {
        String extension = extensions.get(i);
        fileTypeIdentifier.registerNewExtension(extension, newArrayList(contentType.getId()));
    }/*  w  w  w  .  ja va 2 s .  com*/

    editorModule.waitReady(new EditorModuleReadyCallback() {

        @Override
        public void onEditorModuleReady() {
            OrionServiceRegistryOverlay serviceRegistry = codeEditWidgetProvider.get().getServiceRegistry();
            serviceRegistry.doRegisterService("orion.core.contenttype", JavaScriptObject.createObject(),
                    contentType.toServiceObject());
            serviceRegistry.doRegisterService("orion.edit.highlighter", JavaScriptObject.createObject(),
                    config);
        }

        @Override
        public void onEditorModuleError() {
        }
    });

}

From source file:org.eclipse.che.ide.jseditor.client.requirejs.RequireJsLoader.java

License:Open Source License

protected static void configureGlobalErrorCallback() {
    Requirejs.get().setOnError(new RequirejsErrorHandler() {

        @Override// w  w  w .  ja va2s . co  m
        public void onError(final RequireError err) {
            final String type = err.getRequireType();
            if ("scripterror".equals(type)) {
                // leave the module as-is
                final JsArrayString modules = err.getRequireModules();
                if (modules != null && modules.length() > 0) {
                    final String failed = modules.get(0);
                    String formattedMsg = "";
                    if (err.getMessage() != null) {
                        formattedMsg = formattedMsg.replace("\n", "\n\t\t");
                    }
                    consoleWarn(
                            "Required module '%s' load failed with script error "
                                    + "(nonexistant script or error in the loaded script)\n"
                                    + "\t- error message = '%s'\n" + "\t- original error = %o",
                            failed, formattedMsg, err);
                } else {
                    consoleWarn(
                            "Unexpected requirejs of type 'scripterror' without requireModules property: %o",
                            err);
                    throw new RuntimeException(err.toString());
                }

            } else if ("timeout".equals(type)) {
                // we'll retry next time
                final JsArrayString modules = err.getRequireModules();
                if (modules != null && modules.length() > 0) {
                    final String failed = modules.get(0);
                    consoleWarn("Required module '%s' load failed on timeout.", failed);
                    Requirejs.get().undef(failed);
                } else {
                    consoleWarn("Unexpected requirejs of type 'timeout' without requireModules property: %o",
                            err);
                    throw new RuntimeException(err.toString());
                }

            } else {
                throw new RuntimeException(err.toString());
            }

        }
    });
}