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:com.ait.toolkit.sencha.ext.ux.gmaps.client.GMapPanel.java

License:Open Source License

private static void inject() {
    MapPanelResources res = GWT.create(MapPanelResources.class);
    ScriptInjector.fromString(res.js().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:com.ait.toolkit.sencha.ext.ux.notification.client.Notification.java

License:Open Source License

private static void load() {
    NotificationResources resources = GWT.create(NotificationResources.class);
    ScriptInjector.fromString(resources.js().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:com.ait.toolkit.xdm.client.XDM.java

License:Open Source License

static void load() {
    if (!isLoaded()) {
        EasyXdmResources resources = GWT.create(EasyXdmResources.class);
        ScriptInjector.fromString(resources.js().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    }/*  w w  w . ja v a  2s.c  om*/
}

From source file:com.arcbees.website.client.application.bees.Konami.java

License:Apache License

@Inject
Konami(EventBus eventBus) {
    this.eventBus = eventBus;
    ScriptInjector.fromString(script).setWindow(ScriptInjector.TOP_WINDOW).inject();
    bind(this);
}

From source file:com.cgxlib.xq.client.plugins.ajax.Ajax.java

License:Apache License

/**
 * Perform an ajax request to the server.
 * <p/>/*  w  w  w  .jav  a2s  .c  o  m*/
 * Example:
 * <p/>
 * <pre>
 * import static com.cgxlib.xq.client.GQ.*
 * ...
 * Properties properties = $$("dataType: xml, type: post; data: {q: 'gwt'}, headers: {X-Powered-By: XQ}");
 * ajax("test.php", new Function() {
 * public void f() {
 * Element xmlElem = getData()[0];
 * System.out.println($("message", xmlElem));
 * }
 * }, new Function(){
 * public void f() {
 * System.err.println("Ajax Error: " + getData()[1]);
 * }
 * }, properties);
 * </pre>
 */
public static Promise ajax(Settings settings) {
    resolveSettings(settings);

    final Function onSuccess = settings.getSuccess();
    if (onSuccess != null) {
        onSuccess.setElement(settings.getContext());
    }

    final Function onError = settings.getError();
    if (onError != null) {
        onError.setElement(settings.getContext());
    }

    final String dataType = settings.getDataType();

    Promise ret = null;

    if ("jsonp".equalsIgnoreCase(dataType)) {
        ret = XQUtil.getAjaxTransport().getJsonP(settings);
    } else if ("loadscript".equalsIgnoreCase(dataType)) {
        ret = XQUtil.getAjaxTransport().getLoadScript(settings);
    } else {
        ret = XQUtil.getAjaxTransport().getXhr(settings).then(new Function() {
            public Object f(Object... args) {
                Response response = arguments(0);
                Request request = arguments(1);
                Object retData = response.getText();
                if (retData != null && !"".equals(retData)) {
                    try {
                        if ("xml".equalsIgnoreCase(dataType)) {
                            retData = JsUtils.parseXML(response.getText());
                        } else if ("json".equalsIgnoreCase(dataType)) {
                            retData = XQUtil.create(response.getText());
                        } else {
                            retData = response.getText();
                            if ("script".equalsIgnoreCase(dataType)) {
                                ScriptInjector.fromString((String) retData).setWindow(window).inject();
                            }
                        }
                    } catch (Exception e) {
                        if (GWT.isClient() && GWT.getUncaughtExceptionHandler() != null) {
                            GWT.getUncaughtExceptionHandler().onUncaughtException(e);
                        } else {
                            e.printStackTrace();
                        }
                    }
                }
                return new Object[] { retData, "success", request, response };
            }
        }, new Function() {
            public Object f(Object... args) {
                Throwable exception = arguments(0);
                Request request = getArgument(1, Request.class);
                String msg = String.valueOf(exception);
                return new Object[] { null, msg, request, null, exception };
            }
        });
    }
    if (onSuccess != null) {
        ret.done(onSuccess);
    }
    if (onError != null) {
        ret.fail(onError);
    }
    return ret;
}

From source file:com.codenvy.ide.MyExtension.java

License:Open Source License

@Inject
public MyExtension(WorkspaceAgent workspaceAgent, ESBEditor graphicalEditor, JSBundle bundle) {

    ScriptInjector.fromString(JSBundle.INSTANCE.jquerysource().getText()).setWindow(ScriptInjector.TOP_WINDOW)
            .inject();//from w w  w.  j a v  a  2s.  co m
    ScriptInjector.fromString(JSBundle.INSTANCE.jqueryuimin().getText()).setWindow(ScriptInjector.TOP_WINDOW)
            .inject();
    ScriptInjector.fromString(JSBundle.INSTANCE.jsplumbsource().getText()).setWindow(ScriptInjector.TOP_WINDOW)
            .inject();
    ScriptInjector.fromString(JSBundle.INSTANCE.gwtresource().getText()).setWindow(ScriptInjector.TOP_WINDOW)
            .inject();

    workspaceAgent.openPart(graphicalEditor, EDITING);

}

From source file:com.eemi.gwt.tour.client.GwtTour.java

License:Apache License

/**
 * Load the javasccript and the stylesheet by using the ScriptInjector
 *//*from w ww . jav  a2  s. c  o  m*/
public static void load() {
    if (!isLoaded()) {
        GwtTourResources resources = GWT.create(GwtTourResources.class);
        StyleInjector.inject(resources.css().getText());
        ScriptInjector.fromString(resources.js().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    }
}

From source file:com.github.christianlacerda.client.GwtBootstrapTour.java

License:Apache License

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

From source file:com.github.gwtcannonjs.client.CANNON.java

License:Open Source License

public static void injectRuntime() {
    if (!runtimeInjected) {
        ScriptInjector.fromString(RuntimeResource.INSTANCE.source().getText())
                .setWindow(ScriptInjector.TOP_WINDOW).inject();
        runtimeInjected = true;/*from w  w  w .j a v  a2s.com*/
    }
}

From source file:com.github.gwtcannonjs.client.CANNON.java

License:Open Source License

public static void injectDemoRuntime() {
    if (!demoRuntimeInjected) {
        injectRuntime();/*from www.ja va  2  s . c o m*/
        ScriptInjector.fromString(DemoRuntimeResource.INSTANCE.source().getText())
                .setWindow(ScriptInjector.TOP_WINDOW).inject();
        runtimeInjected = true;
    }
}