| [DataBinding] Binding elements in different views [message #645091] |
Wed, 15 December 2010 09:58  |
 |
Gabriele Messages: 19 Registered: November 2010 |
Junior Member |
|
|
Hi all!!
I'm developing a RAP application in which I need a master-detail scenario between a table or list and a form (of Control elements).
I have yet used the examples in the snippets page (http://wiki.eclipse.org/JFace_Data_Binding/Snippets) or the RAP project from Eclipse CVS repository org.eclipse.rap.demo.databinding.
I can create a master-detail which reside in a single view:
// Creating table viewer and relativa columns
viewer = new TableViewer(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
createColumns(viewer);
// Setting content provider
ObservableListContentProvider viewerContent = new ObservableListContentProvider();
viewer.setContentProvider(viewerContent);
// Setting label provider
String[] attrPerson = new String[] { "name", "address", "city" };
IObservableMap[] attributeMaps = BeansObservables.observeMaps( viewerContent.getKnownElements(), Person.class, attrPerson);
omlProvider = new ObservableMapLabelProvider(attributeMaps);
viewer.setLabelProvider(omlProvider);
// In "list" I have my list of data to populate the table
input = new WritableList(list, Person.class);
viewer.setInput(input);
// Let's binding
// Making the table observable
IObservableValue selectedPerson = ViewersObservables.observeSingleSelection(viewer);
Realm realm = SWTObservables.getRealm(parent.getDisplay());
DataBindingContext bindingContext = new DataBindingContext(realm);
// Binding the form elements with the selected element of the table
// 1st element; other one are set in a similar way
IObservableValue modelObservableValue = BeansObservables.observeDetailValue(selectedPerson, "name", String.class);
ISWTObservableValue targetObservableValue = SWTObservables.observeText(name, SWT.Modify);
Binding binding = bindingContext.bindValue(targetObservableValue, modelObservableValue);
This code works because I have all the needed elements in the same view. If, for example, I have the table in a view and the form in another one, how can I make the data of the selection from the table available to the form view?
My problem is in the step of the creation of the "selectedPerson" object on which the UI elements of the form are based. The method ViewersObservables#observeSingleSelection works woth teh viewer object which in my case is in a different view.
Thank you in advanced who can help.
Gabriele
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02442 seconds