List of usage examples for com.vaadin.ui Notification show
public static Notification show(String caption)
From source file:com.cavisson.gui.dashboard.components.controls.Dragging.java
License:Apache License
private List<Component> createComponents() { final List<Component> components = new ArrayList<Component>(); final Label label = new Label("This is a long text block that will wrap."); label.setWidth("120px"); components.add(label);// w w w .ja v a2 s . c o m final Embedded image = new Embedded("", new ThemeResource("../runo/icons/64/document.png")); components.add(image); final CssLayout documentLayout = new CssLayout(); documentLayout.setWidth("19px"); for (int i = 0; i < 5; ++i) { final Embedded e = new Embedded(null, new ThemeResource("../runo/icons/16/document.png")); e.setHeight("16px"); e.setWidth("16px"); documentLayout.addComponent(e); } components.add(documentLayout); final VerticalLayout buttonLayout = new VerticalLayout(); final Button button = new Button("Button"); button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { Notification.show("Button clicked"); } }); buttonLayout.addComponent(button); buttonLayout.setComponentAlignment(button, Alignment.MIDDLE_CENTER); components.add(buttonLayout); return components; }
From source file:com.cavisson.gui.dashboard.components.controls.MenuBars.java
License:Apache License
static MenuBar getMenuBar() { Command click = new Command() { @Override//from www .jav a2 s . co m public void menuSelected(MenuItem selectedItem) { Notification.show("Clicked " + selectedItem.getText()); } }; MenuBar menubar = new MenuBar(); menubar.setWidth("100%"); final MenuBar.MenuItem file = menubar.addItem("File", null); final MenuBar.MenuItem newItem = file.addItem("New", null); file.addItem("Open file...", click); file.addSeparator(); newItem.addItem("File", click); newItem.addItem("Folder", click); newItem.addItem("Project...", click); file.addItem("Close", click); file.addItem("Close All", click); file.addSeparator(); file.addItem("Save", click); file.addItem("Save As...", click); file.addItem("Save All", click); final MenuBar.MenuItem edit = menubar.addItem("Edit", null); edit.addItem("Undo", click); edit.addItem("Redo", click).setEnabled(false); edit.addSeparator(); edit.addItem("Cut", click); edit.addItem("Copy", click); edit.addItem("Paste", click); edit.addSeparator(); final MenuBar.MenuItem find = edit.addItem("Find/Replace", null); find.addItem("Google Search", click); find.addSeparator(); find.addItem("Find/Replace...", click); find.addItem("Find Next", click); find.addItem("Find Previous", click); Command check = new Command() { @Override public void menuSelected(MenuItem selectedItem) { Notification.show(selectedItem.isChecked() ? "Checked" : "Unchecked"); } }; final MenuBar.MenuItem view = menubar.addItem("View", null); view.addItem("Show Status Bar", check).setCheckable(true); MenuItem title = view.addItem("Show Title Bar", check); title.setCheckable(true); title.setChecked(true); view.addItem("Customize Toolbar...", click); view.addSeparator(); view.addItem("Actual Size", click); view.addItem("Zoom In", click); view.addItem("Zoom Out", click); TestIcon testIcon = new TestIcon(50); MenuItem fav = menubar.addItem("", check); fav.setIcon(testIcon.get()); fav.setStyleName("icon-only"); fav.setCheckable(true); fav.setChecked(true); fav = menubar.addItem("", check); fav.setIcon(testIcon.get()); fav.setStyleName("icon-only"); fav.setCheckable(true); fav.setCheckable(true); menubar.addItem("Attach", click).setIcon(FontAwesome.PAPERCLIP); menubar.addItem("Undo", click).setIcon(FontAwesome.UNDO); MenuItem redo = menubar.addItem("Redo", click); redo.setIcon(FontAwesome.REPEAT); redo.setEnabled(false); menubar.addItem("Upload", click).setIcon(FontAwesome.UPLOAD); return menubar; }
From source file:com.cavisson.gui.dashboard.components.controls.Tables.java
License:Apache License
static void configure(Table table, boolean footer, boolean sized, boolean expandRatios, boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) { table.setSelectable(true);/*from w w w . ja v a 2 s .c o m*/ table.setMultiSelect(true); table.setSortEnabled(true); table.setColumnCollapsingAllowed(true); table.setColumnReorderingAllowed(true); table.setPageLength(6); table.addActionHandler(ValoThemeUI.getActionHandler()); table.setDragMode(TableDragMode.MULTIROW); table.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); table.setColumnAlignment(ValoThemeUI.DESCRIPTION_PROPERTY, Align.RIGHT); table.setColumnAlignment(ValoThemeUI.INDEX_PROPERTY, Align.CENTER); table.removeContainerProperty("textfield"); table.removeGeneratedColumn("textfield"); table.removeContainerProperty("button"); table.removeGeneratedColumn("button"); table.removeContainerProperty("label"); table.removeGeneratedColumn("label"); table.removeContainerProperty("checkbox"); table.removeGeneratedColumn("checkbox"); table.removeContainerProperty("datefield"); table.removeGeneratedColumn("datefield"); table.removeContainerProperty("combobox"); table.removeGeneratedColumn("combobox"); table.removeContainerProperty("optiongroup"); table.removeGeneratedColumn("optiongroup"); table.removeContainerProperty("slider"); table.removeGeneratedColumn("slider"); table.removeContainerProperty("progress"); table.removeGeneratedColumn("progress"); if (componentsInRows) { table.addContainerProperty("textfield", TextField.class, null); table.addGeneratedColumn("textfield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { TextField tf = new TextField(); tf.setInputPrompt("Type here"); // tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("datefield", TextField.class, null); table.addGeneratedColumn("datefield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { DateField tf = new DateField(); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("combobox", TextField.class, null); table.addGeneratedColumn("combobox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ComboBox tf = new ComboBox(); tf.setInputPrompt("Select"); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("button", Button.class, null); table.addGeneratedColumn("button", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button b = new Button("Button"); b.addStyleName("small"); return b; } }); table.addContainerProperty("label", TextField.class, null); table.addGeneratedColumn("label", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Label label = new Label("Label component"); label.setSizeUndefined(); label.addStyleName("bold"); return label; } }); table.addContainerProperty("checkbox", TextField.class, null); table.addGeneratedColumn("checkbox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { CheckBox cb = new CheckBox(null, true); return cb; } }); table.addContainerProperty("optiongroup", TextField.class, null); table.addGeneratedColumn("optiongroup", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { OptionGroup op = new OptionGroup(); op.addItem("Male"); op.addItem("Female"); op.addStyleName("horizontal"); return op; } }); table.addContainerProperty("slider", TextField.class, null); table.addGeneratedColumn("slider", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Slider s = new Slider(); s.setValue(30.0); return s; } }); table.addContainerProperty("progress", TextField.class, null); table.addGeneratedColumn("progress", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ProgressBar bar = new ProgressBar(); bar.setValue(0.7f); return bar; } }); } table.setFooterVisible(footer); if (footer) { table.setColumnFooter(ValoThemeUI.CAPTION_PROPERTY, "caption"); table.setColumnFooter(ValoThemeUI.DESCRIPTION_PROPERTY, "description"); table.setColumnFooter(ValoThemeUI.ICON_PROPERTY, "icon"); table.setColumnFooter(ValoThemeUI.INDEX_PROPERTY, "index"); } if (sized) { table.setWidth("400px"); table.setHeight("300px"); } else { table.setSizeUndefined(); } if (expandRatios) { if (!sized) { table.setWidth("100%"); } } table.setColumnExpandRatio(ValoThemeUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0); table.setColumnExpandRatio(ValoThemeUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0); if (!stripes) { table.addStyleName("no-stripes"); } else { table.removeStyleName("no-stripes"); } if (!verticalLines) { table.addStyleName("no-vertical-lines"); } else { table.removeStyleName("no-vertical-lines"); } if (!horizontalLines) { table.addStyleName("no-horizontal-lines"); } else { table.removeStyleName("no-horizontal-lines"); } if (borderless) { table.addStyleName("borderless"); } else { table.removeStyleName("borderless"); } if (!headers) { table.addStyleName("no-header"); } else { table.removeStyleName("no-header"); } if (compact) { table.addStyleName("compact"); } else { table.removeStyleName("compact"); } if (small) { table.addStyleName("small"); } else { table.removeStyleName("small"); } if (!rowIndex && !rowCaption && rowIcon) { table.setRowHeaderMode(RowHeaderMode.HIDDEN); } if (rowIndex) { table.setRowHeaderMode(RowHeaderMode.INDEX); } if (rowCaption) { table.setRowHeaderMode(RowHeaderMode.PROPERTY); table.setItemCaptionPropertyId(ValoThemeUI.CAPTION_PROPERTY); } else { table.setItemCaptionPropertyId(null); } if (rowIcon) { table.setRowHeaderMode(RowHeaderMode.ICON_ONLY); table.setItemIconPropertyId(ValoThemeUI.ICON_PROPERTY); } else { table.setItemIconPropertyId(null); } }
From source file:com.cerebro.provevaadin.database.Configurazione.java
public Configurazione() { System.out.println("Componente per la personalizzazione"); this.setMargin(true); TextField db_host = new TextField("Database Host Name"); db_host.isRequired();/*w w w . j av a 2 s . c o m*/ TextField db_port = new TextField("Database Port"); db_port.isRequired(); TextField db_user = new TextField("Username"); db_user.isRequired(); PasswordField db_pwd = new PasswordField("Password"); db_pwd.isRequired(); PasswordField pwd_conf = new PasswordField("Conferma Password"); pwd_conf.setImmediate(true); Properties props = new Properties(); InputStream config = VaadinServlet.getCurrent().getServletContext() .getResourceAsStream("/WEB-INF/config.properties"); if (config != null) { System.out.println("Carico file di configurazione"); try { props.load(config); } catch (IOException ex) { Logger.getLogger(MySQLServer.class.getName()).log(Level.SEVERE, null, ex); } } db_host.setValue(props.getProperty("db_host")); db_user.setValue(props.getProperty("db_user")); Button salva = new Button("Salva"); salva.addClickListener((Button.ClickEvent event) -> { System.out.println("Salvo i parametri"); if (db_host.isValid() && db_port.isValid() && db_user.isValid() && db_pwd.isValid() && pwd_conf.getValue().equals(db_pwd.getValue())) { String dbHost = "jdbc:mysql://" + db_host.getValue() + ":" + db_port.getValue() + "/grizzly?useSSL=false&serverTimezone=UTC"; props.setProperty("db_host", dbHost); props.setProperty("db_user", db_user.getValue()); props.setProperty("db_pwd", db_pwd.getValue()); String webInfPath = VaadinServlet.getCurrent().getServletConfig().getServletContext() .getRealPath("WEB-INF"); File f = new File(webInfPath + "/config.properties"); try { OutputStream o = new FileOutputStream(f); try { props.store(o, "Prova"); } catch (IOException ex) { Logger.getLogger(Configurazione.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(Configurazione.class.getName()).log(Level.SEVERE, null, ex); } Notification.show("Parametri salvati"); } else { Notification.show("Ricontrolla i parametri"); } }); Button test = new Button("Test per i parametri salvati"); test.addClickListener((Button.ClickEvent event) -> { System.out.println("Testo i parametri"); MySQLServer mysql = new MySQLServer(); JDBCConnectionPool conn = mysql.getJDBCConnPool(); if (!mysql.testJDBCConnPool(conn)) { Notification.show("Errore nella connessione al database"); } else { Notification.show("Connessione avvenuta con successo"); } }); this.addComponents(db_host, db_port, db_user, db_pwd, pwd_conf, salva, test); }
From source file:com.cerebro.provevaadin.smtp.ConfigurazioneSMTP.java
public ConfigurazioneSMTP() { this.setMargin(true); TextField smtpHost = new TextField("SMTP Host Server"); smtpHost.setRequired(true);/*w w w . j av a 2 s. c o m*/ TextField smtpPort = new TextField("SMTP Port"); smtpPort.setRequired(true); TextField smtpUser = new TextField("SMTP Username"); smtpUser.setRequired(true); TextField smtpPwd = new TextField("SMTP Password"); smtpPwd.setRequired(true); TextField pwdConf = new TextField("Conferma la Password"); pwdConf.setRequired(true); CheckBox security = new CheckBox("Sicurezza del server"); Properties props = new Properties(); InputStream config = VaadinServlet.getCurrent().getServletContext() .getResourceAsStream("/WEB-INF/config.properties"); if (config != null) { System.out.println("Carico file di configurazione"); try { props.load(config); } catch (IOException ex) { Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex); } } smtpHost.setValue(props.getProperty("smtp_host")); smtpUser.setValue(props.getProperty("smtp_user")); security.setValue(Boolean.parseBoolean(props.getProperty("smtp_sec"))); Button salva = new Button("Salva i parametri"); salva.addClickListener((Button.ClickEvent event) -> { System.out.println("Salvo i parametri SMTP"); if (smtpHost.isValid() && smtpPort.isValid() && smtpUser.isValid() && smtpPwd.isValid() && smtpPwd.getValue().equals(pwdConf.getValue())) { props.setProperty("smtp_host", smtpHost.getValue()); props.setProperty("smtp_port", smtpPort.getValue()); props.setProperty("smtp_user", smtpUser.getValue()); props.setProperty("smtp_pwd", smtpPwd.getValue()); props.setProperty("smtp_sec", security.getValue().toString()); String webInfPath = VaadinServlet.getCurrent().getServletConfig().getServletContext() .getRealPath("WEB-INF"); File f = new File(webInfPath + "/config.properties"); try { OutputStream o = new FileOutputStream(f); try { props.store(o, "Prova"); } catch (IOException ex) { Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex); } Notification.show("Parametri salvati"); } else { Notification.show("Ricontrolla i parametri"); } }); TextField emailTest = new TextField("Destinatario Mail di Prova"); emailTest.setImmediate(true); emailTest.addValidator(new EmailValidator("Mail non valida")); Button test = new Button("Invia una mail di prova"); test.addClickListener((Button.ClickEvent event) -> { System.out.println("Invio della mail di prova"); if (emailTest.isValid()) { try { System.out.println("Invio mail di prova a " + emailTest.getValue()); HtmlEmail email = new HtmlEmail(); email.setHostName(props.getProperty("smtp_host")); email.setSmtpPort(Integer.parseInt(props.getProperty("smtp_port"))); email.setSSLOnConnect(Boolean.parseBoolean(props.getProperty("smtp_sec"))); email.setAuthentication(props.getProperty("smtp_user"), props.getProperty("smtp_pwd")); email.setFrom("prova@prova.it"); email.setSubject("Mail di prova"); email.addTo(emailTest.getValue()); email.setHtmlMsg("This is the message"); email.send(); } catch (EmailException ex) { Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex); } } else { Notification.show("Controlla l'indirizzo mail del destinatario"); } }); this.addComponents(smtpHost, smtpPort, smtpUser, smtpPwd, pwdConf, security, salva, emailTest, test); }
From source file:com.cerebro.provevaadin.smtp.ConfigurazioneSMTPSpring.java
public ConfigurazioneSMTPSpring() { TextField smtpHost = new TextField("SMTP Host Server"); smtpHost.setRequired(true);//from ww w . j a va 2 s . com TextField smtpPort = new TextField("SMTP Port"); smtpPort.setRequired(true); TextField smtpUser = new TextField("SMTP Username"); smtpUser.setRequired(true); PasswordField smtpPwd = new PasswordField("SMTP Password"); smtpPwd.setRequired(true); PasswordField pwdConf = new PasswordField("Conferma la Password"); pwdConf.setRequired(true); CheckBox security = new CheckBox("Sicurezza del server"); Properties props = new Properties(); InputStream config = VaadinServlet.getCurrent().getServletContext() .getResourceAsStream("/WEB-INF/config.properties"); if (config != null) { System.out.println("Carico file di configurazione"); try { props.load(config); } catch (IOException ex) { Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex); } } smtpHost.setValue(props.getProperty("mail.smtp.host")); smtpUser.setValue(props.getProperty("smtp_user")); security.setValue(Boolean.parseBoolean(props.getProperty("smtp_sec"))); Button salva = new Button("Salva i parametri"); salva.addClickListener((Button.ClickEvent event) -> { System.out.println("Salvo i parametri SMTP"); if (smtpHost.isValid() && smtpPort.isValid() && smtpUser.isValid() && smtpPwd.isValid() && smtpPwd.getValue().equals(pwdConf.getValue())) { System.out.println(smtpHost.getValue() + smtpPort.getValue() + smtpUser.getValue() + smtpPwd.getValue() + security.getValue().toString()); props.setProperty("mail.smtp.host", smtpHost.getValue()); props.setProperty("mail.smtp.port", smtpPort.getValue()); props.setProperty("smtp_user", smtpUser.getValue()); props.setProperty("smtp_pwd", smtpPwd.getValue()); props.setProperty("mail.smtp.ssl.enable", security.getValue().toString()); String webInfPath = VaadinServlet.getCurrent().getServletConfig().getServletContext() .getRealPath("WEB-INF"); File f = new File(webInfPath + "/config.properties"); try { OutputStream o = new FileOutputStream(f); try { props.store(o, "Prova"); } catch (IOException ex) { Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex); } Notification.show("Parametri salvati"); } else { Notification.show("Ricontrolla i parametri"); } }); TextField emailTest = new TextField("Destinatario Mail di Prova"); emailTest.setImmediate(true); emailTest.addValidator(new EmailValidator("Mail non valida")); Button test = new Button("Invia una mail di prova"); test.addClickListener((Button.ClickEvent event) -> { System.out.println("Invio della mail di prova"); if (emailTest.isValid() && !emailTest.isEmpty()) { System.out.println("Invio mail di prova a " + emailTest.getValue()); JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); mailSender.setJavaMailProperties(props); mailSender.setUsername(props.getProperty("smtp_user")); mailSender.setPassword(props.getProperty("smtp_pwd")); MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message); try { helper.setFrom("dottmatteocasagrande@gmail.com"); helper.setSubject("Subject"); helper.setText("It works!"); helper.addTo(emailTest.getValue()); mailSender.send(message); } catch (MessagingException ex) { Logger.getLogger(ConfigurazioneSMTPSpring.class.getName()).log(Level.SEVERE, null, ex); } } else { Notification.show("Controlla l'indirizzo mail del destinatario"); } }); this.addComponents(smtpHost, smtpPort, smtpUser, smtpPwd, pwdConf, security, salva, emailTest, test); }
From source file:com.cms.component.CommonFunction.java
public static void showMessage(String message) { Notification noti = new Notification(message); noti.setDelayMsec(1500);/* w w w.j a v a2s . co m*/ Notification.show(message); }
From source file:com.cms.component.CommonFunctionTableFilter.java
public static void showMessage(String message) { Notification noti = new Notification(message); noti.setDelayMsec(1500);/*from w w w. j ava 2s . co m*/ noti.show(message); }
From source file:com.cms.utils.CommonValidator.java
public boolean validateNumber(TextField field, String message) { try {/*from www . ja v a 2 s .c o m*/ field.validate(); } catch (Validator.InvalidValueException e) { field.focus(); Notification.show(message); return false; } return true; }
From source file:com.esofthead.mycollab.vaadin.ui.NotificationUtil.java
License:Open Source License
public static void showNotification(String caption, String description, Type type) { Notification warnNotif = new Notification(caption, description, type); warnNotif.setHtmlContentAllowed(true); warnNotif.setDelayMsec(3000);//from w w w.j a v a 2 s . c o m if (Page.getCurrent() != null) { warnNotif.show(Page.getCurrent()); } else { LOG.error("Current page is null"); } }