List of usage examples for com.vaadin.ui Notification show
public static Notification show(String caption)
From source file:com.hack23.cia.web.impl.ui.application.views.admin.datasummary.pagemode.DataSummaryOverviewPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_ADMIN" }) @Override/*from w ww . ja v a 2 s. c o m*/ public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout content = createPanelContent(); getMenuItemFactory().createMainPageMenuBar(menuBar); LabelFactory.createHeader2Label(content, ADMIN_DATA_SUMMARY); final Table createDataSummaryTable = tableFactory.createDataSummaryTable(); content.addComponent(createDataSummaryTable); content.setExpandRatio(createDataSummaryTable, ContentRatio.LARGE); content.setSizeFull(); content.setMargin(false); content.setSpacing(true); final Button refreshViewsButton = new Button(REFRESH_VIEWS, FontAwesome.REFRESH); refreshViewsButton.addClickListener(event -> { final RefreshDataViewsRequest serviceRequest = new RefreshDataViewsRequest(); serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); getApplicationManager().asyncService(serviceRequest); Notification.show(REFRESH_VIEWS_STARTED); }); content.addComponent(refreshViewsButton); content.setExpandRatio(refreshViewsButton, ContentRatio.SMALL); final Button updateSearchIndexButton = new Button(UPDATE_SEARCH_INDEX, FontAwesome.REFRESH); updateSearchIndexButton.addClickListener(event -> { final UpdateSearchIndexRequest serviceRequest = new UpdateSearchIndexRequest(); serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); getApplicationManager().asyncService(serviceRequest); Notification.show(UPDATE_SEARCH_INDEX_STARTED); }); content.addComponent(updateSearchIndexButton); content.setExpandRatio(updateSearchIndexButton, ContentRatio.SMALL); return content; }
From source file:com.haulmont.cuba.web.exception.ExceptionDialog.java
License:Apache License
public void sendSupportEmail(String message, String stackTrace) { try {// w ww .j ava 2 s . c o m User user = userSessionSource.getUserSession().getUser(); String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timeSource.currentTimestamp()); Map<String, Object> binding = new HashMap<>(); binding.put("timestamp", date); binding.put("errorMessage", message); binding.put("stacktrace", stackTrace); binding.put("systemId", clientConfig.getSystemID()); binding.put("userLogin", user.getLogin()); if (MapUtils.isNotEmpty(additionalExceptionReportBinding)) { binding.putAll(additionalExceptionReportBinding); } reportService.sendExceptionReport(clientConfig.getSupportEmail(), MapUtils.unmodifiableMap(binding)); Notification.show(messages.getMainMessage("exceptionDialog.emailSent")); } catch (Throwable e) { log.error("Error sending exception report", e); Notification.show(messages.getMainMessage("exceptionDialog.emailSendingErr")); } }
From source file:com.haulmont.cuba.web.LoginWindow.java
License:Apache License
protected void login() { String login = loginField.getValue(); String password = passwordField.getValue() != null ? passwordField.getValue() : ""; if (StringUtils.isEmpty(login) || StringUtils.isEmpty(password)) { String message = messages.getMainMessage("loginWindow.emptyLoginOrPassword", resolvedLocale); Notification notification = new Notification(message, Type.WARNING_MESSAGE); notification.setDelayMsec(WebWindowManager.WARNING_NOTIFICATION_DELAY_MSEC); notification.show(ui.getPage()); return;/*from w ww. java2 s . c o m*/ } if (!bruteForceProtectionCheck(login, app.getClientAddress())) { return; } try { Locale locale = getUserLocale(); app.setLocale(locale); PasswordEncryption passwordEncryption = AppBeans.get(PasswordEncryption.NAME); if (loginByRememberMe && rememberMeAllowed) { loginByRememberMe(login, password, locale); } else if (configuration.getConfig(WebAuthConfig.class).getExternalAuthentication()) { // try to login as externally authenticated user, fallback to regular authentication // we use resolved locale for error messages if (authenticateExternally(login, password, resolvedLocale)) { login = convertLoginString(login); ((ExternallyAuthenticatedConnection) connection).loginAfterExternalAuthentication(login, locale); } else { login(login, passwordEncryption.getPlainHash(password), locale); } } else { login(login, passwordEncryption.getPlainHash(password), locale); } // locale could be set on the server if (connection.getSession() != null) { app.setLocale(connection.getSession().getLocale()); if (globalConfig.getLocaleSelectVisible()) { app.addCookie(COOKIE_LOCALE, locale.toLanguageTag()); } } } catch (LoginException e) { log.info("Login failed: {}", e.toString()); String message = StringUtils.abbreviate(e.getMessage(), 1000); String bruteForceMsg = registerUnsuccessfulLoginAttempt(login, app.getClientAddress()); if (!Strings.isNullOrEmpty(bruteForceMsg)) { message = bruteForceMsg; } showLoginException(message); } catch (Exception e) { log.warn("Unable to login", e); showException(e); } }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
@Override public void showNotification(String caption, String description, NotificationType type) { backgroundWorker.checkUIAccess();/*from w w w . j ava 2 s. co m*/ Notification notification = new Notification(caption, description, convertNotificationType(type)); notification.setHtmlContentAllowed(NotificationType.isHTML(type)); setNotificationDelayMsec(notification, type); notification.show(Page.getCurrent()); }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
@Override protected void checkCanOpenWindow(WindowInfo windowInfo, OpenType openType, Map<String, Object> params) { if (openType.getOpenMode() != OpenMode.NEW_TAB && openType.getOpenMode() != OpenMode.NEW_WINDOW) { return;// ww w . j av a 2 s .c om } if (!windowInfo.getMultipleOpen() && getWindow(getHash(windowInfo, params)) != null) { //window is already open return; } int maxCount = webConfig.getMaxTabCount(); if (maxCount > 0 && maxCount <= tabs.size()) { Notification notification = new Notification( messages.formatMainMessage("tooManyOpenTabs.message", maxCount), Notification.Type.WARNING_MESSAGE); notification.setDelayMsec(WARNING_NOTIFICATION_DELAY_MSEC); notification.show(ui.getPage()); throw new SilentException(); } }
From source file:com.hivesys.dashboard.view.search.TextualView.java
public void UpdateSearchPane(String searchString) { css.removeAllComponents();/*from w w w .java 2 s. c o m*/ SearchResponse response = ElasticSearchContext.getInstance().searchSimpleQuery(searchString); logResponse(response); SearchHits results = response.getHits(); Label labelResultSummary = new Label("About " + results.getHits().length + " results found <br><br>", ContentMode.HTML); css.addComponent(labelResultSummary); for (SearchHit hit : results) { CssLayout cssResult = new CssLayout(); cssResult.setStyleName("search-result"); try { String filename = DocumentDB.getInstance().getDocumentNameFromHash(hit.getId()); String boxviewID = DocumentDB.getInstance().getBoxViewIDFromHash(hit.getId()); String highlight = ""; HighlightField objhighlight = hit.highlightFields().get("file"); if (objhighlight != null) { for (Text fgmt : objhighlight.getFragments()) { highlight += fgmt.string() + "<br>"; } } Button lblfileName = new Button(filename); lblfileName.addClickListener((Button.ClickEvent event) -> { if (boxviewID != null) { String url = BoxViewDocuments.getInstance().getViewURL(boxviewID); if (url != null || !url.equals("")) { url = BoxViewDocuments.getInstance().getViewURL(boxviewID); BrowserFrame bframe = new BrowserFrame(filename, new ExternalResource(url)); VerticalLayout vlayout = new VerticalLayout(bframe); final Window w = new Window(); w.setSizeFull(); w.setModal(true); w.setWindowMode(WindowMode.MAXIMIZED); w.setContent(vlayout); vlayout.setSizeFull(); vlayout.setMargin(true); w.setResizable(false); w.setDraggable(false); UI.getCurrent().addWindow(w); bframe.setSizeFull(); return; } Notification.show("Preview not available for this document!"); } }); lblfileName.setPrimaryStyleName("filename"); Label lblHighlight = new Label(highlight, ContentMode.HTML); lblHighlight.setStyleName("highlight"); cssResult.addComponent(lblfileName); cssResult.addComponent(lblHighlight); css.addComponent(cssResult); css.addComponent(new Label("<br>", ContentMode.HTML)); } catch (SQLException ex) { } } }
From source file:com.jain.addon.component.upload.JUploader.java
License:Apache License
protected void interruptUpload() { upload.interruptUpload();/* w w w . ja v a2 s . com*/ I18NProvider provider = ((I18NUI) getUI()).getI18nProvider(); Notification n = new Notification(provider.getTitle(getLocale(), interruptionMessage), Type.TRAY_NOTIFICATION); n.setPosition(Position.MIDDLE_CENTER); n.setDescription(provider.getMessage(getLocale(), interruptionMessage)); n.show(getUI().getPage()); pi.setVisible(false); upload.setVisible(true); }
From source file:com.jain.addon.helper.JNHelper.java
License:Apache License
/** * Method to create and Show notification * @param currentUI//w ww . ja va 2s .c o m * @param title * @param message * @param params */ public static void showNotification(UI currentUI, String title, String message, Object... params) { Notification notification = createNotification(currentUI, title, message, params); notification.show(currentUI.getPage()); }
From source file:com.jain.i18N.annotation.PersonAnnotationTabContent.java
License:Apache License
@JNIObserver(PERSON_CREATED_OR_UPDATED) public void createUpdateObserver(Person person) { Notification notification = VaadinHelper.createNotificationMessage("person.object.created.updated", "person.object.created.updated", person.getDisplayName()); notification.show(getUI().getPage()); }
From source file:com.jain.i18N.annotation.PersonAnnotationTabContent.java
License:Apache License
@JNIObserver(PERSON_DELETED) public void deletedObserver(Person person) { Notification notification = VaadinHelper.createNotificationMessage("person.object.deleted", "person.object.deleted", person.getDisplayName()); notification.show(getUI().getPage()); }