List of usage examples for com.vaadin.ui Notification Notification
public Notification(String caption, String description)
From source file:com.mcparland.john.vaadin_mvn_arch.samples.crud.ProductForm.java
License:Apache License
public ProductForm(SampleCrudLogic sampleCrudLogic) { viewLogic = sampleCrudLogic;/*from w w w. j a v a 2 s . c om*/ addStyleName("product-form-wrapper"); setId("product-form"); productName.setWidth("100%"); price.setConverter(new EuroConverter()); stockCount.setWidth("80px"); availability.setNullSelectionAllowed(false); availability.setTextInputAllowed(false); for (Availability s : Availability.values()) { availability.addItem(s); } category.setWidth("100%"); saveButton.addStyleName(ValoTheme.BUTTON_PRIMARY); cancelButton.addStyleName("cancel"); removeButton.addStyleName(ValoTheme.BUTTON_DANGER); VerticalLayout layout = new VerticalLayout(); layout.setHeight("100%"); layout.setSpacing(true); layout.addStyleName("form-layout"); HorizontalLayout priceAndStock = new HorizontalLayout(price, stockCount); priceAndStock.setSpacing(true); priceAndStock.setWidth("100%"); price.setWidth("100%"); stockCount.setWidth("100%"); availability.setWidth("100%"); layout.addComponent(productName); layout.addComponent(priceAndStock); layout.addComponent(availability); layout.addComponent(category); CssLayout expander = new CssLayout(); expander.addStyleName("expander"); layout.addComponent(expander); layout.setExpandRatio(expander, 1); layout.addComponent(saveButton); layout.addComponent(cancelButton); layout.addComponent(removeButton); addComponent(layout); fieldGroup = new BeanFieldGroup<Product>(Product.class); fieldGroup.bindMemberFields(this); // perform validation and enable/disable buttons while editing ValueChangeListener valueListener = new ValueChangeListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { formHasChanged(); } }; for (Field<?> f : fieldGroup.getFields()) { f.addValueChangeListener(valueListener); } fieldGroup.addCommitHandler(new CommitHandler() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void preCommit(CommitEvent commitEvent) throws CommitException { } @Override public void postCommit(CommitEvent commitEvent) throws CommitException { DataService.get().updateProduct(fieldGroup.getItemDataSource().getBean()); } }); saveButton.addClickListener(new ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { try { fieldGroup.commit(); // only if validation succeeds Product product = fieldGroup.getItemDataSource().getBean(); viewLogic.saveProduct(product); } catch (CommitException e) { Notification n = new Notification("Please re-check the fields", Type.ERROR_MESSAGE); n.setDelayMsec(500); n.show(getUI().getPage()); } } }); cancelButton.setClickShortcut(KeyCode.ESCAPE); cancelButton.addClickListener(new ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { viewLogic.cancelProduct(); } }); removeButton.addClickListener(new ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { Product product = fieldGroup.getItemDataSource().getBean(); viewLogic.deleteProduct(product); } }); }
From source file:com.toptal.ui.view.LoginView.java
License:Open Source License
/** * Error notification./* w w w.jav a2 s . c om*/ * @param message Message. */ private void error(final String message) { final int delay = 5000; final Notification notification = new Notification(message, Notification.Type.WARNING_MESSAGE); notification.setHtmlContentAllowed(true); notification.setStyleName("closable"); notification.setPosition(Position.BOTTOM_CENTER); notification.setIcon(FontAwesome.WARNING); notification.setDelayMsec(delay); notification.show(Page.getCurrent()); }
From source file:com.vaadHL.utl.msgs.Msgs.java
License:Apache License
public void showWarning(String caption, int delay) { Notification not = new Notification(caption, Notification.Type.WARNING_MESSAGE); not.setDelayMsec(delay);// www. j a v a 2s . c o m not.setHtmlContentAllowed(true); not.setCaption(caption); not.show(Page.getCurrent()); }
From source file:com.vaadHL.utl.msgs.Msgs.java
License:Apache License
public void showError(String caption, int delay) { Notification not = new Notification("", Notification.Type.ERROR_MESSAGE); not.setDelayMsec(delay);// w w w . j av a 2 s . c om not.setHtmlContentAllowed(true); not.setCaption(caption); not.show(Page.getCurrent()); }
From source file:com.wintindustries.pfserver.uploads.PFUploadUnit.java
@Override protected void handleFile(File file, String fileName, String mimeType, long length) { Notification note = new Notification(fileName + " Uploaded", Notification.Type.TRAY_NOTIFICATION); note.show(Page.getCurrent());//from w w w . ja v a 2s . c om // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
From source file:de.fatalix.app.view.login.LoginView.java
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined();//from w ww . ja va 2s . c om loginForm.setMargin(false); loginForm.addComponent(username = new TextField("Username", "admin")); username.setWidth(15, Unit.EM); loginForm.addComponent(password = new PasswordField("Password")); password.setWidth(15, Unit.EM); password.setDescription("Write anything"); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); buttons.addComponent(login = new Button("Login")); login.setDisableOnClick(true); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { presenter.doLogin(username.getValue(), password.getValue()); } catch (AuthenticationException ex) { LoginView.this.showNotification( new Notification("Wrong login", Notification.Type.ERROR_MESSAGE), ValoTheme.NOTIFICATION_FAILURE); } finally { login.setEnabled(true); } } }); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); buttons.addComponent(forgotPassword = new Button("Forgot password?")); forgotPassword.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { showNotification(new Notification("Hint: Try anything", Notification.Type.HUMANIZED_MESSAGE), ValoTheme.NOTIFICATION_SUCCESS); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); return loginForm; }
From source file:de.fatalix.bookery.view.login.LoginView.java
License:Open Source License
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined();//from w ww . java2 s . co m loginForm.setMargin(false); loginForm.addComponent(username = new TextField("Username", "admin")); username.setWidth(15, Unit.EM); loginForm.addComponent(password = new PasswordField("Password")); password.setWidth(15, Unit.EM); password.setDescription(""); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); login = new Button("login"); buttons.addComponent(login); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { presenter.doLogin(username.getValue(), password.getValue()); } catch (AuthenticationException ex) { LoginView.this.showNotification( new Notification("Wrong login", Notification.Type.ERROR_MESSAGE), ValoTheme.NOTIFICATION_FAILURE); } finally { login.setEnabled(true); } } }); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); buttons.addComponent(forgotPassword = new Button("Forgot password?")); forgotPassword.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { showNotification(new Notification("Hint: Ask me", Notification.Type.HUMANIZED_MESSAGE), ValoTheme.NOTIFICATION_SUCCESS); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); Panel loginPanel = new Panel(loginForm); loginPanel.setWidthUndefined(); loginPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); loginPanel.addAction(new ShortcutListener("commit", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { try { presenter.doLogin(username.getValue(), password.getValue()); } catch (AuthenticationException ex) { LoginView.this.showNotification( new Notification("Wrong login", Notification.Type.ERROR_MESSAGE), ValoTheme.NOTIFICATION_FAILURE); } } }); return loginPanel; }
From source file:de.metas.ui.web.service.impl.VaadinWebProcessCtl.java
License:Open Source License
@Override public void reportAsync(final ProcessInfo pi, final ActionEvent event) { final ASyncProcess asyncCtrl = new ASyncProcess() { private boolean locked = false; @Override//from w w w .ja va 2 s . com public void lockUI(final ProcessInfo pi) { locked = true; final Notification notification = new Notification("Executing " + event.getAction().getCaption(), Notification.Type.TRAY_NOTIFICATION); notification.setIcon(Theme.getVaadinResource(event.getAction().getIcon())); notification.show(Page.getCurrent()); } @Override public void unlockUI(final ProcessInfo pi) { locked = false; } @Override public boolean isUILocked() { return locked; } @Override public void executeASync(final ProcessInfo pi) { logger.debug("executeASync: {}", pi); } }; ProcessCtl.process(asyncCtrl, pi.getWindowNo(), pi, ITrx.TRX_None); // calls lockUI, unlockUI }
From source file:de.symeda.sormas.ui.caze.CaseController.java
License:Open Source License
private void saveCase(CaseDataDto cazeDto) { // Compare old and new case CaseDataDto existingDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(cazeDto.getUuid()); onCaseChanged(existingDto, cazeDto); CaseDataDto resultDto = FacadeProvider.getCaseFacade().saveCase(cazeDto); if (resultDto.getPlagueType() != cazeDto.getPlagueType()) { // TODO would be much better to have a notification for this triggered in the backend Window window = VaadinUiUtil.showSimplePopupWindow( I18nProperties.getString(Strings.headingSaveNotification), String.format(I18nProperties.getString(Strings.messagePlagueTypeChange), resultDto.getPlagueType().toString(), resultDto.getPlagueType().toString())); window.addCloseListener(new CloseListener() { private static final long serialVersionUID = 1L; @Override// w w w . j a va 2 s .c om public void windowClose(CloseEvent e) { if (existingDto.getCaseClassification() != resultDto.getCaseClassification() && resultDto.getClassificationUser() == null) { Notification notification = new Notification(String.format( I18nProperties.getString(Strings.messageCaseSavedClassificationChanged), resultDto.getCaseClassification().toString()), Type.WARNING_MESSAGE); notification.setDelayMsec(-1); notification.show(Page.getCurrent()); } else { Notification.show(I18nProperties.getString(Strings.messageCaseSaved), Type.WARNING_MESSAGE); } SormasUI.refreshView(); } }); } else { // Notify user about an automatic case classification change if (existingDto != null && existingDto.getCaseClassification() != resultDto.getCaseClassification() && resultDto.getClassificationUser() == null) { Notification notification = new Notification( String.format(I18nProperties.getString(Strings.messageCaseSavedClassificationChanged), resultDto.getCaseClassification().toString()), Type.WARNING_MESSAGE); notification.setDelayMsec(-1); notification.show(Page.getCurrent()); } else { Notification.show(I18nProperties.getString(Strings.messageCaseSaved), Type.WARNING_MESSAGE); } SormasUI.refreshView(); } }
From source file:de.symeda.sormas.ui.person.PersonController.java
License:Open Source License
private void savePerson(PersonDto personDto) { PersonDto existingPerson = FacadeProvider.getPersonFacade().getPersonByUuid(personDto.getUuid()); List<CaseDataDto> personCases = FacadeProvider.getCaseFacade().getAllCasesOfPerson(personDto.getUuid(), UserProvider.getCurrent().getUserReference().getUuid()); onPersonChanged(existingPerson, personDto); personFacade.savePerson(personDto);/*from www.j a va 2 s . c o m*/ // Check whether the classification of any of this person's cases has changed CaseClassification newClassification = null; for (CaseDataDto personCase : personCases) { CaseDataDto updatedPersonCase = FacadeProvider.getCaseFacade().getCaseDataByUuid(personCase.getUuid()); if (personCase.getCaseClassification() != updatedPersonCase.getCaseClassification() && updatedPersonCase.getClassificationUser() == null) { newClassification = updatedPersonCase.getCaseClassification(); break; } } if (newClassification != null) { Notification notification = new Notification( String.format(I18nProperties.getString(Strings.messagePersonSavedClassificationChanged), newClassification.toString()), Type.WARNING_MESSAGE); notification.setDelayMsec(-1); notification.show(Page.getCurrent()); } else { Notification.show(I18nProperties.getString(Strings.messagePersonSaved), Type.WARNING_MESSAGE); } SormasUI.refreshView(); }