package org.ufacekit.ui.gwtext.example.eform.client.expls; import org.ufacekit.model.ModelHelper; import org.ufacekit.ui.UIComposite; import org.ufacekit.ui.controls.UIButton; import org.ufacekit.ui.controls.UIInputField; import org.ufacekit.ui.controls.UILabel; import org.ufacekit.ui.controls.UIFormControl.BindingInfo; import org.ufacekit.ui.controls.events.SelectionEvent; import org.ufacekit.ui.controls.events.SelectionListener; import org.ufacekit.ui.eform.EMFForm; import org.ufacekit.ui.example.emfmodel.ufacekit.Person; import org.ufacekit.ui.example.emfmodel.ufacekit.UfacekitFactory; import org.ufacekit.ui.example.emfmodel.ufacekit.UfacekitPackage; import org.ufacekit.ui.gwtext.GwtExtComposite; import org.ufacekit.ui.gwtext.GwtExtFactory; import org.ufacekit.ui.gwtext.example.eform.client.ShowcasePanel; import org.ufacekit.ui.layouts.GridLayoutData; import com.google.gwt.user.client.Window; import com.gwtext.client.widgets.Panel; public class EFormExample extends ShowcasePanel { @Override public Panel getViewPanel() { if (panel == null) { panel = new Panel(); final Person p = UfacekitFactory.eINSTANCE.createPerson(); p.setName("Tom Schindl"); p.setId(1); p.setLocation("Baumkirchen"); GwtExtFactory fact = new GwtExtFactory(); UIComposite comp = new GwtExtComposite(panel,fact.newFillLayout()); UIComposite subComp = fact.newComposite(comp, null, fact.newGridLayout(2)); UILabel label = fact.newLabel(subComp, new UILabel.LabelUIInfo(new GridLayoutData(GridLayoutData.ALIGN_BEGINNING,GridLayoutData.ALIGN_CENTER))); label.setText("Name"); UIInputField nameField = fact.newInputField(subComp, new UIInputField.InputFieldUIInfo(GridLayoutData.fillHorizontalData(),UIInputField.InputFieldUIInfo.SIMPLE)); label = fact.newLabel(subComp, new UILabel.LabelUIInfo(new GridLayoutData(GridLayoutData.ALIGN_BEGINNING,GridLayoutData.ALIGN_CENTER))); label.setText("Birthday"); UIInputField locationField = fact.newInputField(subComp, new UIInputField.InputFieldUIInfo(GridLayoutData.fillHorizontalData(),UIInputField.InputFieldUIInfo.SIMPLE)); UIComposite buttonComp = fact.newComposite(subComp, GridLayoutData.fillHorizontalData(2,1), fact.newGridLayout(2)); UIButton button = fact.newButton(buttonComp, new UIButton.ButtonUIInfo(null) ); button.setText("Show"); button.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent event) { Window.alert("Person: " + p); } }); fact.newButton(buttonComp, new UIButton.ButtonUIInfo(null)).setText("Reset"); final EMFForm form = new EMFForm(); BindingInfo bindingInfo = UIInputField.InputFieldBindingInfo.newTextFieldInfo(form.detailValue(UfacekitPackage.Literals.PERSON__NAME, String.class)); form.add(nameField, bindingInfo); bindingInfo = UIInputField.InputFieldBindingInfo.newTextFieldInfo(form.detailValue(UfacekitPackage.Literals.PERSON__LOCATION, String.class)); form.add(locationField, bindingInfo); form.bind(ModelHelper.createWritableValue(p)); } return panel; } }