Java 类com.google.gwt.core.client.ScriptInjector 实例源码

项目:che-archetypes    文件:HelloWorldViewPresenter.java   
@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
            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();
}
项目:domino-todolist    文件:LayoutUIClientModule.java   
public void onModuleLoad() {
    ScriptInjector.fromUrl(GWT.getModuleBaseURL()+"bower_components/webcomponents-lite.min.js").setWindow(ScriptInjector.TOP_WINDOW).setCallback(
               new Callback<Void, Exception>() {
                   @Override
                   public void onSuccess(Void result) {
                    LOGGER.info("injection success");
                    importPolymer();
                }

                @Override
                public void onFailure(Exception reason) {

                }
            }).inject();


    LOGGER.info("Initializing Layout client UI module ...");
    new ModuleConfigurator().configureModule(new LayoutUIModuleConfiguration());
}
项目:convertigo-che-assembly    文件:MainViewPresenter.java   
private void injectDocReadyAndC8OCoreScripts(final String convertigoMachineUrl) {
    final String convertigoStudioJsUrl = convertigoMachineUrl + "/convertigo/studio/js/";

    // First, inject docready.js = $(document).ready() (but native JS function)
    final String docReadyJsUrl = convertigoStudioJsUrl + "libs/docready.js";
    ScriptInjector
        .fromUrl(docReadyJsUrl)
        .setWindow(ScriptInjector.TOP_WINDOW)
        .setCallback(new Callback<Void, Exception>() {
            @Override
            public void onSuccess(Void result) {
                // ... then convertigo.js and main.js
                injectC8OCoreScripts(convertigoStudioJsUrl);
            }

            @Override
            public void onFailure(Exception reason) {
                Window.alert(formatScriptInjectFailure(docReadyJsUrl, convertigoMachineUrl));
            }
        })
        .inject();
}
项目:gdx-bullet-gwt    文件:GwtBullet.java   
public static void init()
{
    if(init)
        return;
    init = true;

    String javaScript = "ammo.js";

    final String js = GWT.getModuleBaseForStaticFiles() + javaScript;

    ScriptInjector.fromUrl(js).setCallback(new Callback<Void, Exception>()
    {
        @Override
        public void onFailure(Exception e)
        {
            GWT.log("inject " + js + " failure " + e);
        }

        @Override
        public void onSuccess(Void ok)
        {
            Bullet.initVariables();
        }
    }).setWindow(ScriptInjector.TOP_WINDOW).inject();
}
项目:demo-gwt-springboot    文件:DemoGwtWebApp.java   
private void injectJqueryScript() {
    // Workaround: https://goo.gl/1OrFqj
    ScriptInjector.fromUrl(JQUERY_UI_URL).setCallback(new Callback<Void, Exception>() {
        @Override
        public void onFailure(Exception reason) {
            logger.info("Script load failed Info: " + reason);
        }

        @Override
        public void onSuccess(Void result) {
            logger.info("JQuery for Select loaded successful!");

            init();
        }

    }).setRemoveTag(true).setWindow(ScriptInjector.TOP_WINDOW).inject();
}
项目:codenvy    文件:HelpExtension.java   
private void addPremiumSupportHelpAction() {
  // userVoice init
  ScriptInjector.fromUrl(resources.userVoice().getSafeUri().asString())
      .setWindow(ScriptInjector.TOP_WINDOW)
      .setCallback(
          new Callback<Void, Exception>() {
            @Override
            public void onSuccess(Void aVoid) {
              // add action
              actionManager.registerAction(
                  localizationConstant.createSupportTicketAction(), createSupportTicketAction);

              helpGroup.addSeparator();
              helpGroup.add(createSupportTicketAction);
            }

            @Override
            public void onFailure(Exception e) {
              Log.error(getClass(), "Unable to inject UserVoice", e);
            }
          })
      .inject();
}
项目:GwtVisualizationWrappers    文件:CytoscapeJsEntryPoint.java   
/** {@inheritDoc} */
@Override
public void onModuleLoad() {
    if (!isjQueryLoaded()) {
        ScriptInjector.fromString(CytoscapeJsClientBundle.INSTANCE.jQuery().getText())
                .setWindow(ScriptInjector.TOP_WINDOW)
                .inject();
    }
    if (!isCytoscapeUtilsLoaded()) {
        ScriptInjector.fromString(CytoscapeJsClientBundle.INSTANCE.sageCytoscapeUtils().getText())
         .setWindow(ScriptInjector.TOP_WINDOW)
         .inject();
    }



}
项目:gwtc3    文件:C3Js.java   
@Override
public void onModuleLoad() {
    C3Resources resources = loadResources();

    boolean pretty = isPretty(resources);
    GWT.log("[C3Js] Loading " + (pretty ? "pretty" : "obfuscated") + " resources");

    TextResource c3Css = resources.c3Css();
    GWT.log("[C3Js] Injecting CSS " + c3Css.getName());
    StyleInjector.inject(c3Css.getText());

    TextResource c3JavaScript = resources.c3JavaScript();
    GWT.log("[C3Js] Injecting JavaScript " + c3JavaScript.getName());
    ScriptInjector.fromString(c3JavaScript.getText()).setRemoveTag(pretty).setWindow(getWindow()).inject();

    GWT.log("[C3Js] C3 v" + getC3Version() + " (using D3 v" + getD3Version() + ") loaded!");
}
项目:gdx-freetype-gwt    文件:FreetypeInjector.java   
@Override
public void inject (final OnCompletion oc) {
    final String js = GWT.getModuleBaseForStaticFiles() + "freetype.js";
    ScriptInjector.fromUrl(js).setCallback(new Callback<Void, Exception>() {

        @Override
        public void onFailure (Exception reason) {
            error = true;
            GWT.log("Exception injecting " + js, reason);
            oc.run();
        }

        @Override
        public void onSuccess (Void result) {
            success = true;
            GWT.log("Success injecting js.");
            oc.run();
        }

    }).setWindow(ScriptInjector.TOP_WINDOW).inject();
}
项目:gdx-bullet-gwt    文件:GwtBullet.java   
public static void init()
{
    if(init)
        return;
    init = true;

    String javaScript = "ammo.js";

    final String js = GWT.getModuleBaseForStaticFiles() + javaScript;

    ScriptInjector.fromUrl(js).setCallback(new Callback<Void, Exception>()
    {
        @Override
        public void onFailure(Exception e)
        {
            GWT.log("inject " + js + " failure " + e);
        }

        @Override
        public void onSuccess(Void ok)
        {
            Bullet.initVariables();
        }
    }).setWindow(ScriptInjector.TOP_WINDOW).inject();
}
项目:scheduling-portal    文件:JSUtil.java   
private static void injectScriptOneAfterAnother(final List<String> pathAsList) {
    ScriptInjector.fromUrl(pathAsList.remove(0))
                  .setWindow(ScriptInjector.TOP_WINDOW)
                  .setCallback(new Callback<Void, Exception>() {
                      @Override
                      public void onFailure(Exception reason) {
                      }

                      @Override
                      public void onSuccess(Void result) {
                          if (!pathAsList.isEmpty()) {
                              injectScriptOneAfterAnother(pathAsList);
                          }
                      }
                  })
                  .inject();
}
项目:che    文件:ActivityTrackingExtension.java   
@Inject
public ActivityTrackingExtension(AppContext appContext) {

  ScriptInjector.fromUrl("/_app/activity.js")
      .setWindow(TOP_WINDOW)
      .setCallback(
          new Callback<Void, Exception>() {
            @Override
            public void onSuccess(Void result) {
              init(appContext.getMasterApiEndpoint(), appContext.getWorkspaceId());
            }

            @Override
            public void onFailure(Exception reason) {}

            private native void init(String restContext, String wsId) /*-{
                            $wnd.ActivityTracker.init(restContext, wsId);
                        }-*/;
          })
      .inject();
}
项目:gerrit    文件:Loader.java   
public static void injectScript(SafeUri js, 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
                public void onSuccess(Void result) {
                  script[0].removeFromParent();
                  callback.onSuccess(result);
                }

                @Override
                public void onFailure(Exception reason) {
                  callback.onFailure(reason);
                }
              })
          .inject()
          .cast();
}
项目:wbi    文件:Script.java   
/**
 * Load the specified script.
 *
 * @param script Path to script.
 * @param callback {@code Callback} called when ready.
 */
