Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 136365 Details for
Bug 262160
Implement the new Property-based Databinding-API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Addressing some of Matt's comments
patch.txt (text/plain), 171.09 KB, created by
Thomas Schindl
on 2009-05-19 15:03:08 EDT
(
hide
)
Description:
Addressing some of Matt's comments
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2009-05-19 15:03:08 EDT
Size:
171.09 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.databinding >Index: src/org/eclipse/emf/databinding/EMFUpdateListStrategy.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/src/org/eclipse/emf/databinding/EMFUpdateListStrategy.java,v >retrieving revision 1.1 >diff -u -r1.1 EMFUpdateListStrategy.java >--- src/org/eclipse/emf/databinding/EMFUpdateListStrategy.java 16 Nov 2007 21:25:21 -0000 1.1 >+++ src/org/eclipse/emf/databinding/EMFUpdateListStrategy.java 19 May 2009 19:03:14 -0000 >@@ -23,27 +23,49 @@ > import org.eclipse.emf.ecore.EDataType; > import org.eclipse.emf.ecore.EFactory; > >+ > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> > */ > public class EMFUpdateListStrategy extends UpdateListStrategy > { >+ /** >+ * A list update strategy with default update policy >+ * {@link UpdateListStrategy#POLICY_UPDATE} and default converters and >+ * validators >+ */ > public EMFUpdateListStrategy() > { > this(true, POLICY_UPDATE); > } > >+ /** >+ * A list update strategy with a specific update policy but with default >+ * converters and validators >+ * >+ * @param updatePolicy >+ * the policy >+ */ > public EMFUpdateListStrategy(int updatePolicy) > { > this(true, updatePolicy); > } > >+ /** >+ * A list update strategy with a specific update policy and with the >+ * possibility to turn of default converters and validators >+ * >+ * @param provideDefaults >+ * <code>false</code> to turn of default converters and >+ * validators >+ * @param updatePolicy >+ * the policy >+ */ > public EMFUpdateListStrategy(boolean provideDefaults, int updatePolicy) > { > super(provideDefaults, updatePolicy); > } >- >+ > @Override > protected IConverter createConverter(Object fromType, Object toType) > { >@@ -54,8 +76,7 @@ > final EAttribute eAttribute = (EAttribute)toType; > final EDataType eDataType = eAttribute.getEAttributeType(); > final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance(); >- return >- new Converter(fromType, toType) >+ return new Converter(fromType, toType) > { > public Object convert(Object fromObject) > { >@@ -71,8 +92,7 @@ > final EAttribute eAttribute = (EAttribute)fromType; > final EDataType eDataType = eAttribute.getEAttributeType(); > final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance(); >- return >- new Converter(fromType, toType) >+ return new Converter(fromType, toType) > { > public Object convert(Object fromObject) > { >Index: src/org/eclipse/emf/databinding/DataBindingPlugin.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/src/org/eclipse/emf/databinding/DataBindingPlugin.java,v >retrieving revision 1.1 >diff -u -r1.1 DataBindingPlugin.java >--- src/org/eclipse/emf/databinding/DataBindingPlugin.java 16 Nov 2007 21:25:21 -0000 1.1 >+++ src/org/eclipse/emf/databinding/DataBindingPlugin.java 19 May 2009 19:03:14 -0000 >@@ -20,7 +20,9 @@ > > import org.eclipse.emf.common.util.ResourceLocator; > >+ > /** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> > * This is the central singleton for the Data Binding plugin. > */ > public final class DataBindingPlugin extends EMFPlugin >@@ -40,7 +42,7 @@ > */ > public DataBindingPlugin() > { >- super(new ResourceLocator [] {}); >+ super(new ResourceLocator []{}); > } > > /** >Index: src/org/eclipse/emf/databinding/EObjectObservableValue.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/src/org/eclipse/emf/databinding/EObjectObservableValue.java,v >retrieving revision 1.2 >diff -u -r1.2 EObjectObservableValue.java >--- src/org/eclipse/emf/databinding/EObjectObservableValue.java 26 Jan 2008 21:01:07 -0000 1.2 >+++ src/org/eclipse/emf/databinding/EObjectObservableValue.java 19 May 2009 19:03:14 -0000 >@@ -26,22 +26,51 @@ > import org.eclipse.emf.common.notify.impl.AdapterImpl; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.util.ExtendedMetaData; >+ > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * @deprecated do not use this value it will be removed in 2.6 > */ > public class EObjectObservableValue extends AbstractObservableValue implements IObserving > { >+ /** >+ * The object instance >+ */ > protected EObject eObject; >+ /** >+ * The feature >+ */ > protected EStructuralFeature eStructuralFeature; >+ /** >+ * The listener >+ */ > protected Adapter listener; > >+ /** >+ * Observe a feature of the instance using the default realm >+ * >+ * @param eObject >+ * the object >+ * @param eStructuralFeature >+ * the feature >+ */ > public EObjectObservableValue(EObject eObject, EStructuralFeature eStructuralFeature) > { > this(Realm.getDefault(), eObject, eStructuralFeature); > } > >+ /** >+ * Observe a feature of the instance using the realm >+ * >+ * @param realm >+ * >+ * @param eObject >+ * the object >+ * @param eStructuralFeature >+ * the feature >+ */ > public EObjectObservableValue(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature) > { > super(realm); >@@ -70,8 +99,7 @@ > @Override > protected void firstListenerAdded() > { >- listener = >- new AdapterImpl() >+ listener = new AdapterImpl() > { > @Override > public void notifyChanged(Notification notification) >@@ -79,14 +107,13 @@ > if (eStructuralFeature == notification.getFeature() && !notification.isTouch()) > { > final ValueDiff diff = Diffs.createValueDiff(notification.getOldValue(), notification.getNewValue()); >- getRealm().exec >- (new Runnable() >- { >- public void run() >- { >- fireValueChange(diff); >- } >- }); >+ getRealm().exec(new Runnable() >+ { >+ public void run() >+ { >+ fireValueChange(diff); >+ } >+ }); > } > } > }; >@@ -103,7 +130,7 @@ > @Override > protected Object doGetValue() > { >- return eObject.eGet(eStructuralFeature); >+ return ExtendedMetaData.INSTANCE.getAffiliation(eObject.eClass(), eStructuralFeature) == null ? null : eObject.eGet(eStructuralFeature); > } > > @Override >Index: src/org/eclipse/emf/databinding/EMFDataBindingContext.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/src/org/eclipse/emf/databinding/EMFDataBindingContext.java,v >retrieving revision 1.1 >diff -u -r1.1 EMFDataBindingContext.java >--- src/org/eclipse/emf/databinding/EMFDataBindingContext.java 16 Nov 2007 21:25:21 -0000 1.1 >+++ src/org/eclipse/emf/databinding/EMFDataBindingContext.java 19 May 2009 19:03:14 -0000 >@@ -21,17 +21,28 @@ > import org.eclipse.core.databinding.observable.Realm; > import org.eclipse.core.databinding.observable.value.IObservableValue; > >+ > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> > */ > public class EMFDataBindingContext extends DataBindingContext > { >+ /** >+ * Create a new databinding context which uses the default realm for >+ * validation >+ */ > public EMFDataBindingContext() > { > this(Realm.getDefault()); > } > >+ /** >+ * Create a databinding context which uses an explicit realm for >+ * validation >+ * >+ * @param validationRealm >+ * the realm to use >+ */ > public EMFDataBindingContext(Realm validationRealm) > { > super(validationRealm); >@@ -42,7 +53,7 @@ > { > return new EMFUpdateValueStrategy(); > } >- >+ > @Override > protected UpdateValueStrategy createTargetToModelUpdateValueStrategy(IObservableValue fromValue, IObservableValue toValue) > { >Index: src/org/eclipse/emf/databinding/EMFObservables.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/src/org/eclipse/emf/databinding/EMFObservables.java,v >retrieving revision 1.3 >diff -u -r1.3 EMFObservables.java >--- src/org/eclipse/emf/databinding/EMFObservables.java 22 Apr 2008 13:36:00 -0000 1.3 >+++ src/org/eclipse/emf/databinding/EMFObservables.java 19 May 2009 19:03:14 -0000 >@@ -17,7 +17,6 @@ > */ > package org.eclipse.emf.databinding; > >- > import org.eclipse.core.databinding.observable.IObservable; > import org.eclipse.core.databinding.observable.Realm; > import org.eclipse.core.databinding.observable.list.IObservableList; >@@ -26,12 +25,15 @@ > import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables; > import org.eclipse.core.databinding.observable.set.IObservableSet; > import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.emf.common.notify.NotifyingList; >+import org.eclipse.emf.databinding.internal.EWritableList; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.resource.Resource; >+ > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> > */ > public class EMFObservables > { >@@ -40,6 +42,7 @@ > * @param eObject the object to observe. > * @param eStructuralFeature the feature of the object to observe. > * @return an observable value for the given feature of the object. >+ * @deprecated you should use {@link EMFProperties#value(FeaturePath)} and {@link IEMFValueProperty#observe(Object)} > */ > public static IObservableValue observeValue(EObject eObject, EStructuralFeature eStructuralFeature) > { >@@ -52,6 +55,7 @@ > * @param eObject the object to observe. > * @param eStructuralFeature the feature of the object to observe. > * @return an observable value for the given feature of the object. >+ * @deprecated you should use {@link EMFProperties#value(EStructuralFeature)} and {@link IEMFValueProperty#observe(Realm, Object)} > */ > public static IObservableValue observeValue(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature) > { >@@ -63,6 +67,7 @@ > * @param eObject the object to observe. > * @param eStructuralFeature the feature of the object to observe. > * @return an observable list for the given multi-valued feature of the object. >+ * @deprecated you should use {@link EMFProperties#list(EStructuralFeature)} and {@link IEMFListProperty#observe(Object)} > */ > public static IObservableList observeList(EObject eObject, EStructuralFeature eStructuralFeature) > { >@@ -75,6 +80,7 @@ > * @param eObject the object to observe. > * @param eStructuralFeature the feature of the object to observe. > * @return an observable list for the given multi-valued feature of the object. >+ * @deprecated you should use {@link EMFProperties#list(EStructuralFeature)} and {@link IEMFListProperty#observe(Realm,Object)} > */ > public static IObservableList observeList(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature) > { >@@ -87,6 +93,7 @@ > * @param objects the objects to track. > * @param eStructuralFeature the feature for which to track the value. > * @return an observable map tracking the current value of the given feature for each object in the given set. >+ * @deprecated you should use {@link EMFProperties#value(EStructuralFeature)} and {@link IEMFValueProperty#observeDetail(IObservableSet)} > */ > public static IObservableMap observeMap(IObservableSet objects, EStructuralFeature eStructuralFeature) > { >@@ -99,6 +106,7 @@ > * @param objects the objects to track. > * @param eStructuralFeatures the features for which to track the value. > * @return an array of observable maps tracking the current value of the given features for each object in the given set. >+ * @deprecated you should use {@link EMFProperties#values(EStructuralFeature...)} and {@link IEMFValueProperty#observeDetail(IObservableSet)} > */ > public static IObservableMap[] observeMaps(IObservableSet objects, EStructuralFeature[] eStructuralFeatures) > { >@@ -117,6 +125,7 @@ > * @param eStructuralFeature the feature for which to track the value. > * @return an observable value that tracks the current value of the named property for the current value of the master observable value > * @see MasterDetailObservables#detailValue(IObservableValue, IObservableFactory, Object) >+ * @deprecated you should use {@link EMFProperties#value(EStructuralFeature)} and {@link IEMFValueProperty#observeDetail(IObservableValue)} > */ > public static IObservableValue observeDetailValue(Realm realm, IObservableValue value, EStructuralFeature eStructuralFeature) > { >@@ -132,8 +141,7 @@ > */ > public static IObservableFactory valueFactory(final Realm realm, final EStructuralFeature eStructuralFeature) > { >- return >- new IObservableFactory() >+ return new IObservableFactory() > { > public IObservable createObservable(Object target) > { >@@ -149,6 +157,7 @@ > * @param eStructuralFeature the feature for which to track the value. > * @return an observable value that tracks the current value of the named property for the current value of the master observable value > * @see MasterDetailObservables#detailList(IObservableValue, IObservableFactory, Object) >+ * @deprecated you should use {@link EMFProperties#value(EStructuralFeature)} and {@link IEMFValueProperty#observeDetail(IObservableList)} > */ > public static IObservableList observeDetailList(Realm realm, IObservableValue value, EStructuralFeature eStructuralFeature) > { >@@ -164,8 +173,7 @@ > */ > public static IObservableFactory listFactory(final Realm realm, final EStructuralFeature eStructuralFeature) > { >- return >- new IObservableFactory() >+ return new IObservableFactory() > { > public IObservable createObservable(Object target) > { >@@ -173,7 +181,7 @@ > } > }; > } >- >+ > /** > * Returns a factory for creating observable maps > * tracking the value of the given feature of a particular {@link EObject object}. >@@ -182,13 +190,26 @@ > */ > public static IObservableFactory mapFactory(final EStructuralFeature eStructuralFeature) > { >- return >- new IObservableFactory() >+ return new IObservableFactory() > { > public IObservable createObservable(Object target) > { > return observeMap((IObservableSet)target, eStructuralFeature); > } > }; >- } >+ } >+ >+ /** >+ * Returns an observable for the resource contents ( >+ * {@link Resource#getContents()}) >+ * >+ * @param resource >+ * the resources the content should be observed >+ * @return an observable list >+ */ >+ public static IObservableList observeResourceContents(Resource resource) >+ { >+ return new EWritableList<EObject>((NotifyingList<EObject>)resource.getContents()); >+ } >+ > } >Index: src/org/eclipse/emf/databinding/EObjectObservableList.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/src/org/eclipse/emf/databinding/EObjectObservableList.java,v >retrieving revision 1.4 >diff -u -r1.4 EObjectObservableList.java >--- src/org/eclipse/emf/databinding/EObjectObservableList.java 21 Feb 2008 15:26:16 -0000 1.4 >+++ src/org/eclipse/emf/databinding/EObjectObservableList.java 19 May 2009 19:03:14 -0000 >@@ -32,24 +32,53 @@ > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EStructuralFeature; > >+ > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * @deprecated do not use this list it will be removed in 2.6 > */ > public class EObjectObservableList extends ObservableList implements IObserving, InternalRawEList > { >+ /** >+ * The object owning the feature >+ */ > protected EObject eObject; >+ /** >+ * The structural feature >+ */ > protected EStructuralFeature eStructuralFeature; >+ /** >+ * The listener attached >+ */ > protected Adapter listener; > >+ /** >+ * Observe a list feature using a default realm >+ * >+ * @param eObject >+ * the object instance >+ * @param eStructuralFeature >+ * the feature >+ */ > public EObjectObservableList(EObject eObject, EStructuralFeature eStructuralFeature) > { > this(Realm.getDefault(), eObject, eStructuralFeature); > } > >+ /** >+ * Observe a list feature using a custom realm >+ * >+ * @param realm >+ * the realm >+ * >+ * @param eObject >+ * the object instance >+ * @param eStructuralFeature >+ * the feature >+ */ > public EObjectObservableList(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature) > { >- super(realm, (EList<?>)eObject.eGet(eStructuralFeature), eStructuralFeature); >+ super(realm, (EList< ? >)eObject.eGet(eStructuralFeature), eStructuralFeature); > this.eObject = eObject; > this.eStructuralFeature = eStructuralFeature; > } >@@ -57,8 +86,7 @@ > @Override > protected void firstListenerAdded() > { >- listener = >- new AdapterImpl() >+ listener = new AdapterImpl() > { > @Override > public void notifyChanged(Notification notification) >@@ -68,15 +96,13 @@ > final ListDiff diff; > switch (notification.getEventType()) > { >- case Notification.ADD: >- { >+ case Notification.ADD: { > diff = Diffs.createListDiff(Diffs.createListDiffEntry(notification.getPosition(), true, notification.getNewValue())); > break; > } >- case Notification.ADD_MANY: >- { >- Collection<?> newValues = (Collection<?>)notification.getNewValue(); >- ListDiffEntry [] listDiffEntries = new ListDiffEntry [newValues.size()]; >+ case Notification.ADD_MANY: { >+ Collection< ? > newValues = (Collection< ? >)notification.getNewValue(); >+ ListDiffEntry[] listDiffEntries = new ListDiffEntry [newValues.size()]; > int position = notification.getPosition(); > int index = 0; > for (Object newValue : newValues) >@@ -86,15 +112,13 @@ > diff = Diffs.createListDiff(listDiffEntries); > break; > } >- case Notification.REMOVE: >- { >+ case Notification.REMOVE: { > diff = Diffs.createListDiff(Diffs.createListDiffEntry(notification.getPosition(), false, notification.getOldValue())); > break; > } >- case Notification.REMOVE_MANY: >- { >- Collection<?> oldValues = (Collection<?>)notification.getOldValue(); >- ListDiffEntry [] listDiffEntries = new ListDiffEntry [oldValues.size()]; >+ case Notification.REMOVE_MANY: { >+ Collection< ? > oldValues = (Collection< ? >)notification.getOldValue(); >+ ListDiffEntry[] listDiffEntries = new ListDiffEntry [oldValues.size()]; > int position = notification.getPosition(); > int index = 0; > for (Object oldValue : oldValues) >@@ -105,36 +129,32 @@ > break; > } > case Notification.SET: >- case Notification.RESOLVE: >- { >- ListDiffEntry [] listDiffEntries = new ListDiffEntry [2]; >+ case Notification.RESOLVE: { >+ ListDiffEntry[] listDiffEntries = new ListDiffEntry [2]; > listDiffEntries[0] = Diffs.createListDiffEntry(notification.getPosition(), false, notification.getOldValue()); > listDiffEntries[1] = Diffs.createListDiffEntry(notification.getPosition(), true, notification.getNewValue()); > diff = Diffs.createListDiff(listDiffEntries); > break; > } >- case Notification.MOVE: >- { >+ case Notification.MOVE: { > Object movedValue = notification.getNewValue(); >- ListDiffEntry [] listDiffEntries = new ListDiffEntry [2]; >+ ListDiffEntry[] listDiffEntries = new ListDiffEntry [2]; > listDiffEntries[0] = Diffs.createListDiffEntry((Integer)notification.getOldValue(), false, movedValue); > listDiffEntries[1] = Diffs.createListDiffEntry(notification.getPosition(), true, movedValue); > diff = Diffs.createListDiff(listDiffEntries); > break; > } >- case Notification.UNSET: >- { >- // This just represents going back to the unset state, but that doesn't affect the contents of the list. >+ case Notification.UNSET: { >+ // This just represents going back to the unset state, >+ // but that doesn't affect the contents of the list. > // > return; > } >- default: >- { >+ default: { > throw new RuntimeException("unhandled case"); > } > } >- getRealm().exec >- (new Runnable() >+ getRealm().exec(new Runnable() > { > public void run() > { >@@ -146,7 +166,7 @@ > }; > eObject.eAdapters().add(listener); > } >- >+ > @Override > protected void lastListenerRemoved() > { >@@ -167,6 +187,9 @@ > super.dispose(); > } > >+ /** >+ * @return the wrapped list >+ */ > @SuppressWarnings("unchecked") > protected final List<Object> wrappedList() > { >@@ -256,7 +279,7 @@ > public Object move(int newPosition, int oldPosition) > { > checkRealm(); >- return ((EList<?>)wrappedList).move(newPosition, oldPosition); >+ return ((EList< ? >)wrappedList).move(newPosition, oldPosition); > } > > public void move(int newPosition, Object object) >@@ -290,5 +313,6 @@ > @SuppressWarnings("unchecked") > interface InternalRawEList extends EList > { >- // This is only at avoid needing an @SuppressWarnings("unchecked") on the EMFObservableList >+ // This is only at avoid needing an @SuppressWarnings("unchecked") on the >+ // EMFObservableList > } >\ No newline at end of file >Index: src/org/eclipse/emf/databinding/EObjectObservableMap.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/src/org/eclipse/emf/databinding/EObjectObservableMap.java,v >retrieving revision 1.4 >diff -u -r1.4 EObjectObservableMap.java >--- src/org/eclipse/emf/databinding/EObjectObservableMap.java 21 Oct 2008 11:03:56 -0000 1.4 >+++ src/org/eclipse/emf/databinding/EObjectObservableMap.java 19 May 2009 19:03:14 -0000 >@@ -27,16 +27,19 @@ > import org.eclipse.emf.ecore.EStructuralFeature; > import org.eclipse.emf.ecore.util.ExtendedMetaData; > >+ > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * @deprecated do not use this map it will be removed in 2.6 > */ > public class EObjectObservableMap extends ComputedObservableMap > { >+ /** >+ * The feature to observe >+ */ > protected EStructuralFeature eStructuralFeature; > >- private Adapter elementListener = >- new AdapterImpl() >+ private Adapter elementListener = new AdapterImpl() > { > @Override > public void notifyChanged(Notification notification) >@@ -44,21 +47,32 @@ > if (eStructuralFeature == notification.getFeature() && !notification.isTouch()) > { > // TODO >- // This assumes we only get a SET notification, which isn't a good assumption. >+ // This assumes we only get a SET notification, which isn't a >+ // good assumption. > // >- final MapDiff diff = Diffs.createMapDiffSingleChange(notification.getNotifier(), notification.getOldValue(), notification.getNewValue()); >- getRealm().exec >- (new Runnable() >- { >- public void run() >- { >- fireMapChange(diff); >- } >- }); >+ final MapDiff diff = Diffs.createMapDiffSingleChange( >+ notification.getNotifier(), >+ notification.getOldValue(), >+ notification.getNewValue()); >+ getRealm().exec(new Runnable() >+ { >+ public void run() >+ { >+ fireMapChange(diff); >+ } >+ }); > } > } > }; > >+ /** >+ * Create a new observable for the set of features >+ * >+ * @param objects >+ * the objects to observe >+ * @param feature >+ * the feature >+ */ > public EObjectObservableMap(IObservableSet objects, EStructuralFeature feature) > { > super(objects); >@@ -81,10 +95,7 @@ > protected Object doGet(Object key) > { > EObject eObject = (EObject)key; >- return >- ExtendedMetaData.INSTANCE.getAffiliation(eObject.eClass(), eStructuralFeature) == null ? >- null : >- eObject.eGet(eStructuralFeature); >+ return ExtendedMetaData.INSTANCE.getAffiliation(eObject.eClass(), eStructuralFeature) == null ? null : eObject.eGet(eStructuralFeature); > } > > @Override >Index: src/org/eclipse/emf/databinding/EMFUpdateValueStrategy.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/src/org/eclipse/emf/databinding/EMFUpdateValueStrategy.java,v >retrieving revision 1.2 >diff -u -r1.2 EMFUpdateValueStrategy.java >--- src/org/eclipse/emf/databinding/EMFUpdateValueStrategy.java 22 Feb 2008 12:10:18 -0000 1.2 >+++ src/org/eclipse/emf/databinding/EMFUpdateValueStrategy.java 19 May 2009 19:03:14 -0000 >@@ -19,6 +19,7 @@ > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.core.databinding.UpdateListStrategy; > import org.eclipse.core.databinding.UpdateValueStrategy; > import org.eclipse.core.databinding.conversion.Converter; > import org.eclipse.core.databinding.conversion.IConverter; >@@ -26,27 +27,49 @@ > import org.eclipse.emf.ecore.EDataType; > import org.eclipse.emf.ecore.EFactory; > >+ > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> > */ > public class EMFUpdateValueStrategy extends UpdateValueStrategy > { >+ /** >+ * A value update strategy with default update policy >+ * {@link UpdateListStrategy#POLICY_UPDATE} and default converters and >+ * validators >+ */ > public EMFUpdateValueStrategy() > { > this(true, POLICY_UPDATE); > } > >+ /** >+ * A value strategy with a specific update policy but with default >+ * converters and validators >+ * >+ * @param updatePolicy >+ * the policy >+ */ > public EMFUpdateValueStrategy(int updatePolicy) > { > this(true, updatePolicy); > } > >+ /** >+ * A value strategy with a specific update policy and with the >+ * possibility to turn of default converters and validators >+ * >+ * @param provideDefaults >+ * <code>false</code> to turn of default converters and >+ * validators >+ * @param updatePolicy >+ * the policy >+ */ > public EMFUpdateValueStrategy(boolean provideDefaults, int updatePolicy) > { > super(provideDefaults, updatePolicy); > } >- >+ > @Override > protected IConverter createConverter(Object fromType, Object toType) > { >@@ -57,8 +80,7 @@ > final EAttribute eAttribute = (EAttribute)toType; > final EDataType eDataType = eAttribute.getEAttributeType(); > final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance(); >- return >- new Converter(fromType, toType) >+ return new Converter(fromType, toType) > { > public Object convert(Object fromObject) > { >@@ -90,15 +112,14 @@ > final EAttribute eAttribute = (EAttribute)fromType; > final EDataType eDataType = eAttribute.getEAttributeType(); > final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance(); >- return >- new Converter(fromType, toType) >+ return new Converter(fromType, toType) > { > public Object convert(Object fromObject) > { > if (eAttribute.isMany()) > { > StringBuilder result = new StringBuilder(); >- for (Object value : (List<?>)fromObject) >+ for (Object value : (List< ? >)fromObject) > { > if (result.length() == 0) > { >@@ -118,4 +139,4 @@ > } > return super.createConverter(fromType, toType); > } >-} >+} >\ No newline at end of file >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/META-INF/MANIFEST.MF,v >retrieving revision 1.5 >diff -u -r1.5 MANIFEST.MF >--- META-INF/MANIFEST.MF 21 Oct 2008 11:03:56 -0000 1.5 >+++ META-INF/MANIFEST.MF 19 May 2009 19:03:14 -0000 >@@ -8,9 +8,11 @@ > Bundle-Vendor: %providerName > Bundle-Localization: plugin > Bundle-RequiredExecutionEnvironment: J2SE-1.5 >-Export-Package: org.eclipse.emf.databinding >+Export-Package: org.eclipse.emf.databinding, >+ org.eclipse.emf.databinding.internal;x-friends:="org.eclipse.emf.databinding.edit" > Require-Bundle: org.eclipse.core.runtime, > org.eclipse.emf.ecore;visibility:=reexport, >- org.eclipse.core.databinding;visibility:=reexport >+ org.eclipse.core.databinding;visibility:=reexport, >+ org.eclipse.core.databinding.property;bundle-version="1.2.0" > Eclipse-LazyStart: true > Bundle-ActivationPolicy: lazy >Index: .settings/org.eclipse.jdt.core.prefs >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/.settings/org.eclipse.jdt.core.prefs,v >retrieving revision 1.1 >diff -u -r1.1 org.eclipse.jdt.core.prefs >--- .settings/org.eclipse.jdt.core.prefs 19 Mar 2009 10:37:20 -0000 1.1 >+++ .settings/org.eclipse.jdt.core.prefs 19 May 2009 19:03:14 -0000 >@@ -1,8 +1,25 @@ >-#Thu Mar 19 06:34:41 EDT 2009 >+#Mon May 04 17:54:25 CEST 2009 > eclipse.preferences.version=1 > org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled > org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 >+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve > org.eclipse.jdt.core.compiler.compliance=1.5 >+org.eclipse.jdt.core.compiler.debug.lineNumber=generate >+org.eclipse.jdt.core.compiler.debug.localVariable=generate >+org.eclipse.jdt.core.compiler.debug.sourceFile=generate >+org.eclipse.jdt.core.compiler.doc.comment.support=enabled > org.eclipse.jdt.core.compiler.problem.assertIdentifier=error > org.eclipse.jdt.core.compiler.problem.enumIdentifier=error >+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning >+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled >+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled >+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled >+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected >+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning >+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled >+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected >+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag >+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning >+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled >+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected > org.eclipse.jdt.core.compiler.source=1.5 >Index: src/org/eclipse/emf/databinding/IEMFMapProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/IEMFMapProperty.java >diff -N src/org/eclipse/emf/databinding/IEMFMapProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/IEMFMapProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 195222) >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding; >+ >+import java.util.Map; >+ >+import org.eclipse.core.databinding.property.map.IMapProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * >+ * An {@link IMapProperty} extension interface with convenience methods for >+ * creating nested {@link EStructuralFeature}s >+ * >+ * @since 2.5 >+ * @noextend This interface is not intended to be extended by clients. >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public interface IEMFMapProperty extends IEMFProperty, IMapProperty >+{ >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * nested value feature. >+ * >+ * @param featurePath >+ * the nested value feature to observe >+ * @return a master-detail combination of this property and the specified >+ * nested value feature. >+ * @see #values(IEMFValueProperty) >+ */ >+ public IEMFMapProperty values(FeaturePath featurePath); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value feature. >+ * >+ * @param feature >+ * the value feature to observe >+ * @return a master-detail combination of this property and the specified >+ * nested value feature. >+ * @see #values(IEMFValueProperty) >+ */ >+ public IEMFMapProperty values(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value property. The returned property will observe the specified value >+ * property for all {@link Map#values() values} observed by this map >+ * property, mapping from this map property's {@link Map#keySet() key set} >+ * to the specified value property's value for each element in the master >+ * property's {@link Map#values() values} collection. >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * value property. >+ */ >+ public IEMFMapProperty values(IEMFValueProperty property); >+} Index: src/org/eclipse/emf/databinding/internal/EMFPropertyHelper.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFPropertyHelper.java >diff -N src/org/eclipse/emf/databinding/internal/EMFPropertyHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFPropertyHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 194734) >+ * Martin Frey <martin.frey@logica.com> - bug 256150 >+ * Matthew Hall - bug 264307 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFPropertyHelper >+{ >+ >+ /** >+ * @param eStructuralFeature >+ * @return String description of property descriptor >+ */ >+ public static String propertyName(EStructuralFeature eStructuralFeature) >+ { >+ return eStructuralFeature.getEContainingClass().getName() + "." + eStructuralFeature.getName() + ""; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ /** >+ * @param eStructuralFeature >+ * @return class name excluding package >+ */ >+ public static String shortClassName(EStructuralFeature eStructuralFeature) >+ { >+ return eStructuralFeature.getEType().getName(); >+ } >+} Index: src/org/eclipse/emf/databinding/internal/EWritableList.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EWritableList.java >diff -N src/org/eclipse/emf/databinding/internal/EWritableList.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EWritableList.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,406 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 BestSolution.at and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl<tom.schindl@bestsolution.at> - Initial API and implementation in 262160 >+ * </copyright> >+ * >+ * $Id: $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import java.util.Collection; >+import java.util.Iterator; >+import java.util.List; >+import java.util.ListIterator; >+ >+import org.eclipse.core.databinding.observable.Diffs; >+import org.eclipse.core.databinding.observable.ObservableTracker; >+import org.eclipse.core.databinding.observable.Realm; >+import org.eclipse.core.databinding.observable.list.AbstractObservableList; >+import org.eclipse.core.databinding.observable.list.IObservableList; >+import org.eclipse.core.databinding.observable.list.ListDiff; >+import org.eclipse.core.databinding.observable.list.ListDiffEntry; >+import org.eclipse.emf.common.notify.Adapter; >+import org.eclipse.emf.common.notify.Notification; >+import org.eclipse.emf.common.notify.Notifier; >+import org.eclipse.emf.common.notify.NotifyingList; >+import org.eclipse.emf.common.notify.impl.AdapterImpl; >+import org.eclipse.emf.ecore.resource.Resource; >+ >+ >+/** >+ * Writable list which can be used to observe an {@link NotifyingList} >+ * >+ * @param <Type> the type >+ * @since 2.5 >+ */ >+public class EWritableList<Type> extends AbstractObservableList implements IObservableList >+{ >+ private NotifyingList<Type> wrappedList; >+ private Object elementType; >+ private boolean stale = false; >+ >+ private class Listener extends AdapterImpl >+ { >+ private Object feature; >+ >+ public Listener(Object feature) >+ { >+ this.feature = feature; >+ } >+ >+ @Override >+ public void notifyChanged(Notification msg) >+ { >+ >+ if (feature == null && msg.getFeature() == null && msg.getFeatureID(Resource.class) != Resource.RESOURCE__CONTENTS) >+ { >+ return; >+ } >+ >+ if (feature == msg.getFeature() && !msg.isTouch()) >+ { >+ final ListDiff diff; >+ switch (msg.getEventType()) >+ { >+ case Notification.ADD: { >+ diff = Diffs.createListDiff(Diffs.createListDiffEntry(msg.getPosition(), true, msg.getNewValue())); >+ // fireListChange(diff); >+ break; >+ } >+ case Notification.ADD_MANY: { >+ Collection< ? > newValues = (Collection< ? >)msg.getNewValue(); >+ ListDiffEntry[] listDiffEntries = new ListDiffEntry [newValues.size()]; >+ int position = msg.getPosition(); >+ int index = 0; >+ for (Object newValue : newValues) >+ { >+ listDiffEntries[index++] = Diffs.createListDiffEntry(position++, true, newValue); >+ } >+ diff = Diffs.createListDiff(listDiffEntries); >+ // fireListChange(diff); >+ break; >+ } >+ case Notification.REMOVE: { >+ diff = Diffs.createListDiff(Diffs.createListDiffEntry(msg.getPosition(), false, msg.getOldValue())); >+ // fireListChange(diff); >+ break; >+ } >+ case Notification.REMOVE_MANY: { >+ Collection< ? > oldValues = (Collection< ? >)msg.getOldValue(); >+ ListDiffEntry[] listDiffEntries = new ListDiffEntry [oldValues.size()]; >+ int position = msg.getPosition(); >+ int index = 0; >+ for (Object oldValue : oldValues) >+ { >+ listDiffEntries[index++] = Diffs.createListDiffEntry(position++, false, oldValue); >+ } >+ diff = Diffs.createListDiff(listDiffEntries); >+ // fireListChange(diff); >+ break; >+ } >+ case Notification.MOVE: { >+ Object movedValue = msg.getNewValue(); >+ ListDiffEntry[] listDiffEntries = new ListDiffEntry [2]; >+ listDiffEntries[0] = Diffs.createListDiffEntry((Integer)msg.getOldValue(), false, movedValue); >+ listDiffEntries[1] = Diffs.createListDiffEntry(msg.getPosition(), true, movedValue); >+ diff = Diffs.createListDiff(listDiffEntries); >+ // fireListChange(diff); >+ break; >+ } >+ case Notification.UNSET: { >+ // This just represents going back to the unset state, but >+ // that doesn't affect the contents of the list. >+ // >+ return; >+ } >+ default: { >+ throw new RuntimeException("unhandled case"); >+ } >+ } >+ >+ getRealm().exec(new Runnable() >+ { >+ public void run() >+ { >+ fireListChange(diff); >+ } >+ }); >+ >+ // System.err.println("CHANGE: " + >+ // diff.getDifferences()[0].getElement()); >+ >+ // fireListChange(diff); >+ // listener.handlePropertyChange(new SimplePropertyEvent(msg >+ // .getNotifier(), EMFListProperty.this, diff)); >+ } >+ } >+ >+ } >+ >+ private Adapter listener; >+ >+ /** >+ * New writable list wrapping the {@link NotifyingList} >+ * >+ * @param wrappedList >+ * the wrapped list >+ */ >+ public EWritableList(NotifyingList<Type> wrappedList) >+ { >+ this(Realm.getDefault(), wrappedList); >+ } >+ >+ /** >+ * New writable list wrapping the {@link NotifyingList} and using the >+ * {@link Realm} >+ * >+ * @param realm >+ * the realm >+ * @param wrappedList >+ * the wrapped list >+ */ >+ public EWritableList(Realm realm, NotifyingList<Type> wrappedList) >+ { >+ this(realm, wrappedList, null); >+ } >+ >+ /** >+ * New writable list wrapping the {@link NotifyingList} >+ * >+ * @param realm >+ * the realm >+ * @param wrappedList >+ * the wrapped list >+ * @param elementType >+ * the element type >+ */ >+ public EWritableList(Realm realm, NotifyingList<Type> wrappedList, Class<Type> elementType) >+ { >+ super(realm); >+ this.wrappedList = wrappedList; >+ this.elementType = elementType; >+ } >+ >+ @Override >+ protected void firstListenerAdded() >+ { >+ if (wrappedList.getNotifier() instanceof Notifier) >+ { >+ Notifier notifier = (Notifier)wrappedList.getNotifier(); >+ listener = new Listener(wrappedList.getFeature()); >+ notifier.eAdapters().add(listener); >+ } >+ else >+ { >+ throw new IllegalArgumentException("Wrapped list must have a notifier attached!"); >+ } >+ } >+ >+ @Override >+ protected void lastListenerRemoved() >+ { >+ if (wrappedList.getNotifier() instanceof Notifier) >+ { >+ Notifier notifier = (Notifier)wrappedList.getNotifier(); >+ listener = new Listener(wrappedList.getFeature()); >+ notifier.eAdapters().remove(listener); >+ } >+ else >+ { >+ throw new IllegalArgumentException("Wrapped list must have a notifier attached!"); >+ } >+ } >+ >+ @Override >+ public synchronized void dispose() >+ { >+ super.dispose(); >+ } >+ >+ private void getterCalled() >+ { >+ ObservableTracker.getterCalled(this); >+ } >+ >+ @SuppressWarnings("unchecked") >+ public boolean add(Object o) >+ { >+ checkRealm(); >+ return wrappedList.add((Type)o); >+ } >+ >+ @SuppressWarnings("unchecked") >+ public boolean addAll(Collection c) >+ { >+ checkRealm(); >+ return wrappedList.addAll(c); >+ } >+ >+ @SuppressWarnings("unchecked") >+ public boolean addAll(int index, Collection c) >+ { >+ checkRealm(); >+ return wrappedList.addAll(index, c); >+ } >+ >+ public boolean contains(Object o) >+ { >+ getterCalled(); >+ return wrappedList.contains(o); >+ } >+ >+ @SuppressWarnings("unchecked") >+ public boolean containsAll(Collection c) >+ { >+ getterCalled(); >+ return wrappedList.containsAll(c); >+ } >+ >+ public Object get(int index) >+ { >+ getterCalled(); >+ return wrappedList.get(index); >+ } >+ >+ public Object getElementType() >+ { >+ checkRealm(); >+ return elementType; >+ } >+ >+ public int indexOf(Object o) >+ { >+ getterCalled(); >+ return wrappedList.indexOf(o); >+ } >+ >+ public boolean isEmpty() >+ { >+ getterCalled(); >+ return wrappedList.isEmpty(); >+ } >+ >+ public Iterator<Type> iterator() >+ { >+ getterCalled(); >+ return wrappedList.iterator(); >+ } >+ >+ public int lastIndexOf(Object o) >+ { >+ getterCalled(); >+ return wrappedList.lastIndexOf(o); >+ } >+ >+ public ListIterator<Type> listIterator() >+ { >+ getterCalled(); >+ return wrappedList.listIterator(); >+ } >+ >+ public ListIterator<Type> listIterator(int index) >+ { >+ getterCalled(); >+ return wrappedList.listIterator(index); >+ } >+ >+ public Object move(int oldIndex, int newIndex) >+ { >+ checkRealm(); >+ return wrappedList.move(oldIndex, newIndex); >+ } >+ >+ public boolean remove(Object o) >+ { >+ checkRealm(); >+ return wrappedList.remove(o); >+ } >+ >+ public Object remove(int index) >+ { >+ checkRealm(); >+ return wrappedList.remove(index); >+ } >+ >+ @SuppressWarnings("unchecked") >+ public boolean removeAll(Collection c) >+ { >+ checkRealm(); >+ return wrappedList.removeAll(c); >+ } >+ >+ @SuppressWarnings("unchecked") >+ public boolean retainAll(Collection c) >+ { >+ checkRealm(); >+ return wrappedList.retainAll(c); >+ } >+ >+ @SuppressWarnings("unchecked") >+ public Object set(int index, Object element) >+ { >+ checkRealm(); >+ return wrappedList.set(index, (Type)element); >+ } >+ >+ public int doGetSize() >+ { >+ getterCalled(); >+ return wrappedList.size(); >+ } >+ >+ public List<Type> subList(int fromIndex, int toIndex) >+ { >+ getterCalled(); >+ return wrappedList.subList(fromIndex, toIndex); >+ } >+ >+ public Object[] toArray() >+ { >+ getterCalled(); >+ return wrappedList.toArray(); >+ } >+ >+ public Object[] toArray(Object[] a) >+ { >+ getterCalled(); >+ return wrappedList.toArray(); >+ } >+ >+ @SuppressWarnings("unchecked") >+ public void add(int index, Object element) >+ { >+ checkRealm(); >+ wrappedList.add(index, (Type)element); >+ } >+ >+ public void clear() >+ { >+ checkRealm(); >+ wrappedList.clear(); >+ } >+ >+ public boolean isStale() >+ { >+ getterCalled(); >+ return stale; >+ } >+ >+ // public void setStale(boolean stale) { >+ // checkRealm(); >+ // >+ // boolean wasStale = this.stale; >+ // this.stale = stale; >+ // if (!wasStale && stale) { >+ // fireStale(); >+ // } >+ // } >+} >\ No newline at end of file >Index: src/org/eclipse/emf/databinding/internal/EMFListPropertyDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFListPropertyDecorator.java >diff -N src/org/eclipse/emf/databinding/internal/EMFListPropertyDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFListPropertyDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,105 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 195222) >+ * Matthew Hall - bug 264307 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import org.eclipse.core.databinding.observable.Realm; >+import org.eclipse.core.databinding.observable.list.IObservableList; >+import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; >+import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.core.databinding.property.list.IListProperty; >+import org.eclipse.core.databinding.property.list.ListProperty; >+import org.eclipse.emf.databinding.EMFProperties; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.IEMFListProperty; >+import org.eclipse.emf.databinding.IEMFValueProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFListPropertyDecorator extends ListProperty implements IEMFListProperty >+{ >+ private final IListProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param delegate >+ * @param eStructuralFeature >+ */ >+ public EMFListPropertyDecorator(IListProperty delegate, EStructuralFeature eStructuralFeature) >+ { >+ this.delegate = delegate; >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ public Object getElementType() >+ { >+ return delegate.getElementType(); >+ } >+ >+ public IEMFListProperty values(EStructuralFeature feature) >+ { >+ return values(FeaturePath.fromList(feature)); >+ } >+ >+ public IEMFListProperty values(FeaturePath featurePath) >+ { >+ return values(EMFProperties.value(featurePath)); >+ } >+ >+ public IEMFListProperty values(IEMFValueProperty property) >+ { >+ return new EMFListPropertyDecorator(super.values(property), property.getStructuralFeature()); >+ } >+ >+ public EStructuralFeature getStructuralFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ public IObservableList observe(Object source) >+ { >+ return new EMFObservableListDecorator(delegate.observe(source), eStructuralFeature); >+ } >+ >+ public IObservableList observe(Realm realm, Object source) >+ { >+ return new EMFObservableListDecorator(delegate.observe(realm, source), eStructuralFeature); >+ } >+ >+ public IObservableFactory listFactory() >+ { >+ return delegate.listFactory(); >+ } >+ >+ public IObservableFactory listFactory(Realm realm) >+ { >+ return delegate.listFactory(realm); >+ } >+ >+ public IObservableList observeDetail(IObservableValue master) >+ { >+ return new EMFObservableListDecorator(delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public String toString() >+ { >+ return delegate.toString(); >+ } >+} Index: src/org/eclipse/emf/databinding/internal/EMFObservableListDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFObservableListDecorator.java >diff -N src/org/eclipse/emf/databinding/internal/EMFObservableListDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFObservableListDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2007 Brad Reynolds and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Brad Reynolds - initial API and implementation >+ * Matthew Hall - bugs 208858, 246625 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import org.eclipse.core.databinding.observable.IObservable; >+import org.eclipse.core.databinding.observable.IObserving; >+import org.eclipse.core.databinding.observable.list.DecoratingObservableList; >+import org.eclipse.core.databinding.observable.list.IObservableList; >+import org.eclipse.emf.databinding.IEMFObservable; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * {@link IEMFObservable} decorator for an {@link IObservableList}. >+ * @since 2.5 >+ */ >+public class EMFObservableListDecorator extends DecoratingObservableList implements IEMFObservable >+{ >+ private EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param decorated >+ * @param eStructuralFeature >+ */ >+ public EMFObservableListDecorator(IObservableList decorated, EStructuralFeature eStructuralFeature) >+ { >+ super(decorated, true); >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ public synchronized void dispose() >+ { >+ this.eStructuralFeature = null; >+ super.dispose(); >+ } >+ >+ public Object getObserved() >+ { >+ IObservable decorated = getDecorated(); >+ if (decorated instanceof IObserving) >+ return ((IObserving)decorated).getObserved(); >+ return null; >+ } >+ >+ public EStructuralFeature getStructuralFeature() >+ { >+ return eStructuralFeature; >+ } >+} Index: src/org/eclipse/emf/databinding/internal/Util.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/Util.java >diff -N src/org/eclipse/emf/databinding/internal/Util.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/Util.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+/** >+ * @since 2.5 >+ */ >+public class Util >+{ >+ >+ /** >+ * Checks whether the two objects are <code>null</code> -- allowing for >+ * <code>null</code>. >+ * >+ * @param left >+ * The left object to compare; may be <code>null</code>. >+ * @param right >+ * The right object to compare; may be <code>null</code>. >+ * @return <code>true</code> if the two objects are equivalent; >+ * <code>false</code> otherwise. >+ */ >+ public static final boolean equals(final Object left, final Object right) >+ { >+ return left == null ? right == null : ((right != null) && left.equals(right)); >+ } >+} Index: src/org/eclipse/emf/databinding/internal/EMFValuePropertyDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFValuePropertyDecorator.java >diff -N src/org/eclipse/emf/databinding/internal/EMFValuePropertyDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFValuePropertyDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,143 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 194734) >+ * Matthew Hall - bugs 195222, 264307, 265561 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import org.eclipse.core.databinding.observable.Realm; >+import org.eclipse.core.databinding.observable.list.IObservableList; >+import org.eclipse.core.databinding.observable.map.IObservableMap; >+import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; >+import org.eclipse.core.databinding.observable.set.IObservableSet; >+import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.core.databinding.property.value.IValueProperty; >+import org.eclipse.core.databinding.property.value.ValueProperty; >+import org.eclipse.emf.databinding.EMFProperties; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.IEMFListProperty; >+import org.eclipse.emf.databinding.IEMFMapProperty; >+import org.eclipse.emf.databinding.IEMFValueProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFValuePropertyDecorator extends ValueProperty implements IEMFValueProperty >+{ >+ private final IValueProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param delegate >+ * @param eStructuralFeature >+ */ >+ public EMFValuePropertyDecorator(IValueProperty delegate, EStructuralFeature eStructuralFeature) >+ { >+ this.delegate = delegate; >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ public EStructuralFeature getStructuralFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ public Object getValueType() >+ { >+ return delegate.getValueType(); >+ } >+ >+ public IEMFValueProperty value(EStructuralFeature feature) >+ { >+ return value(FeaturePath.fromList(feature)); >+ } >+ >+ public IEMFValueProperty value(FeaturePath featurePath) >+ { >+ return value(EMFProperties.value(featurePath)); >+ } >+ >+ public IEMFValueProperty value(IEMFValueProperty property) >+ { >+ return new EMFValuePropertyDecorator(super.value(property), property.getStructuralFeature()); >+ } >+ >+ public IEMFListProperty list(EStructuralFeature feature) >+ { >+ return list(EMFProperties.list(feature)); >+ } >+ >+ public IEMFListProperty list(IEMFListProperty property) >+ { >+ return new EMFListPropertyDecorator(super.list(property), property.getStructuralFeature()); >+ } >+ >+ public IEMFMapProperty map(EStructuralFeature feature) >+ { >+ return map(EMFProperties.map(feature)); >+ } >+ >+ public IEMFMapProperty map(IEMFMapProperty property) >+ { >+ return new EMFMapPropertyDecorator(super.map(property), property.getStructuralFeature()); >+ } >+ >+ public IObservableValue observe(Object source) >+ { >+ return new EMFObservableValueDecorator(delegate.observe(source), eStructuralFeature); >+ } >+ >+ public IObservableValue observe(Realm realm, Object source) >+ { >+ return new EMFObservableValueDecorator(delegate.observe(realm, source), eStructuralFeature); >+ } >+ >+ public IObservableFactory valueFactory() >+ { >+ return delegate.valueFactory(); >+ } >+ >+ public IObservableFactory valueFactory(Realm realm) >+ { >+ return delegate.valueFactory(realm); >+ } >+ >+ public IObservableValue observeDetail(IObservableValue master) >+ { >+ return new EMFObservableValueDecorator(delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public IObservableList observeDetail(IObservableList master) >+ { >+ return new EMFObservableListDecorator(delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public IObservableMap observeDetail(IObservableSet master) >+ { >+ return new EMFObservableMapDecorator(delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public IObservableMap observeDetail(IObservableMap master) >+ { >+ return new EMFObservableMapDecorator(delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public String toString() >+ { >+ return delegate.toString(); >+ } >+} Index: src/org/eclipse/emf/databinding/internal/EMFObservableMapDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFObservableMapDecorator.java >diff -N src/org/eclipse/emf/databinding/internal/EMFObservableMapDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFObservableMapDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 221704) >+ * Matthew Hall - bug 246625 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import org.eclipse.core.databinding.observable.IObservable; >+import org.eclipse.core.databinding.observable.IObserving; >+import org.eclipse.core.databinding.observable.map.DecoratingObservableMap; >+import org.eclipse.core.databinding.observable.map.IObservableMap; >+import org.eclipse.emf.databinding.IEMFObservable; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * {@link IEMFObservable} decorator for an {@link IObservableMap}. >+ * >+ * @since 2.5 >+ */ >+public class EMFObservableMapDecorator extends DecoratingObservableMap implements IEMFObservable >+{ >+ private EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param decorated >+ * @param eStructuralFeature >+ */ >+ public EMFObservableMapDecorator(IObservableMap decorated, EStructuralFeature eStructuralFeature) >+ { >+ super(decorated, true); >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ public synchronized void dispose() >+ { >+ this.eStructuralFeature = null; >+ super.dispose(); >+ } >+ >+ public Object getObserved() >+ { >+ IObservable decorated = getDecorated(); >+ if (decorated instanceof IObserving) >+ return ((IObserving)decorated).getObserved(); >+ return null; >+ } >+ >+ public EStructuralFeature getStructuralFeature() >+ { >+ return eStructuralFeature; >+ } >+} Index: src/org/eclipse/emf/databinding/internal/EMFListProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFListProperty.java >diff -N src/org/eclipse/emf/databinding/internal/EMFListProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFListProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,104 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 194734) >+ * Matthew Hall - bugs 195222, 264307, 265561 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import java.util.List; >+ >+import org.eclipse.core.databinding.observable.list.ListDiff; >+import org.eclipse.core.databinding.property.INativePropertyListener; >+import org.eclipse.core.databinding.property.IProperty; >+import org.eclipse.core.databinding.property.ISimplePropertyListener; >+import org.eclipse.core.databinding.property.list.SimpleListProperty; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFListProperty extends SimpleListProperty >+{ >+ private EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param eStructuralFeature >+ */ >+ public EMFListProperty(EStructuralFeature eStructuralFeature) >+ { >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ /** >+ * @return the feature >+ */ >+ protected EStructuralFeature getFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ public Object getElementType() >+ { >+ return eStructuralFeature; >+ } >+ >+ protected List< ? > doGetList(Object source) >+ { >+ EObject eObj = (EObject)source; >+ return (List< ? >)eObj.eGet(eStructuralFeature); >+ } >+ >+ @SuppressWarnings("unchecked") >+ protected void doSetList(Object source, List list, ListDiff diff) >+ { >+ List< ? > currentList = doGetList(source); >+ diff.applyTo(currentList); >+ } >+ >+ public INativePropertyListener adaptListener(final ISimplePropertyListener listener) >+ { >+ return new EMFPropertyListener.EMFListPropertyListener() >+ { >+ >+ @Override >+ protected EStructuralFeature getFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ @Override >+ protected ISimplePropertyListener getListener() >+ { >+ return listener; >+ } >+ >+ @Override >+ protected IProperty getOwner() >+ { >+ return EMFListProperty.this; >+ } >+ }; >+ } >+ >+ public String toString() >+ { >+ String s = EMFPropertyHelper.propertyName(eStructuralFeature) + "[]"; //$NON-NLS-1$ >+ s += "<" + EMFPropertyHelper.shortClassName(eStructuralFeature) + ">"; //$NON-NLS-1$//$NON-NLS-2$ >+ return s; >+ } >+ >+} Index: src/org/eclipse/emf/databinding/IEMFObservable.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/IEMFObservable.java >diff -N src/org/eclipse/emf/databinding/IEMFObservable.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/IEMFObservable.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2007 Brad Reynolds and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Brad Reynolds - initial API and implementation >+ * Brad Reynolds - bug 147515 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.core.databinding.observable.IObserving; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * >+ * Provides access to details of EObject observables. >+ * <p> >+ * This interface is not meant to be implemented by clients. >+ * </p> >+ * >+ * @since 2.5 >+ * @noextend This interface is not intended to be extended by clients. >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public interface IEMFObservable extends IObserving >+{ >+ /** >+ * @return property descriptor of the property being observed, >+ * <code>null</code> if the runtime time information was not >+ * provided on construction of the observable >+ */ >+ public EStructuralFeature getStructuralFeature(); >+} Index: src/org/eclipse/emf/databinding/IEMFValueProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/IEMFValueProperty.java >diff -N src/org/eclipse/emf/databinding/IEMFValueProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/IEMFValueProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,154 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 195222) >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.core.databinding.property.value.IValueProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * >+ * An {@link IValueProperty} extension interface with convenience methods for >+ * creating nested {@link EStructuralFeature} properties. >+ * >+ * @since 2.5 >+ * @noextend This interface is not intended to be extended by clients. >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public interface IEMFValueProperty extends IEMFProperty, IValueProperty >+{ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * nested value feature. >+ * >+ * @param featurePath >+ * the nested value property to observe. >+ * @return a master-detail combination of this property and the specified >+ * nested value feature. >+ * @see #value(IEMFValueProperty) >+ */ >+ public IEMFValueProperty value(FeaturePath featurePath); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value feature. >+ * >+ * @param feature >+ * the nested value property to observe. >+ * @return a master-detail combination of this property and the specified >+ * value feature. >+ * @see #value(IEMFValueProperty) >+ */ >+ public IEMFValueProperty value(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value property. The returned property will observe the specified detail >+ * value property for the value of the master value property. >+ * <p> >+ * Example: >+ * >+ * <pre> >+ * // Observes the Node-typed "parent" property of a Node object >+ * IEMFValueProperty parent = EMFProperties.value(MyPackage.Literals.NODE_PARENT); >+ * // Observes the string-typed "name" property of a Node object >+ * IEMFValueProperty name = EMFProperties.value(MyPackage.Literals.NODE_NAME); >+ * // Observes the name of the parent of a Node object. >+ * IEMFValueProperty parentName = parent.value(name); >+ * </pre> >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * value property. >+ */ >+ public IEMFValueProperty value(IEMFValueProperty property); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * list feature. >+ * >+ * @param feature >+ * the list feature to observe >+ * @return a master-detail combination of this property and the specified >+ * list feature. >+ * @see #list(IEMFListProperty) >+ */ >+ public IEMFListProperty list(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * list property. The returned property will observe the specified list >+ * property for the value of the master property. >+ * <p> >+ * Example: >+ * >+ * <pre> >+ * // Observes the Node-typed "parent" property of a Node object. >+ * IEMFValueProperty parent = EMFProperties.value(MyPackage.Literals.NODE_PARENT); >+ * // Observes the List-typed "children" property of a Node object >+ * // where the elements are Node objects >+ * IEMFListProperty children = EMFProperties.list(MyPackage.Literals.NODE_CHILDREN); >+ * // Observes the children of the parent (siblings) of a Node object. >+ * IEMFListProperty siblings = parent.list(children); >+ * </pre> >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * list property. >+ */ >+ public IEMFListProperty list(IEMFListProperty property); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * map feature. >+ * >+ * @param feature >+ * the map property to observe >+ * @return a master-detail combination of this property and the specified >+ * map feature. >+ * @see #map(IEMFMapProperty) >+ */ >+ public IEMFMapProperty map(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * map property. The returned property will observe the specified map >+ * property for the value of the master property. >+ * <p> >+ * Example: >+ * >+ * <pre> >+ * // Observes the Contact-typed "supervisor" property of a >+ * // Contact class >+ * IEMFValueProperty supervisor = EMFProperties.value(MyPackage.Literals.CONTACT_SUPERVISOR); >+ * // Observes the property "phoneNumbers" of a Contact object--a property mapping >+ * // from PhoneNumberType to PhoneNumber "set-typed "children", >+ * IEMFMapProperty phoneNumbers = EMFProperties.map(MyPackage.Literals.CONTACT_PHONENUMBERS); >+ * // Observes the phone numbers of a contact's supervisor: >+ * IEMFMapProperty supervisorPhoneNumbers = supervisor.map(phoneNumbers); >+ * </pre> >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * map property. >+ */ >+ public IEMFMapProperty map(IEMFMapProperty property); >+} Index: src/org/eclipse/emf/databinding/internal/EMFValueProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFValueProperty.java >diff -N src/org/eclipse/emf/databinding/internal/EMFValueProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFValueProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,100 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 194734) >+ * Matthew Hall - bug 195222, 264307, 265561 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import org.eclipse.core.databinding.property.INativePropertyListener; >+import org.eclipse.core.databinding.property.IProperty; >+import org.eclipse.core.databinding.property.ISimplePropertyListener; >+import org.eclipse.core.databinding.property.value.SimpleValueProperty; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.util.ExtendedMetaData; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFValueProperty extends SimpleValueProperty >+{ >+ private final EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param eStructuralFeature >+ */ >+ public EMFValueProperty(EStructuralFeature eStructuralFeature) >+ { >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ public Object getValueType() >+ { >+ return eStructuralFeature; >+ } >+ >+ /** >+ * @return the feature >+ */ >+ protected EStructuralFeature getFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ protected Object doGetValue(Object source) >+ { >+ EObject eObj = (EObject)source; >+ return ExtendedMetaData.INSTANCE.getAffiliation(eObj.eClass(), eStructuralFeature) == null ? null : eObj.eGet(eStructuralFeature); >+ } >+ >+ protected void doSetValue(Object source, Object value) >+ { >+ EObject eObject = (EObject)source; >+ eObject.eSet(eStructuralFeature, value); >+ } >+ >+ public INativePropertyListener adaptListener(final ISimplePropertyListener listener) >+ { >+ return new EMFPropertyListener.EMFValuePropertyListener() >+ { >+ >+ @Override >+ protected IProperty getOwner() >+ { >+ return EMFValueProperty.this; >+ } >+ >+ @Override >+ protected ISimplePropertyListener getListener() >+ { >+ return listener; >+ } >+ >+ @Override >+ protected EStructuralFeature getFeature() >+ { >+ return eStructuralFeature; >+ } >+ }; >+ } >+ >+ public String toString() >+ { >+ String s = EMFPropertyHelper.propertyName(eStructuralFeature); >+ s += "<" + EMFPropertyHelper.shortClassName(eStructuralFeature) + ">"; //$NON-NLS-1$//$NON-NLS-2$ >+ return s; >+ } >+} Index: src/org/eclipse/emf/databinding/internal/EMFObservableValueDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFObservableValueDecorator.java >diff -N src/org/eclipse/emf/databinding/internal/EMFObservableValueDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFObservableValueDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2007 Brad Reynolds and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Brad Reynolds - initial API and implementation >+ * Matthew Hall - bug 246625 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import org.eclipse.core.databinding.observable.IObservable; >+import org.eclipse.core.databinding.observable.IObserving; >+import org.eclipse.core.databinding.observable.value.DecoratingObservableValue; >+import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.emf.databinding.IEMFObservable; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * {@link IEMFObservable} decorator for an {@link IObservableValue}. >+ * >+ * @since 2.5 >+ */ >+public class EMFObservableValueDecorator extends DecoratingObservableValue implements IEMFObservable >+{ >+ private EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param decorated >+ * @param eStructuralFeature >+ */ >+ public EMFObservableValueDecorator(IObservableValue decorated, EStructuralFeature eStructuralFeature) >+ { >+ super(decorated, true); >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ public synchronized void dispose() >+ { >+ this.eStructuralFeature = null; >+ super.dispose(); >+ } >+ >+ public Object getObserved() >+ { >+ IObservable decorated = getDecorated(); >+ if (decorated instanceof IObserving) >+ return ((IObserving)decorated).getObserved(); >+ return null; >+ } >+ >+ public EStructuralFeature getStructuralFeature() >+ { >+ return eStructuralFeature; >+ } >+} Index: src/org/eclipse/emf/databinding/EMFProperties.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/EMFProperties.java >diff -N src/org/eclipse/emf/databinding/EMFProperties.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/EMFProperties.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,144 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 194734) >+ * Matthew Hall - bug 195222, 247997, 261843, 264307 >+ * Hasan Ceylan - patch in bug 262160 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.core.databinding.property.list.IListProperty; >+import org.eclipse.core.databinding.property.map.IMapProperty; >+import org.eclipse.core.databinding.property.value.IValueProperty; >+import org.eclipse.emf.databinding.internal.EMFListProperty; >+import org.eclipse.emf.databinding.internal.EMFListPropertyDecorator; >+import org.eclipse.emf.databinding.internal.EMFMapProperty; >+import org.eclipse.emf.databinding.internal.EMFMapPropertyDecorator; >+import org.eclipse.emf.databinding.internal.EMFValueProperty; >+import org.eclipse.emf.databinding.internal.EMFValuePropertyDecorator; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * >+ * A factory to create property bound attributes for {@link EObject} >+ * >+ * @since 2.5 >+ */ >+public class EMFProperties >+{ >+ /** >+ * Debug constant to turn on/off debugging >+ */ >+ public static final boolean DEBUG = false; >+ >+ /** >+ * Returns a value property for the given {@link EStructuralFeature} >+ * >+ * @param feature >+ * the feature instance the property is created for >+ * @return a value property for the given {@link EStructuralFeature} >+ */ >+ public static IEMFValueProperty value(EStructuralFeature feature) >+ { >+ return value(FeaturePath.fromList(feature)); >+ } >+ >+ /** >+ * Returns a value property for the given nested {@link EStructuralFeature} >+ * feature like the <code>name</code> of a <code>person</code> >+ * >+ * @param featurePath >+ * path to the feature >+ * @return a value property for the given {@link FeaturePath} >+ */ >+ public static IEMFValueProperty value(FeaturePath featurePath) >+ { >+ IValueProperty property; >+ property = new EMFValueProperty(featurePath.getFeaturePath()[0]); >+ >+ IEMFValueProperty featureProperty = new EMFValuePropertyDecorator(property, featurePath.getFeaturePath()[0]); >+ >+ for (int i = 1; i < featurePath.getFeaturePath().length; i++) >+ { >+ featureProperty = featureProperty.value(featurePath.getFeaturePath()[i]); >+ } >+ >+ return featureProperty; >+ } >+ >+ /** >+ * Returns multiple value properties for the given >+ * {@link EStructuralFeature}s >+ * >+ * @param features >+ * the feature instances the properties are created for >+ * @return an array of properties for the given {@link EStructuralFeature}s >+ */ >+ public static IEMFValueProperty[] values(EStructuralFeature... features) >+ { >+ IEMFValueProperty[] properties = new IEMFValueProperty [features.length]; >+ for (int i = 0; i < properties.length; i++) >+ properties[i] = value(features[i]); >+ return properties; >+ } >+ >+ /** >+ * Returns multiple value property for the given nested >+ * {@link EStructuralFeature} features like the <code>name</code> of a >+ * <code>person</code> >+ * >+ * @param featurePaths >+ * path to the feature >+ * @return an array of properties for the given {@link FeaturePath}s >+ */ >+ public static IEMFValueProperty[] values(FeaturePath... featurePaths) >+ { >+ IEMFValueProperty[] properties = new IEMFValueProperty [featurePaths.length]; >+ for (int i = 0; i < properties.length; i++) >+ properties[i] = value(featurePaths[i]); >+ return properties; >+ } >+ >+ /** >+ * Returns a list property for the given {@link EStructuralFeature} >+ * >+ * @param feature >+ * the feature instance the property is created for >+ * @return a list property for the given {@link EStructuralFeature} >+ */ >+ public static IEMFListProperty list(EStructuralFeature feature) >+ { >+ IListProperty property; >+ property = new EMFListProperty(feature); >+ return new EMFListPropertyDecorator(property, feature); >+ } >+ >+ /** >+ * Returns a map property for the given {@link EStructuralFeature}. Objects lacking the named property are treated the same as if the >+ * property always contains an empty map. >+ * >+ * @param feature >+ * the feature the property is created for >+ * @return a map property for the given {@link EStructuralFeature} >+ */ >+ public static IEMFMapProperty map(EStructuralFeature feature) >+ { >+ IMapProperty property; >+ property = new EMFMapProperty(feature); >+ return new EMFMapPropertyDecorator(property, feature); >+ } >+} Index: src/org/eclipse/emf/databinding/FeaturePath.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/FeaturePath.java >diff -N src/org/eclipse/emf/databinding/FeaturePath.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/FeaturePath.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 BestSolution.at and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * >+ * Encapsulate a path to features also known as nested feature like person.name >+ * >+ * @since 2.5 >+ * @noextend This interface is not intended to be extended by clients. >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public class FeaturePath >+{ >+ private EStructuralFeature[] featurePath; >+ >+ private FeaturePath(EStructuralFeature[] featurePath) >+ { >+ this.featurePath = featurePath; >+ } >+ >+ /** >+ * @return the path to the feature from the local position >+ */ >+ public EStructuralFeature[] getFeaturePath() >+ { >+ return featurePath; >+ } >+ >+ /** >+ * Create a feature path from the list of given features >+ * >+ * @param featurePath >+ * the list of feature to go from the local instance to the >+ * requested instance >+ * @return the path constructed >+ */ >+ public static FeaturePath fromList(EStructuralFeature... featurePath) >+ { >+ return new FeaturePath(featurePath); >+ } >+} Index: src/org/eclipse/emf/databinding/IEMFProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/IEMFProperty.java >diff -N src/org/eclipse/emf/databinding/IEMFProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/IEMFProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 194734) >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.core.databinding.property.IProperty; >+ >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * >+ * An IProperty extension interface providing access to details of {@link EObject}s >+ * >+ * @since 2.5 >+ * @noextend This interface is not intended to be extended by clients. >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public interface IEMFProperty extends IProperty >+{ >+ /** >+ * Returns the descriptor of the {@link EStructuralFeature} being observed. >+ * >+ * @return the {@link EStructuralFeature} being observed >+ */ >+ public EStructuralFeature getStructuralFeature(); >+} Index: src/org/eclipse/emf/databinding/IEMFListProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/IEMFListProperty.java >diff -N src/org/eclipse/emf/databinding/IEMFListProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/IEMFListProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,82 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 195222) >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.core.databinding.property.list.IListProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * >+ * An {@link IListProperty} extension interface with convenience methods for >+ * creating nested {@link EStructuralFeature}s >+ * >+ * @since 2.5 >+ * @noextend This interface is not intended to be extended by clients. >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public interface IEMFListProperty extends IEMFProperty, IListProperty >+{ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value nested feature. >+ * >+ * @param featurePath >+ * the nested feature to observe >+ * @return a nested combination of this property and the specified nested >+ * feature. >+ * @see #values(IEMFValueProperty) >+ */ >+ public IEMFListProperty values(FeaturePath featurePath); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value property. >+ * >+ * @param feature >+ * the feature >+ * @return a nested combination of this property and the specified nested >+ * feature. >+ */ >+ public IEMFListProperty values(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value property. The returned property will observe the specified value >+ * property for all elements observed by this list property. >+ * <p> >+ * Example: >+ * >+ * <pre> >+ * // Observes the list-typed "children" property of a Person object, >+ * // where the elements are Person objects >+ * IEMFListProperty children = EMFProperties >+ * .list(MyPackage.Literals.PERSON_CHILDREN); >+ * // Observes the string-typed "name" property of a Person object >+ * IEMFValueProperty name = EMFProperties.value(MyPackage.Literals.PERSON_NAME); >+ * // Observes the names of children of a Person object. >+ * IEMFListProperty childrenNames = children.values(name); >+ * </pre> >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * value property. >+ */ >+ public IEMFListProperty values(IEMFValueProperty property); >+} Index: src/org/eclipse/emf/databinding/internal/EMFPropertyListener.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFPropertyListener.java >diff -N src/org/eclipse/emf/databinding/internal/EMFPropertyListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFPropertyListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,179 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 Tom Schindl and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import java.util.Collection; >+import java.util.Map; >+ >+import org.eclipse.core.databinding.observable.Diffs; >+import org.eclipse.core.databinding.observable.list.ListDiff; >+import org.eclipse.core.databinding.observable.list.ListDiffEntry; >+import org.eclipse.core.databinding.property.INativePropertyListener; >+import org.eclipse.core.databinding.property.IProperty; >+import org.eclipse.core.databinding.property.ISimplePropertyListener; >+import org.eclipse.core.databinding.property.SimplePropertyEvent; >+import org.eclipse.emf.common.notify.Notification; >+import org.eclipse.emf.common.notify.impl.AdapterImpl; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public abstract class EMFPropertyListener extends AdapterImpl implements INativePropertyListener >+{ >+ >+ public void addTo(Object source) >+ { >+ ((EObject)source).eAdapters().add(this); >+ } >+ >+ public void removeFrom(Object source) >+ { >+ ((EObject)source).eAdapters().remove(this); >+ } >+ >+ @Override >+ public abstract void notifyChanged(Notification msg); >+ >+ /** >+ * @return the listener >+ */ >+ protected abstract ISimplePropertyListener getListener(); >+ >+ /** >+ * @return the feature >+ */ >+ protected abstract EStructuralFeature getFeature(); >+ >+ /** >+ * @return the owner property >+ */ >+ protected abstract IProperty getOwner(); >+ >+ /** >+ * >+ */ >+ public abstract static class EMFListPropertyListener extends EMFPropertyListener >+ { >+ @Override >+ public void notifyChanged(Notification msg) >+ { >+ if (getFeature() == msg.getFeature() && !msg.isTouch()) >+ { >+ final ListDiff diff; >+ switch (msg.getEventType()) >+ { >+ case Notification.ADD: { >+ diff = Diffs.createListDiff(Diffs.createListDiffEntry(msg.getPosition(), true, msg.getNewValue())); >+ break; >+ } >+ case Notification.ADD_MANY: { >+ Collection< ? > newValues = (Collection< ? >)msg.getNewValue(); >+ ListDiffEntry[] listDiffEntries = new ListDiffEntry [newValues.size()]; >+ int position = msg.getPosition(); >+ int index = 0; >+ for (Object newValue : newValues) >+ { >+ listDiffEntries[index++] = Diffs.createListDiffEntry(position++, true, newValue); >+ } >+ diff = Diffs.createListDiff(listDiffEntries); >+ break; >+ } >+ case Notification.REMOVE: { >+ diff = Diffs.createListDiff(Diffs.createListDiffEntry(msg.getPosition(), false, msg.getOldValue())); >+ break; >+ } >+ case Notification.REMOVE_MANY: { >+ Collection< ? > oldValues = (Collection< ? >)msg.getOldValue(); >+ ListDiffEntry[] listDiffEntries = new ListDiffEntry [oldValues.size()]; >+ int position = msg.getPosition(); >+ int index = 0; >+ for (Object oldValue : oldValues) >+ { >+ listDiffEntries[index++] = Diffs.createListDiffEntry(position++, false, oldValue); >+ } >+ diff = Diffs.createListDiff(listDiffEntries); >+ break; >+ } >+ case Notification.SET: >+ case Notification.RESOLVE: { >+ ListDiffEntry[] listDiffEntries = new ListDiffEntry [2]; >+ listDiffEntries[0] = Diffs.createListDiffEntry(msg.getPosition(), false, msg.getOldValue()); >+ listDiffEntries[1] = Diffs.createListDiffEntry(msg.getPosition(), true, msg.getNewValue()); >+ diff = Diffs.createListDiff(listDiffEntries); >+ break; >+ } >+ case Notification.MOVE: { >+ Object movedValue = msg.getNewValue(); >+ ListDiffEntry[] listDiffEntries = new ListDiffEntry [2]; >+ listDiffEntries[0] = Diffs.createListDiffEntry((Integer)msg.getOldValue(), false, movedValue); >+ listDiffEntries[1] = Diffs.createListDiffEntry(msg.getPosition(), true, movedValue); >+ diff = Diffs.createListDiff(listDiffEntries); >+ break; >+ } >+ case Notification.UNSET: { >+ // This just represents going back to the unset state, but >+ // that doesn't affect the contents of the list. >+ // >+ return; >+ } >+ default: { >+ throw new RuntimeException("unhandled case"); >+ } >+ } >+ getListener().handleEvent((new SimplePropertyEvent(SimplePropertyEvent.CHANGE, msg.getNotifier(), getOwner(), diff))); >+ } >+ } >+ } >+ >+ /** >+ * >+ */ >+ public abstract static class EMFMapPropertyListener extends EMFPropertyListener >+ { >+ @Override >+ public void notifyChanged(Notification msg) >+ { >+ if (getFeature() == msg.getFeature() && !msg.isTouch()) >+ { >+ getListener().handleEvent( >+ new SimplePropertyEvent(SimplePropertyEvent.CHANGE, msg.getNotifier(), getOwner(), Diffs.computeMapDiff( >+ (Map< ? , ? >)msg.getOldValue(), >+ (Map< ? , ? >)msg.getNewValue()))); >+ } >+ } >+ } >+ >+ /** >+ * >+ */ >+ public abstract static class EMFValuePropertyListener extends EMFPropertyListener >+ { >+ @Override >+ public void notifyChanged(Notification msg) >+ { >+ if (getFeature() == msg.getFeature() && !msg.isTouch()) >+ { >+ getListener().handleEvent( >+ new SimplePropertyEvent(SimplePropertyEvent.CHANGE, msg.getNotifier(), getOwner(), Diffs.createValueDiff( >+ msg.getOldValue(), >+ msg.getNewValue()))); >+ } >+ } >+ } >+} Index: src/org/eclipse/emf/databinding/internal/EMFMapPropertyDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFMapPropertyDecorator.java >diff -N src/org/eclipse/emf/databinding/internal/EMFMapPropertyDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFMapPropertyDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,110 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 195222) >+ * Matthew Hall - bug 264307 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import org.eclipse.core.databinding.observable.Realm; >+import org.eclipse.core.databinding.observable.map.IObservableMap; >+import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; >+import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.core.databinding.property.map.IMapProperty; >+import org.eclipse.core.databinding.property.map.MapProperty; >+import org.eclipse.emf.databinding.EMFProperties; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.IEMFMapProperty; >+import org.eclipse.emf.databinding.IEMFValueProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFMapPropertyDecorator extends MapProperty implements IEMFMapProperty >+{ >+ private final IMapProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param delegate >+ * @param eStructuralFeature >+ */ >+ public EMFMapPropertyDecorator(IMapProperty delegate, EStructuralFeature eStructuralFeature) >+ { >+ this.delegate = delegate; >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ public EStructuralFeature getStructuralFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ public Object getKeyType() >+ { >+ return delegate.getKeyType(); >+ } >+ >+ public Object getValueType() >+ { >+ return delegate.getValueType(); >+ } >+ >+ public IEMFMapProperty values(EStructuralFeature feature) >+ { >+ return values(FeaturePath.fromList(feature)); >+ } >+ >+ public IEMFMapProperty values(FeaturePath featurePath) >+ { >+ return values(EMFProperties.value(featurePath)); >+ } >+ >+ public IEMFMapProperty values(IEMFValueProperty property) >+ { >+ return new EMFMapPropertyDecorator(super.values(property), property.getStructuralFeature()); >+ } >+ >+ public IObservableMap observe(Object source) >+ { >+ return new EMFObservableMapDecorator(delegate.observe(source), eStructuralFeature); >+ } >+ >+ public IObservableMap observe(Realm realm, Object source) >+ { >+ return new EMFObservableMapDecorator(delegate.observe(realm, source), eStructuralFeature); >+ } >+ >+ public IObservableFactory mapFactory() >+ { >+ return delegate.mapFactory(); >+ } >+ >+ public IObservableFactory mapFactory(Realm realm) >+ { >+ return delegate.mapFactory(realm); >+ } >+ >+ public IObservableMap observeDetail(IObservableValue master) >+ { >+ return new EMFObservableMapDecorator(delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public String toString() >+ { >+ return delegate.toString(); >+ } >+} Index: src/org/eclipse/emf/databinding/internal/EMFMapProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFMapProperty.java >diff -N src/org/eclipse/emf/databinding/internal/EMFMapProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFMapProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,132 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 194734) >+ * Matthew Hall - bugs 195222, 264307, 265561 >+ * Hasan Ceylan - patch in bug 262160 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.internal; >+ >+import java.util.Map; >+ >+import org.eclipse.core.databinding.observable.map.MapDiff; >+import org.eclipse.core.databinding.property.INativePropertyListener; >+import org.eclipse.core.databinding.property.IProperty; >+import org.eclipse.core.databinding.property.ISimplePropertyListener; >+import org.eclipse.core.databinding.property.map.SimpleMapProperty; >+import org.eclipse.emf.ecore.EClass; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFMapProperty extends SimpleMapProperty >+{ >+ private EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param eStructuralFeature >+ */ >+ public EMFMapProperty(EStructuralFeature eStructuralFeature) >+ { >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ /** >+ * @return the feature >+ */ >+ protected EStructuralFeature getFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ public Object getKeyType() >+ { >+ final EClass eType = (EClass)this.eStructuralFeature.getEType(); >+ >+ for (final EStructuralFeature feature : eType.getEAllStructuralFeatures()) >+ { >+ if (feature.getName().equals("key")) >+ { >+ return feature; >+ } >+ } >+ >+ return null; >+ } >+ >+ public Object getValueType() >+ { >+ final EClass eType = (EClass)this.eStructuralFeature.getEType(); >+ >+ for (final EStructuralFeature feature : eType.getEAllStructuralFeatures()) >+ { >+ if (feature.getName().equals("value")) >+ { >+ return feature; >+ } >+ } >+ >+ return null; >+ } >+ >+ protected Map< ? , ? > doGetMap(Object source) >+ { >+ EObject eObj = (EObject)source; >+ return (Map< ? , ? >)eObj.eGet(eStructuralFeature); >+ } >+ >+ @SuppressWarnings("unchecked") >+ protected void doSetMap(Object source, Map map, MapDiff diff) >+ { >+ EObject eObject = (EObject)source; >+ eObject.eSet(eStructuralFeature, map); >+ } >+ >+ public INativePropertyListener adaptListener(final ISimplePropertyListener listener) >+ { >+ return new EMFPropertyListener.EMFMapPropertyListener() >+ { >+ >+ @Override >+ protected IProperty getOwner() >+ { >+ return EMFMapProperty.this; >+ } >+ >+ @Override >+ protected ISimplePropertyListener getListener() >+ { >+ return listener; >+ } >+ >+ @Override >+ protected EStructuralFeature getFeature() >+ { >+ return eStructuralFeature; >+ } >+ }; >+ } >+ >+ public String toString() >+ { >+ String s = EMFPropertyHelper.propertyName(eStructuralFeature) + "{:}"; //$NON-NLS-1$ >+ >+ s += "<" + EMFPropertyHelper.shortClassName((EStructuralFeature)getKeyType()) + ", " //$NON-NLS-1$ //$NON-NLS-2$ >+ + EMFPropertyHelper.shortClassName((EStructuralFeature)getValueType()) + ">"; //$NON-NLS-1$ >+ return s; >+ } >+} #P org.eclipse.emf.databinding.edit >Index: src/org/eclipse/emf/databinding/edit/DataBindingEditPlugin.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding.edit/src/org/eclipse/emf/databinding/edit/DataBindingEditPlugin.java,v >retrieving revision 1.1 >diff -u -r1.1 DataBindingEditPlugin.java >--- src/org/eclipse/emf/databinding/edit/DataBindingEditPlugin.java 16 Nov 2007 20:58:05 -0000 1.1 >+++ src/org/eclipse/emf/databinding/edit/DataBindingEditPlugin.java 19 May 2009 19:03:16 -0000 >@@ -20,7 +20,9 @@ > > import org.eclipse.emf.common.util.ResourceLocator; > >+ > /** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> > * This is the central singleton for the Data binding Edit plugin. > */ > public final class DataBindingEditPlugin extends EMFPlugin >@@ -40,7 +42,7 @@ > */ > public DataBindingEditPlugin() > { >- super(new ResourceLocator [] {}); >+ super(new ResourceLocator []{}); > } > > /** >Index: src/org/eclipse/emf/databinding/edit/EMFEditObservables.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding.edit/src/org/eclipse/emf/databinding/edit/EMFEditObservables.java,v >retrieving revision 1.3 >diff -u -r1.3 EMFEditObservables.java >--- src/org/eclipse/emf/databinding/edit/EMFEditObservables.java 22 Apr 2008 13:35:52 -0000 1.3 >+++ src/org/eclipse/emf/databinding/edit/EMFEditObservables.java 19 May 2009 19:03:16 -0000 >@@ -24,13 +24,16 @@ > import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables; > import org.eclipse.core.databinding.observable.set.IObservableSet; > import org.eclipse.core.databinding.observable.value.IObservableValue; >+ >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.IEMFValueProperty; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EStructuralFeature; > import org.eclipse.emf.edit.domain.EditingDomain; > >+ > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> > */ > public class EMFEditObservables > { >@@ -40,6 +43,7 @@ > * @param eObject the object to observe. > * @param eStructuralFeature the feature of the object to observe. > * @return an observable value for the given feature of the object. >+ * @deprecated you should use {@link EMFEditProperties#value(EditingDomain,FeaturePath)} and {@link IEMFValueProperty#observe(Object)} > */ > public static IObservableValue observeValue(EditingDomain domain, EObject eObject, EStructuralFeature eStructuralFeature) > { >@@ -53,6 +57,7 @@ > * @param eObject the object to observe. > * @param eStructuralFeature the feature of the object to observe. > * @return an observable value for the given feature of the object. >+ * @deprecated you should use {@link EMFEditProperties#value(EditingDomain,EStructuralFeature)} and {@link IEMFEditValueProperty#observe(Realm, Object)} > */ > public static IObservableValue observeValue(Realm realm, EditingDomain domain, EObject eObject, EStructuralFeature eStructuralFeature) > { >@@ -65,6 +70,7 @@ > * @param eObject the object to observe. > * @param eStructuralFeature the feature of the object to observe. > * @return an observable list for the given multi-valued feature of the object. >+ * @deprecated you should use {@link EMFEditProperties#list(EditingDomain,EStructuralFeature)} and {@link IEMFEditListProperty#observe(Object)} > */ > public static IObservableList observeList(EditingDomain domain, EObject eObject, EStructuralFeature eStructuralFeature) > { >@@ -78,6 +84,7 @@ > * @param eObject the object to observe. > * @param eStructuralFeature the feature of the object to observe. > * @return an observable list for the given multi-valued feature of the object. >+ * @deprecated you should use {@link EMFEditProperties#list(EditingDomain,EStructuralFeature)} and {@link IEMFEditListProperty#observe(Realm,Object)} > */ > public static IObservableList observeList(Realm realm, EditingDomain domain, EObject eObject, EStructuralFeature eStructuralFeature) > { >@@ -91,6 +98,7 @@ > * @param objects the objects to track. > * @param eStructuralFeature the feature for which to track the value. > * @return an observable map tracking the current value of the given feature for each object in the given set. >+ * @deprecated you should use {@link EMFEditProperties#value(EditingDomain,EStructuralFeature)} and {@link IEMFEditValueProperty#observeDetail(IObservableSet)} > */ > public static IObservableMap observeMap(EditingDomain domain, IObservableSet objects, EStructuralFeature eStructuralFeature) > { >@@ -104,6 +112,7 @@ > * @param objects the objects to track. > * @param eStructuralFeatures the features for which to track the value. > * @return an array of observable maps tracking the current value of the given features for each object in the given set. >+ * @deprecated you should use {@link EMFEditProperties#values(EditingDomain,EStructuralFeature...)} and {@link IEMFEditValueProperty#observeDetail(IObservableSet)} > */ > public static IObservableMap[] observeMaps(EditingDomain domain, IObservableSet objects, EStructuralFeature[] eStructuralFeatures) > { >@@ -123,8 +132,13 @@ > * @param eStructuralFeature the feature for which to track the value. > * @return an observable value that tracks the current value of the named property for the current value of the master observable value > * @see MasterDetailObservables#detailValue(IObservableValue, IObservableFactory, Object) >+ * @deprecated you should use {@link EMFEditProperties#value(EditingDomain,EStructuralFeature)} and {@link IEMFEditValueProperty#observeDetail(IObservableValue)} > */ >- public static IObservableValue observeDetailValue(Realm realm, EditingDomain domain, IObservableValue value, EStructuralFeature eStructuralFeature) >+ public static IObservableValue observeDetailValue( >+ Realm realm, >+ EditingDomain domain, >+ IObservableValue value, >+ EStructuralFeature eStructuralFeature) > { > return MasterDetailObservables.detailValue(value, valueFactory(realm, domain, eStructuralFeature), eStructuralFeature); > } >@@ -156,8 +170,13 @@ > * @param eStructuralFeature the feature for which to track the value. > * @return an observable value that tracks the current value of the named property for the current value of the master observable value > * @see MasterDetailObservables#detailList(IObservableValue, IObservableFactory, Object) >+ * @deprecated you should use {@link EMFEditProperties#value(EditingDomain,EStructuralFeature)} and {@link IEMFEditValueProperty#observeDetail(IObservableList)} > */ >- public static IObservableList observeDetailList(Realm realm, EditingDomain domain, IObservableValue value, EStructuralFeature eStructuralFeature) >+ public static IObservableList observeDetailList( >+ Realm realm, >+ EditingDomain domain, >+ IObservableValue value, >+ EStructuralFeature eStructuralFeature) > { > return MasterDetailObservables.detailList(value, listFactory(realm, domain, eStructuralFeature), eStructuralFeature); > } >@@ -172,8 +191,7 @@ > */ > public static IObservableFactory listFactory(final Realm realm, final EditingDomain domain, final EStructuralFeature eStructuralFeature) > { >- return >- new IObservableFactory() >+ return new IObservableFactory() > { > public IObservable createObservable(Object target) > { >@@ -191,13 +209,12 @@ > */ > public static IObservableFactory mapFactory(final EditingDomain domain, final EStructuralFeature eStructuralFeature) > { >- return >- new IObservableFactory() >+ return new IObservableFactory() > { > public IObservable createObservable(Object target) > { > return observeMap(domain, (IObservableSet)target, eStructuralFeature); > } > }; >- } >+ } > } >Index: src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableValue.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding.edit/src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableValue.java,v >retrieving revision 1.1 >diff -u -r1.1 EditingDomainEObjectObservableValue.java >--- src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableValue.java 16 Nov 2007 20:58:05 -0000 1.1 >+++ src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableValue.java 19 May 2009 19:03:17 -0000 >@@ -24,18 +24,45 @@ > import org.eclipse.emf.edit.command.SetCommand; > import org.eclipse.emf.edit.domain.EditingDomain; > >+ > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * @deprecated do not use this value it will be removed in 2.6 > */ > public class EditingDomainEObjectObservableValue extends EObjectObservableValue > { >+ /** >+ * The editing domain >+ */ > protected EditingDomain domain; > >+ /** >+ * Observe a list feature using a default realm >+ * >+ * @param domain >+ * the editing domain >+ * @param eObject >+ * the object instance >+ * @param eStructuralFeature >+ * the feature >+ */ > public EditingDomainEObjectObservableValue(EditingDomain domain, EObject eObject, EStructuralFeature eStructuralFeature) > { > this(Realm.getDefault(), domain, eObject, eStructuralFeature); > } >+ >+ /** >+ * Observe a list feature using a custom realm >+ * >+ * @param realm >+ * the realm >+ * @param domain >+ * the editing domain >+ * @param eObject >+ * the object instance >+ * @param eStructuralFeature >+ * the feature >+ */ > public EditingDomainEObjectObservableValue(Realm realm, EditingDomain domain, EObject eObject, EStructuralFeature eStructuralFeature) > { > super(realm, eObject, eStructuralFeature); >Index: src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableList.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding.edit/src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableList.java,v >retrieving revision 1.1 >diff -u -r1.1 EditingDomainEObjectObservableList.java >--- src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableList.java 16 Nov 2007 20:58:05 -0000 1.1 >+++ src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableList.java 19 May 2009 19:03:16 -0000 >@@ -30,25 +30,48 @@ > import org.eclipse.emf.edit.command.SetCommand; > import org.eclipse.emf.edit.domain.EditingDomain; > >+ > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * @deprecated do not use this list it will be removed in 2.6 > */ > public class EditingDomainEObjectObservableList extends EObjectObservableList > { >+ /** >+ * The editing domain >+ */ > protected EditingDomain domain; > >+ /** >+ * Observe a feature of the instance using the default realm >+ * @param domain >+ * the editing domain >+ * @param eObject >+ * the object >+ * @param eStructuralFeature >+ * the feature >+ */ > public EditingDomainEObjectObservableList(EditingDomain domain, EObject eObject, EStructuralFeature eStructuralFeature) > { > this(Realm.getDefault(), domain, eObject, eStructuralFeature); > } > >+ /** >+ * Observe a feature of the instance using the realm >+ * @param domain >+ * the editing domain >+ * @param realm >+ * >+ * @param eObject >+ * the object >+ * @param eStructuralFeature >+ * the feature >+ */ > public EditingDomainEObjectObservableList(Realm realm, EditingDomain domain, EObject eObject, EStructuralFeature eStructuralFeature) > { > super(realm, eObject, eStructuralFeature); > this.domain = domain; > } >- > > @Override > public synchronized void dispose() >@@ -57,6 +80,11 @@ > super.dispose(); > } > >+ /** >+ * Execute a command >+ * @param command the command to execute >+ * @return <code>true</code> if execute else <code>false</code> >+ */ > protected boolean execute(Command command) > { > if (command.canExecute()) >@@ -70,7 +98,6 @@ > } > } > >- > @Override > public boolean add(Object object) > { >Index: src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableMap.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding.edit/src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableMap.java,v >retrieving revision 1.1 >diff -u -r1.1 EditingDomainEObjectObservableMap.java >--- src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableMap.java 16 Nov 2007 20:58:05 -0000 1.1 >+++ src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableMap.java 19 May 2009 19:03:17 -0000 >@@ -24,20 +24,33 @@ > import org.eclipse.emf.edit.command.SetCommand; > import org.eclipse.emf.edit.domain.EditingDomain; > >+ > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * @deprecated do not use this map it will be removed in 2.6 > */ > public class EditingDomainEObjectObservableMap extends EObjectObservableMap > { >+ /** >+ * The editing domain >+ */ > protected EditingDomain domain; > >+ /** >+ * Create a new observable for the set of features >+ * @param domain >+ * the editing domain >+ * @param objects >+ * the objects to observe >+ * @param eStructuralFeature >+ * the feature >+ */ > public EditingDomainEObjectObservableMap(EditingDomain domain, IObservableSet objects, EStructuralFeature eStructuralFeature) > { > super(objects, eStructuralFeature); > this.domain = domain; > } >- >+ > @Override > protected Object doPut(Object key, Object value) > { >@@ -45,7 +58,7 @@ > Object result = eObject.eGet(eStructuralFeature); > Command command = SetCommand.create(domain, eObject, eStructuralFeature, value); > domain.getCommandStack().execute(command); >- >+ > eObject.eSet(eStructuralFeature, value); > return result; > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding.edit/META-INF/MANIFEST.MF,v >retrieving revision 1.6 >diff -u -r1.6 MANIFEST.MF >--- META-INF/MANIFEST.MF 21 Mar 2009 01:53:07 -0000 1.6 >+++ META-INF/MANIFEST.MF 19 May 2009 19:03:16 -0000 >@@ -11,6 +11,7 @@ > Export-Package: org.eclipse.emf.databinding.edit > Require-Bundle: org.eclipse.core.runtime, > org.eclipse.emf.databinding;visibility:=reexport, >- org.eclipse.emf.edit;visibility:=reexport >+ org.eclipse.emf.edit;visibility:=reexport, >+ org.eclipse.core.databinding.property;bundle-version="1.2.0" > Eclipse-LazyStart: true > Bundle-ActivationPolicy: lazy >Index: src/org/eclipse/emf/databinding/edit/internal/EMFEditMapProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditMapProperty.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditMapProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditMapProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,55 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 BestSolution.at and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl <tom.schindl@bestsolution.at> - Initial API and implementation (bug 262160) >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit.internal; >+ >+import java.util.Map; >+ >+import org.eclipse.core.databinding.observable.map.MapDiff; >+import org.eclipse.emf.common.command.Command; >+import org.eclipse.emf.databinding.internal.EMFMapProperty; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.command.SetCommand; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFEditMapProperty extends EMFMapProperty >+{ >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param editingDomain >+ * @param eStructuralFeature >+ */ >+ public EMFEditMapProperty(EditingDomain editingDomain, EStructuralFeature eStructuralFeature) >+ { >+ super(eStructuralFeature); >+ this.editingDomain = editingDomain; >+ } >+ >+ @SuppressWarnings("unchecked") >+ @Override >+ protected void doSetMap(Object source, Map map, MapDiff diff) >+ { >+ EObject eObject = (EObject)source; >+ Command command = SetCommand.create(editingDomain, eObject, getFeature(), map); >+ editingDomain.getCommandStack().execute(command); >+ } >+ >+} >\ No newline at end of file >Index: src/org/eclipse/emf/databinding/edit/IEMFEditListProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/IEMFEditListProperty.java >diff -N src/org/eclipse/emf/databinding/edit/IEMFEditListProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/IEMFEditListProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 195222) >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit; >+ >+import org.eclipse.core.databinding.property.list.IListProperty; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * >+ * An {@link IListProperty} extension interface with convenience methods for >+ * creating nested {@link EStructuralFeature}s >+ * >+ * @since 2.5 >+ * @noextend This interface is not intended to be extended by clients. >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public interface IEMFEditListProperty extends IEMFEditProperty, IListProperty >+{ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value nested feature. >+ * >+ * @param featurePath >+ * the nested feature to observe >+ * @return a nested combination of this property and the specified nested >+ * feature. >+ * @see #values(IEMFEditValueProperty) >+ */ >+ public IEMFEditListProperty values(FeaturePath featurePath); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value property. >+ * >+ * @param feature >+ * the feature >+ * @return a nested combination of this property and the specified nested >+ * feature. >+ */ >+ public IEMFEditListProperty values(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value property. The returned property will observe the specified value >+ * property for all elements observed by this list property. >+ * <p> >+ * Example: >+ * >+ * <pre> >+ * // Observes the list-typed "children" property of a Person object, >+ * // where the elements are Person objects >+ * IEMFListProperty children = EMFProperties >+ * .list(MyPackage.Literals.PERSON_CHILDREN); >+ * // Observes the string-typed "name" property of a Person object >+ * IEMFValueProperty name = EMFProperties.value(MyPackage.Literals.PERSON_NAME); >+ * // Observes the names of children of a Person object. >+ * IEMFListProperty childrenNames = children.values(name); >+ * </pre> >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * value property. >+ */ >+ public IEMFEditListProperty values(IEMFEditValueProperty property); >+} Index: src/org/eclipse/emf/databinding/edit/IEMFEditMapProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/IEMFEditMapProperty.java >diff -N src/org/eclipse/emf/databinding/edit/IEMFEditMapProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/IEMFEditMapProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,77 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 195222) >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit; >+ >+import java.util.Map; >+ >+import org.eclipse.core.databinding.property.map.IMapProperty; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * >+ * An {@link IMapProperty} extension interface with convenience methods for >+ * creating nested {@link EStructuralFeature} properties. >+ * >+ * @since 2.5 >+ * @noextend This interface is not intended to be extended by clients. >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public interface IEMFEditMapProperty extends IEMFEditProperty, IMapProperty >+{ >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * nested value feature. >+ * >+ * @param featurePath >+ * the nested value feature to observe >+ * @return a master-detail combination of this property and the specified >+ * nested value feature. >+ * @see #values(IEMFEditValueProperty) >+ */ >+ public IEMFEditMapProperty values(FeaturePath featurePath); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value feature. >+ * >+ * @param feature >+ * the value feature to observe >+ * @return a master-detail combination of this property and the specified >+ * nested value feature. >+ * @see #values(IEMFEditValueProperty) >+ */ >+ public IEMFEditMapProperty values(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value property. The returned property will observe the specified value >+ * property for all {@link Map#values() values} observed by this map >+ * property, mapping from this map property's {@link Map#keySet() key set} >+ * to the specified value property's value for each element in the master >+ * property's {@link Map#values() values} collection. >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * value property. >+ */ >+ public IEMFEditMapProperty values(IEMFEditValueProperty property); >+} Index: src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableMapDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableMapDecorator.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableMapDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableMapDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 BestSolution.at and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl <tom.schindl@bestsolution.at> - Initial API and implementation (bug 262160) >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit.internal; >+ >+import org.eclipse.core.databinding.observable.map.IObservableMap; >+import org.eclipse.emf.databinding.edit.IEMFEditObservable; >+import org.eclipse.emf.databinding.internal.EMFObservableMapDecorator; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * {@link IEMFEditObservable} decorator for an {@link IObservableMap}. >+ * >+ * @since 2.5 >+ */ >+public class EMFEditObservableMapDecorator extends EMFObservableMapDecorator implements IEMFEditObservable >+{ >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param editingDomain >+ * @param decorated >+ * @param eStructuralFeature >+ */ >+ public EMFEditObservableMapDecorator(EditingDomain editingDomain, IObservableMap decorated, EStructuralFeature eStructuralFeature) >+ { >+ super(decorated, eStructuralFeature); >+ this.editingDomain = editingDomain; >+ } >+ >+ public EditingDomain getEditingDomain() >+ { >+ return editingDomain; >+ } >+} Index: src/org/eclipse/emf/databinding/edit/IEMFEditObservable.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/IEMFEditObservable.java >diff -N src/org/eclipse/emf/databinding/edit/IEMFEditObservable.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/IEMFEditObservable.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,43 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2007 Brad Reynolds and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Brad Reynolds - initial API and implementation >+ * Brad Reynolds - bug 147515 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit; >+ >+ >+import org.eclipse.emf.databinding.IEMFObservable; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * Provides access to details of {@link EObject} observables. >+ * <p> >+ * This interface is not meant to be implemented by clients. >+ * </p> >+ * >+ * @since 2.5 >+ * @noextend This interface is not intended to be extended by clients. >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public interface IEMFEditObservable extends IEMFObservable >+{ >+ /** >+ * @return the editing domain to execute commands >+ */ >+ public EditingDomain getEditingDomain(); >+} Index: src/org/eclipse/emf/databinding/edit/internal/EMFEditListPropertyDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditListPropertyDecorator.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditListPropertyDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditListPropertyDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,113 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 BestSolution.at and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl <tom.schindl@bestsolution.at> - Initial API and implementation (bug 262160) >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit.internal; >+ >+import org.eclipse.core.databinding.observable.Realm; >+import org.eclipse.core.databinding.observable.list.IObservableList; >+import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; >+import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.core.databinding.property.list.IListProperty; >+import org.eclipse.core.databinding.property.list.ListProperty; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.edit.EMFEditProperties; >+import org.eclipse.emf.databinding.edit.IEMFEditListProperty; >+import org.eclipse.emf.databinding.edit.IEMFEditValueProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFEditListPropertyDecorator extends ListProperty implements IEMFEditListProperty >+{ >+ private final IListProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ private final EditingDomain editingDomain; >+ >+ >+ /** >+ * @param editingDomain >+ * @param delegate >+ * @param eStructuralFeature >+ */ >+ public EMFEditListPropertyDecorator(EditingDomain editingDomain, IListProperty delegate, EStructuralFeature eStructuralFeature) >+ { >+ this.delegate = delegate; >+ this.eStructuralFeature = eStructuralFeature; >+ this.editingDomain = editingDomain; >+ } >+ >+ public Object getElementType() >+ { >+ return delegate.getElementType(); >+ } >+ >+ public IEMFEditListProperty values(EStructuralFeature feature) >+ { >+ return values(FeaturePath.fromList(feature)); >+ } >+ >+ public IEMFEditListProperty values(FeaturePath featurePath) >+ { >+ return values(EMFEditProperties.value(editingDomain, featurePath)); >+ } >+ >+ public IEMFEditListProperty values(IEMFEditValueProperty property) >+ { >+ return new EMFEditListPropertyDecorator(editingDomain, super.values(property), property.getStructuralFeature()); >+ } >+ >+ public EStructuralFeature getStructuralFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ public IObservableList observe(Object source) >+ { >+ return new EMFEditObservableListDecorator(editingDomain, delegate.observe(source), eStructuralFeature); >+ } >+ >+ public IObservableList observe(Realm realm, Object source) >+ { >+ return new EMFEditObservableListDecorator(editingDomain, delegate.observe(realm, source), eStructuralFeature); >+ } >+ >+ public IObservableFactory listFactory() >+ { >+ return delegate.listFactory(); >+ } >+ >+ public IObservableFactory listFactory(Realm realm) >+ { >+ return delegate.listFactory(realm); >+ } >+ >+ public IObservableList observeDetail(IObservableValue master) >+ { >+ return new EMFEditObservableListDecorator(editingDomain, delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public String toString() >+ { >+ return delegate.toString(); >+ } >+ >+ public EditingDomain getEditingDomain() >+ { >+ return editingDomain; >+ } >+} Index: src/org/eclipse/emf/databinding/edit/internal/EMFEditValuePropertyDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditValuePropertyDecorator.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditValuePropertyDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditValuePropertyDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,150 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 BestSolution.at and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl <tom.schindl@bestsolution.at> - Initial API and implementation (bug 262160) >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit.internal; >+ >+import org.eclipse.core.databinding.observable.Realm; >+import org.eclipse.core.databinding.observable.list.IObservableList; >+import org.eclipse.core.databinding.observable.map.IObservableMap; >+import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; >+import org.eclipse.core.databinding.observable.set.IObservableSet; >+import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.core.databinding.property.value.IValueProperty; >+import org.eclipse.core.databinding.property.value.ValueProperty; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.edit.EMFEditProperties; >+import org.eclipse.emf.databinding.edit.IEMFEditListProperty; >+import org.eclipse.emf.databinding.edit.IEMFEditMapProperty; >+import org.eclipse.emf.databinding.edit.IEMFEditValueProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFEditValuePropertyDecorator extends ValueProperty implements IEMFEditValueProperty >+{ >+ private final IValueProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param editingDomain >+ * @param delegate >+ * @param eStructuralFeature >+ */ >+ public EMFEditValuePropertyDecorator(EditingDomain editingDomain, IValueProperty delegate, EStructuralFeature eStructuralFeature) >+ { >+ this.delegate = delegate; >+ this.eStructuralFeature = eStructuralFeature; >+ this.editingDomain = editingDomain; >+ } >+ >+ public EStructuralFeature getStructuralFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ public Object getValueType() >+ { >+ return delegate.getValueType(); >+ } >+ >+ public IEMFEditValueProperty value(EStructuralFeature feature) >+ { >+ return value(FeaturePath.fromList(feature)); >+ } >+ >+ public IEMFEditValueProperty value(FeaturePath featurePath) >+ { >+ return value(EMFEditProperties.value(editingDomain, featurePath)); >+ } >+ >+ public IEMFEditValueProperty value(IEMFEditValueProperty property) >+ { >+ return new EMFEditValuePropertyDecorator(editingDomain, super.value(property), property.getStructuralFeature()); >+ } >+ >+ public IEMFEditListProperty list(EStructuralFeature feature) >+ { >+ return list(EMFEditProperties.list(editingDomain, feature)); >+ } >+ >+ public IEMFEditListProperty list(IEMFEditListProperty property) >+ { >+ return new EMFEditListPropertyDecorator(editingDomain, super.list(property), property.getStructuralFeature()); >+ } >+ >+ public IEMFEditMapProperty map(EStructuralFeature feature) >+ { >+ return EMFEditProperties.map(editingDomain, feature); >+ } >+ >+ public IEMFEditMapProperty map(IEMFEditMapProperty property) >+ { >+ return new EMFEditMapPropertyDecorator(editingDomain, super.map(property), property.getStructuralFeature()); >+ } >+ >+ public IObservableValue observe(Object source) >+ { >+ return new EMFEditObservableValueDecorator(editingDomain, delegate.observe(source), eStructuralFeature); >+ } >+ >+ public IObservableValue observe(Realm realm, Object source) >+ { >+ return new EMFEditObservableValueDecorator(editingDomain, delegate.observe(realm, source), eStructuralFeature); >+ } >+ >+ public IObservableFactory valueFactory() >+ { >+ return delegate.valueFactory(); >+ } >+ >+ public IObservableFactory valueFactory(Realm realm) >+ { >+ return delegate.valueFactory(realm); >+ } >+ >+ public IObservableValue observeDetail(IObservableValue master) >+ { >+ return new EMFEditObservableValueDecorator(editingDomain, delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public IObservableList observeDetail(IObservableList master) >+ { >+ return new EMFEditObservableListDecorator(editingDomain, delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public IObservableMap observeDetail(IObservableSet master) >+ { >+ return new EMFEditObservableMapDecorator(editingDomain, delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public IObservableMap observeDetail(IObservableMap master) >+ { >+ return new EMFEditObservableMapDecorator(editingDomain, delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public String toString() >+ { >+ return delegate.toString(); >+ } >+ >+ public EditingDomain getEditingDomain() >+ { >+ return editingDomain; >+ } >+} Index: src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableValueDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableValueDecorator.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableValueDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableValueDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,50 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 BestSolution.at and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl <tom.schindl@bestsolution.at> - Initial API and implementation (bug 262160) >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit.internal; >+ >+import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.emf.databinding.edit.IEMFEditObservable; >+import org.eclipse.emf.databinding.internal.EMFObservableValueDecorator; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * {@link IEMFEditObservable} decorator for an {@link IObservableValue}. >+ * >+ * @since 2.5 >+ */ >+public class EMFEditObservableValueDecorator extends EMFObservableValueDecorator implements IEMFEditObservable >+{ >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param editingDomain >+ * @param decorated >+ * @param eStructuralFeature >+ */ >+ public EMFEditObservableValueDecorator(EditingDomain editingDomain, IObservableValue decorated, EStructuralFeature eStructuralFeature) >+ { >+ super(decorated, eStructuralFeature); >+ this.editingDomain = editingDomain; >+ } >+ >+ public EditingDomain getEditingDomain() >+ { >+ return editingDomain; >+ } >+ >+} Index: src/org/eclipse/emf/databinding/edit/IEMFEditProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/IEMFEditProperty.java >diff -N src/org/eclipse/emf/databinding/edit/IEMFEditProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/IEMFEditProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 194734) >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit; >+ >+import org.eclipse.emf.databinding.IEMFProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * An IProperty extension interface providing access to details of {@link EStructuralFeature} >+ * properties. >+ * >+ * @since 2.5 >+ * @noextend This interface is not intended to be extended by clients. >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public interface IEMFEditProperty extends IEMFProperty >+{ >+ /** >+ * @return the editing domain to execute commands >+ */ >+ public EditingDomain getEditingDomain(); >+} Index: src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableListDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableListDecorator.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableListDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableListDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 BestSolution.at and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl <tom.schindl@bestsolution.at> - Initial API and implementation (bug 262160) >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit.internal; >+ >+import org.eclipse.core.databinding.observable.list.IObservableList; >+import org.eclipse.emf.databinding.edit.IEMFEditObservable; >+import org.eclipse.emf.databinding.internal.EMFObservableListDecorator; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * {@link IEMFEditObservable} decorator for an {@link IObservableList}. >+ * >+ * @since 2.5 >+ */ >+public class EMFEditObservableListDecorator extends EMFObservableListDecorator implements IEMFEditObservable >+{ >+ >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param editingDomain >+ * @param decorated >+ * @param eStructuralFeature >+ */ >+ public EMFEditObservableListDecorator(EditingDomain editingDomain, IObservableList decorated, EStructuralFeature eStructuralFeature) >+ { >+ super(decorated, eStructuralFeature); >+ this.editingDomain = editingDomain; >+ } >+ >+ public EditingDomain getEditingDomain() >+ { >+ return editingDomain; >+ } >+ >+} Index: src/org/eclipse/emf/databinding/edit/internal/EMFEditMapPropertyDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditMapPropertyDecorator.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditMapPropertyDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditMapPropertyDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,117 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 BestSolution.at and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl <tom.schindl@bestsolution.at> - Initial API and implementation (bug 262160) >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit.internal; >+ >+import org.eclipse.core.databinding.observable.Realm; >+import org.eclipse.core.databinding.observable.map.IObservableMap; >+import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; >+import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.core.databinding.property.map.IMapProperty; >+import org.eclipse.core.databinding.property.map.MapProperty; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.edit.EMFEditProperties; >+import org.eclipse.emf.databinding.edit.IEMFEditMapProperty; >+import org.eclipse.emf.databinding.edit.IEMFEditValueProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFEditMapPropertyDecorator extends MapProperty implements IEMFEditMapProperty >+{ >+ private final IMapProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param editingDomain >+ * @param delegate >+ * @param eStructuralFeature >+ */ >+ public EMFEditMapPropertyDecorator(EditingDomain editingDomain, IMapProperty delegate, EStructuralFeature eStructuralFeature) >+ { >+ this.delegate = delegate; >+ this.eStructuralFeature = eStructuralFeature; >+ this.editingDomain = editingDomain; >+ } >+ >+ public EStructuralFeature getStructuralFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ public Object getKeyType() >+ { >+ return delegate.getKeyType(); >+ } >+ >+ public Object getValueType() >+ { >+ return delegate.getValueType(); >+ } >+ >+ public IEMFEditMapProperty values(EStructuralFeature feature) >+ { >+ return values(FeaturePath.fromList(feature)); >+ } >+ >+ public IEMFEditMapProperty values(FeaturePath featurePath) >+ { >+ return values(EMFEditProperties.value(editingDomain, featurePath)); >+ } >+ >+ public IEMFEditMapProperty values(IEMFEditValueProperty property) >+ { >+ return new EMFEditMapPropertyDecorator(editingDomain, super.values(property), property.getStructuralFeature()); >+ } >+ >+ public IObservableMap observe(Object source) >+ { >+ return new EMFEditObservableMapDecorator(editingDomain, delegate.observe(source), eStructuralFeature); >+ } >+ >+ public IObservableMap observe(Realm realm, Object source) >+ { >+ return new EMFEditObservableMapDecorator(editingDomain, delegate.observe(realm, source), eStructuralFeature); >+ } >+ >+ public IObservableFactory mapFactory() >+ { >+ return delegate.mapFactory(); >+ } >+ >+ public IObservableFactory mapFactory(Realm realm) >+ { >+ return delegate.mapFactory(realm); >+ } >+ >+ public IObservableMap observeDetail(IObservableValue master) >+ { >+ return new EMFEditObservableMapDecorator(editingDomain, delegate.observeDetail(master), eStructuralFeature); >+ } >+ >+ public String toString() >+ { >+ return delegate.toString(); >+ } >+ >+ public EditingDomain getEditingDomain() >+ { >+ return editingDomain; >+ } >+} Index: src/org/eclipse/emf/databinding/edit/EMFEditProperties.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/EMFEditProperties.java >diff -N src/org/eclipse/emf/databinding/edit/EMFEditProperties.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/EMFEditProperties.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,156 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 194734) >+ * Matthew Hall - bug 195222, 247997, 261843, 264307 >+ * Hasan Ceylan - patch in bug 262160 >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit; >+ >+import org.eclipse.core.databinding.property.list.IListProperty; >+import org.eclipse.core.databinding.property.map.IMapProperty; >+import org.eclipse.core.databinding.property.value.IValueProperty; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.edit.internal.EMFEditListProperty; >+import org.eclipse.emf.databinding.edit.internal.EMFEditListPropertyDecorator; >+import org.eclipse.emf.databinding.edit.internal.EMFEditMapProperty; >+import org.eclipse.emf.databinding.edit.internal.EMFEditMapPropertyDecorator; >+import org.eclipse.emf.databinding.edit.internal.EMFEditValueProperty; >+import org.eclipse.emf.databinding.edit.internal.EMFEditValuePropertyDecorator; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * >+ * A factory to create property bound attributes for {@link EObject} which use an {@link EditingDomain} to make changes to the {@link EObject} >+ * >+ * @since 2.5 >+ */ >+public class EMFEditProperties >+{ >+ /** >+ * Turn on debug logging >+ */ >+ public static final boolean DEBUG = false; >+ >+ /** >+ * Returns a value property for the given {@link EStructuralFeature} >+ * >+ * @param editingDomain the editing domain >+ * @param feature >+ * the feature instance the property is created for >+ * @return a value property for the given {@link EStructuralFeature} >+ */ >+ public static IEMFEditValueProperty value(EditingDomain editingDomain, EStructuralFeature feature) >+ { >+ return value(editingDomain, FeaturePath.fromList(feature)); >+ } >+ >+ /** >+ * Returns a value property for the given nested {@link EStructuralFeature} >+ * feature like the <code>name</code> of a <code>person</code> >+ * >+ * @param editingDomain the editing domain >+ * @param featurePath >+ * path to the feature >+ * @return a value property for the given {@link FeaturePath} >+ */ >+ public static IEMFEditValueProperty value(EditingDomain editingDomain, FeaturePath featurePath) >+ { >+ IValueProperty property; >+ property = new EMFEditValueProperty(editingDomain, featurePath.getFeaturePath()[0]); >+ >+ IEMFEditValueProperty featureProperty = new EMFEditValuePropertyDecorator(editingDomain, property, featurePath.getFeaturePath()[0]); >+ >+ for (int i = 1; i < featurePath.getFeaturePath().length; i++) >+ { >+ featureProperty = featureProperty.value(featurePath.getFeaturePath()[i]); >+ } >+ >+ return featureProperty; >+ } >+ >+ /** >+ * Returns multiple value properties for the given >+ * {@link EStructuralFeature}s >+ * >+ * @param editingDomain >+ * the editing domain >+ * @param features >+ * the feature instances the properties are created for >+ * @return an array of properties for the given {@link EStructuralFeature}s >+ */ >+ public static IEMFEditValueProperty[] values(EditingDomain editingDomain, EStructuralFeature... features) >+ { >+ IEMFEditValueProperty[] properties = new IEMFEditValueProperty [features.length]; >+ for (int i = 0; i < properties.length; i++) >+ properties[i] = value(editingDomain, features[i]); >+ return properties; >+ } >+ >+ /** >+ * Returns multiple value property for the given nested >+ * {@link EStructuralFeature} features like the <code>name</code> of a >+ * <code>person</code> >+ * >+ * @param editingDomain >+ * the editing domain >+ * @param featurePaths >+ * path to the feature >+ * @return an array of properties for the given {@link FeaturePath}s >+ */ >+ public static IEMFEditValueProperty[] values(EditingDomain editingDomain, FeaturePath... featurePaths) >+ { >+ IEMFEditValueProperty[] properties = new IEMFEditValueProperty [featurePaths.length]; >+ for (int i = 0; i < properties.length; i++) >+ properties[i] = value(editingDomain, featurePaths[i]); >+ return properties; >+ } >+ >+ /** >+ * Returns a list property for the given {@link EStructuralFeature} >+ * >+ * @param editingDomain >+ * the editing domain >+ * @param feature >+ * the feature instance the property is created for >+ * @return a list property for the given {@link EStructuralFeature} >+ */ >+ public static IEMFEditListProperty list(EditingDomain editingDomain, EStructuralFeature feature) >+ { >+ IListProperty property; >+ property = new EMFEditListProperty(editingDomain, feature); >+ return new EMFEditListPropertyDecorator(editingDomain, property, feature); >+ } >+ >+ /** >+ * Returns a map property for the given {@link EStructuralFeature}. Objects lacking the named property are treated the same as if the >+ * property always contains an empty map. >+ * >+ * @param editingDomain >+ * the editing domain >+ * @param feature >+ * the feature the property is created for >+ * @return a map property for the given {@link EStructuralFeature} >+ */ >+ public static IEMFEditMapProperty map(EditingDomain editingDomain, EStructuralFeature feature) >+ { >+ IMapProperty property; >+ property = new EMFEditMapProperty(editingDomain, feature); >+ return new EMFEditMapPropertyDecorator(editingDomain, property, feature); >+ } >+} Index: src/org/eclipse/emf/databinding/edit/internal/EMFEditValueProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditValueProperty.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditValueProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditValueProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,50 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 BestSolution.at and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl <tom.schindl@bestsolution.at> - Initial API and implementation (bug 262160) >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit.internal; >+ >+import org.eclipse.emf.common.command.Command; >+import org.eclipse.emf.databinding.internal.EMFValueProperty; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.command.SetCommand; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFEditValueProperty extends EMFValueProperty >+{ >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param editingDomain >+ * @param eStructuralFeature >+ */ >+ public EMFEditValueProperty(EditingDomain editingDomain, EStructuralFeature eStructuralFeature) >+ { >+ super(eStructuralFeature); >+ this.editingDomain = editingDomain; >+ } >+ >+ @Override >+ protected void doSetValue(Object source, Object value) >+ { >+ EObject eObject = (EObject)source; >+ Command command = SetCommand.create(editingDomain, eObject, getFeature(), value); >+ editingDomain.getCommandStack().execute(command); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/emf/databinding/edit/IEMFEditValueProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/IEMFEditValueProperty.java >diff -N src/org/eclipse/emf/databinding/edit/IEMFEditValueProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/IEMFEditValueProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,156 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Matthew Hall and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Matthew Hall - initial API and implementation (bug 195222) >+ * Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit; >+ >+import org.eclipse.core.databinding.property.value.IValueProperty; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> >+ * >+ * An {@link IValueProperty} extension interface with convenience methods for >+ * creating nested {@link EStructuralFeature} properties and does changes through the {@link EditingDomain} >+ * >+ * @since 2.5 >+ * @noextend This interface is not intended to be extended by clients. >+ * @noimplement This interface is not intended to be implemented by clients. >+ */ >+public interface IEMFEditValueProperty extends IEMFEditProperty, IValueProperty >+{ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * nested value feature. >+ * >+ * @param featurePath >+ * the nested value property to observe. >+ * @return a master-detail combination of this property and the specified >+ * nested value feature. >+ * @see #value(IEMFEditValueProperty) >+ */ >+ public IEMFEditValueProperty value(FeaturePath featurePath); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value feature. >+ * >+ * @param feature >+ * the nested value property to observe. >+ * @return a master-detail combination of this property and the specified >+ * value feature. >+ * @see #value(IEMFEditValueProperty) >+ */ >+ public IEMFEditValueProperty value(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value property. The returned property will observe the specified detail >+ * value property for the value of the master value property. >+ * <p> >+ * Example: >+ * >+ * <pre> >+ * // Observes the Node-typed "parent" property of a Node object >+ * IEMFValueProperty parent = EMFProperties.value(MyPackage.Literals.NODE_PARENT); >+ * // Observes the string-typed "name" property of a Node object >+ * IEMFValueProperty name = EMFProperties.value(MyPackage.Literals.NODE_NAME); >+ * // Observes the name of the parent of a Node object. >+ * IEMFValueProperty parentName = parent.value(name); >+ * </pre> >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * value property. >+ */ >+ public IEMFEditValueProperty value(IEMFEditValueProperty property); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * list feature. >+ * >+ * @param feature >+ * the list feature to observe >+ * @return a master-detail combination of this property and the specified >+ * list feature. >+ * @see #list(IEMFEditListProperty) >+ */ >+ public IEMFEditListProperty list(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * list property. The returned property will observe the specified list >+ * property for the value of the master property. >+ * <p> >+ * Example: >+ * >+ * <pre> >+ * // Observes the Node-typed "parent" property of a Node object. >+ * IEMFValueProperty parent = EMFProperties.value(MyPackage.Literals.NODE_PARENT); >+ * // Observes the List-typed "children" property of a Node object >+ * // where the elements are Node objects >+ * IEMFListProperty children = EMFProperties.list(MyPackage.Literals.NODE_CHILDREN); >+ * // Observes the children of the parent (siblings) of a Node object. >+ * IEMFListProperty siblings = parent.list(children); >+ * </pre> >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * list property. >+ */ >+ public IEMFEditListProperty list(IEMFEditListProperty property); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * map feature. >+ * >+ * @param feature >+ * the map property to observe >+ * @return a master-detail combination of this property and the specified >+ * map feature. >+ * @see #map(IEMFEditMapProperty) >+ */ >+ public IEMFEditMapProperty map(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * map property. The returned property will observe the specified map >+ * property for the value of the master property. >+ * <p> >+ * Example: >+ * >+ * <pre> >+ * // Observes the Contact-typed "supervisor" property of a >+ * // Contact class >+ * IEMFValueProperty supervisor = EMFProperties.value(MyPackage.Literals.CONTACT_SUPERVISOR); >+ * // Observes the property "phoneNumbers" of a Contact object--a property mapping >+ * // from PhoneNumberType to PhoneNumber "set-typed "children", >+ * IEMFMapProperty phoneNumbers = EMFProperties.map(MyPackage.Literals.CONTACT_PHONENUMBERS); >+ * // Observes the phone numbers of a contact's supervisor: >+ * IEMFMapProperty supervisorPhoneNumbers = supervisor.map(phoneNumbers); >+ * </pre> >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * map property. >+ */ >+ public IEMFEditMapProperty map(IEMFEditMapProperty property); >+} Index: src/org/eclipse/emf/databinding/edit/internal/EMFEditListProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditListProperty.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditListProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditListProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,106 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2009 BestSolution.at and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tom Schindl <tom.schindl@bestsolution.at> - Initial API and implementation (bug 262160) >+ * </copyright> >+ * >+ * $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ >+ */ >+package org.eclipse.emf.databinding.edit.internal; >+ >+import java.util.Collections; >+import java.util.List; >+ >+import org.eclipse.core.databinding.observable.list.ListDiff; >+import org.eclipse.core.databinding.observable.list.ListDiffVisitor; >+import org.eclipse.emf.common.command.Command; >+import org.eclipse.emf.databinding.internal.EMFListProperty; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.command.AddCommand; >+import org.eclipse.emf.edit.command.MoveCommand; >+import org.eclipse.emf.edit.command.RemoveCommand; >+import org.eclipse.emf.edit.command.ReplaceCommand; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+ >+/** >+ * @since 2.5 >+ */ >+public class EMFEditListProperty extends EMFListProperty >+{ >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param editingDomain >+ * @param eStructuralFeature >+ */ >+ public EMFEditListProperty(EditingDomain editingDomain, EStructuralFeature eStructuralFeature) >+ { >+ super(eStructuralFeature); >+ this.editingDomain = editingDomain; >+ } >+ >+ @SuppressWarnings("unchecked") >+ @Override >+ protected void doSetList(Object source, List list, ListDiff diff) >+ { >+ diff.accept(new ListVisitorImpl((EObject)source, getFeature())); >+ } >+ >+ private class ListVisitorImpl extends ListDiffVisitor >+ { >+ private EObject eObj; >+ private EStructuralFeature feature; >+ >+ private ListVisitorImpl(EObject eObj, EStructuralFeature feature) >+ { >+ this.eObj = eObj; >+ this.feature = feature; >+ } >+ >+ @Override >+ public void handleAdd(int index, Object element) >+ { >+ execute(AddCommand.create(editingDomain, eObj, feature, element, index)); >+ } >+ >+ @Override >+ public void handleMove(int oldIndex, int newIndex, Object element) >+ { >+ execute(MoveCommand.create(editingDomain, eObj, feature, element, newIndex)); >+ } >+ >+ @Override >+ public void handleReplace(int index, Object oldElement, Object newElement) >+ { >+ execute(ReplaceCommand.create(editingDomain, eObj, feature, oldElement, Collections.singleton(newElement))); >+ } >+ >+ @Override >+ public void handleRemove(int index, Object element) >+ { >+ execute(RemoveCommand.create(editingDomain, eObj, feature, element)); >+ } >+ >+ private boolean execute(Command command) >+ { >+ if (command.canExecute()) >+ { >+ editingDomain.getCommandStack().execute(command); >+ return true; >+ } >+ else >+ { >+ return false; >+ } >+ } >+ } >+} >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 262160
:
123633
|
124701
|
125052
|
125836
|
125841
|
132310
|
132579
|
132670
|
134185
|
134272
|
134465
|
134529
|
134710
|
136365
|
136370