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 125836 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]
Databinding patch
databinding.patch (text/plain), 62.08 KB, created by
Thomas Schindl
on 2009-02-16 19:16:16 EST
(
hide
)
Description:
Databinding patch
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2009-02-16 19:16:16 EST
Size:
62.08 KB
patch
obsolete
>? .settings >? src/org/eclipse/emf/databinding/internal >? src/org/eclipse/emf/databinding/properties >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 17 Feb 2009 00:18:26 -0000 >@@ -8,7 +8,8 @@ > 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.properties > Require-Bundle: org.eclipse.core.runtime, > org.eclipse.emf.ecore;visibility:=reexport, > org.eclipse.core.databinding;visibility:=reexport >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 17 Feb 2009 00:18:26 -0000 >@@ -9,43 +9,84 @@ > * > * Contributors: > * IBM - Initial API and implementation >- * >+ * Tom Schindl<tom.schindl@bestsolution.at> > * </copyright> > * > * $Id: EMFDataBindingContext.java,v 1.1 2007/11/16 21:25:21 emerks Exp $ > */ > package org.eclipse.emf.databinding; > >+import org.eclipse.core.databinding.Binding; > import org.eclipse.core.databinding.DataBindingContext; > import org.eclipse.core.databinding.UpdateValueStrategy; > import org.eclipse.core.databinding.observable.Realm; >+import org.eclipse.core.databinding.observable.list.IObservableList; > import org.eclipse.core.databinding.observable.value.IObservableValue; > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p> >+ * <b>PROVISIONAL This API is subject to arbitrary change, including renaming or >+ * removal.</b> >+ * </p> >+ * >+ * A DataBindingContext is the point of contact for the creation and management >+ * of {@link Binding bindings}, and aggregates validation statuses of its >+ * bindings, or more generally, its validation status providers. >+ * <p> >+ * A DataBindingContext provides the following abilities: >+ * <ul> >+ * <li>Ability to create bindings between {@link IObservableValue observable >+ * values}.</li> >+ * <li>Ability to create bindings between {@link IObservableList observable >+ * lists}.</li> >+ * <li>Access to the bindings created by the instance.</li> >+ * <li>Access to the list of validation status providers (this includes all >+ * bindings).</li> >+ * </ul> >+ * </p> >+ * <p> >+ * Multiple contexts can be used at any point in time. One strategy for the >+ * management of contexts is the aggregation of validation statuses. For example >+ * an <code>IWizardPage</code> could use a single context and the statuses could >+ * be aggregated to set the page status and fulfillment. Each page in the >+ * <code>IWizard</code> would have its own context instance. >+ * </p> >+ * >+ * @since 1.0 > */ >-public class EMFDataBindingContext extends DataBindingContext >-{ >- public EMFDataBindingContext() >- { >- this(Realm.getDefault()); >- } >+public class EMFDataBindingContext extends DataBindingContext { >+ /** >+ * Creates a data binding context, using the current default realm for the >+ * validation observables. >+ * >+ * @see Realm >+ */ >+ public EMFDataBindingContext() { >+ this(Realm.getDefault()); >+ } >+ >+ /** >+ * Creates a data binding context using the given realm for the validation >+ * observables. >+ * >+ * @param validationRealm >+ * the realm to be used for the validation observables >+ * >+ * @see Realm >+ */ >+ public EMFDataBindingContext(Realm validationRealm) { >+ super(validationRealm); >+ } > >- public EMFDataBindingContext(Realm validationRealm) >- { >- super(validationRealm); >- } >+ @Override >+ protected UpdateValueStrategy createModelToTargetUpdateValueStrategy( >+ IObservableValue fromValue, IObservableValue toValue) { >+ return new EMFUpdateValueStrategy(); >+ } > >- @Override >- protected UpdateValueStrategy createModelToTargetUpdateValueStrategy(IObservableValue fromValue, IObservableValue toValue) >- { >- return new EMFUpdateValueStrategy(); >- } >- >- @Override >- protected UpdateValueStrategy createTargetToModelUpdateValueStrategy(IObservableValue fromValue, IObservableValue toValue) >- { >- return new EMFUpdateValueStrategy(); >- } >+ @Override >+ protected UpdateValueStrategy createTargetToModelUpdateValueStrategy( >+ IObservableValue fromValue, IObservableValue toValue) { >+ return new EMFUpdateValueStrategy(); >+ } > } >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 17 Feb 2009 00:18:26 -0000 >@@ -10,14 +10,13 @@ > * Contributors: > * IBM - Initial API and implementation > * Trevor S. Kaufman - Bug 215131 - added mapFactory >- * >+ * Tom Schindl<tom.schindl@bestsolution.at> > * </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.IObservable; > import org.eclipse.core.databinding.observable.Realm; > import org.eclipse.core.databinding.observable.list.IObservableList; >@@ -26,169 +25,227 @@ > 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 This API is subject to arbitrary change, including renaming or >+ * removal.</b> >+ * </p> >+ * A factory for creating observable objects of Java objects that conform to the >+ * <a href="http://java.sun.com/products/javabeans/docs/spec.html">JavaBean >+ * specification</a> for bound properties. >+ * >+ * @since 1.0 > */ >-public class EMFObservables >-{ >- /** >- * Returns an observable value for the given feature of the object. >- * @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. >- */ >- public static IObservableValue observeValue(EObject eObject, EStructuralFeature eStructuralFeature) >- { >- return new EObjectObservableValue(eObject, eStructuralFeature); >- } >- >- /** >- * Returns an observable value for the given feature of the object. >- * @param realm the realm in which to observe. >- * @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. >- */ >- public static IObservableValue observeValue(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature) >- { >- return new EObjectObservableValue(realm, eObject, eStructuralFeature); >- } >- >- /** >- * Returns an observable list for the given multi-valued feature of the object. >- * @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. >- */ >- public static IObservableList observeList(EObject eObject, EStructuralFeature eStructuralFeature) >- { >- return new EObjectObservableList(eObject, eStructuralFeature); >- } >- >- /** >- * Returns an observable list for the given multi-valued feature of the object. >- * @param realm the realm in which to observe. >- * @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. >- */ >- public static IObservableList observeList(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature) >- { >- return new EObjectObservableList(realm, eObject, eStructuralFeature); >- } >- >- /** >- * Returns an observable map in the default realm >- * tracking the current value of the given feature for each object in the given set. >- * @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. >- */ >- public static IObservableMap observeMap(IObservableSet objects, EStructuralFeature eStructuralFeature) >- { >- return new EObjectObservableMap(objects, eStructuralFeature); >- } >- >- /** >- * Returns an array of observable maps in the default realm >- * tracking the current value of the given features for each object in the given set. >- * @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. >- */ >- public static IObservableMap[] observeMaps(IObservableSet objects, EStructuralFeature[] eStructuralFeatures) >- { >- IObservableMap[] result = new IObservableMap [eStructuralFeatures.length]; >- for (int i = 0; i < eStructuralFeatures.length; i++) >- { >- result[i] = observeMap(objects, eStructuralFeatures[i]); >- } >- return result; >- } >- >- /** >- * Returns an observable value that tracks the current value of the feature of the current value of the master observable value. >- * @param realm the realm in which to observe. >- * @param value the master observable value. >- * @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) >- */ >- public static IObservableValue observeDetailValue(Realm realm, IObservableValue value, EStructuralFeature eStructuralFeature) >- { >- return MasterDetailObservables.detailValue(value, valueFactory(realm, eStructuralFeature), eStructuralFeature); >- } >- >- /** >- * Returns a factory for creating observable values >- * tracking the value of the given feature of a particular {@link EObject object}. >- * @param realm the realm in which to observe. >- * @param eStructuralFeature the feature for which to track the value. >- * @return an observable factory. >- */ >- public static IObservableFactory valueFactory(final Realm realm, final EStructuralFeature eStructuralFeature) >- { >- return >- new IObservableFactory() >- { >- public IObservable createObservable(Object target) >- { >- return observeValue(realm, (EObject)target, eStructuralFeature); >- } >- }; >- } >- >- /** >- * Returns an observable list that tracks the current value of the feature of the current value of the master observable value. >- * @param realm the realm in which to observe. >- * @param value the master observable value. >- * @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) >- */ >- public static IObservableList observeDetailList(Realm realm, IObservableValue value, EStructuralFeature eStructuralFeature) >- { >- return MasterDetailObservables.detailList(value, listFactory(realm, eStructuralFeature), eStructuralFeature); >- } >- >- /** >- * Returns a factory for creating observable lists >- * tracking the value of the given feature of a particular {@link EObject object}. >- * @param realm the realm in which to observe. >- * @param eStructuralFeature the feature for which to track the value. >- * @return an observable factory. >- */ >- public static IObservableFactory listFactory(final Realm realm, final EStructuralFeature eStructuralFeature) >- { >- return >- new IObservableFactory() >- { >- public IObservable createObservable(Object target) >- { >- return observeList(realm, (EObject)target, eStructuralFeature); >- } >- }; >- } >- >- /** >- * Returns a factory for creating observable maps >- * tracking the value of the given feature of a particular {@link EObject object}. >- * @param eStructuralFeature the feature for which to track the value. >- * @return an observable factory. >- */ >- public static IObservableFactory mapFactory(final EStructuralFeature eStructuralFeature) >- { >- return >- new IObservableFactory() >- { >- public IObservable createObservable(Object target) >- { >- return observeMap((IObservableSet)target, eStructuralFeature); >- } >- }; >- } >+public class EMFObservables { >+ /** >+ * >+ */ >+ public static final boolean DEBUG = false; >+ >+ /** >+ * Returns an observable value for the given feature of the object. >+ * >+ * @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. >+ */ >+ public static IObservableValue observeValue(EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ return new EObjectObservableValue(eObject, eStructuralFeature); >+ } >+ >+ /** >+ * Returns an observable value for the given feature of the object. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @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. >+ */ >+ public static IObservableValue observeValue(Realm realm, EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ return new EObjectObservableValue(realm, eObject, eStructuralFeature); >+ } >+ >+ /** >+ * Returns an observable list for the given multi-valued feature of the >+ * object. >+ * >+ * @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. >+ */ >+ public static IObservableList observeList(EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ return new EObjectObservableList(eObject, eStructuralFeature); >+ } >+ >+ /** >+ * Returns an observable list for the given multi-valued feature of the >+ * object. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @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. >+ */ >+ public static IObservableList observeList(Realm realm, EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ return new EObjectObservableList(realm, eObject, eStructuralFeature); >+ } >+ >+ /** >+ * Returns an observable map in the default realm tracking the current value >+ * of the given feature for each object in the given set. >+ * >+ * @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. >+ */ >+ public static IObservableMap observeMap(IObservableSet objects, >+ EStructuralFeature eStructuralFeature) { >+ return new EObjectObservableMap(objects, eStructuralFeature); >+ } >+ >+ /** >+ * Returns an array of observable maps in the default realm tracking the >+ * current value of the given features for each object in the given set. >+ * >+ * @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. >+ */ >+ public static IObservableMap[] observeMaps(IObservableSet objects, >+ EStructuralFeature[] eStructuralFeatures) { >+ IObservableMap[] result = new IObservableMap[eStructuralFeatures.length]; >+ for (int i = 0; i < eStructuralFeatures.length; i++) { >+ result[i] = observeMap(objects, eStructuralFeatures[i]); >+ } >+ return result; >+ } >+ >+ /** >+ * Returns an observable value that tracks the current value of the feature >+ * of the current value of the master observable value. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @param value >+ * the master observable value. >+ * @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) >+ */ >+ public static IObservableValue observeDetailValue(Realm realm, >+ IObservableValue value, EStructuralFeature eStructuralFeature) { >+ return MasterDetailObservables.detailValue(value, valueFactory(realm, >+ eStructuralFeature), eStructuralFeature); >+ } >+ >+ /** >+ * Returns a factory for creating observable values tracking the value of >+ * the given feature of a particular {@link EObject object}. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @param eStructuralFeature >+ * the feature for which to track the value. >+ * @return an observable factory. >+ */ >+ public static IObservableFactory valueFactory(final Realm realm, >+ final EStructuralFeature eStructuralFeature) { >+ return new IObservableFactory() { >+ public IObservable createObservable(Object target) { >+ return observeValue(realm, (EObject) target, eStructuralFeature); >+ } >+ }; >+ } >+ >+ /** >+ * Returns an observable list that tracks the current value of the feature >+ * of the current value of the master observable value. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @param value >+ * the master observable value. >+ * @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) >+ */ >+ public static IObservableList observeDetailList(Realm realm, >+ IObservableValue value, EStructuralFeature eStructuralFeature) { >+ return MasterDetailObservables.detailList(value, listFactory(realm, >+ eStructuralFeature), eStructuralFeature); >+ } >+ >+ /** >+ * Returns a factory for creating observable lists tracking the value of the >+ * given feature of a particular {@link EObject object}. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @param eStructuralFeature >+ * the feature for which to track the value. >+ * @return an observable factory. >+ */ >+ public static IObservableFactory listFactory(final Realm realm, >+ final EStructuralFeature eStructuralFeature) { >+ return new IObservableFactory() { >+ public IObservable createObservable(Object target) { >+ return observeList(realm, (EObject) target, eStructuralFeature); >+ } >+ }; >+ } >+ >+ /** >+ * Returns a factory for creating observable maps tracking the value of the >+ * given feature of a particular {@link EObject object}. >+ * >+ * @param eStructuralFeature >+ * the feature for which to track the value. >+ * @return an observable factory. >+ */ >+ public static IObservableFactory mapFactory( >+ final EStructuralFeature eStructuralFeature) { >+ return new IObservableFactory() { >+ public IObservable createObservable(Object target) { >+ return observeMap((IObservableSet) target, eStructuralFeature); >+ } >+ }; >+ } >+ >+ public static IObservableList observeResourceContents(Resource resource) { >+ return new EWritableList<EObject>((NotifyingList<EObject>) resource.getContents()); >+ } > } >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 17 Feb 2009 00:18:26 -0000 >@@ -9,78 +9,122 @@ > * > * Contributors: > * IBM - Initial API and implementation >- * >+ * Tom Schindl<tom.schindl@bestsolution.at> > * </copyright> > * > * $Id: EMFUpdateListStrategy.java,v 1.1 2007/11/16 21:25:21 emerks Exp $ > */ > package org.eclipse.emf.databinding; > >+import org.eclipse.core.databinding.Binding; >+import org.eclipse.core.databinding.DataBindingContext; > import org.eclipse.core.databinding.UpdateListStrategy; > import org.eclipse.core.databinding.conversion.Converter; > import org.eclipse.core.databinding.conversion.IConverter; >+import org.eclipse.core.databinding.observable.list.IObservableList; > import org.eclipse.emf.ecore.EAttribute; > 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 This API is subject to arbitrary change, including renaming or >+ * removal.</b> >+ * </p> >+ * Customizes a {@link Binding} between two {@link IObservableList observable >+ * lists}. The following behaviors can be customized via the strategy: >+ * <ul> >+ * <li>Conversion</li> >+ * <li>Automatic processing</li> >+ * </ul> >+ * <p> >+ * Conversion:<br/> >+ * When elements are added they can be {@link #convert(Object) converted} to the >+ * destination element type. >+ * </p> >+ * <p> >+ * Automatic processing:<br/> >+ * The processing to perform when the source observable changes. This behavior >+ * is configured via policies provided on construction of the strategy (e.g. >+ * {@link #POLICY_NEVER}, {@link #POLICY_ON_REQUEST}, {@link #POLICY_UPDATE}). >+ * </p> >+ * >+ * >+ * @see DataBindingContext#bindList(IObservableList, IObservableList, >+ * UpdateListStrategy, UpdateListStrategy) >+ * @see IConverter >+ * @since 1.0 > */ >-public class EMFUpdateListStrategy extends UpdateListStrategy >-{ >- public EMFUpdateListStrategy() >- { >- this(true, POLICY_UPDATE); >- } >+public class EMFUpdateListStrategy extends UpdateListStrategy { >+ /** >+ * Creates a new update list strategy for automatically updating the >+ * destination observable list whenever the source observable list changes. >+ * A default converter will be provided. The defaults can be changed by >+ * calling one of the setter methods. >+ */ >+ public EMFUpdateListStrategy() { >+ this(true, POLICY_UPDATE); >+ } >+ >+ /** >+ * Creates a new update list strategy with a configurable update policy. A >+ * default converter will be provided. The defaults can be changed by >+ * calling one of the setter methods. >+ * >+ * @param updatePolicy >+ * one of {@link #POLICY_NEVER}, {@link #POLICY_ON_REQUEST}, or >+ * {@link #POLICY_UPDATE} >+ */ >+ public EMFUpdateListStrategy(int updatePolicy) { >+ this(true, updatePolicy); >+ } > >- public EMFUpdateListStrategy(int updatePolicy) >- { >- this(true, updatePolicy); >- } >+ /** >+ * Creates a new update list strategy with a configurable update policy. A >+ * default converter will be provided if <code>provideDefaults</code> is >+ * <code>true</code>. The defaults can be changed by calling one of the >+ * setter methods. >+ * >+ * @param provideDefaults >+ * if <code>true</code>, default validators and a default >+ * converter will be provided based on the observable list's >+ * type. >+ * @param updatePolicy >+ * one of {@link #POLICY_NEVER}, {@link #POLICY_ON_REQUEST}, or >+ * {@link #POLICY_UPDATE} >+ */ >+ public EMFUpdateListStrategy(boolean provideDefaults, int updatePolicy) { >+ super(provideDefaults, updatePolicy); >+ } > >- public EMFUpdateListStrategy(boolean provideDefaults, int updatePolicy) >- { >- super(provideDefaults, updatePolicy); >- } >- >- @Override >- protected IConverter createConverter(Object fromType, Object toType) >- { >- if (fromType == String.class) >- { >- if (toType instanceof EAttribute) >- { >- final EAttribute eAttribute = (EAttribute)toType; >- final EDataType eDataType = eAttribute.getEAttributeType(); >- final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance(); >- return >- new Converter(fromType, toType) >- { >- public Object convert(Object fromObject) >- { >- return eFactory.createFromString(eDataType, (String)fromObject); >- } >- }; >- } >- } >- else if (toType == String.class) >- { >- if (fromType instanceof EAttribute) >- { >- final EAttribute eAttribute = (EAttribute)fromType; >- final EDataType eDataType = eAttribute.getEAttributeType(); >- final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance(); >- return >- new Converter(fromType, toType) >- { >- public Object convert(Object fromObject) >- { >- return eFactory.convertToString(eDataType, fromObject); >- } >- }; >- } >- } >- return super.createConverter(fromType, toType); >- } >+ @Override >+ protected IConverter createConverter(Object fromType, Object toType) { >+ if (fromType == String.class) { >+ if (toType instanceof EAttribute) { >+ final EAttribute eAttribute = (EAttribute) toType; >+ final EDataType eDataType = eAttribute.getEAttributeType(); >+ final EFactory eFactory = eDataType.getEPackage() >+ .getEFactoryInstance(); >+ return new Converter(fromType, toType) { >+ public Object convert(Object fromObject) { >+ return eFactory.createFromString(eDataType, >+ (String) fromObject); >+ } >+ }; >+ } >+ } else if (toType == String.class) { >+ if (fromType instanceof EAttribute) { >+ final EAttribute eAttribute = (EAttribute) fromType; >+ final EDataType eDataType = eAttribute.getEAttributeType(); >+ final EFactory eFactory = eDataType.getEPackage() >+ .getEFactoryInstance(); >+ return new Converter(fromType, toType) { >+ public Object convert(Object fromObject) { >+ return eFactory.convertToString(eDataType, fromObject); >+ } >+ }; >+ } >+ } >+ return super.createConverter(fromType, toType); >+ } > } >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 17 Feb 2009 00:18:27 -0000 >@@ -9,7 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >- * >+ * Tom Schindl<tom.schindl@bestsolution.at> > * </copyright> > * > * $Id: EMFUpdateValueStrategy.java,v 1.2 2008/02/22 12:10:18 emerks Exp $ >@@ -19,103 +19,164 @@ > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.core.databinding.Binding; >+import org.eclipse.core.databinding.DataBindingContext; > import org.eclipse.core.databinding.UpdateValueStrategy; > import org.eclipse.core.databinding.conversion.Converter; > import org.eclipse.core.databinding.conversion.IConverter; >+import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.core.databinding.validation.IValidator; > import org.eclipse.emf.ecore.EAttribute; > 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 This API is subject to arbitrary change, including renaming or >+ * removal.</b> >+ * </p> >+ * Customizes a {@link Binding} between two {@link IObservableValue observable >+ * values}. The following behaviors can be customized via the strategy: >+ * <ul> >+ * <li>Validation</li> >+ * <li>Conversion</li> >+ * <li>Automatic processing</li> >+ * </ul> >+ * <p> >+ * The update phases are: >+ * <ol> >+ * <li>Validate after get - {@link #validateAfterGet(Object)}</li> >+ * <li>Conversion - {@link #convert(Object)}</li> >+ * <li>Validate after conversion - {@link #validateAfterConvert(Object)}</li> >+ * <li>Validate before set - {@link #validateBeforeSet(Object)}</li> >+ * <li>Value set - {@link #doSet(IObservableValue, Object)}</li> >+ * </ol> >+ * </p> >+ * <p> >+ * Validation:<br/> >+ * {@link IValidator Validators} validate the value at multiple phases in the >+ * update process. Statuses returned from validators are aggregated into a >+ * <code>MultiStatus</code> until a status of <code>ERROR</code> or >+ * <code>CANCEL</code> is encountered. Either of these statuses will abort the >+ * update process. These statuses are available as the >+ * {@link Binding#getValidationStatus() binding validation status}. >+ * </p> >+ * <p> >+ * Conversion:<br/> >+ * A {@link IConverter converter} will convert the value from the type of the >+ * source observable into the type of the destination. The strategy has the >+ * ability to default converters for common scenarios. >+ * </p> >+ * <p> >+ * Automatic processing:<br/> >+ * The processing to perform when the source observable changes. This behavior >+ * is configured via policies provided on construction of the strategy (e.g. >+ * {@link #POLICY_NEVER}, {@link #POLICY_CONVERT}, {@link #POLICY_ON_REQUEST}, >+ * {@link #POLICY_UPDATE}). >+ * </p> >+ * >+ * @see DataBindingContext#bindValue(IObservableValue, IObservableValue, >+ * UpdateValueStrategy, UpdateValueStrategy) >+ * @see Binding#getValidationStatus() >+ * @see IValidator >+ * @see IConverter >+ * @since 1.0 > */ >-public class EMFUpdateValueStrategy extends UpdateValueStrategy >-{ >- public EMFUpdateValueStrategy() >- { >- this(true, POLICY_UPDATE); >- } >+public class EMFUpdateValueStrategy extends UpdateValueStrategy { >+ /** >+ * Creates a new update value strategy for automatically updating the >+ * destination observable value whenever the source observable value >+ * changes. Default validators and a default converter will be provided. The >+ * defaults can be changed by calling one of the setter methods. >+ */ >+ public EMFUpdateValueStrategy() { >+ this(true, POLICY_UPDATE); >+ } >+ >+ /** >+ * Creates a new update value strategy with a configurable update policy. >+ * Default validators and a default converter will be provided. The defaults >+ * can be changed by calling one of the setter methods. >+ * >+ * @param updatePolicy >+ * one of {@link #POLICY_NEVER}, {@link #POLICY_ON_REQUEST}, >+ * {@link #POLICY_CONVERT}, or {@link #POLICY_UPDATE} >+ */ >+ public EMFUpdateValueStrategy(int updatePolicy) { >+ this(true, updatePolicy); >+ } > >- public EMFUpdateValueStrategy(int updatePolicy) >- { >- this(true, updatePolicy); >- } >+ /** >+ * Creates a new update value strategy with a configurable update policy. >+ * Default validators and a default converter will be provided if >+ * <code>provideDefaults</code> is <code>true</code>. The defaults can >+ * be changed by calling one of the setter methods. >+ * >+ * @param provideDefaults >+ * if <code>true</code>, default validators and a default >+ * converter will be provided based on the observable value's >+ * type. >+ * @param updatePolicy >+ * one of {@link #POLICY_NEVER}, {@link #POLICY_ON_REQUEST}, >+ * {@link #POLICY_CONVERT}, or {@link #POLICY_UPDATE} >+ */ >+ public EMFUpdateValueStrategy(boolean provideDefaults, int updatePolicy) { >+ super(provideDefaults, updatePolicy); >+ } > >- public EMFUpdateValueStrategy(boolean provideDefaults, int updatePolicy) >- { >- super(provideDefaults, updatePolicy); >- } >- >- @Override >- protected IConverter createConverter(Object fromType, Object toType) >- { >- if (fromType == String.class) >- { >- if (toType instanceof EAttribute) >- { >- final EAttribute eAttribute = (EAttribute)toType; >- final EDataType eDataType = eAttribute.getEAttributeType(); >- final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance(); >- return >- new Converter(fromType, toType) >- { >- public Object convert(Object fromObject) >- { >- String value = fromObject == null ? null : fromObject.toString(); >- if (eAttribute.isMany()) >- { >- List<Object> result = new ArrayList<Object>(); >- if (value != null) >- { >- for (String element : value.split(" ")) >- { >- result.add(eFactory.createFromString(eDataType, element)); >- } >- } >- return result; >- } >- else >- { >- return eFactory.createFromString(eDataType, value); >- } >- } >- }; >- } >- } >- else if (toType == String.class) >- { >- if (fromType instanceof EAttribute) >- { >- final EAttribute eAttribute = (EAttribute)fromType; >- final EDataType eDataType = eAttribute.getEAttributeType(); >- final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance(); >- return >- new Converter(fromType, toType) >- { >- public Object convert(Object fromObject) >- { >- if (eAttribute.isMany()) >- { >- StringBuilder result = new StringBuilder(); >- for (Object value : (List<?>)fromObject) >- { >- if (result.length() == 0) >- { >- result.append(' '); >- } >- result.append(eFactory.convertToString(eDataType, value)); >- } >- return result.toString(); >- } >- else >- { >- return eFactory.convertToString(eDataType, fromObject); >- } >- } >- }; >- } >- } >- return super.createConverter(fromType, toType); >- } >+ @Override >+ protected IConverter createConverter(Object fromType, Object toType) { >+ if (fromType == String.class) { >+ if (toType instanceof EAttribute) { >+ final EAttribute eAttribute = (EAttribute) toType; >+ final EDataType eDataType = eAttribute.getEAttributeType(); >+ final EFactory eFactory = eDataType.getEPackage() >+ .getEFactoryInstance(); >+ return new Converter(fromType, toType) { >+ public Object convert(Object fromObject) { >+ String value = fromObject == null ? null : fromObject >+ .toString(); >+ if (eAttribute.isMany()) { >+ List<Object> result = new ArrayList<Object>(); >+ if (value != null) { >+ for (String element : value.split(" ")) { >+ result.add(eFactory.createFromString( >+ eDataType, element)); >+ } >+ } >+ return result; >+ } else { >+ return eFactory.createFromString(eDataType, value); >+ } >+ } >+ }; >+ } >+ } else if (toType == String.class) { >+ if (fromType instanceof EAttribute) { >+ final EAttribute eAttribute = (EAttribute) fromType; >+ final EDataType eDataType = eAttribute.getEAttributeType(); >+ final EFactory eFactory = eDataType.getEPackage() >+ .getEFactoryInstance(); >+ return new Converter(fromType, toType) { >+ public Object convert(Object fromObject) { >+ if (eAttribute.isMany()) { >+ StringBuilder result = new StringBuilder(); >+ for (Object value : (List<?>) fromObject) { >+ if (result.length() == 0) { >+ result.append(' '); >+ } >+ result.append(eFactory.convertToString( >+ eDataType, value)); >+ } >+ return result.toString(); >+ } else { >+ return eFactory.convertToString(eDataType, >+ fromObject); >+ } >+ } >+ }; >+ } >+ } >+ return super.createConverter(fromType, toType); >+ } > } >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 17 Feb 2009 00:18:27 -0000 >@@ -9,7 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >- * >+ * Tom Schindl<tom.schindl@bestsolution.at> > * </copyright> > * > * $Id: EObjectObservableList.java,v 1.4 2008/02/21 15:26:16 emerks Exp $ >@@ -33,262 +33,249 @@ > import org.eclipse.emf.ecore.EStructuralFeature; > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p> >+ * <b>PROVISIONAL This API is subject to arbitrary change, including renaming or >+ * removal.</b> >+ * </p> > */ >-public class EObjectObservableList extends ObservableList implements IObserving, InternalRawEList >-{ >- protected EObject eObject; >- protected EStructuralFeature eStructuralFeature; >- protected Adapter listener; >- >- public EObjectObservableList(EObject eObject, EStructuralFeature eStructuralFeature) >- { >- this(Realm.getDefault(), eObject, eStructuralFeature); >- } >- >- public EObjectObservableList(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature) >- { >- super(realm, (EList<?>)eObject.eGet(eStructuralFeature), eStructuralFeature); >- this.eObject = eObject; >- this.eStructuralFeature = eStructuralFeature; >- } >- >- @Override >- protected void firstListenerAdded() >- { >- listener = >- new AdapterImpl() >- { >- @Override >- public void notifyChanged(Notification notification) >- { >- if (eStructuralFeature == notification.getFeature() && !notification.isTouch()) >- { >- final ListDiff diff; >- switch (notification.getEventType()) >- { >- 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()]; >- int position = notification.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(notification.getPosition(), false, notification.getOldValue())); >- break; >- } >- 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) >- { >- 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(notification.getPosition(), false, notification.getOldValue()); >- listDiffEntries[1] = Diffs.createListDiffEntry(notification.getPosition(), true, notification.getNewValue()); >- diff = Diffs.createListDiff(listDiffEntries); >- break; >- } >- case Notification.MOVE: >- { >- Object movedValue = notification.getNewValue(); >- 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. >- // >- return; >- } >- default: >- { >- throw new RuntimeException("unhandled case"); >- } >- } >- getRealm().exec >- (new Runnable() >- { >- public void run() >- { >- fireListChange(diff); >- } >- }); >- } >- } >- }; >- eObject.eAdapters().add(listener); >- } >- >- @Override >- protected void lastListenerRemoved() >- { >- eObject.eAdapters().remove(listener); >- listener = null; >- } >- >- @Override >- public synchronized void dispose() >- { >- if (listener != null) >- { >- eObject.eAdapters().remove(listener); >- listener = null; >- } >- eObject = null; >- eStructuralFeature = null; >- super.dispose(); >- } >- >- @SuppressWarnings("unchecked") >- protected final List<Object> wrappedList() >- { >- return wrappedList; >- } >- >- public Object getObserved() >- { >- return eObject; >- } >- >- @Override >- public boolean add(Object object) >- { >- checkRealm(); >- return wrappedList().add(object); >- } >- >- @Override >- public void add(int index, Object object) >- { >- checkRealm(); >- wrappedList().add(index, object); >- } >- >- @SuppressWarnings("unchecked") >- @Override >- public boolean addAll(Collection collection) >- { >- checkRealm(); >- return wrappedList().addAll(collection); >- } >- >- @SuppressWarnings("unchecked") >- @Override >- public boolean addAll(int index, Collection collection) >- { >- checkRealm(); >- return wrappedList().addAll(index, collection); >- } >- >- @Override >- public Object set(int index, Object element) >- { >- checkRealm(); >- return wrappedList().set(index, element); >- } >- >- @Override >- public Object remove(int index) >- { >- checkRealm(); >- return wrappedList.remove(index); >- } >- >- @Override >- public boolean remove(Object element) >- { >- checkRealm(); >- return wrappedList.remove(element); >- } >- >- @SuppressWarnings("unchecked") >- @Override >- public boolean removeAll(Collection collection) >- { >- checkRealm(); >- return wrappedList().removeAll(collection); >- } >- >- @SuppressWarnings("unchecked") >- @Override >- public boolean retainAll(Collection collection) >- { >- checkRealm(); >- return wrappedList().retainAll(collection); >- } >- >- @Override >- public void clear() >- { >- checkRealm(); >- wrappedList.clear(); >- } >- >- @Override >- public Object move(int newPosition, int oldPosition) >- { >- checkRealm(); >- return ((EList<?>)wrappedList).move(newPosition, oldPosition); >- } >- >- public void move(int newPosition, Object object) >- { >- move(newPosition, indexOf(object)); >- } >- >- @Override >- public String toString() >- { >- StringBuilder result = new StringBuilder(getClass().getName()); >- result.append('@'); >- result.append(Integer.toHexString(hashCode())); >- >- result.append(" (eObject:"); >- result.append(eObject); >- result.append(")"); >- >- result.append(" (eStructuralFeature: "); >- result.append(eStructuralFeature); >- result.append(")"); >- >- result.append(" (wrappedList: "); >- result.append(wrappedList); >- result.append(")"); >+public class EObjectObservableList extends ObservableList implements >+ IObserving, InternalRawEList { >+ protected EObject eObject; >+ protected EStructuralFeature eStructuralFeature; >+ protected Adapter listener; >+ >+ public EObjectObservableList(EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ this(Realm.getDefault(), eObject, eStructuralFeature); >+ } >+ >+ public EObjectObservableList(Realm realm, EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ super(realm, (EList<?>) eObject.eGet(eStructuralFeature), >+ eStructuralFeature); >+ this.eObject = eObject; >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ @Override >+ protected void firstListenerAdded() { >+ listener = new AdapterImpl() { >+ @Override >+ public void notifyChanged(Notification notification) { >+ if (eStructuralFeature == notification.getFeature() >+ && !notification.isTouch()) { >+ final ListDiff diff; >+ switch (notification.getEventType()) { >+ 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()]; >+ int position = notification.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( >+ notification.getPosition(), false, notification >+ .getOldValue())); >+ break; >+ } >+ 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) { >+ 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( >+ notification.getPosition(), false, notification >+ .getOldValue()); >+ listDiffEntries[1] = Diffs.createListDiffEntry( >+ notification.getPosition(), true, notification >+ .getNewValue()); >+ diff = Diffs.createListDiff(listDiffEntries); >+ break; >+ } >+ case Notification.MOVE: { >+ Object movedValue = notification.getNewValue(); >+ 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. >+ // >+ return; >+ } >+ default: { >+ throw new RuntimeException("unhandled case"); >+ } >+ } >+ getRealm().exec(new Runnable() { >+ public void run() { >+ fireListChange(diff); >+ } >+ }); >+ } >+ } >+ }; >+ eObject.eAdapters().add(listener); >+ } >+ >+ @Override >+ protected void lastListenerRemoved() { >+ eObject.eAdapters().remove(listener); >+ listener = null; >+ } >+ >+ @Override >+ public synchronized void dispose() { >+ if (listener != null) { >+ eObject.eAdapters().remove(listener); >+ listener = null; >+ } >+ eObject = null; >+ eStructuralFeature = null; >+ super.dispose(); >+ } >+ >+ @SuppressWarnings("unchecked") >+ protected final List<Object> wrappedList() { >+ return wrappedList; >+ } >+ >+ public Object getObserved() { >+ return eObject; >+ } >+ >+ @Override >+ public boolean add(Object object) { >+ checkRealm(); >+ return wrappedList().add(object); >+ } >+ >+ @Override >+ public void add(int index, Object object) { >+ checkRealm(); >+ wrappedList().add(index, object); >+ } >+ >+ @SuppressWarnings("unchecked") >+ @Override >+ public boolean addAll(Collection collection) { >+ checkRealm(); >+ return wrappedList().addAll(collection); >+ } >+ >+ @SuppressWarnings("unchecked") >+ @Override >+ public boolean addAll(int index, Collection collection) { >+ checkRealm(); >+ return wrappedList().addAll(index, collection); >+ } >+ >+ @Override >+ public Object set(int index, Object element) { >+ checkRealm(); >+ return wrappedList().set(index, element); >+ } >+ >+ @Override >+ public Object remove(int index) { >+ checkRealm(); >+ return wrappedList.remove(index); >+ } >+ >+ @Override >+ public boolean remove(Object element) { >+ checkRealm(); >+ return wrappedList.remove(element); >+ } >+ >+ @SuppressWarnings("unchecked") >+ @Override >+ public boolean removeAll(Collection collection) { >+ checkRealm(); >+ return wrappedList().removeAll(collection); >+ } >+ >+ @SuppressWarnings("unchecked") >+ @Override >+ public boolean retainAll(Collection collection) { >+ checkRealm(); >+ return wrappedList().retainAll(collection); >+ } >+ >+ @Override >+ public void clear() { >+ checkRealm(); >+ wrappedList.clear(); >+ } >+ >+ @Override >+ public Object move(int newPosition, int oldPosition) { >+ checkRealm(); >+ return ((EList<?>) wrappedList).move(newPosition, oldPosition); >+ } >+ >+ public void move(int newPosition, Object object) { >+ move(newPosition, indexOf(object)); >+ } >+ >+ @Override >+ public String toString() { >+ StringBuilder result = new StringBuilder(getClass().getName()); >+ result.append('@'); >+ result.append(Integer.toHexString(hashCode())); >+ >+ result.append(" (eObject:"); >+ result.append(eObject); >+ result.append(")"); >+ >+ result.append(" (eStructuralFeature: "); >+ result.append(eStructuralFeature); >+ result.append(")"); >+ >+ result.append(" (wrappedList: "); >+ result.append(wrappedList); >+ result.append(")"); > >- return result.toString(); >- } >+ return result.toString(); >+ } > } > > @SuppressWarnings("unchecked") >-interface InternalRawEList extends EList >-{ >- // This is only at avoid needing an @SuppressWarnings("unchecked") on the EMFObservableList >+interface InternalRawEList extends EList { >+ // 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 17 Feb 2009 00:18:27 -0000 >@@ -9,7 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >- * >+ * Tom Schindl<tom.schindl@bestsolution.at> > * </copyright> > * > * $Id: EObjectObservableMap.java,v 1.4 2008/10/21 11:03:56 emerks Exp $ >@@ -28,71 +28,64 @@ > import org.eclipse.emf.ecore.util.ExtendedMetaData; > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p> >+ * <b>PROVISIONAL This API is subject to arbitrary change, including renaming or >+ * removal.</b> >+ * </p> > */ >-public class EObjectObservableMap extends ComputedObservableMap >-{ >- protected EStructuralFeature eStructuralFeature; >- >- private Adapter elementListener = >- new AdapterImpl() >- { >- @Override >- public void notifyChanged(Notification notification) >- { >- if (eStructuralFeature == notification.getFeature() && !notification.isTouch()) >- { >- // TODO >- // 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); >- } >- }); >- } >- } >- }; >- >- public EObjectObservableMap(IObservableSet objects, EStructuralFeature feature) >- { >- super(objects); >- this.eStructuralFeature = feature; >- } >- >- @Override >- protected void hookListener(Object domainElement) >- { >- ((EObject)domainElement).eAdapters().add(elementListener); >- } >- >- @Override >- protected void unhookListener(Object domainElement) >- { >- ((EObject)domainElement).eAdapters().remove(elementListener); >- } >- >- @Override >- protected Object doGet(Object key) >- { >- EObject eObject = (EObject)key; >- return >- ExtendedMetaData.INSTANCE.getAffiliation(eObject.eClass(), eStructuralFeature) == null ? >- null : >- eObject.eGet(eStructuralFeature); >- } >- >- @Override >- protected Object doPut(Object key, Object value) >- { >- EObject eObject = (EObject)key; >- Object result = eObject.eGet(eStructuralFeature); >- eObject.eSet(eStructuralFeature, value); >- return result; >- } >+public class EObjectObservableMap extends ComputedObservableMap { >+ protected EStructuralFeature eStructuralFeature; >+ >+ private Adapter elementListener = new AdapterImpl() { >+ @Override >+ public void notifyChanged(Notification notification) { >+ if (eStructuralFeature == notification.getFeature() >+ && !notification.isTouch()) { >+ // TODO >+ // 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); >+ } >+ }); >+ } >+ } >+ }; >+ >+ public EObjectObservableMap(IObservableSet objects, >+ EStructuralFeature feature) { >+ super(objects); >+ this.eStructuralFeature = feature; >+ } >+ >+ @Override >+ protected void hookListener(Object domainElement) { >+ ((EObject) domainElement).eAdapters().add(elementListener); >+ } >+ >+ @Override >+ protected void unhookListener(Object domainElement) { >+ ((EObject) domainElement).eAdapters().remove(elementListener); >+ } >+ >+ @Override >+ protected Object doGet(Object key) { >+ EObject eObject = (EObject) key; >+ return ExtendedMetaData.INSTANCE.getAffiliation(eObject.eClass(), >+ eStructuralFeature) == null ? null : eObject >+ .eGet(eStructuralFeature); >+ } >+ >+ @Override >+ protected Object doPut(Object key, Object value) { >+ EObject eObject = (EObject) key; >+ Object result = eObject.eGet(eStructuralFeature); >+ eObject.eSet(eStructuralFeature, value); >+ return result; >+ } > } >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 17 Feb 2009 00:18:27 -0000 >@@ -9,7 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >- * >+ * Tom Schindl<tom.schindl@bestsolution.at> > * </copyright> > * > * $Id: EObjectObservableValue.java,v 1.2 2008/01/26 21:01:07 emerks Exp $ >@@ -28,122 +28,107 @@ > import org.eclipse.emf.ecore.EStructuralFeature; > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * <p> >+ * <b>PROVISIONAL This API is subject to arbitrary change, including renaming or >+ * removal.</b> >+ * </p> > */ >-public class EObjectObservableValue extends AbstractObservableValue implements IObserving >-{ >- protected EObject eObject; >- protected EStructuralFeature eStructuralFeature; >- protected Adapter listener; >- >- public EObjectObservableValue(EObject eObject, EStructuralFeature eStructuralFeature) >- { >- this(Realm.getDefault(), eObject, eStructuralFeature); >- } >- >- public EObjectObservableValue(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature) >- { >- super(realm); >- this.eObject = eObject; >- this.eStructuralFeature = eStructuralFeature; >- } >- >- @Override >- public synchronized void dispose() >- { >- if (listener != null) >- { >- eObject.eAdapters().remove(listener); >- listener = null; >- } >- eObject = null; >- eStructuralFeature = null; >- super.dispose(); >- } >- >- public Object getObserved() >- { >- return eObject; >- } >- >- @Override >- protected void firstListenerAdded() >- { >- listener = >- new AdapterImpl() >- { >- @Override >- public void notifyChanged(Notification notification) >- { >- if (eStructuralFeature == notification.getFeature() && !notification.isTouch()) >- { >- final ValueDiff diff = Diffs.createValueDiff(notification.getOldValue(), notification.getNewValue()); >- getRealm().exec >- (new Runnable() >- { >- public void run() >- { >- fireValueChange(diff); >- } >- }); >- } >- } >- }; >- eObject.eAdapters().add(listener); >- } >- >- @Override >- protected void lastListenerRemoved() >- { >- eObject.eAdapters().remove(listener); >- listener = null; >- } >- >- @Override >- protected Object doGetValue() >- { >- return eObject.eGet(eStructuralFeature); >- } >- >- @Override >- protected void doSetValue(Object value) >- { >- eObject.eSet(eStructuralFeature, value); >- } >- >- public Object getValueType() >- { >- return eStructuralFeature; >- } >- >- @Override >- public String toString() >- { >- StringBuilder result = new StringBuilder(getClass().getName()); >- result.append('@'); >- result.append(Integer.toHexString(hashCode())); >- >- result.append(" (eObject:"); >- result.append(eObject); >- result.append(")"); >- >- result.append(" (eStructuralFeature: "); >- result.append(eStructuralFeature); >- result.append(")"); >- >- try >- { >- Object value = eObject.eGet(eStructuralFeature, false); >- result.append(" (value: "); >- result.append(value); >- result.append(")"); >- } >- catch (Exception exception) >- { >- // Ignore. >- } >+public class EObjectObservableValue extends AbstractObservableValue implements >+ IObserving { >+ protected EObject eObject; >+ protected EStructuralFeature eStructuralFeature; >+ protected Adapter listener; >+ >+ public EObjectObservableValue(EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ this(Realm.getDefault(), eObject, eStructuralFeature); >+ } >+ >+ public EObjectObservableValue(Realm realm, EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ super(realm); >+ this.eObject = eObject; >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ @Override >+ public synchronized void dispose() { >+ if (listener != null) { >+ eObject.eAdapters().remove(listener); >+ listener = null; >+ } >+ eObject = null; >+ eStructuralFeature = null; >+ super.dispose(); >+ } >+ >+ public Object getObserved() { >+ return eObject; >+ } >+ >+ @Override >+ protected void firstListenerAdded() { >+ listener = new AdapterImpl() { >+ @Override >+ public void notifyChanged(Notification notification) { >+ if (eStructuralFeature == notification.getFeature() >+ && !notification.isTouch()) { >+ final ValueDiff diff = Diffs.createValueDiff(notification >+ .getOldValue(), notification.getNewValue()); >+ getRealm().exec(new Runnable() { >+ public void run() { >+ fireValueChange(diff); >+ } >+ }); >+ } >+ } >+ }; >+ eObject.eAdapters().add(listener); >+ } >+ >+ @Override >+ protected void lastListenerRemoved() { >+ eObject.eAdapters().remove(listener); >+ listener = null; >+ } >+ >+ @Override >+ protected Object doGetValue() { >+ return eObject.eGet(eStructuralFeature); >+ } >+ >+ @Override >+ protected void doSetValue(Object value) { >+ eObject.eSet(eStructuralFeature, value); >+ } >+ >+ public Object getValueType() { >+ return eStructuralFeature; >+ } >+ >+ @Override >+ public String toString() { >+ StringBuilder result = new StringBuilder(getClass().getName()); >+ result.append('@'); >+ result.append(Integer.toHexString(hashCode())); >+ >+ result.append(" (eObject:"); >+ result.append(eObject); >+ result.append(")"); >+ >+ result.append(" (eStructuralFeature: "); >+ result.append(eStructuralFeature); >+ result.append(")"); >+ >+ try { >+ Object value = eObject.eGet(eStructuralFeature, false); >+ result.append(" (value: "); >+ result.append(value); >+ result.append(")"); >+ } catch (Exception exception) { >+ // Ignore. >+ } > >- return result.toString(); >- } >+ return result.toString(); >+ } > }
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