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:org.eclipse.che.plugin.embedjsexample.ide.view.HelloWorldViewPresenter.java

License:Open Source License

@Inject
public HelloWorldViewPresenter(final HelloWorldView helloWorldView) {
    this.helloWorldView = helloWorldView;

    ScriptInjector.fromUrl(GWT.getModuleBaseURL() + Constants.JAVASCRIPT_FILE_ID)
            .setWindow(ScriptInjector.TOP_WINDOW).setCallback(new Callback<Void, Exception>() {
                @Override//from  w ww . j  av  a 2s . c o m
                public void onSuccess(final Void result) {
                    Log.info(HelloWorldViewPresenter.class, Constants.JAVASCRIPT_FILE_ID + " loaded.");
                    sayHello("Hello from Java Script!");
                }

                @Override
                public void onFailure(final Exception e) {
                    Log.error(HelloWorldViewPresenter.class, "Unable to load " + Constants.JAVASCRIPT_FILE_ID,
                            e);
                }
            }).inject();

}

From source file:org.eclipse.che.plugin.emf.ide.editor.client.EcoreEditorPresenter.java

License:Open Source License

/**
 * {@inheritDoc}/*from   w w w . j a va  2  s. c o m*/
 */
@Override
protected void initializeEditor(OpenEditorCallback callback) {
    ScriptInjector.fromUrl(GWT.getModuleBaseURL() + "ecore-editor.js").setWindow(ScriptInjector.TOP_WINDOW)
            .setCallback(new Callback<Void, Exception>() {
                @Override
                public void onSuccess(final Void result) {

                    input.getFile().getContent().then(new Operation<String>() {
                        @Override
                        public void apply(String content) throws OperationException {
                            Log.info(EcoreEditorPresenter.class, "Ecore editor loaded.");
                            new EditorWidgetInitializedCallback()
                                    .initialized(EcoreEditorPresenter.this.ecoreView, content);
                            updateDirtyState(true);
                        }
                    });

                }

                @Override
                public void onFailure(final Exception e) {
                    Log.error(EcoreEditorPresenter.class, "Unable to load ecore-editor.js", e);
                }
            }).inject();
}

From source file:org.geomajas.hammergwt.client.HammerGwt.java

License:Open Source License

private static void injectScript() {
    if (!isHammerJsDefined()) {
        //deffered binding
        HammerGwtResource hammerGwtResource = GWT.create(HammerGwtResource.class);
        String hammerJsScript = hammerGwtResource.getHammerJsScript();

        //inject hammer js javascript at top level window object
        ScriptInjector.fromString(hammerJsScript).setWindow(ScriptInjector.TOP_WINDOW).setRemoveTag(false)
                .inject();/*from w  w  w .  j  a  v  a2 s. com*/
    }
}

From source file:org.gwt.dynamic.common.client.module.AbstractModule.java

License:MIT License

@Override
public final void onModuleLoad() {
    LOG.info("AbstractModule.onModuleLoad: moduleName=" + GWT.getModuleName());
    ScriptInjector.fromUrl(GWT.getModuleBaseURL() + "config.js").setRemoveTag(true)
            .setWindow(ScriptInjector.TOP_WINDOW).setCallback(new Callback<Void, Exception>() {

                @Override//from   w w w.j  a v a2  s . c  o  m
                public void onSuccess(Void result) {
                    LOG.info("AbstractModule.onModuleLoad#fromUrl#onSuccess");
                    onModuleConfigured();
                }

                @Override
                public void onFailure(Exception reason) {
                    LOG.log(Level.SEVERE, "AbstractModule.onModuleLoad#fromUrl#onFailure:", reason);
                }
            }).inject();
}

From source file:org.gwt.dynamic.host.client.module.ScriptInjectorModuleLoader.java

License:MIT License

@Override
public void load(List<ModuleBean> modules) {
    LOG.info("ScriptInjectorModuleLoader.load: modules=" + modules);
    if (isEmpty(modules))
        return;/*from   w w w  .  j a v  a  2s . c  o m*/
    for (ModuleBean module : modules) {
        String url = module.getUrl();
        if (!isEmpty(url) && !url.endsWith("/"))
            url += "/";
        ScriptInjector.fromUrl(url + module.getName() + "/" + module.getName() + ".nocache.js")
                .setRemoveTag(true).setWindow(ScriptInjector.TOP_WINDOW).inject();
    }
}

From source file:org.gwtbootstrap3.client.GwtBootstrap3EntryPoint.java

License:Apache License

/** {@inheritDoc} */
@Override// w  w w. j  av  a 2 s  .  c o  m
public void onModuleLoad() {
    if (!isjQueryLoaded()) {
        ScriptInjector.fromString(GwtBootstrap3ClientBundle.INSTANCE.jQuery().getText())
                .setWindow(ScriptInjector.TOP_WINDOW).inject();
    }

    if (!isBootstrapLoaded()) {
        ScriptInjector.fromString(GwtBootstrap3ClientBundle.INSTANCE.bootstrap().getText())
                .setWindow(ScriptInjector.TOP_WINDOW).inject();
    }
}

From source file:org.gwtbootstrap3.demo.client.GwtBootstrap3DemoEntryPoint.java

License:Apache License

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

From source file:org.gwtbootstrap3.extras.bootbox.client.BootboxEntryPoint.java

License:Apache License

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

From source file:org.gwtbootstrap3.extras.datepicker.client.DatePickerEntryPoint.java

License:Apache License

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

From source file:org.gwtbootstrap3.extras.datepicker.client.ui.base.DatePickerBase.java

License:Apache License

/** {@inheritDoc} */
@Override//from   w w w  .j a  va  2s .  co m
public void setLanguage(final DatePickerLanguage language) {
    this.language = language;

    // Inject the JS for the language
    if (language.getJs() != null) {
        ScriptInjector.fromString(language.getJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    }
}