List of usage examples for com.vaadin.ui VerticalLayout VerticalLayout
public VerticalLayout()
From source file:com.cavisson.gui.dashboard.components.controls.Tabsheets.java
License:Apache License
static TabSheet getTabSheet(boolean caption, String style, boolean closable, boolean scrolling, boolean icon, boolean disable) { TestIcon testIcon = new TestIcon(60); TabSheet ts = new TabSheet(); ts.addStyleName(style);//from w ww .j a va 2 s .co m StringGenerator sg = new StringGenerator(); for (int i = 1; i <= (scrolling ? 10 : 3); i++) { String tabcaption = caption ? sg.nextString(true) + " " + sg.nextString(false) : null; VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); content.addComponent(new Label("Content for tab " + i)); if (i == 2) { content.addComponent(new Label( "Excepteur sint obcaecat cupiditat non proident culpa. Magna pars studiorum, prodita quaerimus.")); } Tab t = ts.addTab(content, tabcaption); t.setClosable(closable); t.setEnabled(!disable); // First tab is always enabled if (i == 1) { t.setEnabled(true); } if (icon) { t.setIcon(testIcon.get(false)); } } ts.addSelectedTabChangeListener(new SelectedTabChangeListener() { @Override public void selectedTabChange(SelectedTabChangeEvent event) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }); return ts; }
From source file:com.cbnserver.gwtp4vaadin.example.MainView.java
License:Apache License
@PostConstruct public void createUI() { panel = new VerticalLayout(); }
From source file:com.cerebro.gorgone.landingpage.SignInWindow.java
private Component setFirstStep() { VerticalLayout firstStep = new VerticalLayout(); firstStep.setMargin(true);// ww w . j av a 2 s .c o m // 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.gorgone.landingpage.SignInWindow.java
private Component setSecondStep() { VerticalLayout secondStep = new VerticalLayout(); HorizontalLayout body = new HorizontalLayout(); Panel sx = new Panel(); VerticalLayout sxContent = new VerticalLayout(); sx.setContent(sxContent);// w ww. j a v a2 s .com Label welcome = null; if (user.getSessoPG().equals("Maschio")) { welcome = new Label("Benvenuto: " + user.getNomePG() + "!"); } else if (user.getSessoPG().equals("Femmina")) { welcome = new Label("Benvenuta: " + user.getNomePG() + "!"); } ComboBox carrieraPG = new ComboBox("Scegli la tua carriera:"); carrieraPG.isRequired(); Panel careerDescription = new Panel(); CssLayout careerDescrContent = new CssLayout(); careerDescription.setContent(careerDescrContent); sxContent.addComponents(welcome, carrieraPG, careerDescription); // Dettagli di popolazione e comportamento ComboBox TableQuery tq_career = new TableQuery(DatabaseTables.CAREER_TABLE, connPool); tq_career.setVersionColumn(DatabaseTables.CAREER_VERSION); SQLContainer container_career = null; try { container_career = new SQLContainer(tq_career); } catch (Exception ex) { logger.error(ex.getMessage()); } carrieraPG.setContainerDataSource(container_career); carrieraPG.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY); carrieraPG.setItemCaptionPropertyId(DatabaseTables.CAREER_NAME); carrieraPG.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (carrieraPG.getValue() != null) { logger.info("Carriera: " + carrieraPG.getValue().toString()); careerDescrContent.removeAllComponents(); Item item = (Item) carrieraPG.getContainerDataSource().getItem(carrieraPG.getValue()); career = (String) item.getItemProperty(DatabaseTables.CAREER_NAME).getValue(); Label careerName = new Label(career); FileResource imageSrc = new FileResource( new File(MyUI.basePath + item.getItemProperty(DatabaseTables.CAREER_IMAGE).getValue())); Image imageCareer = new Image(null, imageSrc); imageCareer.setWidth("200px"); Label careerDescription = new Label(item.getItemProperty(DatabaseTables.CAREER_DESCRIPTION), ContentMode.HTML); strenght_car = (int) item.getItemProperty(DatabaseTables.CAREER_STRENGTH).getValue(); resistance_car = (int) item.getItemProperty(DatabaseTables.CAREER_RESISTANCE).getValue(); agility_car = (int) item.getItemProperty(DatabaseTables.CAREER_AGILITY).getValue(); intelligence_car = (int) item.getItemProperty(DatabaseTables.CAREER_INTELLIGENCE).getValue(); wisdom_car = (int) item.getItemProperty(DatabaseTables.CAREER_WISDOM).getValue(); charm_car = (int) item.getItemProperty(DatabaseTables.CAREER_CHARM).getValue(); String modsTable = "<table><tr><td>Forza</td><td>Resistenza</td><td>Agilit</td><td>Intelligenza</td>" + "<td>Saggezza</td><td>Carisma</td></tr><tr>" + "<td>" + strenght_car + "</td>" + "<td>" + resistance_car + "</td>" + "<td>" + agility_car + "</td>" + "<td>" + intelligence_car + "</td>" + "<td>" + wisdom_car + "</td>" + "<td>" + charm_car + "</td>" + "</tr></table>"; Label mods = new Label(modsTable, ContentMode.HTML); careerDescrContent.addComponents(careerName, imageCareer, careerDescription, mods); } } }); Panel dx = new Panel(); VerticalLayout dxContent = new VerticalLayout(); dx.setContent(dxContent); ComboBox orientamentoPG = new ComboBox("Scegli il tuo orientamento:"); orientamentoPG.isRequired(); Panel orientamentoDescription = new Panel(); CssLayout orientamentoDescrContent = new CssLayout(); orientamentoDescription.setContent(orientamentoDescrContent); dxContent.addComponents(orientamentoPG, orientamentoDescription); // Dettagli di popolazione e comportamento ComboBox TableQuery tq_orientamento = new TableQuery(DatabaseTables.MORALCODE_TABLE, connPool); tq_orientamento.setVersionColumn(DatabaseTables.MORALCODE_VERSION); SQLContainer container_orientamento = null; try { container_orientamento = new SQLContainer(tq_orientamento); } catch (Exception ex) { logger.error(ex.getMessage()); } orientamentoPG.setContainerDataSource(container_orientamento); orientamentoPG.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY); orientamentoPG.setItemCaptionPropertyId(DatabaseTables.MORALCODE_TENDENCY); orientamentoPG.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (orientamentoPG.getValue() != null) { logger.info("Orientamento: " + orientamentoPG.getValue().toString()); orientamentoDescrContent.removeAllComponents(); Item item = (Item) orientamentoPG.getContainerDataSource().getItem(orientamentoPG.getValue()); moralCode = (String) item.getItemProperty(DatabaseTables.MORALCODE_TENDENCY).getValue(); Label orientamentoName = new Label(moralCode); FileResource imageSrc = new FileResource(new File( MyUI.basePath + item.getItemProperty(DatabaseTables.MORALCODE_IMAGE).getValue())); Image imageTendency = new Image(null, imageSrc); imageTendency.setWidth("200px"); Label orientamentoDescription = new Label( item.getItemProperty(DatabaseTables.MORALCODE_DESCRIPTION), ContentMode.HTML); orientamentoDescrContent.addComponents(orientamentoName, imageTendency, orientamentoDescription); } } }); body.addComponents(sx, dx); CssLayout footer = new CssLayout(); Button next = new Button("Avanti ->"); next.addClickListener((Button.ClickEvent event) -> { user.setCarrieraPG(career); // Gestire modificatori user.setForzaPG(user.getForzaPG() + strenght_car); user.setResistenzaPG(user.getResistenzaPG() + resistance_car); user.setAgilitaPG(user.getAgilitaPG() + agility_car); user.setIntelligenzaPG(user.getIntelligenzaPG() + intelligence_car); user.setSaggezzaPG(user.getSaggezzaPG() + wisdom_car); user.setCarismaPG(user.getCarismaPG() + charm_car); user.setOrientamentoPG(moralCode); this.setContent(setThirdStep()); }); footer.addComponents(next, createCancelButton()); secondStep.addComponents(setHeader("3/4"), body, footer); return secondStep; }
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 . ja v a 2 s . c o 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.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(""); });//w ww .j a v a 2 s .c om top.addComponent(logout); }
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 ww.j a v a 2 s .com 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);// www . j ava 2 s . c om 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; }
From source file:com.cerebro.provevaadin.SignIn.java
private Component setThirdStep() { VerticalLayout thirdStep = 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("3/*"); header.addComponents(title, istructions, step); HorizontalLayout body = new HorizontalLayout(); VerticalLayout carrieraPanel = new VerticalLayout(); ComboBox carriera = new ComboBox("Scegli la tua carriera:"); carriera.addItem("Guerriero"); HorizontalLayout descrizioneCarriera = new HorizontalLayout(); // Comportamento ComboBox carrieraPanel.addComponents(carriera, descrizioneCarriera); VerticalLayout orientamentoPanel = new VerticalLayout(); ComboBox orientamento = new ComboBox("Scegli il tuo orientamento"); orientamento.addItem("Buono Ordine"); HorizontalLayout descrizioneOrientamento = new HorizontalLayout(); // Comportamento ComboBox orientamentoPanel.addComponents(orientamento, descrizioneOrientamento); body.addComponents(carrieraPanel, orientamentoPanel); CssLayout footer = new CssLayout(); Button next = new Button("Avanti ->"); next.addClickListener((Button.ClickEvent event) -> { u.setCarrieraPG(carriera.getValue().toString()); u.setOrientamentoPG(orientamento.getValue().toString()); this.setContent(setFourthStep()); });/*from w w w . j ava2 s .c o m*/ footer.addComponents(next, createCancelButton()); thirdStep.addComponents(header, body, footer); return thirdStep; }
From source file:com.cerebro.provevaadin.SignIn.java
private Component setFourthStep() { VerticalLayout fourthStep = 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("3/*"); header.addComponents(title, istructions, step); CssLayout body = new CssLayout(); Label resoconto = new Label("Stai per registrare il seguente personaggio: "); Label nomePG = new Label(u.getNomePG()); CssLayout footer = new CssLayout(); Button next = new Button("Fine"); next.addClickListener((Button.ClickEvent event) -> { // Salvare i dati nel database, inviare la mail, rimandare all'ultima pagina this.setContent(setFourthStep()); });//from ww w . j a v a2 s . c o m footer.addComponents(next, createCancelButton()); fourthStep.addComponents(header, body, footer); return fourthStep; }