Example usage for com.google.gwt.core.client ScriptInjector TOP_WINDOW

List of usage examples for com.google.gwt.core.client ScriptInjector TOP_WINDOW

Introduction

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

Prototype

JavaScriptObject TOP_WINDOW

To view the source code for com.google.gwt.core.client ScriptInjector TOP_WINDOW.

Click Source Link

Document

Returns the top level window object.

Usage

From source file:gwt.material.design.components.client.jquery.api.JQuery.java

License:Apache License

@JsOverlay
public static Element window() {
    return ScriptInjector.TOP_WINDOW.cast();
}

From source file:io.pelle.mango.client.web.MangoClientWeb.java

License:Open Source License

/** {@inheritDoc} */
@Override/*  ww w  .  jav a 2s  .  c  o  m*/
public void onModuleLoad() {

    instance = this;

    String dictionaryScriptUrl = com.google.gwt.core.client.GWT.getModuleBaseURL()
            + "../remote/systemservice/getdictionaryi18nscript?variableName=dictionary";
    ScriptInjector.fromUrl(dictionaryScriptUrl).setCallback(new Callback<Void, Exception>() {
        public void onFailure(Exception reason) {
            GWT.log("failed to load dictionary translations from .");
        }

        public void onSuccess(Void result) {
            Dictionary dictionary = Dictionary.getDictionary("dictionary");

            if (mangoProvider instanceof MangoGwtImplProvider) {
                ((MangoGwtImplProvider) mangoProvider).setDictionary(dictionary);
            }

        }
    }).setRemoveTag(false).setWindow(ScriptInjector.TOP_WINDOW).inject();

    init();
}

From source file:io.reinert.requestor.auth.MD5.java

License:Apache License