public static void load(
        String script, Callback<Void, Exception> callback) {

    if (loadedScripts.contains(script)) {
        callback.onSuccess(null);
        return;
    }

    ScriptInjector.fromUrl(script)
        .setWindow(ScriptInjector.TOP_WINDOW)
        .setCallback(callback)
        .inject();

    loadedScripts.add(script);
}
项目:appformer    文件:RuntimePluginStartup.java   
void startPlugins(@Observes UberfireJSAPIReadyEvent event) {

        runtimePlugins.call(new RemoteCallback<List<RuntimePlugin>>() {
            @Override
            public void callback(List<RuntimePlugin> plugins) {
                try {
                    for (final RuntimePlugin p : plugins) {
                        if (isJSPlugin(p)) {
                            ScriptInjector.fromString(p.getPluginContent()).setWindow(ScriptInjector.TOP_WINDOW).inject();
                        } else if (isPerspectivePlugin(p)) {
                            perspectiveEditorGenerator.generatePerspective(p.getPluginContent());
                        }
                    }
                } finally {
                    workbench.removeStartupBlocker(RuntimePluginStartup.class);
                }
            }
        }).getRuntimePlugins();
    }
项目:ahome-core    文件:ResourceInjector.java   
/**
 * Loads a javascript file base on the file url
 */
