com.google.gwt.core.client.ScriptInjector Java Examples
The following examples show how to use
com.google.gwt.core.client.ScriptInjector.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceLoader.java From core with GNU Lesser General Public License v2.1 | 6 votes |
@Inject public ResourceLoader(ConsoleResources resources, ProductConfig productConfig) { resources.css().ensureInjected(); if (productConfig.getProfile().equals(ProductConfig.Profile.COMMUNITY)) { resources.communityStyles().ensureInjected(); } else { resources.productStyles().ensureInjected(); } //resources.verticalTabPanelStyles().ensureInjected(); resources.prettifyCss().ensureInjected(); ProgressPolyfill.inject(); ScriptInjector.fromString(resources.prettifyJs().getText()).setWindow(ScriptInjector.TOP_WINDOW) .inject(); ScriptInjector.fromString(resources.lunrJs().getText()).setWindow(ScriptInjector.TOP_WINDOW) .inject(); ScriptInjector.fromString(resources.mousetrapJs().getText()).setWindow( ScriptInjector.TOP_WINDOW).inject(); ScriptInjector.fromString(resources.protovis().getText()).setWindow(ScriptInjector.TOP_WINDOW) .inject(); }
Example #2
Source File: FullCalendarEntryPoint.java From gwtbootstrap3-extras with Apache License 2.0 | 6 votes |
@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(); } }
Example #3
Source File: EventSource.java From gwtbootstrap3-extras with Apache License 2.0 | 6 votes |
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); }
Example #4
Source File: CollectionWebApp.java From gwt-boot-samples with Apache License 2.0 | 6 votes |
private void injectTomatoScript() { logger.info("Inject tomato.js"); ScriptInjector.fromUrl(TOMATO_JS_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( "tomato.js loaded successfully and executed!"); } }).setRemoveTag(true).setWindow(ScriptInjector.TOP_WINDOW) .inject(); }
Example #5
Source File: LeafletMap.java From unitime with Apache License 2.0 | 6 votes |
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 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(); }
Example #6
Source File: GoogleMap.java From unitime with Apache License 2.0 | 6 votes |
@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 public void onSuccess(Void result) { } @Override public void onFailure(Exception e) { UniTimeNotifications.error(e.getMessage(), e); setVisible(false); iMapControl = null; } }).inject(); }
Example #7
Source File: ApiRegistry.java From gwt-material with Apache License 2.0 | 6 votes |
/** * Will register the {@link ApiFeature} to the list of features providing also the Javascript Script element object * for later removal / update. */ public static void register(ApiFeature apiFeature, Callback<Void, Exception> callback) { if (apiFeature != null && apiFeature.getApiKey() != null && !apiFeature.getApiKey().isEmpty()) { JavaScriptObject scriptObject = ScriptInjector.fromUrl(apiFeature.constructApiUrl()) .setWindow(ScriptInjector.TOP_WINDOW) .setCallback(new Callback<Void, Exception>() { @Override public void onFailure(Exception e) { callback.onFailure(e); } @Override public void onSuccess(Void aVoid) { callback.onSuccess(aVoid); } }).inject(); features.put(apiFeature, scriptObject); } }
Example #8
Source File: HelpExtension.java From codenvy with Eclipse Public License 1.0 | 6 votes |
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(); }
Example #9
Source File: DemoGwtWebApp.java From demo-gwt-springboot with Apache License 2.0 | 6 votes |
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(); }
Example #10
Source File: AppTest.java From gdx-fireapp with Apache License 2.0 | 6 votes |
@Test public void configure() throws Exception { // Given App app = new App(); FirebaseConfigParser configParser = PowerMockito.mock(FirebaseConfigParser.class); PowerMockito.whenNew(FirebaseConfigParser.class).withAnyArguments().thenReturn(configParser); ScriptInjector.FromUrl fromUrl = PowerMockito.mock(ScriptInjector.FromUrl.class); Mockito.when(ScriptInjector.fromUrl(Mockito.nullable(String.class))).thenReturn(fromUrl); Mockito.when(fromUrl.setCallback(Mockito.nullable(Callback.class))).thenReturn(fromUrl); Mockito.when(fromUrl.setRemoveTag(Mockito.anyBoolean())).thenReturn(fromUrl); Mockito.when(fromUrl.setWindow(Mockito.nullable(JavaScriptObject.class))).thenReturn(fromUrl); // When app.configure(); // Then PowerMockito.verifyNew(FirebaseConfigParser.class, VerificationModeFactory.times(1)).withArguments(Mockito.anyString()); Mockito.verify(configParser, VerificationModeFactory.times(1)).getFirebaseScriptSrc(); }
Example #11
Source File: SummernoteBase.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
private void initialize() { // Inject the language JS is necessary if (language.getJs() != null) { ScriptInjector.fromString(language.getJs().getText()) .setWindow(ScriptInjector.TOP_WINDOW).inject(); } // Initialize initialize(getElement(), options); // Enable/Disable editor setEnabled(enabled); }
Example #12
Source File: DateTimePickerBase.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void setLanguage(final DateTimePickerLanguage language) { this.language = language; // Inject the JS for the language if (language.getJs() != null) { ScriptInjector.fromString(language.getJs().getText()) .setWindow(ScriptInjector.TOP_WINDOW).inject(); } }
Example #13
Source File: RespondEntryPoint.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
@Override public void onModuleLoad() { if (Window.Navigator.getUserAgent().contains(MSIE) && Window.Navigator.getUserAgent().contains(EIGHT)) { ScriptInjector.fromString(RespondClientBundle.INSTANCE.respond().getText()).setWindow(ScriptInjector.TOP_WINDOW) .inject(); ScriptInjector.fromString(RespondClientBundle.INSTANCE.html5Shiv().getText()).setWindow(ScriptInjector.TOP_WINDOW) .inject(); } }
Example #14
Source File: DatePickerBase.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void setLanguage(final DatePickerLanguage language) { this.language = language; // Inject the JS for the language if (language.getJs() != null) { ScriptInjector.fromString(language.getJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); } }
Example #15
Source File: SelectBase.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
@Override protected void onLoad() { super.onLoad(); // Inject the language JS is necessary if (language.getJs() != null) { ScriptInjector.fromString(language.getJs().getText()) .setWindow(ScriptInjector.TOP_WINDOW).inject(); } initialize(getElement(), options); bindSelectEvents(getElement()); }
Example #16
Source File: EntryPoint.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void onModuleLoad() { ScriptInjector.fromString(Resources.INSTANCE.aceJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); ScriptInjector.fromString(Resources.INSTANCE.extSearchBoxJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); ScriptInjector.fromString(Resources.INSTANCE.modeXmlJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); ScriptInjector.fromString(Resources.INSTANCE.modeJsonJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); ScriptInjector.fromString(Resources.INSTANCE.modeLogfileJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); ScriptInjector.fromString(Resources.INSTANCE.themeChromeJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); ScriptInjector.fromString(Resources.INSTANCE.themeLogFileJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); }
Example #17
Source File: FullCalendar.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
private void ensureInjected(final Language language) { if (!languageScripts.isEmpty()) { for (final JavaScriptObject script : languageScripts.values()) { try { final Element ele = (Element) script; ele.removeFromParent(); } catch (final Exception e) { // TODO: handle exception } } } final JavaScriptObject scriptElement = ScriptInjector.fromString(language.getResource().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); languageScripts.put(language.getCode(), scriptElement); }
Example #18
Source File: FirebaseConfiguration.java From gdx-fireapp with Apache License 2.0 | 5 votes |
public void init() { if (rawHtml == null) { Gdx.app.error(GdxFIRLogger.getLogTag(), "You forgot about FirebaseConfiguration#init()"); return; } ScriptInjector.fromUrl(configParser.getFirebaseScriptSrc()) .setRemoveTag(false) .setWindow(ScriptInjector.TOP_WINDOW) .setCallback(new ScriptLoadedCallback(configParser)) .inject(); }
Example #19
Source File: FirebaseConfigurationTest.java From gdx-fireapp with Apache License 2.0 | 5 votes |
@Test public void init() { // Given Mockito.when(configFileMock.exists()).thenReturn(true); FirebaseConfiguration firebaseConfiguration = Mockito.spy(new FirebaseConfiguration()); // When firebaseConfiguration.load().init(); // Then PowerMockito.verifyStatic(ScriptInjector.class, VerificationModeFactory.times(1)); ScriptInjector.fromUrl(Mockito.anyString()); }
Example #20
Source File: MetricView.java From dashbuilder with Apache License 2.0 | 5 votes |
@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; } return true; }, 100); }
Example #21
Source File: DemoGwtWebApp.java From demo-gwt-springboot with Apache License 2.0 | 5 votes |
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(); }
Example #22
Source File: MaterialDesignBase.java From gwt-material with Apache License 2.0 | 5 votes |
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(); }
Example #23
Source File: MaterialDatePicker.java From gwt-material with Apache License 2.0 | 5 votes |
protected void setupLanguage(DatePickerLanguage language) { if (language.getJs() != null) { ScriptInjector.fromString(language.getJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); getPicker().stop(); Scheduler.get().scheduleDeferred(this::load); } }
Example #24
Source File: TypeaheadEntryPoint.java From gwtbootstrap3-extras with Apache License 2.0 | 4 votes |
@Override public void onModuleLoad() { ScriptInjector.fromString(TypeaheadClientBundle.INSTANCE.typeahead().getText()) .setWindow(ScriptInjector.TOP_WINDOW) .inject(); }
Example #25
Source File: ProgressPolyfill.java From core with GNU Lesser General Public License v2.1 | 4 votes |
public static void inject() { String js = Resources.INSTANCE.progressPolyfill().getText(); ScriptInjector.fromString(js).inject(); }
Example #26
Source File: ToggleSwitchEntryPoint.java From gwtbootstrap3-extras with Apache License 2.0 | 4 votes |
@Override public void onModuleLoad() { ScriptInjector.fromString(ToggleSwitchClientBundle.INSTANCE.toggleswitch().getText()).setWindow(ScriptInjector.TOP_WINDOW) .inject(); }
Example #27
Source File: NotifyEntryPoint.java From gwtbootstrap3-extras with Apache License 2.0 | 4 votes |
@Override public void onModuleLoad() { if (!isNotifyLoaded()) { ScriptInjector.fromString(NotifyClientBundle.INSTANCE.notifyJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); } }
Example #28
Source File: SummernoteEntryPoint.java From gwtbootstrap3-extras with Apache License 2.0 | 4 votes |
@Override public void onModuleLoad() { ScriptInjector.fromString(SummernoteClientBundle.INSTANCE.summernote().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); }
Example #29
Source File: DateTimePickerEntryPoint.java From gwtbootstrap3-extras with Apache License 2.0 | 4 votes |
@Override public void onModuleLoad() { ScriptInjector.fromString(DateTimePickerClientBundle.INSTANCE.dateTimePicker().getText()) .setWindow(ScriptInjector.TOP_WINDOW).inject(); }
Example #30
Source File: BootboxEntryPoint.java From gwtbootstrap3-extras with Apache License 2.0 | 4 votes |
@Override public void onModuleLoad() { ScriptInjector.fromString(BootboxClientBundle.INSTANCE.bootbox().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); }