private static void inject() {
    ScriptInjector.fromString("(function(){function n(f,d){var c=f[0],a=f[1],b=f[2],e=f[3],c=g(c,a,b,e,d[0],7,"
            + "-680876936),e=g(e,c,a,b,d[1],12,-389564586),b=g(b,e,c,a,d[2],17,606105819),a=g(a,b,e,c,d[3],22,"
            + "-1044525330),c=g(c,a,b,e,d[4],7,-176418897),e=g(e,c,a,b,d[5],12,1200080426),b=g(b,e,c,a,d[6],17,"
            + "-1473231341),a=g(a,b,e,c,d[7],22,-45705983),c=g(c,a,b,e,d[8],7,1770035416),e=g(e,c,a,b,d[9],12,"
            + "-1958414417),b=g(b,e,c,a,d[10],17,-42063),a=g(a,b,e,c,d[11],22,-1990404162),c=g(c,a,b,e,d[12],7,"
            + "1804603682),e=g(e,c,a,b,d[13],12,-40341101),\n"
            + "b=g(b,e,c,a,d[14],17,-1502002290),a=g(a,b,e,c,d[15],22,1236535329),c=k(c,a,b,e,d[1],5,-165796510),"
            + "e=k(e,c,a,b,d[6],9,-1069501632),b=k(b,e,c,a,d[11],14,643717713),a=k(a,b,e,c,d[0],20,-373897302),c=k"
            + "(c,a,b,e,d[5],5,-701558691),e=k(e,c,a,b,d[10],9,38016083),b=k(b,e,c,a,d[15],14,-660478335),a=k(a,b,"
            + "e,c,d[4],20,-405537848),c=k(c,a,b,e,d[9],5,568446438),e=k(e,c,a,b,d[14],9,-1019803690),b=k(b,e,c,a,"
            + "d[3],14,-187363961),a=k(a,b,e,c,d[8],20,1163531501),c=k(c,a,b,e,d[13],5,-1444681467),e=k(e,c,a,b,"
            + "d[2],9,-51403784),\n"
            + "b=k(b,e,c,a,d[7],14,1735328473),a=k(a,b,e,c,d[12],20,-1926607734),c=h(a^b^e,c,a,d[5],4,-378558),e=h"
            + "(c^a^b,e,c,d[8],11,-2022574463),b=h(e^c^a,b,e,d[11],16,1839030562),a=h(b^e^c,a,b,d[14],23,-35309556)"
            + ",c=h(a^b^e,c,a,d[1],4,-1530992060),e=h(c^a^b,e,c,d[4],11,1272893353),b=h(e^c^a,b,e,d[7],16,"
            + "-155497632),a=h(b^e^c,a,b,d[10],23,-1094730640),c=h(a^b^e,c,a,d[13],4,681279174),e=h(c^a^b,e,c,d[0],"
            + "11,-358537222),b=h(e^c^a,b,e,d[3],16,-722521979),a=h(b^e^c,a,b,d[6],23,76029189),c=h(a^b^e,c,a,d[9],"
            + "4,-640364487),\n"
            + "e=h(c^a^b,e,c,d[12],11,-421815835),b=h(e^c^a,b,e,d[15],16,530742520),a=h(b^e^c,a,b,d[2],23,"
            + "-995338651),c=l(c,a,b,e,d[0],6,-198630844),e=l(e,c,a,b,d[7],10,1126891415),b=l(b,e,c,a,d[14],15,"
            + "-1416354905),a=l(a,b,e,c,d[5],21,-57434055),c=l(c,a,b,e,d[12],6,1700485571),e=l(e,c,a,b,d[3],10,"
            + "-1894986606),b=l(b,e,c,a,d[10],15,-1051523),a=l(a,b,e,c,d[1],21,-2054922799),c=l(c,a,b,e,d[8],6,"
            + "1873313359),e=l(e,c,a,b,d[15],10,-30611744),b=l(b,e,c,a,d[6],15,-1560198380),a=l(a,b,e,c,d[13],21,"
            + "1309151649),c=l(c,a,b,e,\n"
            + "d[4],6,-145523070),e=l(e,c,a,b,d[11],10,-1120210379),b=l(b,e,c,a,d[2],15,718787259),a=l(a,b,e,c,"
            + "d[9],21,-343485551);f[0]=m(c,f[0]);f[1]=m(a,f[1]);f[2]=m(b,f[2]);f[3]=m(e,f[3])}function h(f,d,c,a,"
            + "b,e){d=m(m(d,f),m(a,e));return m(d<<b|d>>>32-b,c)}function g(f,d,c,a,b,e,g){return h(d&c|~d&a,f,d,b,"
            + "e,g)}function k(f,d,c,a,b,e,g){return h(d&a|c&~a,f,d,b,e,g)}function l(f,d,c,a,b,e,g){return h(c^"
            + "(d|~a),f,d,b,e,g)}function p(f){var d=f;txt=\"\";var c=d.length;f=[1732584193,-271733879,"
            + "-1732584194,271733878];\n"
            + "var a;for(a=64;a<=d.length;a+=64){for(var b=d.substring(a-64,a),e=[],g=void 0,g=0;64>g;g+=4)"
            + "e[g>>2]=b.charCodeAt(g)+(b.charCodeAt(g+1)<<8)+(b.charCodeAt(g+2)<<16)+(b.charCodeAt(g+3)<<24);n(f,"
            + "e)}d=d.substring(a-64);b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(a=0;a<d.length;a++)b[a>>2]|=d"
            + ".charCodeAt(a)<<(a%4<<3);b[a>>2]|=128<<(a%4<<3);if(55<a)for(n(f,b),a=0;16>a;a++)b[a]=0;b[14]=8*c;n"
            + "(f,b);for(d=0;d<f.length;d++){c=f[d];a=\"\";for(b=0;4>b;b++)a+=q[c>>8*b+4&15]+q[c>>8*b&15];"
            + "f[d]=a}return f.join(\"\")}function m(f,\n"
            + "d){return f+d&4294967295}var q=\"0123456789abcdef\".split(\"\");"
            + "\"5d41402abc4b2a76b9719d911017c592\"!=p(\"hello\")&&(m=function(f,d){var c=(f&65535)+(d&65535);"
            + "return(f>>16)+(d>>16)+(c>>16)<<16|c&65535});window.md5hash=p})()")
            .setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:mx.org.pescadormvp.core.client.components.GlobalSetup.java

private static void launchScriptInjector(final String url) {

    ScriptInjector.fromUrl(url).setWindow(ScriptInjector.TOP_WINDOW)
            .setCallback(new Callback<Void, Exception>() {

                public void onFailure(Exception reason) {
                    pendingLogs.add(new PendingLog(Level.SEVERE, "Failed to load JS " + url));

                    scriptsFailedToLoad.add(url);
                    scriptInjectReturned();
                }//  ww w. ja  v a2s. com

                public void onSuccess(Void result) {
                    pendingLogs.add(new PendingLog(Level.INFO, "Successfully loaded JS " + url));

                    scriptsLoaded.add(url);
                    scriptInjectReturned();
                }

            }).inject();
}

From source file:net.codemirror.lib.Loader.java

License:Apache License

static void injectScript(SafeUri js, final AsyncCallback<Void> callback) {
    final ScriptElement[] script = new ScriptElement[1];
    script[0] = ScriptInjector.fromUrl(js.asString()).setWindow(ScriptInjector.TOP_WINDOW)
            .setCallback(new Callback<Void, Exception>() {
                @Override//  www . j  a  va  2  s .  co m
                public void onSuccess(Void result) {
                    script[0].removeFromParent();
                    callback.onSuccess(result);
                }

                @Override
                public void onFailure(Exception reason) {
                    error(reason);
                    callback.onFailure(reason);
                }
            }).inject().cast();
}

From source file:nz.co.doltech.gwtjui.demo.client.DemoEntryPoint.java

License:Apache License

@Override
public void onModuleLoad() {
    ScriptInjector.fromString(DemoClientBundle.INSTANCE.prettify().getText())
            .setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:org.apache.hupa.client.Hupa.java

License:Apache License

@Override
public void onModuleLoad() {
    InstrumentationLoggerProvider.set(new gwtTestSelection.client.InstrumentationLogger());
    ScriptInjector.fromString(//from  w ww.j  av a  2  s . c om
            "var nameSuffix = ''; var record = false; var nodeIdCounter = 0; var bufferedNodeIdentifiers = {}; var testCaseName = window.top.location.search.substring(1); var loggingServer = new WebSocket('ws://localhost:8090/loggingServer'); loggingServer.onopen = function() {}; loggingServer.onmessage = function(evt) { if(evt.data=='0') {flushNodeIdentifiers(nameSuffix); record = false; } else if(evt.data=='1') {record = true; flushNodeIdentifiers(nameSuffix); nameSuffix = ''; } else if(evt.data!==undefined) {flushNodeIdentifiers(nameSuffix); nameSuffix = evt.data; record = true; } }; loggingServer.onclose = function() { flushNodeIdentifiers(nameSuffix) }; function flushNodeIdentifiers(nameSufx) { if(nodeIdCounter > 0) { if(loggingServer.readyState === 1) { loggingServer.send('testName='+testCaseName+'&nr='+JSON.stringify(bufferedNodeIdentifiers)+'&testSuffix='+nameSufx); bufferedNodeIdentifiers = {}; nodeIdCounter = 0; } else { setTimeout(function() { flushNodeIdentifiers(nameSuffix); },250); } } } function sendToLoggingServer(nodeIdentifier) { if(!record) {return;} bufferedNodeIdentifiers[nodeIdentifier]=nodeIdentifier; nodeIdCounter++; if(nodeIdCounter > 1200) { flushNodeIdentifiers(nameSuffix); } }")
            .setRemoveTag(false).setWindow(ScriptInjector.TOP_WINDOW).inject();
    InstrumentationLoggerProvider.get().instrument("org_apache_hupa_client_Hupa_java0x031c56b958af03dc2");
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x0_____org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x2_____org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x1");
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_Hupa_java0x031c56b950x1_____org_apache_hupa_client_Hupa_java0x031c56b95_____org_apache_hupa_client_Hupa_java0x031c56b950x0");
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x20x00x0_____org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x20x0");
    handleExceptionsAsync();
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x20x10x0_____org_apache_hupa_client_Hupa_java0x031c56b958af03dc20x20x1");
    initApp();
}

From source file:org.bonitasoft.console.client.JsInjector.java

License:Open Source License

public void inject(String script) {
    ScriptInjector.fromString(script).setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:org.consoli.filesaver.client.Initializer.java

License:Apache License

@Override
public void onModuleLoad() {
    final String scriptTextFromResource = Resources.INSTANCE.fileSaverJavaScript().getText();
    final FromString inlinedScript = ScriptInjector.fromString(scriptTextFromResource);
    inlinedScript.setRemoveTag(false).setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:org.cruxframework.crux.core.client.html5.api.MutationObserver.java

License:Apache License

private static void injectPolyfill(ExternalTextResource resource,
        final ResourceCallback<TextResource> resourceCallback) {
    try {//from   w  w  w.  j av  a 2  s  . c  o m
        resource.getText(new ResourceCallback<TextResource>() {
            @Override
            public void onError(ResourceException e) {
                resourceCallback.onError(e);
            }

            @Override
            public void onSuccess(final TextResource resource) {
                ScriptInjector.fromString(resource.getText()).setWindow(ScriptInjector.TOP_WINDOW)
                        .setRemoveTag(true).inject();
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                    @Override
                    public void execute() {
                        resourceCallback.onSuccess(resource);
                    }
                });
            }
        });
    } catch (ResourceException e) {
        resourceCallback.onError(e);
    }
}