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

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

Introduction

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

Prototype

public static FromString fromString(String scriptBody) 

Source Link

Document

Build an injection call for directly setting the script text in the DOM.

Usage

From source file:org.obiba.opal.web.gwt.markdown.client.MarkdownEntryPoint.java

License:Open Source License

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

From source file:org.obiba.opal.web.gwt.plot.client.PlotEntryPoint.java

License:Open Source License

@Override
public void onModuleLoad() {
    //ScriptInjector.fromString(Scripts.INSTANCE.scriptJQuery().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    ScriptInjector.fromString(Scripts.INSTANCE.scriptHighCharts().getText())
            .setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:org.ol3cesium.client.ol.OLInitializer.java

License:Apache License

public void initialize() {
    final String url = _path + _name;

    ScriptInjector.fromUrl(url).setWindow(getWindow(_document)).setCallback(new Callback<Void, Exception>() {
        @Override/* w  ww.java 2s. c om*/
        public void onFailure(Exception reason) {
            for (Callback<Void, Exception> callback : _callbacks) {
                callback.onFailure(reason);
            }
        }

        @Override
        public void onSuccess(Void result) {
            createSetter(_document);

            String script;
            if (olcsDefined()) {
                script = "document.setGlobalInGWT(ol, olcs);";
            } else {
                script = "document.setGlobalInGWT(ol, undefined);";
            }
            ScriptInjector.fromString(script).setWindow(getWindow(_document)).inject();
        }
    }).inject();
}

From source file:org.piwik.wrapper.client.PiwikWrapperEntryPoint.java

License:Apache License

public void onModuleLoad() {
    ScriptInjector.fromString("var _paq = _paq || [];").setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:org.primordion.xholon.io.gwt.HtmlScriptHelper.java

License:Open Source License

/**
 * Inject a script into the app, and execute it once.
 * @param scriptBody /*from  ww w. ja  va2s .c  o m*/
 * @param removeTag Whether or not to remove the HTML tag after the script is run.
 *        GWT default is true
 * @return 
 */
public static JavaScriptObject fromString(String scriptBody, boolean removeTag) {
    JavaScriptObject jso = ScriptInjector.fromString(scriptBody).setWindow(ScriptInjector.TOP_WINDOW)
            .setRemoveTag(removeTag).inject();
    return jso;
}

From source file:org.uberfire.client.JSEntryPoint.java

License:Apache License

@AfterInitialization
public void setup() {
    runtimePluginsService.listFrameworksContent(new ParameterizedCommand<Collection<String>>() {
        @Override//from   w  w w  .  j  a  va 2  s  .  co m
        public void execute(final Collection<String> response) {
            for (final String s : response) {
                ScriptInjector.fromString(s).setWindow(TOP_WINDOW).inject();
            }
            runtimePluginsService.listPluginsContent(new ParameterizedCommand<Collection<String>>() {
                @Override
                public void execute(final Collection<String> response) {
                    try {
                        for (final String s : response) {
                            ScriptInjector.fromString(s).setWindow(TOP_WINDOW).inject();
                        }
                    } finally {
                        workbench.removeStartupBlocker(JSEntryPoint.class);
                    }
                }
            });
        }
    });
}

From source file:org.uberfire.client.promise.PromisePolyfillBootstrapper.java

License:Apache License

static void ensurePromiseApiIsAvailable() {
    if (!isPromiseApiAvailable()) {
        ScriptInjector.fromString(PromisePolyfillClientBundle.INSTANCE.promisePolyfill().getText())
                .setWindow(ScriptInjector.TOP_WINDOW).inject();
    }// w  w  w.java2s  .co  m
}

From source file:org.uberfire.client.views.pfly.sys.PatternFlyBootstrapper.java

License:Apache License

/**
 * Uses GWT's ScriptInjector to put jQuery in the page if it isn't already. All Errai IOC beans that rely on
 * GWTBootstrap 3 widgets should call this before creating their first such widget.
 *//*  w ww . j  a  v a  2s . com*/
public static void ensurejQueryIsAvailable() {
    if (!isjQueryLoaded()) {
        ScriptInjector.fromString(GwtBootstrap3ClientBundle.INSTANCE.jQuery().getText())
                .setWindow(ScriptInjector.TOP_WINDOW).inject();
    }
}

From source file:org.uberfire.client.views.pfly.sys.PatternFlyBootstrapper.java

License:Apache License

public static void ensurePrettifyIsAvailable() {
    if (!isPrettifyLoaded()) {
        ScriptInjector.fromString(PatternFlyClientBundle.INSTANCE.prettify().getText())
                .setWindow(ScriptInjector.TOP_WINDOW).inject();
    }/*w w  w .j av a 2s.c om*/
}

From source file:org.uberfire.client.views.pfly.sys.PatternFlyBootstrapper.java

License:Apache License

public static void ensureBootstrapSelectIsAvailable() {
    if (!isBootstrapSelectLoaded()) {
        ScriptInjector.fromString(PatternFlyClientBundle.INSTANCE.bootstrapSelect().getText())
                .setWindow(ScriptInjector.TOP_WINDOW).inject();
    }// www . ja v  a 2s .  c o m
}