List of usage examples for com.vaadin.ui FormLayout iterator
@Override
public Iterator<Component> iterator()
From source file:fr.amapj.view.engine.tools.InLineFormHelper.java
License:Open Source License
/** * Permet de positionner une form en mode Edition, avec un bouton cancel et * save/*from www .j a va 2s . co m*/ * * @param footer * @param canceListener * @param saveListener * @param form */ private void formInCancelSaveMode(FormLayout form) { // form.removeStyleName("light"); // Iterator<Component> i = form.iterator(); while (i.hasNext()) { Component c = i.next(); if (c instanceof com.vaadin.ui.AbstractField) { AbstractField field = (AbstractField) c; field.setReadOnly(false); } } // footer.removeAllComponents(); footer.setMargin(false); footer.setSpacing(true); Label l = new Label(); footer.addComponent(l); footer.setExpandRatio(l, 1.0f); Button cancel = new Button("Annuler"); cancel.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { refreshListener.onPopupClose(); formInLectureMode(form); } }); footer.addComponent(cancel); Button save = new Button("Sauvegarder"); save.addStyleName("primary"); save.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { List<String> msg = validatorManager.validate(); if (msg.size() > 0) { msg.add(0, "Merci de corriger les points suivants :"); MessagePopup.open(new MessagePopup("Notification", msg)); return; } saveListener.buttonClick(null); refreshListener.onPopupClose(); formInLectureMode(form); } }); footer.addComponent(save); footer.setComponentAlignment(save, Alignment.MIDDLE_LEFT); }
From source file:fr.amapj.view.engine.tools.InLineFormHelper.java
License:Open Source License
/** * Permet de positionner une form en mode Lecture, avec un bouton Editer * //from w ww . j a va2s . com * @param footer * @param canceListener * @param saveListener * @param form */ private void formInLectureMode(FormLayout form) { // form.addStyleName("light"); // Iterator<Component> i = form.iterator(); while (i.hasNext()) { Component c = i.next(); if (c instanceof com.vaadin.ui.AbstractField) { AbstractField field = (AbstractField) c; field.setReadOnly(true); } } // footer.removeAllComponents(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); Label l = new Label(); footer.addComponent(l); footer.setExpandRatio(l, 1.0f); Button edit = new Button(libModifier, new ClickListener() { @Override public void buttonClick(ClickEvent event) { formInCancelSaveMode(form); } }); footer.addComponent(edit); }