List of usage examples for com.vaadin.ui Notification Notification
public Notification(String caption, String description, Type type)
From source file:com.mycollab.vaadin.web.ui.NotificationComponent.java
License:Open Source License
private void displayTrayNotification(AbstractNotification item) { if (item instanceof NewUpdateAvailableNotification) { NewUpdateAvailableNotification updateNo = (NewUpdateAvailableNotification) item; Notification no;//ww w . j av a 2s . com if (UserUIContext.isAdmin()) { no = new Notification(UserUIContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE), UserUIContext.getMessage(ShellI18nEnum.OPT_HAVING_NEW_VERSION, ((NewUpdateAvailableNotification) item).getVersion()) + " " + new A("javascript:com.mycollab.scripts.upgrade('" + updateNo.getVersion() + "','" + updateNo.getAutoDownloadLink() + "','" + updateNo.getManualDownloadLink() + "')").appendText(UserUIContext.getMessage(ShellI18nEnum.ACTION_UPGRADE)), Notification.Type.TRAY_NOTIFICATION); } else { no = new Notification(UserUIContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE), UserUIContext.getMessage(ShellI18nEnum.OPT_HAVING_NEW_VERSION, ((NewUpdateAvailableNotification) item).getVersion()), Notification.Type.TRAY_NOTIFICATION); } no.setHtmlContentAllowed(true); no.setDelayMsec(300000); UI currentUI = this.getUI(); AsyncInvoker.access(getUI(), new AsyncInvoker.PageCommand() { @Override public void run() { no.show(currentUI.getPage()); } }); } }
From source file:com.salsaw.msalsa.HomePageView.java
License:Apache License
/** * The constructor should first build the main layout, set the * composition root and then do any custom initialization. * * The constructor will not be automatically regenerated by the * visual editor./*from w ww. j a v a 2 s . c om*/ * @param navigator */ public HomePageView(SalsaParameters salsaParameters) { if (salsaParameters == null) { throw new IllegalArgumentException("salsaParameters"); } buildMainLayout(); // Create form with salsa parameters BeanItem<SalsaParameters> salsaParametersBeanItem = new BeanItem<SalsaParameters>(salsaParameters); SalsaParametersForm salsaParametersForm = new SalsaParametersForm(salsaParametersBeanItem); Button toogleSalsaParametersButton = new Button("Show/Hide M-SALSA Parameters"); toogleSalsaParametersButton.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { salsaParametersForm.setVisible(!salsaParametersForm.isVisible()); } }); toogleSalsaParametersButton.setWidth("-1px"); toogleSalsaParametersButton.setHeight("-1px"); mainLayout.addComponent(toogleSalsaParametersButton); mainLayout.setComponentAlignment(toogleSalsaParametersButton, new Alignment(48)); salsaParametersForm.setWidth("-1px"); salsaParametersForm.setHeight("-1px"); mainLayout.addComponent(salsaParametersForm); mainLayout.setComponentAlignment(salsaParametersForm, new Alignment(48)); setCompositionRoot(mainLayout); // TODO add user code here // Implement both receiver that saves upload in a file and // listener for successful upload class AligmentUploader implements Receiver, SucceededListener { /** * */ private static final long serialVersionUID = 1L; public File file; public OutputStream receiveUpload(String filename, String mimeType) { // Create upload stream FileOutputStream fos = null; // Stream to write to try { // Load server configuration String tmpFolder = ConfigurationManager.getInstance().getServerConfiguration() .getTemporaryFilePath(); // Open the file for writing. file = Paths.get(tmpFolder, filename).toFile(); fos = new FileOutputStream(file); } catch (final java.io.FileNotFoundException e) { new Notification("Could not open file<br/>", e.getMessage(), Notification.Type.ERROR_MESSAGE) .show(Page.getCurrent()); return null; } return fos; // Return the output stream to write to } public void uploadSucceeded(SucceededEvent event) { try { for (IHomePageListener listener : listeners) { listener.buttonClick(file); } } catch (SALSAException | IOException | InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); new Notification("ERROR: ", e.getMessage(), Notification.Type.ERROR_MESSAGE) .show(Page.getCurrent()); } } } ; AligmentUploader receiver = new AligmentUploader(); uploadInput.setReceiver(receiver); uploadInput.addSucceededListener(receiver); }
From source file:com.savoirfairelinux.presentations.QuoteView.java
License:Open Source License
/** * Listeners allow us to attach actions to different events. For example, a value change listener is triggered * when a UI component such a drop down menu has a change in its value. Or, a click listener is triggered when * an action is performed on a button./*from w w w . ja va 2 s . com*/ */ private void addClickListeners() { // We basically indicate that aside from the initial setup, we can't have a null or empty value, avoids things // like null pointer exceptions. vehicleType.setNullSelectionAllowed(false); /* Slightly quick and dirty, and in terms of space and time complexity, it isn't ideal: We have detected that we switched to an item Remove all existing data in the dropdown boxes Add appropriate data to the boxes Make sure that the boxes are modifiable */ vehicleType.addValueChangeListener(valueChangeEvent -> { if (valueChangeEvent.getProperty().getValue().equals("Motorcycle")) { year.setEnabled(true); } else if (valueChangeEvent.getProperty().getValue().equals("Automobile")) { year.setEnabled(true); } }); // We only allow a user to click next if we validated the current form. Otherwise, we should throw an error. next.addClickListener(e -> { if (personalGroup.isValid()) { setEnabled(true); setSelectedTab(1); } else { new Notification("Required Fields", "Please check that all fields are filled correctly", Notification.Type.ERROR_MESSAGE).show(Page.getCurrent()); } }); }
From source file:com.squadd.UI.UploadGroupImageWindow.java
protected void configureDownload() { // Show uploaded file in this placeholder image = new Image(""); image.setVisible(false);/*from ww w. j ava 2s . c o m*/ image.setHeight("256px"); // Implement both receiver that saves upload in a file and // listener for successful upload class ImageReceiver implements Upload.Receiver, Upload.SucceededListener { private static final long serialVersionUID = -1276759102490466761L; public java.io.File file; public OutputStream receiveUpload(String filename, String mimeType) { // Create upload stream FileOutputStream fos = null; // Stream to write to try { // Open the file for writing. grp.setLastUploadDate(System.currentTimeMillis()); String path = new ImageGetter().getPath(grp); file = new java.io.File(path); fos = new FileOutputStream(file); } catch (final java.io.FileNotFoundException e) { new Notification("Could not open file<br/>", e.getMessage(), Notification.Type.ERROR_MESSAGE) .show(Page.getCurrent()); return null; } return fos; // Return the output stream to write to } public void uploadSucceeded(Upload.SucceededEvent event) { // Show the uploaded file in the image viewer userImageFile = new File(); userImageFile.setPath(file.getPath()); image.setVisible(true); image.setSource(new FileResource(file)); } } ; ImageReceiver receiver = new ImageReceiver(); // Create the upload with a caption and set receiver later upload = new Upload("", receiver); //upload.setButtonCaption("Ok"); upload.addSucceededListener(receiver); }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.FolderView.java
@Override public void enter(ViewChangeListener.ViewChangeEvent event) { // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. if (event.getParameters() == null || event.getParameters().isEmpty()) { this.addComponent(new EmptyView()); return;/* w ww .j a va 2s .c o m*/ } else { this.loadFolder(event.getParameters()); Notification note = new Notification("Notificaton", event.getParameters().toString(), Notification.Type.TRAY_NOTIFICATION); note.show(Page.getCurrent()); } // event.getParameters())); }
From source file:com.wintindustries.pfserver.uploads.PFUploadUnit.java
public void upload() { final ProgressIndicator pi = new ProgressIndicator(); pi.setCaption(html5File.getFileName()); progress.setCaption(html5File.getFileName()); getprogressBarsLayout().addComponent(pi); final FileBuffer receiver = createReceiver(); html5File.setStreamVariable(new StreamVariable() { private String name; private String mime; public OutputStream getOutputStream() { return receiver.receiveUpload(name, mime); }// w w w .j a va 2s . co m public boolean listenProgress() { return true; } public void onProgress(StreamVariable.StreamingProgressEvent event) { float p = (float) event.getBytesReceived() / (float) event.getContentLength(); pi.setValue(p); progress.setProgress(p); } public void streamingStarted(StreamVariable.StreamingStartEvent event) { name = event.getFileName(); mime = event.getMimeType(); progress.setProgressState(progress.kUPLOADPROGRESS_UPLOADING); } public void streamingFinished(StreamVariable.StreamingEndEvent event) { getprogressBarsLayout().removeComponent(pi); handleFile(receiver.getFile(), html5File.getFileName(), html5File.getType(), html5File.getFileSize()); receiver.setValue(null); progress.setProgressState(progress.kUPLOADPROGRESS_DONE); } public void streamingFailed(StreamVariable.StreamingErrorEvent event) { getprogressBarsLayout().removeComponent(pi); progress.setProgressState(progress.kUPLOADPROGRESS_ERROR); progress.setErrmsg(event.toString()); Notification note = new Notification("Upload Failed", event.toString(), Notification.Type.ERROR_MESSAGE); note.show(Page.getCurrent()); } public boolean isInterrupted() { return false; } }); }
From source file:de.metas.procurement.webui.ui.view.LoginView.java
License:Open Source License
protected void onForgotPassword(final String email) { if (Strings.isNullOrEmpty(email)) { throw new PasswordResetFailedException(email, i18n.get("LoginView.passwordReset.error.fillEmail")); }//from w ww .j a v a2 s .c o m final String passwordResetKey = loginService.generatePasswordResetKey(email); final URI passwordResetURI = PasswordResetView.buildPasswordResetURI(passwordResetKey); loginService.sendPasswordResetKey(email, passwordResetURI); final Notification notification = new Notification(i18n.get("LoginView.passwordReset.notification.title") // "Password reset" , i18n.get("LoginView.passwordReset.notification.message") // "Your password has been reset. Please check your email and click on that link" , Type.HUMANIZED_MESSAGE); notification.setDelayMsec(15 * 1000); notification.show(Page.getCurrent()); }
From source file:de.symeda.sormas.ui.login.LoginScreen.java
License:Open Source License
private void login(String username, String password) { try {/*from w w w . ja v a 2s.c om*/ if (LoginHelper.login(username, password)) { loginListener.loginSuccessful(); } else { showNotification(new Notification(I18nProperties.getString(Strings.headingLoginFailed), I18nProperties.getString(Strings.messageLoginFailed), Notification.Type.WARNING_MESSAGE)); } } catch (UserRightsException e) { showNotification(new Notification(I18nProperties.getString(Strings.headingLoginFailed), e.getMessage(), Notification.Type.WARNING_MESSAGE)); } }
From source file:de.unioninvestment.eai.portal.portlet.crud.scripting.domain.NotificationProvider.java
License:Apache License
/** * Zeigt entweder eine Warnung, einen Fehler oder eine Info im Window fr * die entsprechende Anzeige// w w w . ja v a2 s . c om * * @param description * Der anzuzeigende Text der Notification */ public void doCall(String description) { if (type == Type.ERROR) { Notification.show(Type.ERROR.value, description, Notification.Type.ERROR_MESSAGE); } else if (type == Type.WARNING) { Notification.show(Type.WARNING.value, description, Notification.Type.WARNING_MESSAGE); } else { Notification notification = new Notification(Type.INFO.value, description, Notification.Type.HUMANIZED_MESSAGE); notification.setDelayMsec(1500); notification.show(Page.getCurrent()); } }
From source file:edu.kit.dama.ui.admin.utils.UIComponentTools.java
License:Apache License
/** * Show a notification with caption <i>caption</i>, message <i>message</i> * of type <i>pType</i> for//w ww .j a va2 s . c o m * <i>delay</i> at top_center position. * * @param caption The caption. * @param message The message. * @param delay The delay (ms) until the nofication disappears. * @param pType The notification type. * @param pPosition The notification position. */ private static void showNotification(String caption, String message, int delay, Notification.Type pType, Position position) { Notification notification = new Notification(caption, message, pType); notification.setPosition(position); notification.setDelayMsec(delay); notification.setHtmlContentAllowed(true); notification.show(Page.getCurrent()); }