List of usage examples for com.vaadin.ui Notification setDelayMsec
public void setDelayMsec(int delayMsec)
From source file:com.mcparland.john.vaadin_mvn_arch.samples.crud.ProductForm.java
License:Apache License
public ProductForm(SampleCrudLogic sampleCrudLogic) { viewLogic = sampleCrudLogic;/* w ww.j ava2 s . c o m*/ 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.mycollab.vaadin.ui.NotificationUtil.java
License:Open Source License
public static void showNotification(String caption, String description, Type type) { Notification notification = new Notification(caption, description, type); notification.setHtmlContentAllowed(true); notification.setDelayMsec(3000); if (Page.getCurrent() != null) { notification.show(Page.getCurrent()); } else {/* w w w. j a v a 2 s. co m*/ LOG.error("Current page is null"); } }
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; 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 {// w ww . j a va 2 s . c o m 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.toptal.ui.view.LoginView.java
License:Open Source License
/** * Error notification./*from w w w . j a v a2s. com*/ * @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 showInfo(String caption, int delay) { Notification not = new Notification(caption); not.setDelayMsec(delay); not.setHtmlContentAllowed(true);// w ww . ja v a 2s. c om not.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); not.setHtmlContentAllowed(true);/* www . j av a2s . co m*/ 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); not.setHtmlContentAllowed(true);// w w w.j a v a2 s.c o m not.setCaption(caption); not.show(Page.getCurrent()); }
From source file:com.vaushell.treetasker.application.window.RegistrationWindow.java
License:Open Source License
@Override /**/*w ww .j av a2 s .co m*/ * Try to register the new account on the server. */ public void ok() { if (content.isValid()) { String userName = content.getUserName(); String encryptedPassword = TT_Tools.encryptPassword(userName, content.getPassword()); UserSession session = TT_ServerControllerDAO.getInstance().registerUser(userName, encryptedPassword); if (session.isValid()) { Notification n = new Notification("Enregistrement russi", "Un mail a t envoy " + userName + " afin de valider votre enregistrement"); n.setDelayMsec(Notification.DELAY_FOREVER); getParent().showNotification(n); close(); } else { showNotification(userName + " est dj utilis.", Notification.TYPE_ERROR_MESSAGE); } } else { showNotification(content.getErrorMsg(), Notification.TYPE_ERROR_MESSAGE); } }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.LoginView.java
public LoginView() { System.out.println("LOAD LLOGIN"); setSizeFull();//from www.jav a 2 s . c o m Component loginForm = buildLoginForm(); addComponent(loginForm); setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER); Notification notification = new Notification("Welcome to Dashboard Demo"); notification.setDescription( "<span>This application is not real, it only demonstrates an application built with the <a href=\"https://vaadin.com\">Vaadin framework</a>.</span> <span>No username or password is required, just click the <b>Sign In</b> button to continue.</span>"); notification.setHtmlContentAllowed(true); notification.setStyleName("tray dark small closable login-help"); notification.setPosition(Position.BOTTOM_CENTER); notification.setDelayMsec(20000); notification.show(Page.getCurrent()); }
From source file:de.fatalix.app.view.login.LoginView.java
private void showNotification(Notification notification, String style) { // keep the notification visible a little while after moving the // mouse, or until clicked notification.setPosition(Position.TOP_CENTER); notification.setStyleName(ValoTheme.NOTIFICATION_BAR); notification.setDelayMsec(2000); notification.show(Page.getCurrent()); }