List of usage examples for com.vaadin.ui FormLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:pl.exsio.frameset.vaadin.ui.support.component.data.form.TabbedForm.java
License:Open Source License
private void initTabs() { int tabIndex = 0; for (String tabName : this.config.keySet()) { VerticalLayout outerLayout = new VerticalLayout() { {//from ww w .ja va 2 s. c o m FormLayout tabLayout = new FormLayout(); tabLayout.setMargin(true); tabLayout.setSizeFull(); addComponent(tabLayout); } }; outerLayout.setMargin(true); outerLayout.setSizeFull(); Tab tab = this.tabs.addTab(outerLayout, tabName); tab.setCaption(t(tabName)); this.tabsMap.put(tabName, tabIndex); tabIndex++; for (String property : this.config.get(tabName)) { this.propertiesMap.put(property, tabName); } } }
From source file:tad.grupo7.ccamistadeslargas.AmigosLayout.java
/** * Muestra el formulario para aadir una nueva amistad. *//*from w ww .j a v a 2 s.c om*/ private void mostrarFormularioAddAmistad() { TextField nombre = new TextField("Nombre"); nombre.setRequired(true); final Button add = new Button("Crear Participante"); add.addStyleName(ValoTheme.BUTTON_PRIMARY); FormLayout form = new FormLayout(nombre, add); add.addClickListener(clickEvent -> { try { nombre.validate(); if (ParticipanteDAO.read(nombre.getValue(), usuario.getId()) == null) { ParticipanteDAO.create(nombre.getValue(), usuario.getId()); UsuarioDAO.addAmigo(nombre.getValue(), usuario.getId()); mostrarAmistades(); } else { Notification n = new Notification("Ya existe un amigo con el mismo nombre", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Error con los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } }); form.setMargin(true); setSecondComponent(form); }
From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java
/** * Se muestra el formulario de aadir un nuevo evento. *//*from www. ja v a2s. co m*/ private void mostrarFormularioAddEvento() { //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Aadir Evento"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO TextField nombre = new TextField("Nombre"); nombre.setRequired(true); ComboBox divisa = new ComboBox("Divisa"); divisa.setRequired(true); divisa.addItem(""); divisa.addItem("$"); final Button add = new Button("Crear evento"); add.addStyleName(ValoTheme.BUTTON_PRIMARY); add.setClickShortcut(ShortcutAction.KeyCode.ENTER); FormLayout form = new FormLayout(nombre, divisa, add); //BOTN PARA AADIR EVENTO add.addClickListener(clickEvent -> { try { nombre.validate(); divisa.validate(); if (EventoDAO.readDBObject(nombre.getValue(), usuario.getId()) == null) { EventoDAO.create(nombre.getValue(), divisa.getValue().toString(), usuario); mostrarEventos(); } else { Notification n = new Notification("Ya existe un evento con ese nombre", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Error con los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } }); //AADIMOS COMPONENTES form.setMargin(true); setSecondComponent(form); }
From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java
/** * Se muestra el formulario para aadir un participante al evento. * * @param e Recoge el evento./*from ww w . j a v a 2s.c o m*/ */ private void mostrarFormularioAddParticipante(Evento e) { //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Aadir Participante"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO List<Participante> participantes = ParticipanteDAO.readAllFromUsuario(usuario.getId()); ComboBox nuevoParticipante = new ComboBox("Participante Nuevo"); nuevoParticipante.setRequired(true); for (Participante p : participantes) { nuevoParticipante.addItem(p.getNombre()); } final Button add = new Button("Aadir participante"); add.addStyleName(ValoTheme.BUTTON_PRIMARY); add.setClickShortcut(ShortcutAction.KeyCode.ENTER); add.addClickListener(clickEvent -> { try { nuevoParticipante.validate(); Participante p = ParticipanteDAO.read(nuevoParticipante.getValue().toString(), usuario.getId()); if (!EventoDAO.esParticipante(e, p)) { EventoDAO.addParticipante(e.getId(), p.getId()); Notification n = new Notification("Participante aadido", Notification.Type.ASSISTIVE_NOTIFICATION); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); setSecondComponent(null); mostrarEvento(e); } else { Notification n = new Notification("El participante ya se encuentra en el evento", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Error con los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } }); FormLayout form = new FormLayout(l, nuevoParticipante, add); form.setMargin(true); setSecondComponent(form); }
From source file:tad.grupo7.ccamistadeslargas.PerfilLayout.java
private void mostrarPerfil() { //T?TULO/*from w w w.j a v a2s .co m*/ CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Perfil"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO TextField nombre = new TextField("Nombre"); nombre.setValue(usuario.getNombre()); nombre.setRequired(true); TextField password = new TextField("Password"); password.setValue(usuario.getPassword()); password.setRequired(true); TextField email = new TextField("Email"); email.setValue(usuario.getEmail()); email.setEnabled(false); Button actualizar = new Button("Actualizar"); //BOTN ACTUALIZAR actualizar.addClickListener(clickEvent -> { UsuarioDAO.update(usuario.getId(), nombre.getValue(), password.getValue(), usuario.getEmail()); Notification n = new Notification("Usuario actualizado", Notification.Type.ASSISTIVE_NOTIFICATION); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); usuario.setNombre(nombre.getValue()); usuario.setPassword(password.getValue()); }); //AADIR COMPONENTES FormLayout form = new FormLayout(l, nombre, password, email, actualizar); form.setMargin(true); addComponents(form); }
From source file:uk.co.intec.keyDatesApp.components.MainViewFilter.java
License:Apache License
/** * Main method to load the filtering fields and valueChangeListeners for * those fields./*from w w w. j a v a2 s . c o m*/ */ public void loadContent() { final FormLayout cust = new FormLayout(); cust.setMargin(false); setCustField(new ComboBox("Customer:", KeyDateDatabaseUtils.getCustContainer())); getCustField().setInputPrompt("No Customer Selected"); getCustField().setFilteringMode(FilteringMode.STARTSWITH); getCustField().setImmediate(true); getCustField().setInvalidAllowed(false); getCustField().setNullSelectionAllowed(true); getCustField().setPageLength(5); getCustField().setWidth("95%"); getCustField().setResponsive(true); getCustField().addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.data.Property.ValueChangeListener#valueChange(com. * vaadin.data.Property.ValueChangeEvent) */ @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper(); getParentView().loadRowData(viewWrapper.getEntriesAsMap((String) event.getProperty().getValue(), viewWrapper.getStartDate(), viewWrapper.isSingleCat(), viewWrapper.getCount())); getParentView().getPager().loadPagerPagesButtons(); } }); cust.addComponent(getCustField()); final FormLayout date = new FormLayout(); date.setMargin(false); setDateField(new PopupDateField("Start Date:")); getDateField().setValue(new Date()); getDateField().setResolution(Resolution.DAY); getDateField().setLocale(Locale.getDefault()); getDateField().setResponsive(true); getDateField().setTextFieldEnabled(false); getDateField().setWidth("95%"); getDateField().setRequired(true); getDateField().setRequiredError("A date is required!"); getDateField().addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.data.Property.ValueChangeListener#valueChange(com. * vaadin.data.Property.ValueChangeEvent) */ @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper(); getParentView().loadRowData(viewWrapper.getEntriesAsMap(viewWrapper.getCustomerName(), (Date) event.getProperty().getValue(), viewWrapper.isSingleCat(), viewWrapper.getCount())); getParentView().getPager().loadPagerPagesButtons(); } }); date.addComponent(getDateField()); final FormLayout singleCatLayout = new FormLayout(); singleCatLayout.setMargin(false); singleCatLayout.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT); setSingleCatButton(new CheckBox()); getSingleCatButton().setStyleName(ValoTheme.CHECKBOX_SMALL); getSingleCatButton().setResponsive(true); getSingleCatButton().setCaption("Restrict to Date"); getSingleCatButton().setWidth("95%"); getSingleCatButton().addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.data.Property.ValueChangeListener#valueChange(com. * vaadin.data.Property.ValueChangeEvent) */ @Override public void valueChange(ValueChangeEvent event) { final KeyDateViewWrapper viewWrapper = getParentView().getViewWrapper(); final Boolean val = (Boolean) event.getProperty().getValue(); getParentView().loadRowData(viewWrapper.getEntriesAsMap(viewWrapper.getCustomerName(), viewWrapper.getStartDate(), val.booleanValue(), viewWrapper.getCount())); getParentView().getPager().loadPagerPagesButtons(); } }); singleCatLayout.addComponent(getSingleCatButton()); addComponents(cust, date, singleCatLayout); setExpandRatio(cust, 2); setExpandRatio(date, 1); setExpandRatio(singleCatLayout, 1); setComponentAlignment(singleCatLayout, Alignment.MIDDLE_RIGHT); }