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

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

Introduction

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

Prototype

public final native String shift() ;

Source Link

Document

Shifts the first value off the array.

Usage

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * A repeat entry is used to indicate that the command following is repeated
 * multiple times./*  www. jav  a 2 s.  co  m*/
 */
private void parseV8RepeatEntry(JsArrayString logEntries) {
    int numRepeats = Integer.parseInt(logEntries.get(1));
    // run the command after the first 2 arguments numRepeats times.
    logEntries.shift();
    logEntries.shift();
    for (int i = 0; i < numRepeats; ++i) {
        parseLogEntry(logEntries);
    }
}

From source file:com.vaadin.client.ApplicationConnection.java

License:Apache License

public void loadScriptDependencies(final JsArrayString dependencies) {
    if (dependencies.length() == 0) {
        return;//from  w  ww .  java2s . c om
    }

    // Listener that loads the next when one is completed
    ResourceLoadListener resourceLoadListener = new ResourceLoadListener() {
        @Override
        public void onLoad(ResourceLoadEvent event) {
            if (dependencies.length() != 0) {
                String url = translateVaadinUri(dependencies.shift());
                ApplicationConfiguration.startDependencyLoading();
                // Load next in chain (hopefully already preloaded)
                event.getResourceLoader().loadScript(url, this);
            }
            // Call start for next before calling end for current
            ApplicationConfiguration.endDependencyLoading();
        }

        @Override
        public void onError(ResourceLoadEvent event) {
            getLogger().severe(event.getResourceUrl() + " could not be loaded.");
            // The show must go on
            onLoad(event);
        }
    };

    ResourceLoader loader = ResourceLoader.get();

    // Start chain by loading first
    String url = translateVaadinUri(dependencies.shift());
    ApplicationConfiguration.startDependencyLoading();
    loader.loadScript(url, resourceLoadListener);

    if (ResourceLoader.supportsInOrderScriptExecution()) {
        for (int i = 0; i < dependencies.length(); i++) {
            String preloadUrl = translateVaadinUri(dependencies.get(i));
            loader.loadScript(preloadUrl, null);
        }
    } else {
        // Preload all remaining
        for (int i = 0; i < dependencies.length(); i++) {
            String preloadUrl = translateVaadinUri(dependencies.get(i));
            loader.preloadResource(preloadUrl, null);
        }
    }
}

From source file:org.opencms.ui.client.CmsWidgetSetEntryPoint.java

License:Open Source License

/**
 * Loads JavaScript resources into the window context.<p>
 *
 * @param dependencies the dependencies to load
 * @param callback the callback to execute once the resources are loaded
 *//*w ww  .  ja  v  a 2  s. c o  m*/
public static void loadScriptDependencies(final JsArrayString dependencies, final JavaScriptObject callback) {

    if (dependencies.length() == 0) {
        return;
    }

    // Listener that loads the next when one is completed
    ResourceLoadListener resourceLoadListener = new ResourceLoadListener() {

        @Override
        public void onError(ResourceLoadEvent event) {

            CmsDebugLog.consoleLog(event.getResourceUrl() + " could not be loaded.");
            // The show must go on
            onLoad(event);
        }

        @Override
        public void onLoad(ResourceLoadEvent event) {

            if (dependencies.length() != 0) {
                String url = dependencies.shift();
                // Load next in chain (hopefully already preloaded)
                event.getResourceLoader().loadScript(url, this);
            } else {
                // finished loading dependencies
                callNativeFunction(callback);
            }
        }
    };

    ResourceLoader loader = ResourceLoader.get();

    // Start chain by loading first
    String url = dependencies.shift();
    loader.loadScript(url, resourceLoadListener);
    if (ResourceLoader.supportsInOrderScriptExecution()) {
        for (int i = 0; i < dependencies.length(); i++) {
            String preloadUrl = dependencies.get(i);
            loader.loadScript(preloadUrl, null);
        }
    } else {
        // Preload all remaining
        for (int i = 0; i < dependencies.length(); i++) {
            String preloadUrl = dependencies.get(i);
            loader.preloadResource(preloadUrl, null);
        }
    }
}