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.cruxframework.crux.plugin.bootstrap.client.ModuleLoader.java

License:Apache License

@SuppressWarnings("unused")
private void injectBoostrap2() {
    final CruxBootstrap2Resources res = GWT.create(CruxBootstrap2Resources.class);

    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override/*  ww w  . j  a v a2 s.  c  o  m*/
        public boolean execute() {
            //JavaScript
            String jquery = res.jquery().getText();
            String bs2JS = res.bootstrap2JS().getText();
            String html5shiv = res.html5shiv().getText();
            String modal = res.bootstrapModal().getText();
            String modalManager = res.bootstrapModalManager().getText();
            String select = res.bootstrapSelect().getText();

            ScriptInjector.fromString(jquery).setWindow(ScriptInjector.TOP_WINDOW).inject();
            ScriptInjector.fromString(bs2JS).setWindow(ScriptInjector.TOP_WINDOW).inject();
            ScriptInjector.fromString(modalManager).setWindow(ScriptInjector.TOP_WINDOW).inject();
            ScriptInjector.fromString(modal).setWindow(ScriptInjector.TOP_WINDOW).inject();
            ScriptInjector.fromString(select).setWindow(ScriptInjector.TOP_WINDOW).inject();
            ScriptInjector.fromString(html5shiv).setWindow(ScriptInjector.TOP_WINDOW).inject();

            //Cascade Style Sheets
            String bs2Responsive = res.cssResponsive().getText();
            String bootstrapModalCSS = res.bootstrapModalCSS().getText();
            String bootstrapSelectCSS = res.bootstrapSelectCSS().getText();
            String bs2Css = res.css().getText();

            StyleInjector.injectStylesheetAtEnd(bs2Css);
            StyleInjector.injectStylesheetAtEnd(bs2Responsive);
            StyleInjector.injectStylesheetAtEnd(bootstrapSelectCSS);
            StyleInjector.injectStylesheetAtEnd(bootstrapModalCSS);

            return false;
        }

    }, 300);
}

From source file:org.dashbuilder.renderer.c3.client.exports.ResourcesInjector.java

License:Apache License

private static void injectC3Resources() {
    PatternFlyBootstrapper.ensureD3IsAvailable();
    ScriptInjector.fromString(NativeLibraryResources.INSTANCE.c3js().getText())
            .setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:org.dashbuilder.renderer.c3.client.exports.ResourcesInjector.java

License:Apache License

private static void injectD3GeoProjectionResources() {
    PatternFlyBootstrapper.ensureD3IsAvailable();
    ScriptInjector.fromString(NativeLibraryResources.INSTANCE.d3geoprojectionjs().getText())
            .setWindow(ScriptInjector.TOP_WINDOW).inject();
}

From source file:org.dashbuilder.renderer.client.metric.MetricView.java

License:Apache License

@Override
public void eval(String js) {
    Scheduler.get().scheduleFixedDelay(() -> {
        Element el = Document.get().getElementById(uniqueId);
        if (el != null) {
            ScriptInjector.fromString(js).setWindow(ScriptInjector.TOP_WINDOW).setRemoveTag(true).inject();
            return false;
        }/*from   www  .ja  v  a 2s . co  m*/
        return true;
    }, 100);
}

From source file:org.eclipse.che.ide.examples.CheFluxLiveEditExtension.java

License:Open Source License

private void injectSocketIO() {
    SocketIOResources ioresources = GWT.create(SocketIOResources.class);
    ScriptInjector.fromString(ioresources.socketIo().getText()).setWindow(ScriptInjector.TOP_WINDOW).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  ww.  ja va2  s.c o m
    }
}

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

License:Apache License

/** {@inheritDoc} */
@Override//from   w w w.j  a va  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();
}