List of usage examples for com.vaadin.ui Button Button
public Button(Resource icon)
From source file:com.cerebro.gorgone.landingpage.SignInWindow.java
private Component setThirdStep() { VerticalLayout thirdStep = new VerticalLayout(); CssLayout body = new CssLayout(); Label title = null;//from w w w . j a v a2s .co m if (user.getSessoPG().equals("Maschio")) { title = new Label("Caro " + user.getNomeUtente() + " stai per registrare il seguente personaggio: "); } else if (user.getSessoPG().equals("Femmina")) { title = new Label("Cara " + user.getNomeUtente() + " stai per registrare il seguente personaggio: "); } Label nomePG = new Label("Nome: " + user.getNomePG()); Label cognomePG = new Label("Cognome: " + user.getCognomePG()); Label sessoPG = new Label("Sesso: " + user.getSessoPG()); Label etaPG = new Label("Et: " + user.getEtaPG()); Label razzaPG = new Label("Razza: " + user.getRazzaPG()); Label carrieraPG = new Label("Carriera: " + user.getCarrieraPG()); Label orientamentoPG = new Label("Orientamento: " + user.getOrientamentoPG()); String valuesTable = "<table><tr><td>Forza</td><td>Resistenza</td><td>Agilit</td><td>Intelligenza</td>" + "<td>Saggezza</td><td>Carisma</td></tr><tr>" + "<td>" + user.getForzaPG() + "</td>" + "<td>" + user.getResistenzaPG() + "</td>" + "<td>" + user.getAgilitaPG() + "</td>" + "<td>" + user.getIntelligenzaPG() + "</td>" + "<td>" + user.getSaggezzaPG() + "</td>" + "<td>" + user.getCarismaPG() + "</td>" + "</tr></table>"; Label values = new Label(valuesTable, ContentMode.HTML); Label alert = new Label("Premendo il tasto di iscrizione ti verr inviata una mail di conferma " + "all'indirizzo che hai inserito all'inizio. Se non lo confermi non potrai giocare!"); // Aggiungere le condizioni d'uso body.addComponents(title, nomePG, cognomePG, sessoPG, etaPG, razzaPG, carrieraPG, orientamentoPG, values, alert); CssLayout footer = new CssLayout(); Button signIn = new Button("Iscriviti"); signIn.addClickListener((Button.ClickEvent event) -> { logger.info("Iscrizione in corso"); // Creazione del codice String confCode = RandomStringUtils.random(10, true, true); user.setCodiceConferma(confCode); // Salvataggio dei dati nel database user.signInNewUser(); // Invio della mail // SendConfEmail sendConfEmail = new SendConfEmail(user.getEmail(), confCode); // SendConfMailjet sendConf = new SendConfMailjet(user.getEmail(), confCode); // Chiusura della finestra this.close(); }); footer.addComponents(signIn, createCancelButton()); thirdStep.addComponents(setHeader("4/4"), body, footer); return thirdStep; }
From source file:com.cerebro.provevaadin.ChatOffGame.java
public ChatOffGame() { Panel messagesPanel = new Panel(); messagesPanel.setSizeFull();// w w w .j ava 2 s .c om 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 {/*ww w. java 2 s . c o 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 w w. java 2 s . 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.FirstTime.java
public FirstTime() { this.setMargin(true); TabSheet tabsheet = new TabSheet(); this.addComponent(tabsheet); tabsheet.addTab(new Configurazione(), "Database MySQL"); tabsheet.addTab(new ConfigurazioneSMTP(), "Server SMTP"); Button logout = new Button("Esci"); this.addComponent(logout); logout.addClickListener((Button.ClickEvent e) -> { // logger.info("Esco dall'applicazione"); // logger.info("Pulsante: " + e.toString()); SecurityUtils.getSubject().logout(); UI.getCurrent().getSession().close(); UI.getCurrent().getPage().setLocation(""); });/*ww w . ja v a 2 s . c om*/ this.addComponent(logout); }
From source file:com.cerebro.provevaadin.Game.java
public Game() { Subject currentUser = SecurityUtils.getSubject(); this.addComponent(new Label("Area di gioco")); Button logout = new Button("Esci"); this.addComponent(logout); logout.addClickListener((Button.ClickEvent e) -> { logger.info("Esco dall'applicazione"); logger.info("Pulsante: " + e.toString()); SecurityUtils.getSubject().logout(); UI.getCurrent().getSession().close(); UI.getCurrent().getPage().setLocation(""); });//from w w w. j a v a 2s . c o m }
From source file:com.cerebro.provevaadin.Secure.java
public Secure() { HorizontalLayout top = new HorizontalLayout(); this.addComponent(top); top.addComponent(new Label("Area sicura")); VerticalLayout content = new VerticalLayout(); this.addComponent(content); Navigator nav = new Navigator(UI.getCurrent(), content); nav.setErrorView(new ErrorView()); nav.addView("", new HomeView()); nav.navigateTo(""); Button logout = new Button("Logout"); logout.addClickListener((Button.ClickEvent event) -> { System.out.println("Esco dalla sessione"); SecurityUtils.getSubject().logout(); UI.getCurrent().getSession().close(); UI.getCurrent().getPage().setLocation(""); });//from w w w.ja v a 2 s . c o m top.addComponent(logout); }
From source file:com.cerebro.provevaadin.SendConfEmail.java
public SendConfEmail() { Button send = new Button("Spedisci"); send.addClickListener((Button.ClickEvent event) -> { try {/*from www . j a va2s. c o m*/ client = new MailjetClient("328cd563c1977097c524f1981f92c8b5", "896ed8a77847d131bffd62668edea39c"); request = new MailjetRequest(Email.resource) .property(Email.FROMEMAIL, "info@ambulatorio-vet-athena.it") .property(Email.FROMNAME, "Matteo Casagrande").property(Email.SUBJECT, "Email di prova") .property(Email.TEXTPART, "Testo semplice di prova") .property(Email.HTMLPART, "<h1>Testo in html</h1>") .property(Email.RECIPIENTS, new JSONArray() .put(new JSONObject().put("Email", "dottmatteocasagrande@gmail.com"))); response = client.post(request); System.out.println(response.getData()); } catch (MailjetException ex) { Logger.getLogger(SendConfEmail.class.getName()).log(Level.SEVERE, null, ex); } catch (MailjetSocketTimeoutException ex) { Logger.getLogger(SendConfEmail.class.getName()).log(Level.SEVERE, null, ex); } }); this.addComponent(send); }
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());/*from w w w.j av a2s . c om*/ u.setCognomePG(cognomePG.getValue()); u.setSessoPG(sessoPG.getValue().toString()); u.setRazzaPG(razzaPG.getValue().toString()); this.setContent(setSecondStep()); }); footer.addComponents(next, createCancelButton()); firstStep.addComponents(header, body, footer); return firstStep; }
From source file:com.cerebro.provevaadin.SignIn.java
private VerticalLayout setSecondStep() { VerticalLayout secondStep = 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("2/*"); header.addComponents(title, istructions, step); VerticalLayout body = new VerticalLayout(); Label ageIstruction = new Label("Indica l'et del tuo personaggio in anni"); // Cambiare i parametri in base alla razza Slider age = new Slider(1, 150); age.setImmediate(true);// w ww . ja v a 2 s. co m age.setSizeFull(); 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"); } }); body.addComponents(ageIstruction, age, ageDescription); CssLayout footer = new CssLayout(); Button next = new Button("Avanti ->"); next.addClickListener((Button.ClickEvent event) -> { u.setEtaPG(age.getValue().toString()); this.setContent(setThirdStep()); }); footer.addComponents(next, createCancelButton()); secondStep.addComponents(header, body, footer); return secondStep; }