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 134465 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.
Updated patch
patch.txt (text/plain), 159.35 KB, created by
Thomas Schindl
on 2009-05-05 12:39:33 EDT
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2009-05-05 12:39:33 EDT
Size:
159.35 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.databinding.edit >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 5 May 2009 16:39:35 -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,45 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 3.3 >+ * >+ */ >+public class EMFEditMapProperty extends EMFMapProperty { >+ private final EditingDomain editingDomain; >+ >+ 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,65 @@ >+/******************************************************************************* >+ * 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) >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding.edit; >+ >+import org.eclipse.core.databinding.property.list.IListProperty; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.IEMFProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * An {@link IListProperty} extension interface with convenience methods for >+ * creating nested bean properties. >+ * >+ * @since 1.2 >+ */ >+public interface IEMFEditListProperty extends IEMFProperty, IListProperty { >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value property. >+ * >+ * @param propertyName >+ * the value property to observe. May be nested e.g. >+ * "parent.name" >+ * @return a nested combination of this property and the specified value >+ * property. >+ * @see #values(IEMFEditValueProperty) >+ */ >+ public IEMFEditListProperty values(FeaturePath featurePath); >+ >+ 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 >+ * IBeanListProperty children = BeanProperties.list(Person.class, "children", >+ * Person.class); >+ * // Observes the string-typed "name" property of a Person object >+ * IBeanValueProperty name = BeanProperties.value(Person.class, "name"); >+ * // Observes the names of children of a Person object. >+ * IBeanListProperty 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,60 @@ >+/******************************************************************************* >+ * 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) >+ ******************************************************************************/ >+ >+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.databinding.IEMFProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * An {@link IMapProperty} extension interface with convenience methods for >+ * creating nested bean properties. >+ * >+ * @since 1.2 >+ * @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 IEMFProperty, IMapProperty { >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value property. >+ * >+ * @param propertyName >+ * the value property to observe. May be nested e.g. >+ * "parent.name" >+ * @return a master-detail combination of this property and the specified >+ * value property. >+ * @see #values(IEMFEditValueProperty) >+ */ >+ public IEMFEditMapProperty values(FeaturePath featurePath); >+ >+ 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,43 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 IEMFObservable} decorator for an {@link IObservableMap}. >+ * >+ * @since 3.3 >+ */ >+public class EMFEditObservableMapDecorator extends EMFObservableMapDecorator >+ implements IEMFEditObservable { >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param decorated >+ * @param propertyDescriptor >+ */ >+ 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,36 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding.edit; >+ >+import org.eclipse.core.databinding.observable.IObserving; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+/** >+ * Provides access to details of bean observables. >+ * <p> >+ * This interface is not meant to be implemented by clients. >+ * </p> >+ * >+ * @since 3.3 >+ */ >+public interface IEMFEditObservable 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(); >+ >+ 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,96 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 3.3 >+ * >+ */ >+public class EMFEditListPropertyDecorator extends ListProperty implements >+ IEMFEditListProperty { >+ private final IListProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param delegate >+ * @param propertyDescriptor >+ */ >+ 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(); >+ } >+} 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,138 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 3.3 >+ * >+ */ >+public class EMFEditValuePropertyDecorator extends ValueProperty implements >+ IEMFEditValueProperty { >+ private final IValueProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param delegate >+ * @param propertyDescriptor >+ */ >+ 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 map(feature, null, null); >+ } >+ >+ public IEMFEditMapProperty map(EStructuralFeature feature, Class<?> keyType, >+ Class<?> valueType) { >+ return map(EMFEditProperties.map(editingDomain,feature, keyType, >+ valueType)); >+ } >+ >+ 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(); >+ } >+} 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,44 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 IEMFObservable} decorator for an {@link IObservableValue}. >+ * >+ * @since 3.3 >+ */ >+public class EMFEditObservableValueDecorator extends EMFObservableValueDecorator >+ implements IEMFEditObservable { >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param decorated >+ * @param propertyDescriptor >+ */ >+ 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,36 @@ >+/******************************************************************************* >+ * 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) >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding.edit; >+ >+import org.eclipse.core.databinding.property.IProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+/** >+ * An IProperty extension interface providing access to details of bean >+ * properties. >+ * >+ * @since 1.2 >+ * @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 IProperty { >+ /** >+ * Returns the property descriptor of the bean property being observed. This >+ * method returns null in the case of anonymous properties. >+ * >+ * @return the property descriptor of the bean property being observed >+ */ >+ public EStructuralFeature getStructuralFeature(); >+ >+ 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,42 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 IEMFObservable} decorator for an {@link IObservableList}. >+ * >+ * @since 3.3 >+ */ >+public class EMFEditObservableListDecorator extends EMFObservableListDecorator >+ implements IEMFEditObservable { >+ >+ private final EditingDomain editingDomain; >+ >+ 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,100 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 3.3 >+ * >+ */ >+public class EMFEditMapPropertyDecorator extends MapProperty implements >+ IEMFEditMapProperty { >+ private final IMapProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param delegate >+ * @param propertyDescriptor >+ */ >+ 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(); >+ } >+} 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,157 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+/** >+ * A factory for creating properties for 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.2 >+ */ >+public class EMFEditProperties { >+ public static final boolean DEBUG = false; >+ >+ public static IEMFEditValueProperty value(EditingDomain editingDomain, >+ EStructuralFeature feature) { >+ return value(editingDomain, FeaturePath.fromList(feature)); >+ } >+ >+ /** >+ * Returns a value property for the given property name of the given bean >+ * class. >+ * >+ * @param beanClass >+ * the bean class >+ * @param propertyName >+ * the property name. May be nested e.g. "parent.name" >+ * @param valueType >+ * the value type of the returned value property >+ * @return a value property for the given property name of the given bean >+ * class. >+ */ >+ public static IEMFEditValueProperty value(EditingDomain editingDomain, >+ FeaturePath featurePath) { >+ IValueProperty property; >+ property = new EMFEditValueProperty(editingDomain, featurePath >+ .getFeaturePath()[0]); >+ >+ IEMFEditValueProperty beanProperty = new EMFEditValuePropertyDecorator( >+ editingDomain, property, featurePath.getFeaturePath()[0]); >+ >+ for (int i = 1; i < featurePath.getFeaturePath().length; i++) { >+ beanProperty = beanProperty.value(featurePath.getFeaturePath()[i]); >+ } >+ >+ return beanProperty; >+ } >+ >+ 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 a value property array for the given property names of the given >+ * bean class. >+ * >+ * @param beanClass >+ * the bean class >+ * @param propertyNames >+ * array of property names. May be nested e.g. "parent.name" >+ * @return a value property array for the given property names of the given >+ * bean class. >+ */ >+ 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 property name of the given bean >+ * class. >+ * >+ * @param beanClass >+ * the bean class >+ * @param propertyName >+ * the property name >+ * @param elementType >+ * the element type of the returned list property >+ * @return a list property for the given property name of the given bean >+ * class. >+ */ >+ 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 property name of an arbitrary bean >+ * class. Objects lacking the named property are treated the same as if the >+ * property always contains an empty map. >+ * >+ * @param propertyName >+ * the property name >+ * @return a map property for the given property name of an arbitrary bean >+ * class. >+ */ >+ public static IEMFEditMapProperty map(EditingDomain editingDomain, >+ EStructuralFeature feature) { >+ return map(editingDomain, feature, null, null); >+ } >+ >+ /** >+ * Returns a map property for the given property name of the given bean >+ * class. >+ * >+ * @param beanClass >+ * the bean class >+ * @param propertyName >+ * the property name >+ * @param keyType >+ * the key type for the returned map property >+ * @param valueType >+ * the value type for the returned map property >+ * @return a map property for the given property name of the given bean >+ * class. >+ */ >+ public static IEMFEditMapProperty map(EditingDomain editingDomain, >+ EStructuralFeature feature, Class<?> keyType, Class<?> valueType) { >+ 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,42 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 3.3 >+ * >+ */ >+public class EMFEditValueProperty extends EMFValueProperty { >+ private final EditingDomain editingDomain; >+ >+ 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,158 @@ >+/******************************************************************************* >+ * 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) >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding.edit; >+ >+import org.eclipse.core.databinding.property.value.IValueProperty; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.IEMFProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * An {@link IValueProperty} extension interface with convenience methods for >+ * creating nested bean properties. >+ * >+ * @since 1.2 >+ * @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 IEMFProperty, IValueProperty { >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * value property. >+ * >+ * @param propertyName >+ * the value property to observe. May be nested e.g. >+ * "parent.name" >+ * @return a master-detail combination of this property and the specified >+ * value property. >+ * @see #value(IEMFEditValueProperty) >+ */ >+ public IEMFEditValueProperty value(FeaturePath featurePath); >+ >+ 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 >+ * IBeanValueProperty parent = BeanProperties.value(Node.class, "parent"); >+ * // Observes the string-typed "name" property of a Node object >+ * IBeanValueProperty name = BeanProperties.value(Node.class, "name"); >+ * // Observes the name of the parent of a Node object. >+ * IBeanValueProperty 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 property. >+ * >+ * @param propertyName >+ * the list property to observe >+ * @return a master-detail combination of this property and the specified >+ * list property. >+ * @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. >+ * IBeanValueProperty parent = BeanProperties.value(Node.class, "parent"); >+ * // Observes the List-typed "children" property of a Node object >+ * // where the elements are Node objects >+ * IBeanListProperty children = BeanProperties.list(Node.class, "children", >+ * Node.class); >+ * // Observes the children of the parent (siblings) of a Node object. >+ * IBeanListProperty 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 property. >+ * >+ * @param propertyName >+ * the map property to observe >+ * @return a master-detail combination of this property and the specified >+ * map property. >+ * @see #map(IEMFEditMapProperty) >+ */ >+ public IEMFEditMapProperty map(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * map property. >+ * >+ * @param propertyName >+ * the map property to observe >+ * @param keyType >+ * the key type of the named property >+ * @param valueType >+ * the value type of the named property >+ * @return a master-detail combination of this property and the specified >+ * map property. >+ * @see #map(IEMFEditMapProperty) >+ */ >+ public IEMFEditMapProperty map(EStructuralFeature feature, Class<?> keyType, >+ Class<?> valueType); >+ >+ /** >+ * 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 >+ * IBeanValueProperty supervisor = BeanProperties.value(Contact.class, >+ * "supervisor"); >+ * // Observes the property "phoneNumbers" of a Contact object--a property mapping >+ * // from PhoneNumberType to PhoneNumber "set-typed "children", >+ * IBeanMapProperty phoneNumbers = BeanProperties.map(Contact.class, >+ * "phoneNumbers", PhoneNumberType.class, PhoneNumber.class); >+ * // Observes the phone numbers of a contact's supervisor: >+ * IBeanMapProperty 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,75 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding.edit.internal; >+ >+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.RemoveCommand; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public class EMFEditListProperty extends EMFListProperty { >+ private final EditingDomain editingDomain; >+ >+ 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 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 >#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 5 May 2009 16:39:36 -0000 >@@ -24,63 +24,72 @@ > import org.eclipse.emf.ecore.EFactory; > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * PROVISIONAL This API is subject to arbitrary change, including renaming or >+ * removal. > */ >-public class EMFUpdateListStrategy extends UpdateListStrategy >-{ >- public EMFUpdateListStrategy() >- { >- this(true, POLICY_UPDATE); >- } >+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); >+ } > >- public EMFUpdateListStrategy(int updatePolicy) >- { >- this(true, updatePolicy); >- } >+ /** >+ * 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); >+ } > >- 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); >- } >+ /** >+ * 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) { >+ 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/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 5 May 2009 16:39:36 -0000 >@@ -22,30 +22,38 @@ > import org.eclipse.core.databinding.observable.value.IObservableValue; > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * PROVISIONAL This API is subject to arbitrary change, including renaming or >+ * removal. > */ >-public class EMFDataBindingContext extends DataBindingContext >-{ >- public EMFDataBindingContext() >- { >- this(Realm.getDefault()); >- } >+public class EMFDataBindingContext extends DataBindingContext { >+ /** >+ * Create a new databinding context which uses the default realm for >+ * validation >+ */ >+ public EMFDataBindingContext() { >+ this(Realm.getDefault()); >+ } > >- public EMFDataBindingContext(Realm validationRealm) >- { >- super(validationRealm); >- } >+ /** >+ * Create a databinding context which uses an explicit realm for >+ * synchronisation >+ * >+ * @param validationRealm >+ * the realm to use >+ */ >+ public EMFDataBindingContext(Realm validationRealm) { >+ super(validationRealm); >+ } > >- @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 createModelToTargetUpdateValueStrategy( >+ IObservableValue fromValue, IObservableValue toValue) { >+ return new EMFUpdateValueStrategy(); >+ } >+ >+ @Override >+ protected UpdateValueStrategy createTargetToModelUpdateValueStrategy( >+ IObservableValue fromValue, IObservableValue toValue) { >+ return new EMFUpdateValueStrategy(); >+ } > } >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 5 May 2009 16:39:37 -0000 >@@ -28,122 +28,132 @@ > import org.eclipse.emf.ecore.EStructuralFeature; > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * PROVISIONAL This API is subject to arbitrary change, including renaming or >+ * removal. > */ >-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 { >+ /** >+ * 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); >+ 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(); >+ } > } >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 5 May 2009 16:39:37 -0000 >@@ -33,262 +33,278 @@ > import org.eclipse.emf.ecore.EStructuralFeature; > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * PROVISIONAL This API is subject to arbitrary change, including renaming or >+ * removal. > */ >-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 { >+ /** >+ * 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); >+ 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(); >+ } >+ >+ /** >+ * @return the wrapped list >+ */ >+ @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 5 May 2009 16:39:37 -0000 >@@ -28,71 +28,73 @@ > import org.eclipse.emf.ecore.util.ExtendedMetaData; > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * PROVISIONAL This API is subject to arbitrary change, including renaming or >+ * removal. > */ >-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 { >+ /** >+ * The feature to observe >+ */ >+ 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); >+ } >+ }); >+ } >+ } >+ }; >+ >+ /** >+ * 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); >+ 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/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 5 May 2009 16:39:36 -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; >@@ -27,95 +28,97 @@ > import org.eclipse.emf.ecore.EFactory; > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * PROVISIONAL This API is subject to arbitrary change, including renaming or >+ * removal. > */ >-public class EMFUpdateValueStrategy extends UpdateValueStrategy >-{ >- public EMFUpdateValueStrategy() >- { >- this(true, POLICY_UPDATE); >- } >+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); >+ } > >- public EMFUpdateValueStrategy(int updatePolicy) >- { >- this(true, updatePolicy); >- } >+ /** >+ * A list value strategy with a specific update policy but with default >+ * converters and validators >+ * >+ * @param updatePolicy >+ * the policy >+ */ >+ public EMFUpdateValueStrategy(int updatePolicy) { >+ this(true, 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); >- } >+ /** >+ * A list 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) { >+ 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: 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 5 May 2009 16:39:36 -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 5 May 2009 16:39:36 -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,67 @@ >+/******************************************************************************* >+ * 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) >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding; >+ >+import java.util.Map; >+ >+import org.eclipse.core.databinding.property.map.IMapProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * An {@link IMapProperty} extension interface with convenience methods for >+ * creating nested bean properties. >+ * >+ * @since 1.2 >+ * @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,41 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding.internal; >+ >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * @since 1.2 >+ * >+ */ >+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,354 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2007 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 >+ * >+ * </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> >+ */ >+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; >+ 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 >+ public synchronized void dispose() { >+ ((Notifier) wrappedList.getNotifier()).eAdapters().remove(listener); >+ 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,92 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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; >+ >+/** >+ * >+ */ >+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,56 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 3.3 >+ */ >+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,35 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding.internal; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+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,129 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 3.3 >+ * >+ */ >+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,56 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 3.3 >+ */ >+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,87 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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; >+ >+/** >+ * >+ */ >+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,33 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.core.databinding.observable.IObserving; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * Provides access to details of bean observables. >+ * <p> >+ * This interface is not meant to be implemented by clients. >+ * </p> >+ * >+ * @since 3.3 >+ */ >+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,145 @@ >+/******************************************************************************* >+ * 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) >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.core.databinding.property.value.IValueProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * An {@link IValueProperty} extension interface with convenience methods for >+ * creating nested features. >+ * >+ * @since 1.2 >+ * @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 >+ * IBeanValueProperty name = BeanProperties.value(MyPackage.Literals.NODE_NAME); >+ * // Observes the name of the parent of a Node object. >+ * IBeanValueProperty 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. >+ * IBeanListProperty 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,85 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 3.3 >+ * >+ */ >+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,56 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 3.3 >+ */ >+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,129 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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; >+ >+/** >+ * A factory to create property bound attributes for {@link EObject} >+ * >+ * @since 1.2 >+ */ >+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 beanProperty = new EMFValuePropertyDecorator( >+ property, featurePath.getFeaturePath()[0]); >+ >+ for (int i = 1; i < featurePath.getFeaturePath().length; i++) { >+ beanProperty = beanProperty.value(featurePath.getFeaturePath()[i]); >+ } >+ >+ return beanProperty; >+ } >+ >+ /** >+ * 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,43 @@ >+/******************************************************************************* >+ * 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) >+ ******************************************************************************/ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * Encapsulate a path to features also known as nested feature like person.name >+ */ >+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,33 @@ >+/******************************************************************************* >+ * 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) >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.core.databinding.property.IProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * An IProperty extension interface providing access to details of bean >+ * properties. >+ * >+ * @since 1.2 >+ * @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 property descriptor of the bean property being observed. This >+ * method returns null in the case of anonymous properties. >+ * >+ * @return the property descriptor of the bean property 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,71 @@ >+/******************************************************************************* >+ * 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) >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.core.databinding.property.list.IListProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * An {@link IListProperty} extension interface with convenience methods for >+ * creating nested bean properties. >+ * >+ * @since 1.2 >+ */ >+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,166 @@ >+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; >+ >+/** >+ * >+ */ >+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,97 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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 3.3 >+ * >+ */ >+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,111 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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; >+ >+/** >+ * >+ */ >+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; >+ } >+}
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 Raw
Actions:
View
Attachments on
bug 262160
:
123633
|
124701
|
125052
|
125836
|
125841
|
132310
|
132579
|
132670
|
134185
|
134272
|
134465
|
134529
|
134710
|
136365
|
136370