protected void bindGUI(DataBindingContext dbc) { // Since we're using a JFace Viewer, we do first wrap our Table... TableViewer peopleViewer = new TableViewer(duckFamily); peopleViewer.addFilter( new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { return element != UNKNOWN; } }); ViewerSupport.bind( peopleViewer, viewModel.getPeople(), BeanProperties.values( Person.class, new String[] { "name", "mother.name", "father.name", "mother.mother.name", "mother.father.name", "father.mother.name", "father.father.name" })); IObservableValue masterSelection = ViewerProperties.singleSelection().observe(peopleViewer); dbc.bindValue( WidgetProperties.text(SWT.Modify).observe(nameText), BeanProperties.value(Person.class, "name").observeDetail(masterSelection)); ComboViewer mothercomboViewer = new ComboViewer(motherCombo); ViewerSupport.bind( mothercomboViewer, viewModel.getPeople(), BeanProperties.value(Person.class, "name")); dbc.bindValue( ViewerProperties.singleSelection().observe(mothercomboViewer), BeanProperties.value(Person.class, "mother").observeDetail(masterSelection)); ComboViewer fatherComboViewer = new ComboViewer(fatherCombo); ViewerSupport.bind( fatherComboViewer, viewModel.getPeople(), BeanProperties.value(Person.class, "name")); dbc.bindValue( ViewerProperties.singleSelection().observe(fatherComboViewer), BeanProperties.value(Person.class, "father").observeDetail(masterSelection)); }
protected void bindGUI(DataBindingContext bindingContext) { // Since we're using a JFace Viewer, we do first wrap our Table... TableViewer peopleViewer = new TableViewer(duckFamily); peopleViewer.addFilter( new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { return element != UNKNOWN; } }); // Bind viewers to model ViewerSupport.bind( peopleViewer, viewModel.getPeople(), BeanProperties.values( new String[] {"name", "mother.name", "father.name", "mother.mother.name"})); // Bind viewer selection to detail fields IObservableValue selection = ViewersObservables.observeSingleSelection(peopleViewer); bindingContext.bindValue( WidgetProperties.text().observe(nameText), BeanProperties.value((Class) selection.getValueType(), "name", String.class) .observeDetail(selection)); ComboViewer mothercomboViewer = new ComboViewer(motherCombo); ViewerSupport.bind(mothercomboViewer, viewModel.getPeople(), BeanProperties.value("name")); bindingContext.bindValue( ViewersObservables.observeSingleSelection(mothercomboViewer), BeanProperties.value((Class) selection.getValueType(), "mother", Person.class) .observeDetail(selection)); ComboViewer fatherComboViewer = new ComboViewer(fatherCombo); ViewerSupport.bind(fatherComboViewer, viewModel.getPeople(), BeanProperties.value("name")); bindingContext.bindValue( ViewersObservables.observeSingleSelection(fatherComboViewer), BeanProperties.value((Class) selection.getValueType(), "father", Person.class) .observeDetail(selection)); }