List of usage examples for com.google.gwt.core.client ScriptInjector fromUrl
public static FromUrl fromUrl(String scriptUrl)
From source file:org.uberfire.jsbridge.client.AppFormerJsBridge.java
License:Apache License
public Promise<Void> loadAppFormerJsAndReactScripts(final String gwtModuleName) { return promises.create((res, rej) -> { final Consumer<Exception> onError = ex -> { workbench.removeStartupBlocker(AppFormerJsBridge.class); rej.onInvoke(null);/*from w ww .j av a 2s. co m*/ }; final CallbackProducer<Void> callback = new CallbackProducer<>(onError); ScriptInjector.fromUrl(gwtModuleName + "/react.production.min.js").setWindow(ScriptInjector.TOP_WINDOW) .setCallback(callback.withSuccess((v) -> ScriptInjector .fromUrl(gwtModuleName + "/react-dom.production.min.js") .setWindow(ScriptInjector.TOP_WINDOW) .setCallback(callback.withSuccess((v1) -> ScriptInjector .fromUrl(gwtModuleName + "/appformer.js").setWindow(ScriptInjector.TOP_WINDOW) .setCallback(callback.withSuccess((v2) -> ScriptInjector .fromUrl(gwtModuleName + "/AppFormerComponentsRegistry.js") .setWindow(ScriptInjector.TOP_WINDOW) .setCallback(callback.withSuccess((v3) -> { res.onInvoke((IThenable<Void>) null); })).inject())) .inject())) .inject())) .inject(); }); }
From source file:org.uberfire.jsbridge.client.loading.AppFormerJsActivityLoader.java
License:Apache License
Promise<Void> loadScript(final String scriptUrl) { return promises.create((res, rej) -> ScriptInjector.fromUrl(scriptUrl).setWindow(TOP_WINDOW) .setCallback(getScriptInjectionCallback(res, rej)).inject()); }
From source file:org.unitime.timetable.gwt.client.rooms.GoogleMap.java
License:Apache License
@Override public void setup() { ScriptInjector .fromUrl("https://maps.googleapis.com/maps/api/js?" + (iApiKey != null && !iApiKey.isEmpty() ? "key=" + iApiKey + "&" : "") + "sensor=false&callback=setupGoogleMap") .setWindow(ScriptInjector.TOP_WINDOW).setCallback(new Callback<Void, Exception>() { @Override/*from ww w .ja va 2s. c o m*/ public void onSuccess(Void result) { } @Override public void onFailure(Exception e) { UniTimeNotifications.error(e.getMessage(), e); setVisible(false); iMapControl = null; } }).inject(); }
From source file:org.unitime.timetable.gwt.client.rooms.LeafletMap.java
License:Apache License
public void setup() { loadCss(GWT.getHostPageBaseURL() + "leaflet/leaflet.css"); ScriptInjector.fromUrl(GWT.getHostPageBaseURL() + "leaflet/leaflet.js").setWindow(ScriptInjector.TOP_WINDOW) .setCallback(new Callback<Void, Exception>() { @Override/*from w ww . j a va2s . c om*/ public void onSuccess(Void result) { setupLeafletMap(iTileUrl, iTileAttribution); setLeafletMarker(); leafletReverseGeocode(); } @Override public void onFailure(Exception e) { UniTimeNotifications.error(e.getMessage(), e); setVisible(false); iMapControl = null; } }).inject(); }
From source file:org.unitime.timetable.gwt.client.rooms.RoomEdit.java
License:Apache License
public void show() { UniTimePageLabel.getInstance()//from ww w . j a va2 s. c o m .setPageName(iRoom.getUniqueId() == null ? MESSAGES.pageAddRoom() : MESSAGES.pageEditRoom()); setVisible(true); iLastScrollLeft = Window.getScrollLeft(); iLastScrollTop = Window.getScrollTop(); onShow(); Window.scrollTo(0, 0); if (iGoogleMap != null && !iGoogleMapInitialized) { iGoogleMapInitialized = true; ScriptInjector.fromUrl("https://maps.google.com/maps/api/js?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(); } }
From source file:org.waveprotocol.box.webclient.client.atmosphere.AtmosphereConnectionImpl.java
License:Apache License
@Override public void connect() { if (socket == null) { ScriptInjector.fromUrl("/atmosphere/atmosphere.js").setCallback(new Callback<Void, Exception>() { public void onFailure(Exception reason) { throw new IllegalStateException("atmosphere.js load failed!"); }//from w w w . j ava 2 s. c o m public void onSuccess(Void result) { socket = AtmosphereSocket.create(AtmosphereConnectionImpl.this, urlBase); socket.connect(); } }).setWindow(ScriptInjector.TOP_WINDOW).inject(); } else { if (AtmosphereConnectionState.CLOSED.equals(this.state)) socket.connect(); } }
From source file:org.waveprotocol.box.webclient.client.atmosphere.WaveSocketAtmosphere.java
License:Apache License
@Override public void connect() { if (socket == null) { // Build the atmosphere.js URL using the Websocket URL final String scriptHost = urlBase.startsWith("wss://") ? "https://" + urlBase.substring(6) : "http://" + urlBase.substring(5); String scriptUrl = new String(scriptHost); // Remove trailing '/' before add context if (scriptUrl.lastIndexOf("/") == scriptUrl.length() - 1) scriptUrl = scriptUrl.substring(0, scriptUrl.length() - 1); scriptUrl += "/atmosphere/atmosphere.js"; ScriptInjector.fromUrl(scriptUrl).setCallback(new Callback<Void, Exception>() { public void onFailure(Exception reason) { throw new IllegalStateException("atmosphere.js load failed!"); }//w w w .j ava 2 s . com public void onSuccess(Void result) { // We assume Atmosphere is going to work only with http(s) schemas socket = AtmosphereSocket.create(WaveSocketAtmosphere.this, scriptHost, useWebSocket ? "websocket" : "long-polling", "long-polling", "1.0", sessionId); // Check version value in Model.MODEL_VERSION socket.connect(); } }).setWindow(ScriptInjector.TOP_WINDOW).inject(); } else { socket.connect(); } }