List of usage examples for com.vaadin.ui FormLayout addComponent
@Override public void addComponent(Component c)
From source file:annis.gui.admin.ImportPanel.java
License:Apache License
public ImportPanel() { setSizeFull();//from www . jav a 2 s . c om layout = new VerticalLayout(); layout.setWidth("100%"); layout.setHeight("100%"); layout.setMargin(true); setContent(layout); FormLayout form = new FormLayout(); layout.addComponent(form); cbOverwrite = new CheckBox("Overwrite existing corpus"); form.addComponent(cbOverwrite); txtMail = new TextField("e-mail address for status updates"); txtMail.addValidator(new EmailValidator("Must be a valid e-mail address")); form.addComponent(txtMail); txtAlias = new TextField("alias name"); form.addComponent(txtAlias); HorizontalLayout actionBar = new HorizontalLayout(); actionBar.setSpacing(true); actionBar.setWidth("100%"); upload = new Upload("", this); upload.setButtonCaption("Upload ZIP file with relANNIS corpus and start import"); upload.setImmediate(true); upload.addStartedListener(this); upload.addFinishedListener(this); upload.setEnabled(true); actionBar.addComponent(upload); progress = new ProgressBar(); progress.setIndeterminate(true); progress.setVisible(false); actionBar.addComponent(progress); lblProgress = new Label(); lblProgress.setWidth("100%"); actionBar.addComponent(lblProgress); actionBar.setExpandRatio(lblProgress, 1.0f); actionBar.setComponentAlignment(lblProgress, Alignment.MIDDLE_LEFT); actionBar.setComponentAlignment(upload, Alignment.MIDDLE_LEFT); actionBar.setComponentAlignment(progress, Alignment.MIDDLE_LEFT); layout.addComponent(actionBar); btDetailedLog = new Button(); btDetailedLog.setStyleName(BaseTheme.BUTTON_LINK); btDetailedLog.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { setLogVisible(!isLogVisible()); } }); layout.addComponent(btDetailedLog); txtMessages = new TextArea(); txtMessages.setSizeFull(); txtMessages.setValue(""); txtMessages.setReadOnly(true); layout.addComponent(txtMessages); layout.setExpandRatio(txtMessages, 1.0f); setLogVisible(false); appendMessage("Ready."); }
From source file:annis.gui.admin.NewPasswordWindow.java
License:Apache License
public NewPasswordWindow(final String userName, final List<UserListView.Listener> listeners) { setCaption("Set new password for user \"" + userName + "\""); setModal(true);// w ww . ja v a 2 s. c o m FormLayout layout = new FormLayout(); setContent(layout); final PasswordField txtPassword1 = new PasswordField("Enter new password"); final PasswordField txtPassword2 = new PasswordField("Repeat new password"); txtPassword1.setValidationVisible(true); txtPassword1.setRequired(true); txtPassword2.addValidator(new Validator() { @Override public void validate(Object value) throws Validator.InvalidValueException { String asString = (String) value; if (asString != null && !asString.equals(txtPassword1.getValue())) { throw new InvalidValueException("Passwords are not the same"); } } }); txtPassword2.setRequired(true); txtPassword2.setValidationVisible(true); Button btOk = new Button("Ok"); btOk.setClickShortcut(ShortcutAction.KeyCode.ENTER); btOk.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { txtPassword1.validate(); txtPassword2.validate(); if (txtPassword1.isValid() && txtPassword2.isValid()) { for (UserListView.Listener l : listeners) { l.passwordChanged(userName, txtPassword1.getValue()); } UI.getCurrent().removeWindow(NewPasswordWindow.this); Notification.show("Password for user \"" + userName + "\" was changed"); } else { } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Validation failed", ex.getHtmlMessage(), Type.ERROR_MESSAGE, true); n.show(Page.getCurrent()); } } }); Button btCancel = new Button("Cancel"); btCancel.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent().removeWindow(NewPasswordWindow.this); } }); HorizontalLayout actionLayout = new HorizontalLayout(btOk, btCancel); layout.addComponent(txtPassword1); layout.addComponent(txtPassword2); layout.addComponent(actionLayout); }
From source file:at.peppol.webgui.app.LoginWindow.java
License:Mozilla Public License
private void init() { HorizontalLayout h1 = new HorizontalLayout(); h1.setSizeFull();/*from w w w.ja v a 2 s .com*/ FormLayout fl = new FormLayout(); fl.setSizeUndefined(); usernameField = new TextField("Username:"); usernameField.setImmediate(true); fl.addComponent(usernameField); passwordField = new PasswordField("Password:"); passwordField.setImmediate(true); fl.addComponent(passwordField); Button loginButton = new Button("Login"); loginButton.addStyleName("default"); loginButton.addListener(this); fl.addComponent(loginButton); loginButton.setClickShortcut(KeyCode.ENTER); h1.addComponent(fl); h1.setComponentAlignment(fl, Alignment.MIDDLE_CENTER); addComponent(h1); }
From source file:be.rvponp.build.CommitViewerUI.java
License:Apache License
private HorizontalLayout createFiltersLayout(Table table, VerticalLayout files, VerticalLayout filesLayout) { HorizontalLayout filtersLayout = new HorizontalLayout(); FormLayout formReleaseLayout = new FormLayout(); fromVersion = new ComboBox("From release"); toVersion = new ComboBox("To release"); filtersLayout.addComponent(formReleaseLayout); formReleaseLayout.setDescription("formReleaseLayout"); formReleaseLayout.addComponent(fromVersion); formReleaseLayout.addComponent(toVersion); formReleaseLayout.setSizeUndefined(); // FormLayout jiraTreeLayout = new FormLayout(); final Tree tree = createTreeComponent(); // jiraTreeLayout.addComponent(tree); filtersLayout.addComponent(tree);/* ww w . j a va 2s. c o m*/ CheckBox jiraParsing = new CheckBox("Jira Parsing"); jiraParsing.setValue(true); // filtersLayout.addComponent(jiraParsing); FormLayout buttonsLayout = new FormLayout(); CompareButton compareButton = new CompareButton(fromVersion, toVersion, table, files, jiraParsing, tree, filesLayout); RefreshButton refreshButton = new RefreshButton(this, fromVersion, toVersion); // refreshButton.buttonClick(null); // compareButton.buttonClick(null); buttonsLayout.addComponent(refreshButton); buttonsLayout.addComponent(compareButton); buttonsLayout.setSizeUndefined(); filtersLayout.addComponent(buttonsLayout); filtersLayout.setSizeUndefined(); return filtersLayout; }
From source file:by.bigvova.LoginUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle("Vaadin Shared Security Demo Login"); FormLayout loginForm = new FormLayout(); loginForm.setSizeUndefined();//from www. j a v a 2s . com userName = new TextField("Username"); passwordField = new PasswordField("Password"); rememberMe = new CheckBox("Remember me"); login = new Button("Login"); Label label = new Label("Name: User / Password: password"); loginForm.addComponent(userName); loginForm.addComponent(passwordField); loginForm.addComponent(rememberMe); loginForm.addComponent(login); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setDisableOnClick(true); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { login(); } }); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSpacing(true); loginLayout.setSizeUndefined(); if (request.getParameter("logout") != null) { loggedOutLabel = new Label("You have been logged out!"); loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS); loggedOutLabel.setSizeUndefined(); loginLayout.addComponent(loggedOutLabel); loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER); } loginLayout.addComponent(loginFailedLabel = new Label()); loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER); loginFailedLabel.setSizeUndefined(); loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE); loginFailedLabel.setVisible(false); loginLayout.addComponent(label); loginLayout.addComponent(loginForm); loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER); VerticalLayout rootLayout = new VerticalLayout(loginLayout); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER); setContent(rootLayout); setSizeFull(); }
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 ww w . j a v a 2 s . c o m @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();/* ww w.j a v a2 s. 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.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 va 2 s. 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);/*w ww . j ava 2 s . c o 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.coatl.pruebas.datastore.DataStoreUI.java
@Override protected void init(VaadinRequest vaadinRequest) { this.principal = new VerticalLayout(); {// ww w . j a va2 s. c o 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(); }