List of usage examples for com.vaadin.ui JavaScript execute
public void execute(String script)
From source file:com.haulmont.cuba.web.sys.LinkHandler.java
License:Apache License
protected void substituteUserAndOpenWindow(final WindowInfo windowInfo, UUID userId) { UserSession userSession = app.getConnection().getSession(); final User substitutedUser = loadUser(userId, userSession.getUser()); if (substitutedUser != null) { Map<String, String> currentRequestParams = new HashMap<>(requestParams); app.getWindowManager().showOptionDialog(messages.getMainMessage("toSubstitutedUser.title"), getDialogMessage(substitutedUser), MessageType.CONFIRMATION_HTML, new Action[] { new ChangeSubstUserAction(substitutedUser) { @Override/*from w ww.j a v a 2 s.c o m*/ public void doAfterChangeUser() { super.doAfterChangeUser(); openWindow(windowInfo, currentRequestParams); } @Override public void doRevert() { super.doRevert(); JavaScript js = Page.getCurrent().getJavaScript(); js.execute("window.close();"); } @Override public String getCaption() { return messages.getMainMessage("action.switch"); } }, new DoNotChangeSubstUserAction() { @Override public void actionPerform(Component component) { super.actionPerform(component); JavaScript js = Page.getCurrent().getJavaScript(); js.execute("window.close();"); } @Override public String getCaption() { return messages.getMainMessage("action.cancel"); } } }); } else { User user = loadUser(userId); app.getWindowManager().showOptionDialog(messages.getMainMessage("warning.title"), getWarningMessage(user), MessageType.WARNING_HTML, new Action[] { new DialogAction(DialogAction.Type.OK).withHandler(event -> { JavaScript js = Page.getCurrent().getJavaScript(); js.execute("window.close();"); }) }); } }
From source file:de.metas.procurement.webui.util.JavascriptUtils.java
License:Open Source License
public static void setBeforePageUnloadMessage(final String message) { final JavaScript javaScript = Page.getCurrent().getJavaScript(); if (message == null || message.trim().isEmpty()) { javaScript.execute("$(window).off('beforeunload');"); } else {/* w ww .j av a2 s.c o m*/ // TODO: escape the message javaScript.execute("$(window).on('beforeunload', function() { return \"" + message + "\"; });"); } }
From source file:de.metas.procurement.webui.util.SwipeHelper.java
License:Open Source License
public synchronized void enable(final Component component, final SwipeHandler handler) { Preconditions.checkNotNull(component, "component is null"); final String componentId = component.getId(); Preconditions.checkNotNull(componentId, "componentId is null"); final ComponentSwipe swipe = new ComponentSwipe(componentId, handler); component2swipe.put(component, swipe); componentId2swipe.put(componentId, swipe); registerJavaScriptFunctionsIfNeeded(); final JavaScript javaScript = JavaScript.getCurrent(); javaScript.execute("" + "if (!window.swipesMap) { window.swipesMap={}; }" ///*w w w . j a va2 s .co m*/ + "window.swipesMap['" + componentId + "'] = Swiped.init({" + "query: '#" + componentId + "'" + ", left: 300" + ", right: 300" + ", tolerance: 200" + ", onOpen: function() { " + JS_FUNC_OnSwipe + "('" + componentId + "'); }" + "});" // + "\n console.log('Enabled swiping for element: " + componentId + "');"); }
From source file:org.eclipse.hawkbit.ui.distributions.smtable.SwModuleTable.java
License:Open Source License
private static void addTypeStyle(final Long tagId, final String color) { final JavaScript javaScript = UI.getCurrent().getPage().getJavaScript(); UI.getCurrent()// w ww . j ava2s . co m .access(() -> javaScript.execute(HawkbitCommonUtil.getScriptSMHighlightWithColor( ".v-table-row-distribution-upload-type-" + tagId + "{background-color:" + color + " !important;background-image:none !important }"))); }