List of usage examples for com.vaadin.ui JavaScriptFunction JavaScriptFunction
JavaScriptFunction
From source file:annis.gui.components.CssRenderInfo.java
License:Apache License
public CssRenderInfo(final Callback callback) { addFunction("publishResults", new JavaScriptFunction() { @Override/*from w w w .j a v a 2 s .co m*/ public void call(JsonArray arguments) throws JSONException { if (callback != null) { callback.renderInfoReceived((int) arguments.getNumber(0), (int) arguments.getNumber(1)); } } }); }
From source file:annis.gui.components.FrequencyWhiteboard.java
License:Apache License
public FrequencyWhiteboard(final FrequencyResultPanel freqPanel) { setHeight("100%"); setWidth("200px"); addStyleName("frequency-chart"); addFunction("selectRow", new JavaScriptFunction() { @Override//from w w w .ja v a 2 s . c om public void call(JsonArray arguments) throws JSONException { freqPanel.selectRow((int) arguments.getNumber(0)); } }); OnLoadCallbackExtension ext = new OnLoadCallbackExtension(this); ext.extend((FrequencyWhiteboard) this); }
From source file:annis.gui.components.medialement.MediaElementPlayer.java
License:Apache License
public MediaElementPlayer(MediaElement elementType, String resourceURL, String mimeType) { this.callbacks = new HashSet<>(); this.wasLoaded = false; getState().setElementType(elementType); getState().setResourceURL(resourceURL); getState().setMimeType(mimeType);//from w w w. j a v a2 s .com final MediaElementPlayer finalThis = this; addFunction("wasLoaded", new JavaScriptFunction() { @Override public void call(JsonArray arguments) throws JSONException { wasLoaded = true; for (Callback c : callbacks) { c.visualizerLoaded(finalThis); } } }); addFunction("cannotPlay", new CannotPlayFunction()); }
From source file:annis.gui.components.OnLoadCallbackExtension.java
License:Apache License
public OnLoadCallbackExtension(final Callback c, final int recallDelay) { addFunction("loaded", new JavaScriptFunction() { @Override/*from w w w.ja v a 2 s . co m*/ public void call(JsonArray arguments) throws JSONException { if (c != null) { boolean handled = c.onCompononentLoaded(target); if (!handled) { callFunction("requestRecall", recallDelay); } } } }); }
From source file:annis.gui.components.ScreenshotMaker.java
License:Apache License
public ScreenshotMaker(final ScreenshotCallback callback) { Validate.notNull(callback);// w w w .j av a2s . com addFunction("finishedScreenshot", new JavaScriptFunction() { @Override public void call(JsonArray arguments) throws JSONException { parseAndCallback(arguments.getString(0), callback); } }); }
From source file:annis.gui.components.SettingsStorage.java
License:Apache License
public SettingsStorage(UI ui) { if (ui != null) { extend(ui);/* ww w . j a v a2 s . c om*/ } addFunction("loadFromClient", new JavaScriptFunction() { @Override public void call(JsonArray args) { JsonObject values = args.get(0); for (String key : values.keys()) { JsonValue v = values.get(key); if (v.getType() == JsonType.STRING) { storage.put(key, v.asString()); } else if (v.getType() == JsonType.OBJECT) { storage.put(key, v.toJson()); } } for (LoadedListener l : loadedListeners) { l.onSettingsLoaded(SettingsStorage.this); } } }); }
From source file:com.constellio.app.ui.pages.base.MainLayoutImpl.java
protected void buildInitJavascript() { JavaScript.getCurrent().addFunction("constellio_easter_egg_code", new JavaScriptFunction() { @Override//ww w . j a v a 2 s . c o m public void call(JsonArray arguments) { ((ConstellioMenuImpl) mainMenu).getUserSettingsItem() .setIcon(new ThemeResource("images/profiles/egg.jpg")); } }); }
From source file:com.esofthead.mycollab.vaadin.web.ui.NotificationComponent.java
License:Open Source License
public NotificationComponent() { super();/*w w w .j a v a 2 s.c o m*/ notificationItems = new ArrayList<>(); notificationContainer = new VerticalLayout(); new Restrain(notificationContainer).setMaxWidth("500px"); this.setContent(notificationContainer); this.setIcon(FontAwesome.BELL); this.setStyleName("notification-button"); addPopupVisibilityListener(this); EventBusFactory.getInstance().register(this); // Register to receive broadcasts NotificationBroadcaster.register(this); JavaScript.getCurrent().addFunction("com.mycollab.scripts.upgrade", new JavaScriptFunction() { @Override public void call(JsonArray arguments) { String version = arguments.getString(0); String installerFile = arguments.getString(1); String manualDownloadLink = arguments.getString(2); UI.getCurrent().addWindow(new UpgradeConfirmWindow(version, manualDownloadLink, installerFile)); } }); }
From source file:com.hybridbpm.ui.component.TransitionManager.java
License:Apache License
public TransitionManager(final ProcessModelLayoutInterface pml) { this.processModelLayout = pml; addFunction("changePosition", new JavaScriptFunction() { private static final long serialVersionUID = 1256984845028849243L; @Override/* w ww.java2s . c o m*/ public void call(JsonArray arguments) { processModelLayout.setTransitionElementValue(arguments.getString(0), (float) arguments.getNumber(1), (float) arguments.getNumber(2)); } }); addFunction("addTransition", new JavaScriptFunction() { private static final long serialVersionUID = 1256984843458849243L; @Override public void call(JsonArray arguments) { processModelLayout.addTransitionElement(arguments.getString(0), arguments.getString(1)); } }); addFunction("addTask", new JavaScriptFunction() { private static final long serialVersionUID = 1256984843458849243L; @Override public void call(JsonArray arguments) { processModelLayout.addTaskModel((float) arguments.getNumber(0), (float) arguments.getNumber(1)); } }); addFunction("setTransitionActive", new JavaScriptFunction() { private static final long serialVersionUID = 1256984843458849243L; @Override public void call(JsonArray arguments) { processModelLayout.setTransitionActive(arguments.getString(0)); } }); addFunction("setProcessActive", new JavaScriptFunction() { private static final long serialVersionUID = 1256984843458849243L; @Override public void call(JsonArray arguments) { processModelLayout.setProcessActive(); } }); }
From source file:com.hybridbpm.ui.util.CookieManager.java
License:Apache License
public static void getCookieValue(String key, final Callback callback) { final String callbackid = "hybridbpmcookie" + UUID.randomUUID().toString().substring(0, 8); JavaScript.getCurrent().addFunction(callbackid, new JavaScriptFunction() { @Override//ww w . j a v a2 s . co m public void call(JsonArray arguments) { JavaScript.getCurrent().removeFunction(callbackid); if (arguments.length() == 0) { callback.onValue(null); } else { callback.onValue(arguments.getString(0)); } } }); JavaScript.getCurrent().execute(String.format( "var nameEQ = \"%2$s=\";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++) {var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) {%1$s( c.substring(nameEQ.length,c.length)); return;};} %1$s();", callbackid, key)); }