本文整理匯總了Java中com.google.gwt.core.client.ScriptInjector類的典型用法代碼示例。如果您正苦於以下問題:Java ScriptInjector類的具體用法?Java ScriptInjector怎麽用?Java ScriptInjector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ScriptInjector類屬於com.google.gwt.core.client包,在下文中一共展示了ScriptInjector類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: HelloWorldViewPresenter
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
@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();
}
示例2: onModuleLoad
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
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());
}
示例3: injectDocReadyAndC8OCoreScripts
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
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();
}
示例4: init
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
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();
}
示例5: injectJqueryScript
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
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();
}
示例6: addPremiumSupportHelpAction
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
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();
}
示例7: onModuleLoad
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
/** {@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();
}
}
示例8: onModuleLoad
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
@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!");
}
示例9: inject
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
@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();
}
示例10: injectScriptOneAfterAnother
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
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();
}
示例11: ActivityTrackingExtension
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
@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();
}
示例12: injectScript
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
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();
}
示例13: load
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
/**
* 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);
}
示例14: startPlugins
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
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();
}
示例15: inject
import com.google.gwt.core.client.ScriptInjector; //導入依賴的package包/類
/**
* 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();
}
}