List of usage examples for com.vaadin.ui TextField getValue
@Override
public String getValue()
From source file:com.bellkenz.modules.PersonalInformation.java
public Window transferEmployee(final String employeeId, final ComboBox div, final ComboBox dept, final TextField post) { VerticalLayout vlayout = new VerticalLayout(); vlayout.setMargin(true);/* w w w .ja v a2 s. c o m*/ vlayout.setSpacing(true); final Window subWindow = new Window("Transfer Employee", vlayout); subWindow.setWidth("200px"); final ComboBox division = new ComboBox("Division: "); division.setWidth("100%"); dropDownBoxList.populateBranchComboBox(division); subWindow.addComponent(division); final ComboBox department = dropDownBoxList.populateDepartment(new ComboBox()); department.setWidth("100%"); division.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (division.getValue() == null) { } else { divisionId = branchDAO.getBranchId(division.getValue().toString()); } } }); subWindow.addComponent(department); final TextField position = createTextField("Position: "); position.setWidth("100%"); subWindow.addComponent(position); final PopupDateField entryDate = (PopupDateField) createDateField("Date of Entry: "); subWindow.addComponent(entryDate); Button updateButton = new Button("UPDATE"); updateButton.setWidth("100%"); updateButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (division.getValue() == null) { getWindow().showNotification("Select Division!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (department.getValue() == null) { getWindow().showNotification("Select Department!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (position.getValue() == null || position.getValue().toString().trim().isEmpty()) { getWindow().showNotification("Enter Position!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (entryDate.getValue() == null) { getWindow().showNotification("Select Entry Date!", Window.Notification.TYPE_WARNING_MESSAGE); return; } List<EmployeePositionHistory> ephList = new ArrayList<EmployeePositionHistory>(); EmployeePositionHistory eph = new EmployeePositionHistory(); eph.setBranch(division.getValue().toString()); eph.setDepartment(department.getValue().toString()); eph.setPosition(position.getValue().toString().trim().toLowerCase()); eph.setEntryDate(conUtil.convertDateFormat(entryDate.getValue().toString())); ephList.add(eph); Integer deptId = departmentDAO.getDepartmentId(divisionId, department.getValue().toString()); Boolean result = employeeInformationDAO.transferEmployee(ephList, deptId); if (result) { Object divObjectId = div.addItem(); div.setItemCaption(divObjectId, division.getValue().toString()); div.setValue(divObjectId); Object deptObjectId = dept.addItem(); dept.setItemCaption(deptObjectId, department.getValue().toString()); dept.setValue(deptObjectId); post.setValue(position.getValue().toString().trim().toLowerCase()); (subWindow.getParent()).removeWindow(subWindow); } else { getWindow().showNotification("Cannot Transfer employee", Window.Notification.TYPE_ERROR_MESSAGE); } } }); subWindow.addComponent(updateButton); return subWindow; }
From source file:com.cerebro.gorgone.landingpage.SignInWindow.java
private Component setFirstStep() { VerticalLayout firstStep = new VerticalLayout(); firstStep.setMargin(true);/*from ww w. j a v a 2s . c om*/ // Body HorizontalLayout body = new HorizontalLayout(); FormLayout datiIniziali = new FormLayout(); TextField nomePG = new TextField("Nome del Personaggio"); nomePG.setRequired(true); TextField cognomePG = new TextField("Cognome del Personaggio"); cognomePG.setRequired(true); OptionGroup sessoPG = new OptionGroup("Sesso del Personaggio"); sessoPG.setRequired(true); sessoPG.addItems("Maschio", "Femmina"); ComboBox razzaPG = new ComboBox("Razza"); razzaPG.setRequired(true); Slider age = new Slider("Et"); age.setImmediate(true); age.setWidth("200px"); age.setVisible(false); HorizontalLayout ageDescription = new HorizontalLayout(); ageDescription.setHeight("250px"); Label ageText = new Label("Valore dell'et: "); Label ageValue = new Label(age.getValue().toString()); Label periodoVita = new Label(""); ageDescription.addComponents(ageText, ageValue, periodoVita); age.addValueChangeListener((Property.ValueChangeEvent event) -> { System.out.println("Valore: " + age.getValue().toString()); ageValue.setValue(age.getValue().toString()); Double value = (100 * (age.getValue()) / (age.getMax())); if (value < 14) { periodoVita.setValue("Bambino"); } else if (value > 14 && value < 24) { periodoVita.setValue("Adolescenza"); } else if (value > 24 && value < 73) { periodoVita.setValue("Et adulta"); } else if (value > 73) { periodoVita.setValue("Et anziana"); } }); ageDescription.addComponents(ageText, ageValue, periodoVita); ageDescription.setVisible(false); datiIniziali.addComponents(nomePG, cognomePG, sessoPG, razzaPG, age, ageDescription); Panel descrizioneRazza = new Panel(); CssLayout descrizioneRazzaContent = new CssLayout(); descrizioneRazza.setWidth("400px"); descrizioneRazza.setHeight("500px"); descrizioneRazza.setContent(descrizioneRazzaContent); // Dettagli di popolazione e comportamento ComboBox TableQuery tq_races = new TableQuery(DatabaseTables.RACES_TABLE, connPool); tq_races.setVersionColumn(DatabaseTables.RACES_VERSION); SQLContainer container_races = null; try { container_races = new SQLContainer(tq_races); } catch (Exception ex) { logger.error(ex.getMessage()); } razzaPG.setContainerDataSource(container_races); razzaPG.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY); razzaPG.setItemCaptionPropertyId(DatabaseTables.RACES_NAME); razzaPG.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (razzaPG.getValue() != null) { logger.info("Razza selezionata: " + razzaPG.getValue()); age.setVisible(true); ageDescription.setVisible(true); descrizioneRazzaContent.removeAllComponents(); Item item = razzaPG.getContainerDataSource().getItem(razzaPG.getValue()); race = (String) item.getItemProperty(DatabaseTables.RACES_NAME).getValue(); Label nameRace = new Label(race); FileResource imageSrc = new FileResource( new File(MyUI.basePath + item.getItemProperty(DatabaseTables.RACES_IMAGE).getValue())); Image imageRace = new Image(null, imageSrc); imageRace.setWidth("200px"); Label descriptionRace = new Label( (String) item.getItemProperty(DatabaseTables.RACES_DESCRIPTION).getValue(), ContentMode.HTML); min_age = (int) item.getItemProperty(DatabaseTables.RACES_MIN_AGE).getValue(); max_age = (int) item.getItemProperty(DatabaseTables.RACES_MAX_AGE).getValue(); age.setMin(min_age); age.setMax(max_age); strenght = (int) item.getItemProperty(DatabaseTables.RACES_STRENGHT).getValue(); resistance = (int) item.getItemProperty(DatabaseTables.RACES_RESISTANCE).getValue(); agility = (int) item.getItemProperty(DatabaseTables.RACES_AGILITY).getValue(); intelligence = (int) item.getItemProperty(DatabaseTables.RACES_INTELLIGENCE).getValue(); wisdom = (int) item.getItemProperty(DatabaseTables.RACES_WISDOM).getValue(); charm = (int) item.getItemProperty(DatabaseTables.RACES_CHARM).getValue(); Label min_ageL = new Label("Et minima: " + min_age); Label max_ageL = new Label("Et masima " + max_age); // Panel levels = new Panel(); // VerticalLayout levelsContent = new VerticalLayout(); // levels.setContent(levelsContent); // Label strenghtL = new Label("Forza: " + strenght); // levelsContent.addComponents(strenghtL); String levelTable = "<table><tr><td>Forza</td><td>Resistenza</td><td>Agilit</td><td>Intelligenza</td>" + "<td>Saggezza</td><td>Carisma</td></tr><tr>" + "<td>" + strenght + "</td>" + "<td>" + resistance + "</td>" + "<td>" + agility + "</td>" + "<td>" + intelligence + "</td>" + "<td>" + wisdom + "</td>" + "<td>" + charm + "</td>" + "</tr></table>"; Label levels = new Label(levelTable, ContentMode.HTML); descrizioneRazzaContent.addComponents(nameRace, imageRace, descriptionRace, min_ageL, max_ageL, levels); } } }); body.addComponents(datiIniziali, descrizioneRazza); CssLayout footer = new CssLayout(); Button next = new Button("Avanti ->"); next.addClickListener((Button.ClickEvent event) -> { user.setNomePG(nomePG.getValue()); user.setCognomePG(cognomePG.getValue()); user.setSessoPG(sessoPG.getValue().toString()); user.setRazzaPG(race); user.setEtaPG(age.getValue().toString()); user.setForzaPG(strenght); user.setResistenzaPG(resistance); user.setAgilitaPG(agility); user.setIntelligenzaPG(intelligence); user.setSaggezzaPG(wisdom); user.setCarismaPG(charm); this.setContent(setSecondStep()); }); footer.addComponents(next, createCancelButton()); firstStep.addComponents(setHeader("2/4"), body, footer); return firstStep; }
From source file:com.cerebro.provevaadin.ChatOffGame.java
public ChatOffGame() { Panel messagesPanel = new Panel(); messagesPanel.setSizeFull();// www . j av a 2s . c o m messagesPanel.setContent(messages); this.addComponent(messagesPanel); this.setExpandRatio(messagesPanel, 1.0f); HorizontalLayout sendBar = new HorizontalLayout(); sendBar.setWidth("100%"); final TextField input = new TextField(); input.setWidth("100%"); sendBar.addComponent(input); sendBar.setExpandRatio(input, 1.0f); Button send = new Button("Send"); send.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); send.addClickListener((Button.ClickEvent event) -> { BroadcasterOffGame.broadcast(input.getValue(), FROM); input.setValue(""); }); sendBar.addComponent(send); this.addComponent(sendBar); BroadcasterOffGame.register(this); }
From source file:com.cerebro.provevaadin.ChatOnGame.java
public ChatOnGame(User user) { if (user.getUltimoLuogoPG() != null) { logger.info("Luogo: " + user.getUltimoLuogoPG()); } else {/*w ww . j a v a 2 s. co m*/ logger.info("Nessun luogo selezionato"); } Panel messagesPanel = new Panel(); messagesPanel.setSizeFull(); messagesPanel.setContent(messages); this.addComponent(messagesPanel); this.setExpandRatio(messagesPanel, 1.0f); HorizontalLayout sendBar = new HorizontalLayout(); sendBar.setWidth("100%"); final TextField input = new TextField(); input.setWidth("100%"); sendBar.addComponent(input); sendBar.setExpandRatio(input, 1.0f); Button send = new Button("Send"); send.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); send.addClickListener((Button.ClickEvent event) -> { logger.info("Invio del messaggio al server"); BroadcasterOnGame.broadcast(input.getValue(), FROM); input.setValue(""); }); sendBar.addComponent(send); this.addComponent(sendBar); BroadcasterOnGame.register(this); }
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();//from w ww . ja v a2s.co 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.SignIn.java
private VerticalLayout setFirstStep() { VerticalLayout firstStep = new VerticalLayout(); CssLayout header = new CssLayout(); Label title = new Label("Benvenuto " + u.getNomeUtente() + "!"); Label istructions = new Label("Crea il tuo personaggio"); Label step = new Label("1/*"); header.addComponents(title, istructions, step); HorizontalLayout body = new HorizontalLayout(); FormLayout datiIniziali = new FormLayout(); TextField nomePG = new TextField("Nome del Personaggio"); TextField cognomePG = new TextField("Cognome del Personaggio"); OptionGroup sessoPG = new OptionGroup("Sesso del Personaggio"); sessoPG.addItems("Maschio", "Femmina"); ComboBox razzaPG = new ComboBox("Razza"); datiIniziali.addComponents(nomePG, cognomePG, sessoPG, razzaPG); HorizontalLayout descrizioneRazza = new HorizontalLayout(); descrizioneRazza.setWidth(datiIniziali.getWidth(), datiIniziali.getWidthUnits()); // Dettagli di popolazione e comportamento ComboBox razzaPG.addItem("Essere umano"); body.addComponents(datiIniziali, descrizioneRazza); CssLayout footer = new CssLayout(); Button next = new Button("Avanti ->"); next.addClickListener((Button.ClickEvent event) -> { u.setNomePG(nomePG.getValue()); u.setCognomePG(cognomePG.getValue()); u.setSessoPG(sessoPG.getValue().toString()); u.setRazzaPG(razzaPG.getValue().toString()); this.setContent(setSecondStep()); });/* w w w .j a v a 2 s .c o m*/ footer.addComponents(next, createCancelButton()); firstStep.addComponents(header, body, footer); return firstStep; }
From source file:com.cerebro.provevaadin.smtp.ConfigurazioneSMTP.java
public ConfigurazioneSMTP() { this.setMargin(true); TextField smtpHost = new TextField("SMTP Host Server"); smtpHost.setRequired(true);//from w w w. ja v 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 ava2 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.CustomPageTable.java
public HorizontalLayout createControls(String pageSizeDefault) { this.pageSizeDefault = pageSizeDefault; separatorTotal.setImmediate(true);//from w w w . j av a2 s.c om Label itemsPerPageLabel = new Label(BundleUtils.getString("common.table.numberRecord")); for (String numberSize : Constants.PAGE_SIZE_LIST) { itemsPerPageSelect.addItem(numberSize); } itemsPerPageSelect.setImmediate(true); itemsPerPageSelect.setNullSelectionAllowed(false); itemsPerPageSelect.setWidth("50px"); itemsPerPageSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -2255853716069800092L; @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { setPageLength(Integer.valueOf(String.valueOf(event.getProperty().getValue()))); firePagedChangedEvent(); } }); itemsPerPageSelect.select(pageSizeDefault); Label pageLabel = new Label(BundleUtils.getString("common.table.page"), ContentMode.HTML); final TextField currentPageTextField = new TextField(); currentPageTextField.setValue(String.valueOf(getCurrentPage())); currentPageTextField.setConverter(Integer.class); currentPageTextField .addValidator(new IntegerRangeValidator("Wrong page number", 1, getTotalAmountOfPages())); Label separatorLabel = new Label(" / ", ContentMode.HTML); final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), ContentMode.HTML); currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL); currentPageTextField.setImmediate(true); currentPageTextField.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -2255853716069800092L; @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { currentPageTextField.removeAllValidators(); currentPageTextField .addValidator(new IntegerRangeValidator("Wrong page number", 1, getTotalAmountOfPages())); if (Integer.valueOf(String.valueOf(currentPageTextField.getValue())) <= getTotalAmountOfPages()) { int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue())); setCurrentPage(page); } } }); pageLabel.setWidth(null); currentPageTextField.setWidth("30px"); separatorLabel.setWidth(null); totalPagesLabel.setWidth(null); HorizontalLayout controlBar = new HorizontalLayout(); HorizontalLayout pageSize = new HorizontalLayout(); HorizontalLayout pageManagement = new HorizontalLayout(); final Button first = new Button("<<", new Button.ClickListener() { private static final long serialVersionUID = -355520120491283992L; @Override public void buttonClick(Button.ClickEvent event) { setCurrentPage(0); } }); previous = new Button("<", new Button.ClickListener() { private static final long serialVersionUID = -355520120491283992L; @Override public void buttonClick(Button.ClickEvent event) { previousPage(); } }); final Button next = new Button(">", new Button.ClickListener() { private static final long serialVersionUID = -1927138212640638452L; @Override public void buttonClick(Button.ClickEvent event) { nextPage(); } }); final Button last = new Button(">>", new Button.ClickListener() { private static final long serialVersionUID = -355520120491283992L; @Override public void buttonClick(Button.ClickEvent event) { setCurrentPage(getTotalAmountOfPages()); } }); first.setStyleName(Reindeer.BUTTON_LINK); previous.setStyleName(Reindeer.BUTTON_LINK); next.setStyleName(Reindeer.BUTTON_LINK); last.setStyleName(Reindeer.BUTTON_LINK); itemsPerPageLabel.addStyleName("pagedtable-itemsperpagecaption"); itemsPerPageSelect.addStyleName("pagedtable-itemsperpagecombobox"); pageLabel.addStyleName("pagedtable-pagecaption"); currentPageTextField.addStyleName("pagedtable-pagefield"); separatorLabel.addStyleName("pagedtable-separator"); separatorTotal.addStyleName("pagedtable-separator"); totalPagesLabel.addStyleName("pagedtable-total"); first.addStyleName("pagedtable-first"); previous.addStyleName("pagedtable-previous"); next.addStyleName("pagedtable-next"); last.addStyleName("pagedtable-last"); itemsPerPageLabel.addStyleName("pagedtable-label"); itemsPerPageSelect.addStyleName("pagedtable-combobox"); pageLabel.addStyleName("pagedtable-label"); currentPageTextField.addStyleName("pagedtable-label"); separatorLabel.addStyleName("pagedtable-label"); separatorTotal.addStyleName("pagedtable-label"); totalPagesLabel.addStyleName("pagedtable-label"); first.addStyleName("pagedtable-button"); previous.addStyleName("pagedtable-button"); next.addStyleName("pagedtable-button"); last.addStyleName("pagedtable-button"); pageSize.addComponent(itemsPerPageLabel); pageSize.addComponent(itemsPerPageSelect); Label separator = new Label(" / ", ContentMode.HTML); pageSize.addComponent(separator); pageSize.addComponent(separatorTotal); pageSize.setComponentAlignment(itemsPerPageLabel, Alignment.MIDDLE_LEFT); pageSize.setComponentAlignment(itemsPerPageSelect, Alignment.MIDDLE_LEFT); pageSize.setComponentAlignment(separator, Alignment.MIDDLE_LEFT); pageSize.setComponentAlignment(separatorTotal, Alignment.MIDDLE_LEFT); pageSize.setSpacing(true); pageManagement.addComponent(first); pageManagement.addComponent(previous); pageManagement.addComponent(pageLabel); pageManagement.addComponent(currentPageTextField); pageManagement.addComponent(separatorLabel); pageManagement.addComponent(totalPagesLabel); pageManagement.addComponent(next); pageManagement.addComponent(last); pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT); pageManagement.setWidth(null); pageManagement.setSpacing(true); controlBar.addComponent(pageSize); controlBar.addComponent(pageManagement); controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER); controlBar.setWidth("100%"); controlBar.setExpandRatio(pageSize, 1); addListener(new PageChangeListener() { @Override public void pageChanged(PagedTableChangeEvent event) { int abc = event.getCurrentPage(); first.setEnabled(container.getStartIndex() > 0); previous.setEnabled(container.getStartIndex() > 0); next.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength()); last.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength()); currentPageTextField.setValue(String.valueOf(getCurrentPage())); totalPagesLabel.setValue(String.valueOf(getTotalAmountOfPages())); if (resizePage) { int lenght = getPageLength(); int a = lenght % 5; int b = lenght / 5; if (a != 0) { int pageLenght = 5 * (b + 1); itemsPerPageSelect.setValue(pageLenght); } } separatorTotal.setValue(String.valueOf(container.getRealSize())); } }); return controlBar; }
From source file:com.cms.utils.CommonUtils.java
public static String getDataTextfield(TextField tf) { return tf.getValue(); }