Because the selected movies have the same director and same writer, those values are displayed in the master-detail fields at the bottom. However, since they have different titles and release dates, those fields use a stand-in "multi value" instead.
Editing the release date field simultaneously changes the release date of all movies in the selection.
Here's the code that was used to hook up the detail fields to the multi-selection of the viewer:
IObservableList selections = ViewerProperties.multipleSelection()See the full code listing for this snippet here.
.observe(viewer);
dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(title),
DuplexingObservableValue.withDefaults(
BeanProperties.value("title").observeDetail(selections),
"", "<Multiple titles>"));
dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(releaseDate),
DuplexingObservableValue.withDefaults(
BeanProperties.value("releaseDate").observeDetail(selections),
"", "<Multiple dates>"));
dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(director),
DuplexingObservableValue.withDefaults(
BeanProperties.value("director").observeDetail(selections),
"", "<Multiple directors>"));
dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(writer),
DuplexingObservableValue.withDefaults(
BeanProperties.value("writer").observeDetail(selections),
"", "<Multiple writers>"));
Disclaimer: The method DuplexingObservableValue.withDefaults() was added after the 3.5M5 milestone, so in order to use it you need to check out the databinding projects from CVS HEAD, or be using a more recent integration build.
8 comments:
Wow, this is quite impressive!
One problem I've had with EMF support for editing merged properties is that it results in multiple commands on the command stack and hence a single edit requires multiple undos. Even EMF's data binding integration for what you show here will have this same type of problem (I think). Should I care or is that just a fundamental limitation?
I'm not too familiar with EMF, but you could extend DuplexingObservableValue and wrap the set operation in a transaction:
class EMFDuplexingObservableValue extends DuplexingObservableValue {
protected void doSetValue(Object value) {
startTransaction();
super.doSetValue(value);
commitTransaction();
}
}
Where startTransaction and commitTransaction are replaced with whatever the appropriate code is for EMF.
This is very helpful. Will this be available in Eclipse 3.5M6?
vogella: yes this will be in M6
Great post
Great, just what I was looking for.
Unfortunately I'm using more specialized widgets than Text for input, i.e. Spinner, DateTime, (C)Combo. Combos work fine but AFAIK Spinner & DateTime don't allow texts like "<multiple Values>" (Spinner) or "dd.mm.yyyy" (DateTime) to represent the situation of multiple selected datasets. All workarounds I can think of are rather clumsy IMO.
I'm not yet a very experienced user in the RCP-SWT-JFace... multiverse, do you have any suggestions how to overcome this problem ?
Hi Anonymous,
I have no good idea either. If your specialized widgets are custom widgets (e.g. from the Nebula project), you could try to extend the custom widget itself.
Post a Comment