public void inject() {
    if (this.cssUrl != null) {
        loadCss(this.cssUrl);
    }
    if (this.jsUrl != null) {

        scriptElement = ScriptInjector.fromUrl(this.jsUrl)
                .setCallback(new Callback<Void, Exception>() {
                    @Override
                    public void onSuccess(Void result) {
                        if (ResourceInjector.this.callBack != null) {
                            ResourceInjector.this.callBack.onJsLoaded();
                        }
                    }

                    @Override
                    public void onFailure(Exception reason) {
                        Window.alert(reason.getMessage() + " for link "
                                + jsUrl);
                    }
                }).setWindow(ScriptInjector.TOP_WINDOW).inject();

    }
}
项目:ahome-ace    文件:AceEditor.java   
public void setMode(final AceEditorMode mode) {
    final String modeId = "mode-" + mode.name().toLowerCase();
    String js = modeId + ".js";
    String path = Util.getModuleBaseUrl() + "ace/" + js;

    Element el = DOM.getElementById(modeId);
    if (el == null) {
        modeScriptElement = ScriptInjector.fromUrl(path).setCallback(new Callback<Void, Exception>() {
            @Override
            public void onSuccess(Void result) {
                JsoHelper.setAttribute(modeScriptElement, "id", modeId);
                AceEditor.this._setMode(mode);
            }

            @Override
            public void onFailure(Exception reason) {
            }
        }).setWindow(ScriptInjector.TOP_WINDOW).inject();

    } else {
        this._setMode(mode);

    }

}
项目:ahome-ace    文件:AceEditor.java   
public void setTheme(final AceEditorTheme theme) {
    final String themeId = "theme-" + theme.name().toLowerCase();
    String js = themeId + ".js";
    String path = Util.getModuleBaseUrl() + "ace/" + js;

    Element el = DOM.getElementById(themeId);
    if (el == null) {
        themeScriptElement = ScriptInjector.fromUrl(path).setCallback(new Callback<Void, Exception>() {
            @Override
            public void onSuccess(Void result) {
                JsoHelper.setAttribute(themeScriptElement, "id", themeId);
                AceEditor.this._setTheme(theme);
            }

            @Override
            public void onFailure(Exception reason) {
            }
        }).setWindow(ScriptInjector.TOP_WINDOW).inject();

    } else {
        _setTheme(theme);
    }
}
项目:xapi    文件:WebComponentSupport.java   
public void ensureWebComponentApi(Do onLoaded) {
  // Check if document.register exists

  if (!hasNativeSupport()) {
    // Nope... Lets inject our polyfill
    Mutable<JavaScriptObject> script = new Mutable<>();
    script.in(ScriptInjector
        .fromUrl(getPolyfillUrl(VERSION))
        .setCallback(voidCallback(() -> {
          if (VERSION == V1) {
            JsSupport.win().addEnteredListener("WebComponentsReady", onLoaded.onlyOnce().ignores1()::in, false);
          } else {
            onLoaded.done();
          }
          // TODO: remove the script
        }))
        .setWindow(ScriptInjector.TOP_WINDOW)
        .inject());
  } else {
    Scheduler.get().scheduleDeferred(onLoaded::done);
  }
}
项目:shared-test-case    文件:SharedTestCase.java   
public void injectScript(String url, final Runnable onComplete) {
  ScriptInjector.fromUrl(url)
  .setCallback(new Callback<Void, Exception>() {
    @Override
    public void onFailure(Exception reason) {
      throw new RuntimeException(reason);
    }

    @Override
    public void onSuccess(Void result) {
      if (onComplete != null) {
        onComplete.run();
      }
    }
  }).inject();
}
项目:gwtbootstrap3-extras    文件:FullCalendarEntryPoint.java   
@Override
public void onModuleLoad() {
    StyleInjector.injectAtEnd(FullCalendarClientBundle.INSTANCE.fullCalendarCss().getText());
    StyleInjector.injectAtEnd("@media print {" + FullCalendarClientBundle.INSTANCE.fullCalendarPrintCss().getText() + "}");

    if (!isMomentPresent()) {
        ScriptInjector.fromString(FullCalendarClientBundle.INSTANCE.getMomentJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    }

    if (!isCalendarPresent()) {
        ScriptInjector.fromString(FullCalendarClientBundle.INSTANCE.getFullCalendarJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    }

    if (!isDragAndResizePresent()) {
        ScriptInjector.fromString(FullCalendarClientBundle.INSTANCE.getCustomDragResizeJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    }
}
项目:gwtbootstrap3-extras    文件:EventSource.java   
public EventSource(final String url,
                   final String color,
                   final String backgroundColor,
                   final String textColor,
                   final String borderColor,
                   final String className,
                   final boolean isEditable,
                   final boolean isStartEditable,
                   final boolean isDurationEditable,
                   final boolean allDayDefault,
                   final boolean ignoreTimeZone,
                   final boolean isGoogle//if true include google script file
) {
    if (isGoogle && !GCAL_ADDED) {
        GCAL_ADDED = true;
        ScriptInjector.fromString(FullCalendarClientBundle.INSTANCE.getGoogleCalJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
    }
    newEvent(url, color, backgroundColor, textColor, borderColor, className, isEditable, isStartEditable, isDurationEditable, allDayDefault, ignoreTimeZone);
}
项目:gwt-dynamic-plugins    文件:AbstractModule.java   
@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
                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();
}
项目:unitimes    文件:RoomEdit.java   
public void show() {
    UniTimePageLabel.getInstance().setPageName(iRoom.getUniqueId() == null ? MESSAGES.pageAddRoom() : MESSAGES.pageEditRoom());
    setVisible(true);
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);

    if (iGoogleMap != null) {
        if (isGoogleMapEditable() || iRoom.hasCoordinates()) {
            iGoogleMap.setVisible(true);
            if (!iGoogleMapInitialized) {
                iGoogleMapInitialized = true;
                ScriptInjector.fromUrl("https://maps.googleapis.com/maps/api/js?" + (iProperties != null && iProperties.hasGoogleMapApiKey() ? "key=" + iProperties.getGoogleMapApiKey() + "&" : "") +
                        "sensor=false&callback=setupGoogleMap").setWindow(ScriptInjector.TOP_WINDOW).setCallback(
                        new Callback<Void, Exception>() {
                            @Override
                            public void onSuccess(Void result) {
                            }
                            @Override
                            public void onFailure(Exception e) {
                                UniTimeNotifications.error(e.getMessage(), e);
                                iGoogleMap = null;
                                iGoogleMapControl = null;
                            }
                        }).inject();
            } else if (iGoogleMap != null) {
                setMarker();
            }
        } else {
            iGoogleMap.setVisible(false);
        }
    }
}
项目:gdx-fireapp    文件:FirebaseConfiguration.java   
/**
 * Injects lazy firebase loading inside GWT application.
 */
public void init()
{
    if (rawHtml == null) {
        Gdx.app.error("GdxFireapp", "You forgot about calling FirebaseConfiguration#init() first.");
        return;
    }
    ScriptInjector.fromUrl(configParser.getFirebaseScriptSrc())
            .setRemoveTag(false)
            .setWindow(ScriptInjector.TOP_WINDOW)
            .setCallback(new ScriptLoadedCallback(configParser))
            .inject();
}
项目:convertigo-che-assembly    文件:MainViewPresenter.java   
@Inject
  public MainViewPresenter(MainView mainView, AppContext appContext) {
    this.mainView = mainView;
    this.appContext = appContext;

    exportGetKeyConvertigoMachineUrl();
    exportInjectDocReadyAndC8OCoreScripts();
    exportGetConvertigoMachineUrl();

defineConvertigoUrl(getConvertigoMachineUrl());

    final String jsFile = "init.js";
    ScriptInjector.fromUrl(GWT.getModuleBaseURL() + jsFile)
       .setWindow(ScriptInjector.TOP_WINDOW)
       .setCallback(new Callback<Void, Exception>() {
           @Override
           public void onSuccess(final Void result) {
               Log.info(MainViewPresenter.class, jsFile + " loaded.");
           }

           @Override
           public void onFailure(final Exception e) {
               Log.error(MainViewPresenter.class, "Unable to load " + jsFile, e);
           }
       })
       .inject();
  }
项目:demo-gwt-springboot    文件:DemoGwtWebApp.java   
private void injectMyFunctionScript() {
    ScriptInjector.fromUrl(MYFUNCTION_URL).setCallback(new Callback<Void, Exception>() {
        @Override
        public void onFailure(Exception reason) {
            logger.info("Script load failed Info: " + reason);
        }

        @Override
        public void onSuccess(Void result) {
            logger.info("MyFunction loaded successful!");
        }

    }).setRemoveTag(true).setWindow(ScriptInjector.TOP_WINDOW).inject();
}
项目:cuba    文件:CubaMultiUploadWidget.java   
public void initComponent(String uploadId) {
    this.jsIncludeUri = bootstrapJsUrl + "?v=" + resourcesVersion;
    this.swfUri = flashUrl + "?v=" + resourcesVersion;

    this.uploadId = uploadId;

    this.uploadButton.setId("upload_button_" + uploadId);
    this.progressDiv.setId("upload_progress_" + uploadId);

    this.themeDiv.setClassName(themeName);

    if (!scriptInjected) {
        ScriptInjector.fromUrl(jsIncludeUri).setCallback(new Callback<Void, Exception>() {
            @Override
            public void onFailure(Exception reason) {
                if (bootstrapFailureHandler != null)
                    bootstrapFailureHandler.resourceLoadFailed();

                setDisabled();
            }

            @Override
            public void onSuccess(Void result) {
                checkAndInitialize();
            }
        }).setWindow(getWindow()).setRemoveTag(false).inject();

        scriptInjected = true;
    } else {
        checkAndInitialize();
    }
}
项目:hftinymce-gwt    文件:HFRichTextEditor.java   
public static boolean loadLibrary() {
        String scriptUrl = "";
        if (libraryVersion == TINYMCE_VERSION_4) {
            scriptUrl = GWT.getModuleBaseURL() + "tinymce4/tinymce.min.js";
        } else if (libraryVersion == TINYMCE_VERSION_3) {
//            scriptUrl = GWT.getModuleBaseURL() + "tinymce3/tiny_mce.js";
            return false; // Security Audit found an issue with using eval. Removing from code base for now. 4.20.2015
        } else {
            // No such version allowed.
            return false;
        }
        JavaScriptObject scriptInstance = ScriptInjector.fromUrl(scriptUrl)
            .setWindow(ScriptInjector.TOP_WINDOW)
            .setCallback(new Callback<Void, Exception>() {

                @Override
                public void onFailure(Exception reason) {
                    Window.alert("TinyMCE failed to load.");
                    libraryLoaded = false;
                }

                @Override
                public void onSuccess(Void result) {
                    // We need to register the Javascript method that will handle all of the events.
                    registerEventHandler();
                    libraryLoaded = true;
                }                
            }).inject();
        return (scriptInstance != null);
    }
项目:gwt-material    文件:MaterialDesignBase.java   
protected static void directInjectJs(TextResource resource, boolean removeTag, boolean sourceUrl) {
    String text = resource.getText() + (sourceUrl ?
        "//# sourceURL=" + resource.getName() + ".js" : "");

    // Inject the script resource
    ScriptInjector.fromString(text)
        .setWindow(ScriptInjector.TOP_WINDOW)
        .setRemoveTag(removeTag)
        .inject();
}
项目:gwt-material    文件:MaterialDatePicker.java   
protected void setupLanguage(DatePickerLanguage language) {
    if (language.getJs() != null) {
        ScriptInjector.fromString(language.getJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
        getPicker().stop();
        Scheduler.get().scheduleDeferred(() -> load());
    }
}
项目:gwt-jui    文件:AbstractEntryPoint.java   
protected void inject(TextResource resource, boolean removeTag, boolean sourceUrl) {
    String text = resource.getText() +
        (sourceUrl ? "//# sourceURL="+resource.getName()+".js" : "");

    // Inject the script resource
    ScriptInjector.fromString(text)
        .setWindow(ScriptInjector.TOP_WINDOW)
        .setRemoveTag(removeTag)
        .inject();
}
项目:che    文件:RequireJsLoader.java   
public void require(
    final RequirejsCallback callback,
    final RequirejsErrorHandler errorHandler,
    final RequirejsConfig config,
    final String[] requiredScripts,
    final String[] moduleKeys) {
  if (!requirejsLoaded && !requirejsLoadFailed) {
    Log.debug(RequireJsLoader.class, "Loading require.js.");
    /** Using GWT.getModuleBaseForStaticFiles() blocks CodeMirror to run under Super Dev Mode */
    ScriptInjector.fromUrl(GWT.getModuleBaseURL() + "require.js")
        .setWindow(ScriptInjector.TOP_WINDOW)
        .setCallback(
            new Callback<Void, Exception>() {
              @Override
              public void onSuccess(final Void result) {
                Log.debug(RequireJsLoader.class, "require.js loaded.");
                configureGlobalErrorCallback();
                requireScripts(callback, errorHandler, config, requiredScripts, moduleKeys);
                requirejsLoaded = true;
              }

              @Override
              public void onFailure(final Exception e) {
                Log.error(RequireJsLoader.class, "Unable to load require.js", e);
                requirejsLoadFailed = true;
              }
            })
        .inject();
  } else if (!requirejsLoadFailed) {
    requireScripts(callback, null, config, requiredScripts, moduleKeys);
  } else {
    Log.error(RequireJsLoader.class, "Require.js load failed, cannot require scripts.");
  }
}
项目:che    文件:DevModeScriptInjector.java   
/**
 * Injects the JS script, that communicates with a Code Server, into a host page.
 *
 * @param url host URL where script is located. Usually should be a Code Server URL
 * @return promise that may be resolved if script has been injected successfully or rejected in
 *     case of any error while script injection
 */
Promise<Void> inject(String url) {
  return CallbackPromiseHelper.createFromCallback(
      promiseCallback ->
          ScriptInjector.fromUrl(url + DEV_MODE_SCRIPT_NAME)
              .setWindow(JsBrowser.getWindow())
              .setCallback(getScriptInjectionCallback(promiseCallback))
              .inject());
}
项目:gerrit    文件:PluginLoader.java   
private void load(List<String> pluginUrls) {
  for (String url : pluginUrls) {
    Plugin plugin = Plugin.create(url);
    plugins().put(url, plugin);
    ScriptInjector.fromUrl(url)
        .setWindow(ScriptInjector.TOP_WINDOW)
        .setCallback(new LoadCallback(plugin))
        .inject();
  }
}
项目:unitime    文件:RoomEdit.java   
public void show() {
    UniTimePageLabel.getInstance().setPageName(iRoom.getUniqueId() == null ? MESSAGES.pageAddRoom() : MESSAGES.pageEditRoom());
    setVisible(true);
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);

    if (iGoogleMap != null) {
        if (isGoogleMapEditable() || iRoom.hasCoordinates()) {
            iGoogleMap.setVisible(true);
            if (!iGoogleMapInitialized) {
                iGoogleMapInitialized = true;
                ScriptInjector.fromUrl("https://maps.googleapis.com/maps/api/js?" + (iProperties != null && iProperties.hasGoogleMapApiKey() ? "key=" + iProperties.getGoogleMapApiKey() + "&" : "") +
                        "sensor=false&callback=setupGoogleMap").setWindow(ScriptInjector.TOP_WINDOW).setCallback(
                        new Callback<Void, Exception>() {
                            @Override
                            public void onSuccess(Void result) {
                            }
                            @Override
                            public void onFailure(Exception e) {
                                UniTimeNotifications.error(e.getMessage(), e);
                                iGoogleMap = null;
                                iGoogleMapControl = null;
                            }
                        }).inject();
            } else if (iGoogleMap != null) {
                setMarker();
            }
        } else {
            iGoogleMap.setVisible(false);
        }
    }
}
项目:wbi    文件:Script.java   
@Override
public void load(final Runnable callback) {
    super.load(new Runnable() {
        @Override
        public void run() {
            ScriptInjector.fromString("jQuery.noConflict();")
                .setWindow(ScriptInjector.TOP_WINDOW)
                .inject();

            callback.run();
        }
    });
}
项目:blogwt    文件:MapPlugin.java   
@Override
public void emit (StringBuilder out, final List<String> lines,
        final Map<String, String> params) {

    MapPluginItem item = new MapPluginItem();
    item.mapManager = manager;
    item.instance = this;
    item.id = HTMLPanel.createUniqueId();
    item.lines = lines;
    item.params = params;

    items.put(item.id, item);

    out.append("<div id=\"");
    out.append(item.id);
    out.append("\">Loading maps API...</div>");

    if (!added) {
        added = true;

        ScriptInjector.fromUrl(
                "https://maps.googleapis.com/maps/api/js?callback=mapsInitialised&key="
                        + apiKey)
                .setCallback(EMPTY).inject();
    }

    if (initialised) {
        mapsInitialised();
    }
}
项目:blogwt    文件:ReCaptchaPart.java   
@Override
protected void onLoad () {
    super.onLoad();
    if (SCRIPT == null) {
        exposeMethod(this);
        SCRIPT = ScriptInjector.fromUrl(
                "https://www.google.com/recaptcha/api.js?onload=call_65fd7992_9064_11e5_aeca_fbe3616fc7e4&render=explicit")
                .setWindow(ScriptInjector.TOP_WINDOW).inject().cast();
    } else {
        render();
    }
}
项目:appformer    文件:HtmlEditorLibraryLoader.java   
void injectScripts() {
    ScriptInjector.fromString(HtmlEditorResources.INSTANCE.wysihtml().getText()).setWindow(TOP_WINDOW).inject();
    ScriptInjector.fromString(HtmlEditorResources.INSTANCE.wysihtmlAllCommands().getText()).setWindow(TOP_WINDOW).inject();
    ScriptInjector.fromString(HtmlEditorResources.INSTANCE.wysihtmlTableEditing().getText()).setWindow(TOP_WINDOW).inject();
    ScriptInjector.fromString(HtmlEditorResources.INSTANCE.wysihtmlToolbar().getText()).setWindow(TOP_WINDOW).inject();
    ScriptInjector.fromString(HtmlEditorResources.INSTANCE.parserRules().getText()).setWindow(TOP_WINDOW).inject();
    PatternFlyBootstrapper.ensurejQueryIsAvailable();
}