List of usage examples for com.vaadin.ui FormLayout FormLayout
public FormLayout()
From source file:ch.bfh.ti.soed.hs16.srs.green.view.MyUI.java
License:Open Source License
/** * Method which actually creates the whole UI. *///from w ww . j a v a 2s. c om @Override protected void init(VaadinRequest vaadinRequest) { VerticalLayout layout = new VerticalLayout(); Panel panel = new Panel("Login"); panel.setSizeUndefined(); FormLayout content = new FormLayout(); userName = new TextField("Username"); content.addComponent(userName); PasswordField password = new PasswordField("Password"); content.addComponent(password); Button login = new Button("Login"); register = new Button("Register"); CheckBox askBox = new CheckBox("Are you a Roommanager?"); login.setStyleName(Reindeer.BUTTON_SMALL); login.setWidth("86px"); register.setStyleName(Reindeer.BUTTON_SMALL); register.setWidth("86px"); askBox.setStyleName(Reindeer.BUTTON_SMALL); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.addComponent(login); hl.addComponent(register); hl.addComponent(askBox); content.addComponent(hl); content.setSizeUndefined(); content.setMargin(true); panel.setContent(content); login.addClickListener(e -> { System.out.println(userName.getValue()); System.out.println(password.getValue()); try { if (controller.login(userName.getValue(), password.getValue()) || userName.equals(userName.getValue()) && password.equals(password.getValue())) { setContent(new ReservationUI()); } } catch (Throwable e1) { e1.printStackTrace(); } }); register.addClickListener(e -> { try { Role x = askBox.getValue() ? Role.ROOMMANAGER : Role.CUSTOMER; controller.register(userName.getValue(), password.getValue(), x); } catch (Throwable e1) { e1.printStackTrace(); } }); layout.setMargin(true); layout.setSpacing(true); layout.addComponent(panel); setContent(layout); }
From source file:cirad.cgh.vcf2fasta.view.Vcf2fastaForm.java
License:Open Source License
private void initComponents() { removeAllComponents();//from w ww . jav a2s . c o m fieldGroup = new BeanFieldGroup<Vcf2fastaInputBean>(Vcf2fastaInputBean.class); vcf2fastaInputBean = new Vcf2fastaInputBean(config); fieldGroup.setItemDataSource(vcf2fastaInputBean); FormLayout layout = new FormLayout(); layout.setResponsive(true); layout.setMargin(true); layout.setWidth("100%"); //layout.addStyleName("light"); layout.setImmediate(true); addComponent(layout); Label section1; final ComboBox analysis_combo; final ComboBox accession_combo; Label section2; ComboBox contig_combo; TextField interval; Label section3; Component buttonLayout; Component progressLayout; section1 = new Label("Input"); section1.addStyleName("h3 colored"); layout.addComponent(section1); analysis_combo = getComboBox(ANALYSIS_CAPTION, ANALYSIS, getAnalysesList(), false); layout.addComponent(analysis_combo); accession_combo = getComboBox(ACCESSION_CAPTION, ACCESSION, getAccessionsList("Cassava 6.1 WGS Bredeson 61 accessions"), false); layout.addComponent(accession_combo); analysis_combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { accession_combo.setContainerDataSource(getAccessionsList((String) analysis_combo.getValue())); accession_combo.select(accession_combo.getContainerDataSource().getItemIds().iterator().next()); } }); section2 = new Label("Parameters"); section2.addStyleName("h3 colored"); layout.addComponent(section2); contig_combo = getComboBox(CONTIG_CAPTION, CONTIG, getContigsList(), true); layout.addComponent(contig_combo); interval = getTextField(INTERVAL_CAPTION, INTERVAL, vcf2fastaUI.getConfig().getString("defaultInterval"), 20); layout.addComponent(interval); section3 = new Label("Result"); section3.addStyleName("h3 colored"); layout.addComponent(section3); resultLayout = new VerticalLayout(); resultLayout.setSizeFull(); resultLayout.setMargin(true); resultLayout.setSpacing(true); resultLayout.addStyleName("light"); layout.addComponent(resultLayout); layout.addComponent(new Label("")); buttonLayout = getSubmitLayout(); layout.addComponent(buttonLayout); progressLayout = getProgressLayout(); layout.addComponent(progressLayout); initCommitHandler(); }
From source file:com.arcusys.liferay.vaadinplugin.ControlPanelUI.java
License:Apache License
private void createUI() { //create main layout mainLayout = new VerticalLayout(); mainLayout.setWidth("720px"); mainLayout.setSpacing(true);/*from w ww. j ava 2s . com*/ setContent(mainLayout); //create Setting layout settingsPanel = new Panel("Settings"); settingsLayout = new FormLayout(); settingsPanel.setContent(settingsLayout); versionUpgradeProgressIndicator = createProgressIndicator(); changeVersionButton = createChangeVersionButton(); updateVaadinVersionButton = createUpdateVaadinVersionButton(); Version vaadinNewestVersion = newestDownloadInfo.getVersion(); //add details detailsButton = createDetailsButton(); vaadinVersionLayout = createVaadinVersionLayout(vaadinNewestVersion.toString(), changeVersionButton, updateVaadinVersionButton, versionUpgradeProgressIndicator, detailsButton); settingsLayout.addComponent(vaadinVersionLayout); activeWidgetsetLabel = createActiveWidgetsetLabel(); settingsLayout.addComponent(activeWidgetsetLabel); // Add-on selection HorizontalLayout addonDirectoryLayout = createAddonDirectoryLayout(); settingsLayout.addComponent(addonDirectoryLayout); //Add-on included includeAddonsOptionGroup = createIncludeAddonsList(); addonsListHolder = createIncludeAddonsListLayout(includeAddonsOptionGroup); settingsLayout.addComponent(addonsListHolder); //addition dependencies additionalDependenciesLabel = createAdditionalDependenciesLabel(); settingsLayout.addComponent(additionalDependenciesLabel); mainLayout.addComponent(settingsPanel); additionalDependenciesButton = createAdditionalDependenciesButton(); mainLayout.addComponent(additionalDependenciesButton); //Compilation layout HorizontalLayout compilationlayout = new HorizontalLayout(); compileWidgetsetButton = createCompileWidgetsetButton(); compilationlayout.addComponent(compileWidgetsetButton); terminateCompilationButton = createTerminateCompilationButton(); compilationlayout.addComponent(terminateCompilationButton); compilationProgressIndicator = createProgressIndicator(); compilationlayout.addComponent(compilationProgressIndicator); compilationlayout.setComponentAlignment(compilationProgressIndicator, Alignment.MIDDLE_LEFT); settingsLayout.addComponent(compilationlayout); //Output console outputConsole = createOutputConsole(); mainLayout.addComponent(outputConsole); addonsNotFoundLabel = createAddonsNotFoundLabel(); }
From source file:com.cavisson.gui.dashboard.components.calender.BeanItemContainerTestUI.java
License:Apache License
/** * Opens up a modal dialog window where an event can be modified * /* w w w. j a v a 2s. c o m*/ * @param event * The event to modify */ private void editEvent(final BasicEvent event) { Window modal = new Window("Add event"); modal.setModal(true); modal.setResizable(false); modal.setDraggable(false); modal.setWidth("300px"); final FieldGroup fieldGroup = new FieldGroup(); FormLayout formLayout = new FormLayout(); TextField captionField = new TextField("Caption"); captionField.setImmediate(true); TextField descriptionField = new TextField("Description"); descriptionField.setImmediate(true); DateField startField = new DateField("Start"); startField.setResolution(Resolution.MINUTE); startField.setImmediate(true); DateField endField = new DateField("End"); endField.setImmediate(true); endField.setResolution(Resolution.MINUTE); formLayout.addComponent(captionField); formLayout.addComponent(descriptionField); formLayout.addComponent(startField); formLayout.addComponent(endField); fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY); fieldGroup.bind(descriptionField, ContainerEventProvider.DESCRIPTION_PROPERTY); fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY); fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY); fieldGroup.setItemDataSource(new BeanItem<BasicEvent>(event, Arrays.asList(ContainerEventProvider.CAPTION_PROPERTY, ContainerEventProvider.DESCRIPTION_PROPERTY, ContainerEventProvider.STARTDATE_PROPERTY, ContainerEventProvider.ENDDATE_PROPERTY))); modal.setContent(formLayout); modal.addCloseListener(new Window.CloseListener() { @Override public void windowClose(CloseEvent e) { // Commit changes to bean try { fieldGroup.commit(); } catch (CommitException e1) { e1.printStackTrace(); } if (events.containsId(event)) { /* * BeanItemContainer does not notify container listeners * when the bean changes so we need to trigger a * ItemSetChange event */ BasicEvent dummy = new BasicEvent(); events.addBean(dummy); events.removeItem(dummy); } else { events.addBean(event); } } }); getUI().addWindow(modal); }
From source file:com.cavisson.gui.dashboard.components.controls.Forms.java
License:Apache License
public Forms() { setSpacing(true);/*from w w w. j av a 2s . co m*/ setMargin(true); Label title = new Label("Forms"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("800px"); form.addStyleName("light"); addComponent(form); Label section = new Label("Personal Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); StringGenerator sg = new StringGenerator(); TextField name = new TextField("Name"); name.setValue(sg.nextString(true) + " " + sg.nextString(true)); name.setWidth("50%"); form.addComponent(name); DateField birthday = new DateField("Birthday"); birthday.setValue(new Date(80, 0, 31)); form.addComponent(birthday); TextField username = new TextField("Username"); username.setValue(sg.nextString(false) + sg.nextString(false)); username.setRequired(true); form.addComponent(username); OptionGroup sex = new OptionGroup("Sex"); sex.addItem("Female"); sex.addItem("Male"); sex.select("Male"); sex.addStyleName("horizontal"); form.addComponent(sex); section = new Label("Contact Info"); section.addStyleName("h3"); section.addStyleName("colored"); form.addComponent(section); TextField email = new TextField("Email"); email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com"); email.setWidth("50%"); email.setRequired(true); form.addComponent(email); TextField location = new TextField("Location"); location.setValue(sg.nextString(true) + ", " + sg.nextString(true)); location.setWidth("50%"); location.setComponentError(new UserError("This address doesn't exist")); form.addComponent(location); TextField phone = new TextField("Phone"); phone.setWidth("50%"); form.addComponent(phone); HorizontalLayout wrap = new HorizontalLayout(); wrap.setSpacing(true); wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); wrap.setCaption("Newsletter"); CheckBox newsletter = new CheckBox("Subscribe to newsletter", true); wrap.addComponent(newsletter); ComboBox period = new ComboBox(); period.setTextInputAllowed(false); period.addItem("Daily"); period.addItem("Weekly"); period.addItem("Montly"); period.setNullSelectionAllowed(false); period.select("Weekly"); period.addStyleName("small"); period.setWidth("10em"); wrap.addComponent(period); form.addComponent(wrap); section = new Label("Additional Info"); section.addStyleName("h4"); section.addStyleName("colored"); form.addComponent(section); TextField website = new TextField("Website"); website.setInputPrompt("http://"); website.setWidth("100%"); form.addComponent(website); TextArea shortbio = new TextArea("Short Bio"); shortbio.setValue( "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum."); shortbio.setWidth("100%"); shortbio.setRows(2); form.addComponent(shortbio); final RichTextArea bio = new RichTextArea("Bio"); bio.setWidth("100%"); bio.setValue( "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>"); form.addComponent(bio); form.setReadOnly(true); bio.setReadOnly(true); Button edit = new Button("Edit", new ClickListener() { @Override public void buttonClick(ClickEvent event) { boolean readOnly = form.isReadOnly(); if (readOnly) { bio.setReadOnly(false); form.setReadOnly(false); form.removeStyleName("light"); event.getButton().setCaption("Save"); event.getButton().addStyleName("primary"); } else { bio.setReadOnly(true); form.setReadOnly(true); form.addStyleName("light"); event.getButton().setCaption("Edit"); event.getButton().removeStyleName("primary"); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); form.addComponent(footer); footer.addComponent(edit); Label lastModified = new Label("Last modified by you a minute ago"); lastModified.addStyleName("light"); footer.addComponent(lastModified); }
From source file:com.cerebro.cable.xforce.view.GestioneRazze.java
public GestioneRazze() { setMargin(true);/*from w ww . j av a2s.co m*/ TableQuery racesTQ = new TableQuery("races", connPool); SQLContainer racesContainer = null; try { racesContainer = new SQLContainer(racesTQ); } catch (Exception ex) { logger.error("Errore nella tabella delle razze: " + ex.getMessage()); } Grid racesTable = new Grid(racesContainer); racesTable.removeAllColumns(); for (int i = 0; i < racesTabCols.length; i++) { racesTable.addColumn(racesTabCols[i][0]); Grid.Column col = racesTable.getColumn(racesTabCols[i][0]); col.setHeaderCaption(racesTabCols[i][1]); } racesTable.getColumn("image").setRenderer(new ImageRenderer(), new Converter<Resource, String>() { @Override public String convertToModel(Resource value, Class<? extends String> targetType, Locale locale) throws Converter.ConversionException { return "not needed"; } @Override public Resource convertToPresentation(String value, Class<? extends Resource> targetType, Locale locale) throws Converter.ConversionException { return new FileResource( new File(VaadinService.getCurrent().getBaseDirectory().getAbsolutePath() + value)); } @Override public Class<String> getModelType() { return String.class; } @Override public Class<Resource> getPresentationType() { return Resource.class; } }); FormLayout raceEditor = new FormLayout(); addComponents(racesTable); }
From source file:com.cerebro.gorgone.landingpage.SignInWindow.java
private Component setFirstStep() { VerticalLayout firstStep = new VerticalLayout(); firstStep.setMargin(true);/* w w w .ja v a2 s . co 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.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());//w w w .j av a 2 s.c o m 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.Start.java
public Start() { InputStream iniFile = VaadinServlet.getCurrent().getServletContext() .getResourceAsStream("/WEB-INF/shiro.ini"); if (iniFile == null) { logger.error("Il file Shiro.ini non esiste"); return;/*from ww w. j a v a 2s. c o m*/ } else { logger.info("File presente"); } Ini ini = new Ini(); ini.load(iniFile); Factory<SecurityManager> factory = new IniSecurityManagerFactory(ini); SecurityManager securityManager = factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); HorizontalLayout root = new HorizontalLayout(); root.setWidth("800px"); root.setHeight("600px"); this.addComponent(root); this.setComponentAlignment(root, Alignment.MIDDLE_CENTER); FormLayout loginDiv = new FormLayout(); root.addComponent(loginDiv); username.focus(); errorMessage.setVisible(false); loginDiv.addComponents(username, password, rememberMe, login, errorMessage); login.addClickListener((Button.ClickEvent e) -> { logger.info("Pulsante: " + e.toString()); Subject currentUser = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(username.getValue(), password.getValue()); token.setRememberMe(rememberMe.getValue()); try { currentUser.login(token); if (currentUser.hasRole("firsttime")) { logger.info("Configurazione parametri del primo avvio"); getUI().setContent(new FirstTime()); } else { logger.info("Classe di gioco principale"); getUI().setContent(new Game()); VaadinService.reinitializeSession(VaadinService.getCurrentRequest()); } } catch (Exception ex) { logger.error("Errore nel login: " + ex.getMessage()); username.setValue(""); password.setValue(""); errorMessage.setVisible(true); } }); FormLayout signInForm = new FormLayout(); root.addComponent(signInForm); usernameSignIn.focus(); sesso.addItems("Maschio", "Femmina"); signInForm.addComponents(usernameSignIn, passwordSignIn, passwordConf, nome, cognome, sesso, eta, signIn); signIn.addClickListener((Button.ClickEvent event) -> { logger.info("Iscrizione al sito"); User utente = new User(); utente.setEmail(usernameSignIn.getValue()); utente.setPassword(passwordSignIn.getValue()); utente.setNomeUtente(nome.getValue()); utente.setCognomeUtente(cognome.getValue()); utente.setSessoUtente(sesso.getValue().toString()); utente.setDataNascitaUtente(eta.getValue()); SignIn signInWindow = new SignIn(utente); signInWindow.center(); UI.getCurrent().addWindow(signInWindow); }); }
From source file:com.coatl.pruebas.datastore.DataStoreUI.java
@Override protected void init(VaadinRequest vaadinRequest) { this.principal = new VerticalLayout(); {/* w w w .ja va 2s .co m*/ principal.addComponent(new Label("Pruebas de DataStore")); HorizontalLayout superior = new HorizontalLayout(); principal.addComponent(superior); this.forma = new FormLayout(); superior.addComponent(forma); { this.tabla = new TextField("Tabla"); tabla.setValue("iq3_usuarios"); forma.addComponents(tabla); this.nombre = new TextField("Nombre"); forma.addComponents(nombre); this.ap1 = new TextField("Apellido Paterno"); forma.addComponents(ap1); this.ap2 = new TextField("Apellido Materno"); forma.addComponents(ap2); this.renglones = new Label("Renglones"); forma.addComponents(renglones); } FormLayout botones = new FormLayout(); /* botones.addComponent(new Label(" ")); botones.addComponent(new Label("Acciones:")); */ superior.addComponent(botones); Button recargar = new Button("Recargar"); botones.addComponent(recargar); recargar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { listarObjetos(); } }); Button guardar = new Button("Guardar"); botones.addComponent(guardar); guardar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Map m = new HashMap(); m.put("nombre", nombre.getValue()); m.put("ap1", ap1.getValue()); m.put("ap2", ap2.getValue()); m.put("id", nombre.getValue()); IU7.ds.guardar(tabla.getValue(), m); System.out.println("Objeto guardado"); listarObjetos(); } }); Button borrar = new Button("Borrar"); botones.addComponent(borrar); borrar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { borrar(); } }); Button mil = new Button("Hacer 1,000"); botones.addComponent(mil); mil.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { for (int i = 0; i < 1000; i++) { Map m = new HashMap(); String id = "ID_" + i + "_" + Math.random(); m.put("id", id); m.put("nombre", "Nombre_" + id + "_" + Math.random()); m.put("ap1", "Ap1_" + id + "_" + Math.random()); m.put("ap2", "Ap2_" + id + "_" + Math.random()); IU7.ds.guardar(tabla.getValue(), m); System.out.println(" >" + id); } } }); } VerticalSplitPanel vsl = new VerticalSplitPanel(); setContent(vsl); vsl.setFirstComponent(principal); grid.setSizeFull(); grid.setComponenteSuperior(new Label("primer panel")); //grid.setComponenteMedio(new Label("segundo panel")); //grid.setComponenteInferior(new Label("tercer panel")); grid.setNombreTabla(tabla.getValue()); grid.setColumnas("id,nombre,ap1,ap2"); grid.setColumnasVisibles("nombre,ap1,ap2"); vsl.setSecondComponent(grid); //grid.setComponenteMedio(grid); this.listarObjetos(); }