|
|
|
Re: How to call data binding from a toolbar handler [message #869031 is a reply to message #868456] |
Wed, 02 May 2012 21:49 |
|
Hi Lanz,
making the databinding in the handler is somewhat strange: the detail view should be aware of selection change (whoever is firing it) and provide for its own databinding.
I suggest the following pattern.
1) in the view that contains the table in which the selection changes do this when you create the tableviewer
getViewSite().setSelectionProvider(viewer);
(this will fire the selection change to whoever will register for this event)
2) in the detail view, when creating the widgets do this:
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getSelectionService()
.addSelectionListener(new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part,
ISelection selection) {
//Selection is changed => call the databinding
}
});
3) since the databindings on a new selection should be made after having removed the databindings on the old selection, it is advisable using a WritableValue attribute, which takes care of this automatically. Just do this:
define, in the detail view, a WritableValue
private WritableValue value = new WritableValue();
the use it to bind to the widgets (an example of this can be found among our tutorials (search "RCP Vision WindowBuilder: advanced databinding with CDO" on Google), just see the part after the definition of the WritableValue)
Hope this help
Let me know
Vincenzo Caselli
RCP Vision
|
|
|
|
Powered by
FUDForum. Page generated in 0.03675 seconds