[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Observing EList size

Pierre Francis Roy wrote:
Required in my situation
IObservableMap[] map = new IObservableMap[3];
..
IEMFValueProperty prop = EMFProperties.value(DairyStudioQualityPackage.Literals.SAMPLE_SET__SAMPLES);


??? map[2] = new NotifyingListSizeProperty().observe(prop); ???

You can make a nested property as follows:

IEMFValueProperty eListSizeProp = EMFProperties
    .value(DairyStudioQualityPackage.Literals.SAMPLE_SET__SAMPLES)
    .value(new NotifyingListSizeProperty());

Assuming you are binding this property to a JFace viewer, your code would be something like:

IObservableSet knownElements =
    observableListContentProvider.getKnownElements();
map[2] = eListSizeProperty.observeDetail(knownElements);

I've also been thinking that we should provide a property reducer method for collection properties:

interface IListProperty {
+ public IValueProperty reduce(IValueProperty)
}

interface ISetProperty {
+ public IValueProperty reduce(IValueProperty)
}

interface IMapProperty {
+ public IValueProperty reduce(IValueProperty)
}

This way we could just provide a generic property Properties.size(), thus:

IValueProperty listSizeProp = EMFProperties
    .list(DairyStudioQualityPackage.Literals.SAMPLE_SET__SAMPLES)
    .reduce(Properties.size());

We could also include several generic reducer properties like average, median, sum, min, max, etc. What do you think?

Matthew