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 132310 Details for
Bug 262160
Implement the new Property-based Databinding-API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Updated to M6 and revised some parts
patch.txt (text/plain), 166.23 KB, created by
Thomas Schindl
on 2009-04-17 18:35:11 EDT
(
hide
)
Description:
Updated to M6 and revised some parts
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2009-04-17 18:35:11 EDT
Size:
166.23 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 17 Apr 2009 22:34: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,46 @@ >+/******************************************************************************* >+ * 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, >+ Class<?> keyType, Class<?> valueType) { >+ super(eStructuralFeature, keyType, valueType); >+ 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/internal/EMFEditSetProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditSetProperty.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditSetProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditSetProperty.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, 265064, 265561 >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding.edit.internal; >+ >+import java.util.Set; >+ >+import org.eclipse.core.databinding.observable.set.SetDiff; >+import org.eclipse.emf.common.command.Command; >+import org.eclipse.emf.databinding.internal.EMFSetProperty; >+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 EMFEditSetProperty extends EMFSetProperty { >+ private final EditingDomain editingDomain; >+ >+ public EMFEditSetProperty(EditingDomain editingDomain, EStructuralFeature eStructuralFeature, >+ Class<?> elementType) { >+ super(eStructuralFeature, elementType); >+ this.editingDomain = editingDomain; >+ } >+ >+ @SuppressWarnings("unchecked") >+ @Override >+ protected void doSetSet(Object source, Set set, SetDiff diff) { >+ EObject eObject = (EObject) source; >+ Command command = SetCommand.create(editingDomain, eObject, getFeature(), set); >+ editingDomain.getCommandStack().execute(command); >+ } >+} >\ No newline at end of file >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/EMFEditSetPropertyDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditSetPropertyDecorator.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditSetPropertyDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditSetPropertyDecorator.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.edit.internal; >+ >+import org.eclipse.core.databinding.observable.Realm; >+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.set.ISetProperty; >+import org.eclipse.core.databinding.property.set.SetProperty; >+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.IEMFEditSetProperty; >+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 EMFEditSetPropertyDecorator extends SetProperty implements >+ IEMFEditSetProperty { >+ private final ISetProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param delegate >+ * @param propertyDescriptor >+ */ >+ public EMFEditSetPropertyDecorator(EditingDomain editingDomain,ISetProperty delegate, >+ EStructuralFeature eStructuralFeature) { >+ this.delegate = delegate; >+ this.eStructuralFeature = eStructuralFeature; >+ this.editingDomain = editingDomain; >+ } >+ >+ public EStructuralFeature getStructuralFeature() { >+ return eStructuralFeature; >+ } >+ >+ public Object getElementType() { >+ return delegate.getElementType(); >+ } >+ >+ 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 IObservableSet observe(Object source) { >+ return new EMFEditObservableSetDecorator(editingDomain,delegate.observe(source), >+ eStructuralFeature); >+ } >+ >+ public IObservableSet observe(Realm realm, Object source) { >+ return new EMFEditObservableSetDecorator(editingDomain,delegate.observe(realm, source), >+ eStructuralFeature); >+ } >+ >+ public IObservableFactory setFactory() { >+ return delegate.setFactory(); >+ } >+ >+ public IObservableFactory setFactory(Realm realm) { >+ return delegate.setFactory(realm); >+ } >+ >+ public IObservableSet observeDetail(IObservableValue master) { >+ return new EMFEditObservableSetDecorator(editingDomain,delegate.observeDetail(master), >+ eStructuralFeature); >+ } >+ >+ public String toString() { >+ return delegate.toString(); >+ } >+} >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,152 @@ >+/******************************************************************************* >+ * 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.IEMFEditSetProperty; >+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 IEMFEditSetProperty set(EStructuralFeature feature) { >+ return set(feature, null); >+ } >+ >+ public IEMFEditSetProperty set(EStructuralFeature feature, Class<?> elementType) { >+ return set(EMFEditProperties.set(editingDomain,feature, elementType)); >+ } >+ >+ public IEMFEditSetProperty set(IEMFEditSetProperty property) { >+ return new EMFEditSetPropertyDecorator(editingDomain,super.set(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,185 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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.set.ISetProperty; >+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.EMFEditSetProperty; >+import org.eclipse.emf.databinding.edit.internal.EMFEditSetPropertyDecorator; >+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; >+ } >+ >+ public static IEMFEditSetProperty set(EditingDomain editingDomain, >+ EStructuralFeature feature) { >+ return set(editingDomain, feature, null); >+ } >+ >+ /** >+ * Returns a set 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 set property >+ * @return a set property for the given property name of the given bean >+ * class. >+ */ >+ public static IEMFEditSetProperty set(EditingDomain editingDomain, >+ EStructuralFeature feature, Class<?> elementType) { >+ ISetProperty property; >+ property = new EMFEditSetProperty(editingDomain, feature, elementType); >+ return new EMFEditSetPropertyDecorator(editingDomain, property, feature); >+ } >+ >+ /** >+ * 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, keyType, >+ valueType); >+ return new EMFEditMapPropertyDecorator(editingDomain, property, feature); >+ } >+} >Index: src/org/eclipse/emf/databinding/edit/IEMFEditSetProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/IEMFEditSetProperty.java >diff -N src/org/eclipse/emf/databinding/edit/IEMFEditSetProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/IEMFEditSetProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,69 @@ >+/******************************************************************************* >+ * 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.set.ISetProperty; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.IEMFProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * An {@link ISetProperty} 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 IEMFEditSetProperty extends IEMFProperty, ISetProperty { >+ /** >+ * 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 elements observed by this set property, mapping from >+ * this set property's elements (keys) to the specified value property's >+ * value for each element (values). >+ * <p> >+ * Example: >+ * >+ * <pre> >+ * // Observes the set-typed "children" property of a Person object, >+ * // where the elements are Person objects >+ * IBeanSetProperty children = BeanProperties.set(Person.class, "children", >+ * Person.class); >+ * // Observes the string-typed "name" property of a Person object >+ * IBeanValueProperty name = BeanProperties.value(Person.class, "name"); >+ * // Observes a map of children objects to their respective names. >+ * IBeanMapProperty 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 IEMFEditMapProperty values(IEMFEditValueProperty property); >+} >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,209 @@ >+/******************************************************************************* >+ * 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 >+ * set property. >+ * >+ * @param propertyName >+ * the set property to observe >+ * @return a master-detail combination of this property and the specified >+ * set property. >+ * @see #set(IEMFEditSetProperty) >+ */ >+ public IEMFEditSetProperty set(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * set property. >+ * >+ * @param propertyName >+ * the set property to observe >+ * @param elementType >+ * the element type of the named property >+ * @return a master-detail combination of this property and the specified >+ * set property. >+ * @see #set(IEMFEditSetProperty) >+ */ >+ public IEMFEditSetProperty set(EStructuralFeature feature, Class<?> elementType); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * set property. The returned property will observe the specified set >+ * 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 Set-typed "children" property of a Node object >+ * // where the elements are Node objects >+ * IBeanSetProperty children = BeanProperties.set(Node.class, "children", >+ * Node.class); >+ * // Observes the children of the parent (siblings) of a Node object. >+ * IBeanSetProperty siblings = parent.set(children); >+ * </pre> >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * set property. >+ */ >+ public IEMFEditSetProperty set(IEMFEditSetProperty 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 >Index: src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableSetDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableSetDecorator.java >diff -N src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableSetDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/edit/internal/EMFEditObservableSetDecorator.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.set.IObservableSet; >+import org.eclipse.emf.databinding.edit.IEMFEditObservable; >+import org.eclipse.emf.databinding.internal.EMFObservableSetDecorator; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.edit.domain.EditingDomain; >+ >+/** >+ * {@link IEMFObservable} decorator for an {@link IObservableSet}. >+ * >+ * @since 3.3 >+ */ >+public class EMFEditObservableSetDecorator extends EMFObservableSetDecorator >+ implements IEMFEditObservable { >+ private final EditingDomain editingDomain; >+ >+ /** >+ * @param decorated >+ * @param propertyDescriptor >+ */ >+ public EMFEditObservableSetDecorator(EditingDomain editingDomain,IObservableSet decorated, >+ EStructuralFeature eStructuralFeature) { >+ super(decorated, eStructuralFeature); >+ this.editingDomain = editingDomain; >+ } >+ >+ public EditingDomain getEditingDomain() { >+ return editingDomain; >+ } >+ >+} >#P org.eclipse.emf.databinding >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/META-INF/MANIFEST.MF,v >retrieving revision 1.5 >diff -u -r1.5 MANIFEST.MF >--- META-INF/MANIFEST.MF 21 Oct 2008 11:03:56 -0000 1.5 >+++ META-INF/MANIFEST.MF 17 Apr 2009 22:34: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: src/org/eclipse/emf/databinding/EMFObservables.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.databinding/src/org/eclipse/emf/databinding/EMFObservables.java,v >retrieving revision 1.3 >diff -u -r1.3 EMFObservables.java >--- src/org/eclipse/emf/databinding/EMFObservables.java 22 Apr 2008 13:36:00 -0000 1.3 >+++ src/org/eclipse/emf/databinding/EMFObservables.java 17 Apr 2009 22:34:36 -0000 >@@ -17,7 +17,6 @@ > */ > package org.eclipse.emf.databinding; > >- > import org.eclipse.core.databinding.observable.IObservable; > import org.eclipse.core.databinding.observable.Realm; > import org.eclipse.core.databinding.observable.list.IObservableList; >@@ -26,169 +25,223 @@ > import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables; > import org.eclipse.core.databinding.observable.set.IObservableSet; > import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.emf.common.notify.NotifyingList; >+import org.eclipse.emf.databinding.internal.EWritableList; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.resource.Resource; > > /** >- * PROVISIONAL >- * This API is subject to arbitrary change, including renaming or removal. >+ * PROVISIONAL This API is subject to arbitrary change, including renaming or >+ * removal. > */ >-public class EMFObservables >-{ >- /** >- * Returns an observable value for the given feature of the object. >- * @param eObject the object to observe. >- * @param eStructuralFeature the feature of the object to observe. >- * @return an observable value for the given feature of the object. >- */ >- public static IObservableValue observeValue(EObject eObject, EStructuralFeature eStructuralFeature) >- { >- return new EObjectObservableValue(eObject, eStructuralFeature); >- } >- >- /** >- * Returns an observable value for the given feature of the object. >- * @param realm the realm in which to observe. >- * @param eObject the object to observe. >- * @param eStructuralFeature the feature of the object to observe. >- * @return an observable value for the given feature of the object. >- */ >- public static IObservableValue observeValue(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature) >- { >- return new EObjectObservableValue(realm, eObject, eStructuralFeature); >- } >- >- /** >- * Returns an observable list for the given multi-valued feature of the object. >- * @param eObject the object to observe. >- * @param eStructuralFeature the feature of the object to observe. >- * @return an observable list for the given multi-valued feature of the object. >- */ >- public static IObservableList observeList(EObject eObject, EStructuralFeature eStructuralFeature) >- { >- return new EObjectObservableList(eObject, eStructuralFeature); >- } >- >- /** >- * Returns an observable list for the given multi-valued feature of the object. >- * @param realm the realm in which to observe. >- * @param eObject the object to observe. >- * @param eStructuralFeature the feature of the object to observe. >- * @return an observable list for the given multi-valued feature of the object. >- */ >- public static IObservableList observeList(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature) >- { >- return new EObjectObservableList(realm, eObject, eStructuralFeature); >- } >- >- /** >- * Returns an observable map in the default realm >- * tracking the current value of the given feature for each object in the given set. >- * @param objects the objects to track. >- * @param eStructuralFeature the feature for which to track the value. >- * @return an observable map tracking the current value of the given feature for each object in the given set. >- */ >- public static IObservableMap observeMap(IObservableSet objects, EStructuralFeature eStructuralFeature) >- { >- return new EObjectObservableMap(objects, eStructuralFeature); >- } >- >- /** >- * Returns an array of observable maps in the default realm >- * tracking the current value of the given features for each object in the given set. >- * @param objects the objects to track. >- * @param eStructuralFeatures the features for which to track the value. >- * @return an array of observable maps tracking the current value of the given features for each object in the given set. >- */ >- public static IObservableMap[] observeMaps(IObservableSet objects, EStructuralFeature[] eStructuralFeatures) >- { >- IObservableMap[] result = new IObservableMap [eStructuralFeatures.length]; >- for (int i = 0; i < eStructuralFeatures.length; i++) >- { >- result[i] = observeMap(objects, eStructuralFeatures[i]); >- } >- return result; >- } >- >- /** >- * Returns an observable value that tracks the current value of the feature of the current value of the master observable value. >- * @param realm the realm in which to observe. >- * @param value the master observable value. >- * @param eStructuralFeature the feature for which to track the value. >- * @return an observable value that tracks the current value of the named property for the current value of the master observable value >- * @see MasterDetailObservables#detailValue(IObservableValue, IObservableFactory, Object) >- */ >- public static IObservableValue observeDetailValue(Realm realm, IObservableValue value, EStructuralFeature eStructuralFeature) >- { >- return MasterDetailObservables.detailValue(value, valueFactory(realm, eStructuralFeature), eStructuralFeature); >- } >- >- /** >- * Returns a factory for creating observable values >- * tracking the value of the given feature of a particular {@link EObject object}. >- * @param realm the realm in which to observe. >- * @param eStructuralFeature the feature for which to track the value. >- * @return an observable factory. >- */ >- public static IObservableFactory valueFactory(final Realm realm, final EStructuralFeature eStructuralFeature) >- { >- return >- new IObservableFactory() >- { >- public IObservable createObservable(Object target) >- { >- return observeValue(realm, (EObject)target, eStructuralFeature); >- } >- }; >- } >- >- /** >- * Returns an observable list that tracks the current value of the feature of the current value of the master observable value. >- * @param realm the realm in which to observe. >- * @param value the master observable value. >- * @param eStructuralFeature the feature for which to track the value. >- * @return an observable value that tracks the current value of the named property for the current value of the master observable value >- * @see MasterDetailObservables#detailList(IObservableValue, IObservableFactory, Object) >- */ >- public static IObservableList observeDetailList(Realm realm, IObservableValue value, EStructuralFeature eStructuralFeature) >- { >- return MasterDetailObservables.detailList(value, listFactory(realm, eStructuralFeature), eStructuralFeature); >- } >- >- /** >- * Returns a factory for creating observable lists >- * tracking the value of the given feature of a particular {@link EObject object}. >- * @param realm the realm in which to observe. >- * @param eStructuralFeature the feature for which to track the value. >- * @return an observable factory. >- */ >- public static IObservableFactory listFactory(final Realm realm, final EStructuralFeature eStructuralFeature) >- { >- return >- new IObservableFactory() >- { >- public IObservable createObservable(Object target) >- { >- return observeList(realm, (EObject)target, eStructuralFeature); >- } >- }; >- } >- >- /** >- * Returns a factory for creating observable maps >- * tracking the value of the given feature of a particular {@link EObject object}. >- * @param eStructuralFeature the feature for which to track the value. >- * @return an observable factory. >- */ >- public static IObservableFactory mapFactory(final EStructuralFeature eStructuralFeature) >- { >- return >- new IObservableFactory() >- { >- public IObservable createObservable(Object target) >- { >- return observeMap((IObservableSet)target, eStructuralFeature); >- } >- }; >- } >+public class EMFObservables { >+ /** >+ * Returns an observable value for the given feature of the object. >+ * >+ * @param eObject >+ * the object to observe. >+ * @param eStructuralFeature >+ * the feature of the object to observe. >+ * @return an observable value for the given feature of the object. >+ */ >+ public static IObservableValue observeValue(EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ return new EObjectObservableValue(eObject, eStructuralFeature); >+ } >+ >+ /** >+ * Returns an observable value for the given feature of the object. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @param eObject >+ * the object to observe. >+ * @param eStructuralFeature >+ * the feature of the object to observe. >+ * @return an observable value for the given feature of the object. >+ */ >+ public static IObservableValue observeValue(Realm realm, EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ return new EObjectObservableValue(realm, eObject, eStructuralFeature); >+ } >+ >+ /** >+ * Returns an observable list for the given multi-valued feature of the >+ * object. >+ * >+ * @param eObject >+ * the object to observe. >+ * @param eStructuralFeature >+ * the feature of the object to observe. >+ * @return an observable list for the given multi-valued feature of the >+ * object. >+ */ >+ public static IObservableList observeList(EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ return new EObjectObservableList(eObject, eStructuralFeature); >+ } >+ >+ /** >+ * Returns an observable list for the given multi-valued feature of the >+ * object. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @param eObject >+ * the object to observe. >+ * @param eStructuralFeature >+ * the feature of the object to observe. >+ * @return an observable list for the given multi-valued feature of the >+ * object. >+ */ >+ public static IObservableList observeList(Realm realm, EObject eObject, >+ EStructuralFeature eStructuralFeature) { >+ return new EObjectObservableList(realm, eObject, eStructuralFeature); >+ } >+ >+ /** >+ * Returns an observable map in the default realm tracking the current value >+ * of the given feature for each object in the given set. >+ * >+ * @param objects >+ * the objects to track. >+ * @param eStructuralFeature >+ * the feature for which to track the value. >+ * @return an observable map tracking the current value of the given feature >+ * for each object in the given set. >+ */ >+ public static IObservableMap observeMap(IObservableSet objects, >+ EStructuralFeature eStructuralFeature) { >+ return new EObjectObservableMap(objects, eStructuralFeature); >+ } >+ >+ /** >+ * Returns an array of observable maps in the default realm tracking the >+ * current value of the given features for each object in the given set. >+ * >+ * @param objects >+ * the objects to track. >+ * @param eStructuralFeatures >+ * the features for which to track the value. >+ * @return an array of observable maps tracking the current value of the >+ * given features for each object in the given set. >+ */ >+ public static IObservableMap[] observeMaps(IObservableSet objects, >+ EStructuralFeature[] eStructuralFeatures) { >+ IObservableMap[] result = new IObservableMap[eStructuralFeatures.length]; >+ for (int i = 0; i < eStructuralFeatures.length; i++) { >+ result[i] = observeMap(objects, eStructuralFeatures[i]); >+ } >+ return result; >+ } >+ >+ /** >+ * Returns an observable value that tracks the current value of the feature >+ * of the current value of the master observable value. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @param value >+ * the master observable value. >+ * @param eStructuralFeature >+ * the feature for which to track the value. >+ * @return an observable value that tracks the current value of the named >+ * property for the current value of the master observable value >+ * @see MasterDetailObservables#detailValue(IObservableValue, >+ * IObservableFactory, Object) >+ */ >+ public static IObservableValue observeDetailValue(Realm realm, >+ IObservableValue value, EStructuralFeature eStructuralFeature) { >+ return MasterDetailObservables.detailValue(value, valueFactory(realm, >+ eStructuralFeature), eStructuralFeature); >+ } >+ >+ /** >+ * Returns a factory for creating observable values tracking the value of >+ * the given feature of a particular {@link EObject object}. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @param eStructuralFeature >+ * the feature for which to track the value. >+ * @return an observable factory. >+ */ >+ public static IObservableFactory valueFactory(final Realm realm, >+ final EStructuralFeature eStructuralFeature) { >+ return new IObservableFactory() { >+ public IObservable createObservable(Object target) { >+ return observeValue(realm, (EObject) target, eStructuralFeature); >+ } >+ }; >+ } >+ >+ /** >+ * Returns an observable list that tracks the current value of the feature >+ * of the current value of the master observable value. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @param value >+ * the master observable value. >+ * @param eStructuralFeature >+ * the feature for which to track the value. >+ * @return an observable value that tracks the current value of the named >+ * property for the current value of the master observable value >+ * @see MasterDetailObservables#detailList(IObservableValue, >+ * IObservableFactory, Object) >+ */ >+ public static IObservableList observeDetailList(Realm realm, >+ IObservableValue value, EStructuralFeature eStructuralFeature) { >+ return MasterDetailObservables.detailList(value, listFactory(realm, >+ eStructuralFeature), eStructuralFeature); >+ } >+ >+ /** >+ * Returns a factory for creating observable lists tracking the value of the >+ * given feature of a particular {@link EObject object}. >+ * >+ * @param realm >+ * the realm in which to observe. >+ * @param eStructuralFeature >+ * the feature for which to track the value. >+ * @return an observable factory. >+ */ >+ public static IObservableFactory listFactory(final Realm realm, >+ final EStructuralFeature eStructuralFeature) { >+ return new IObservableFactory() { >+ public IObservable createObservable(Object target) { >+ return observeList(realm, (EObject) target, eStructuralFeature); >+ } >+ }; >+ } >+ >+ /** >+ * Returns a factory for creating observable maps tracking the value of the >+ * given feature of a particular {@link EObject object}. >+ * >+ * @param eStructuralFeature >+ * the feature for which to track the value. >+ * @return an observable factory. >+ */ >+ public static IObservableFactory mapFactory( >+ final EStructuralFeature eStructuralFeature) { >+ return new IObservableFactory() { >+ public IObservable createObservable(Object target) { >+ return observeMap((IObservableSet) target, eStructuralFeature); >+ } >+ }; >+ } >+ >+ /** >+ * Returns an observable for the resource contents ( >+ * {@link Resource#getContents()}) >+ * >+ * @param resource >+ * the resources the content should be observed >+ * @return an observable list >+ */ >+ public static IObservableList observeResourceContents(Resource resource) { >+ return new EWritableList<EObject>((NotifyingList<EObject>) resource.getContents()); >+ } > } >Index: src/org/eclipse/emf/databinding/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,69 @@ >+/******************************************************************************* >+ * 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 { >+ >+ /** >+ * Returns the element type of the given collection-typed property for the >+ * given bean. >+ * >+ * @param descriptor >+ * the property being inspected >+ * @return the element type of the given collection-typed property if it is >+ * an array property, or Object.class otherwise. >+ */ >+ public static Class<?> getCollectionPropertyElementType( >+ EStructuralFeature eStructuralFeature) { >+ return Object.class; >+ } >+ >+ >+ /** >+ * @param propertyDescriptor >+ * @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 beanClass >+ * @return class name excluding package >+ */ >+ public static String shortClassName(EStructuralFeature eStructuralFeature) { >+ return eStructuralFeature.getEType().getName(); >+ } >+ >+ /** >+ * @param beanClass >+ * @return class name excluding package >+ */ >+ public static String shortClassName(Class<?> beanClass) { >+ if (beanClass == null) >+ return "?"; //$NON-NLS-1$ >+ String className = beanClass.getName(); >+ int lastDot = className.lastIndexOf('.'); >+ if (lastDot != -1) >+ className = className.substring(lastDot + 1); >+ return className; >+ } >+} >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/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,149 @@ >+/******************************************************************************* >+ * 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.IEMFSetProperty; >+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 propertyDescriptor >+ */ >+ 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 IEMFSetProperty set(EStructuralFeature feature) { >+ return set(feature, null); >+ } >+ >+ public IEMFSetProperty set(EStructuralFeature feature, Class<?> elementType) { >+ return set(EMFProperties.set(feature, elementType)); >+ } >+ >+ public IEMFSetProperty set(IEMFSetProperty property) { >+ return new EMFSetPropertyDecorator(super.set(property), property >+ .getStructuralFeature()); >+ } >+ >+ public IEMFMapProperty map(EStructuralFeature feature) { >+ return map(feature, null, null); >+ } >+ >+ public IEMFMapProperty map(EStructuralFeature feature, Class<?> keyType, >+ Class<?> valueType) { >+ return map(EMFProperties.map(feature, keyType, >+ valueType)); >+ } >+ >+ 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 propertyDescriptor >+ */ >+ 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,86 @@ >+/******************************************************************************* >+ * 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; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public class EMFListProperty extends SimpleListProperty { >+ private EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param propertyDescriptor >+ * @param elementType >+ */ >+ public EMFListProperty(EStructuralFeature eStructuralFeature) { >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ 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/internal/EMFPropertyListenerSupport.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFPropertyListenerSupport.java >diff -N src/org/eclipse/emf/databinding/internal/EMFPropertyListenerSupport.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFPropertyListenerSupport.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2008 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 >+ * Matthew Hall - bug 118516 >+ *******************************************************************************/ >+package org.eclipse.emf.databinding.internal; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.emf.common.notify.Adapter; >+import org.eclipse.emf.ecore.EObject; >+ >+/** >+ * This is a helper that will hook up and listen for >+ * <code>PropertyChangeEvent</code> events for a set of target JavaBeans >+ * >+ * @since 1.0 >+ */ >+public class EMFPropertyListenerSupport { >+ /** >+ * Start listen to target (if it supports the JavaBean property change >+ * listener pattern) >+ * >+ * @param bean >+ * @param propertyName >+ * @param listener >+ */ >+ public static void hookListener(EObject bean, Adapter listener) { >+ Assert.isNotNull(bean, "Bean cannot be null"); //$NON-NLS-1$ >+ Assert.isNotNull(listener, "Listener cannot be null"); //$NON-NLS-1$ >+ bean.eAdapters().add(listener); >+ } >+ >+ /** >+ * Stop listen to target >+ * >+ * @param bean >+ * @param propertyName >+ * @param listener >+ */ >+ public static void unhookListener(EObject bean, Adapter listener) { >+ Assert.isNotNull(bean, "Bean cannot be null"); //$NON-NLS-1$ >+ Assert.isNotNull(listener, "Listener cannot be null"); //$NON-NLS-1$ >+ bean.eAdapters().remove(listener); >+ } >+} >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/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,81 @@ >+/******************************************************************************* >+ * 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; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public class EMFValueProperty extends SimpleValueProperty { >+ private final EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param propertyDescriptor >+ * @param valueType >+ */ >+ public EMFValueProperty(EStructuralFeature eStructuralFeature) { >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ public Object getValueType() { >+ return eStructuralFeature; >+ } >+ >+ protected EStructuralFeature getFeature() { >+ return eStructuralFeature; >+ } >+ >+ protected Object doGetValue(Object source) { >+ EObject eObj = (EObject) source; >+ return 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/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,207 @@ >+/******************************************************************************* >+ * 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 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 IEMFValueProperty 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(IEMFValueProperty) >+ */ >+ public IEMFValueProperty value(FeaturePath featurePath); >+ >+ 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 >+ * 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 IEMFValueProperty value(IEMFValueProperty 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(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. >+ * 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 IEMFListProperty list(IEMFListProperty property); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * set property. >+ * >+ * @param propertyName >+ * the set property to observe >+ * @return a master-detail combination of this property and the specified >+ * set property. >+ * @see #set(IEMFSetProperty) >+ */ >+ public IEMFSetProperty set(EStructuralFeature feature); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * set property. >+ * >+ * @param propertyName >+ * the set property to observe >+ * @param elementType >+ * the element type of the named property >+ * @return a master-detail combination of this property and the specified >+ * set property. >+ * @see #set(IEMFSetProperty) >+ */ >+ public IEMFSetProperty set(EStructuralFeature feature, Class<?> elementType); >+ >+ /** >+ * Returns a master-detail combination of this property and the specified >+ * set property. The returned property will observe the specified set >+ * 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 Set-typed "children" property of a Node object >+ * // where the elements are Node objects >+ * IBeanSetProperty children = BeanProperties.set(Node.class, "children", >+ * Node.class); >+ * // Observes the children of the parent (siblings) of a Node object. >+ * IBeanSetProperty siblings = parent.set(children); >+ * </pre> >+ * >+ * @param property >+ * the detail property to observe >+ * @return a master-detail combination of this property and the specified >+ * set property. >+ */ >+ public IEMFSetProperty set(IEMFSetProperty 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(IEMFMapProperty) >+ */ >+ public IEMFMapProperty 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(IEMFMapProperty) >+ */ >+ public IEMFMapProperty 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 IEMFMapProperty map(IEMFMapProperty 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,163 @@ >+package org.eclipse.emf.databinding.internal; >+ >+import java.util.Collection; >+import java.util.Map; >+import java.util.Set; >+ >+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 { >+ >+ private EMFPropertyListener() { >+ } >+ >+ public void addTo(Object source) { >+ EMFPropertyListenerSupport.hookListener((EObject) source, this); >+ } >+ >+ public void removeFrom(Object source) { >+ EMFPropertyListenerSupport.unhookListener((EObject) source, this); >+ } >+ >+ @Override >+ public abstract void notifyChanged(Notification msg); >+ >+ protected abstract ISimplePropertyListener getListener(); >+ >+ protected abstract EStructuralFeature getFeature(); >+ >+ 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 EMFSetPropertyListener extends >+ EMFPropertyListener { >+ @Override >+ public void notifyChanged(Notification msg) { >+ if (getFeature() == msg.getFeature() && !msg.isTouch()) { >+ getListener().handleEvent( >+ new SimplePropertyEvent(SimplePropertyEvent.CHANGE, msg >+ .getNotifier(), getOwner(), Diffs >+ .computeSetDiff((Set<?>) msg.getOldValue(), >+ (Set<?>) 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/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,63 @@ >+/******************************************************************************* >+ * 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 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(IEMFValueProperty) >+ */ >+ public IEMFListProperty values(FeaturePath featurePath); >+ >+ 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 >+ * 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 IEMFListProperty values(IEMFValueProperty property); >+} >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/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,58 @@ >+/******************************************************************************* >+ * 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 >+ * 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(IEMFValueProperty) >+ */ >+ public IEMFMapProperty values(FeaturePath featurePath); >+ >+ 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/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 propertyDescriptor >+ */ >+ 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/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,93 @@ >+/******************************************************************************* >+ * 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; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public class EMFListPropertyDecorator extends ListProperty implements >+ IEMFListProperty { >+ private final IListProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param delegate >+ * @param propertyDescriptor >+ */ >+ 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/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/EMFSetProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFSetProperty.java >diff -N src/org/eclipse/emf/databinding/internal/EMFSetProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFSetProperty.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,91 @@ >+/******************************************************************************* >+ * 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, 265064, 265561 >+ ******************************************************************************/ >+ >+package org.eclipse.emf.databinding.internal; >+ >+import java.util.Set; >+ >+import org.eclipse.core.databinding.observable.set.SetDiff; >+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.set.SimpleSetProperty; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public class EMFSetProperty extends SimpleSetProperty { >+ private final EStructuralFeature eStructuralFeature; >+ private final Class<?> elementType; >+ >+ /** >+ * @param propertyDescriptor >+ * @param elementType >+ */ >+ public EMFSetProperty(EStructuralFeature eStructuralFeature, >+ Class<?> elementType) { >+ this.eStructuralFeature = eStructuralFeature; >+ this.elementType = elementType == null ? EMFPropertyHelper >+ .getCollectionPropertyElementType(eStructuralFeature) >+ : elementType; >+ } >+ >+ protected EStructuralFeature getFeature() { >+ return eStructuralFeature; >+ } >+ >+ public Object getElementType() { >+ return elementType; >+ } >+ >+ protected Set<?> doGetSet(Object source) { >+ EObject eObj = (EObject) source; >+ return (Set<?>) eObj.eGet(eStructuralFeature); >+ } >+ >+ @SuppressWarnings("unchecked") >+ protected void doSetSet(Object source, Set set, SetDiff diff) { >+ EObject eObject = (EObject) source; >+ eObject.eSet(eStructuralFeature, set); >+ } >+ >+ public INativePropertyListener adaptListener( >+ final ISimplePropertyListener listener) { >+ return new EMFPropertyListener.EMFSetPropertyListener(){ >+ >+ @Override >+ protected IProperty getOwner() { >+ return EMFSetProperty.this; >+ } >+ >+ @Override >+ protected ISimplePropertyListener getListener() { >+ return listener; >+ } >+ >+ @Override >+ protected EStructuralFeature getFeature() { >+ return eStructuralFeature; >+ } >+ }; >+ } >+ >+ public String toString() { >+ String s = EMFPropertyHelper.propertyName(eStructuralFeature) + "{}"; //$NON-NLS-1$ >+ if (elementType != null) >+ s += "<" + EMFPropertyHelper.shortClassName(elementType) + ">"; //$NON-NLS-1$//$NON-NLS-2$ >+ return s; >+ } >+} >Index: src/org/eclipse/emf/databinding/internal/EMFObservableSetDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFObservableSetDecorator.java >diff -N src/org/eclipse/emf/databinding/internal/EMFObservableSetDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFObservableSetDecorator.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.set.DecoratingObservableSet; >+import org.eclipse.core.databinding.observable.set.IObservableSet; >+import org.eclipse.emf.databinding.IEMFObservable; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * {@link IEMFObservable} decorator for an {@link IObservableSet}. >+ * >+ * @since 3.3 >+ */ >+public class EMFObservableSetDecorator extends DecoratingObservableSet >+ implements IEMFObservable { >+ private EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param decorated >+ * @param propertyDescriptor >+ */ >+ public EMFObservableSetDecorator(IObservableSet 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/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 propertyDescriptor >+ */ >+ 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,173 @@ >+/******************************************************************************* >+ * 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 >+ ******************************************************************************/ >+ >+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.set.ISetProperty; >+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.EMFSetProperty; >+import org.eclipse.emf.databinding.internal.EMFSetPropertyDecorator; >+import org.eclipse.emf.databinding.internal.EMFValueProperty; >+import org.eclipse.emf.databinding.internal.EMFValuePropertyDecorator; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * 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 EMFProperties { >+ public static final boolean DEBUG = false; >+ >+ public static IEMFValueProperty value(EStructuralFeature feature) { >+ return value(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 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; >+ } >+ >+ 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 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 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; >+ } >+ >+ public static IEMFSetProperty set(EStructuralFeature feature) { >+ return set(feature,null); >+ } >+ >+ /** >+ * Returns a set 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 set property >+ * @return a set property for the given property name of the given bean >+ * class. >+ */ >+ public static IEMFSetProperty set(EStructuralFeature feature, Class<?> elementType) { >+ ISetProperty property; >+ property = new EMFSetProperty(feature, elementType); >+ return new EMFSetPropertyDecorator(property, feature); >+ } >+ >+ /** >+ * 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 IEMFListProperty list(EStructuralFeature feature) { >+ IListProperty property; >+ property = new EMFListProperty(feature); >+ return new EMFListPropertyDecorator(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 IEMFMapProperty map(EStructuralFeature feature) { >+ return map(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 IEMFMapProperty map(EStructuralFeature feature, >+ Class<?> keyType, Class<?> valueType) { >+ IMapProperty property; >+ property = new EMFMapProperty(feature, keyType, >+ valueType); >+ return new EMFMapPropertyDecorator(property, feature); >+ } >+} >Index: src/org/eclipse/emf/databinding/IEMFSetProperty.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/IEMFSetProperty.java >diff -N src/org/eclipse/emf/databinding/IEMFSetProperty.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/IEMFSetProperty.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 org.eclipse.core.databinding.property.set.ISetProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * An {@link ISetProperty} 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 IEMFSetProperty extends IEMFProperty, ISetProperty { >+ /** >+ * 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(IEMFValueProperty) >+ */ >+ public IEMFMapProperty values(FeaturePath featurePath); >+ >+ 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 elements observed by this set property, mapping from >+ * this set property's elements (keys) to the specified value property's >+ * value for each element (values). >+ * <p> >+ * Example: >+ * >+ * <pre> >+ * // Observes the set-typed "children" property of a Person object, >+ * // where the elements are Person objects >+ * IBeanSetProperty children = BeanProperties.set(Person.class, "children", >+ * Person.class); >+ * // Observes the string-typed "name" property of a Person object >+ * IBeanValueProperty name = BeanProperties.value(Person.class, "name"); >+ * // Observes a map of children objects to their respective names. >+ * IBeanMapProperty 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 IEMFMapProperty values(IEMFValueProperty property); >+} >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,19 @@ >+package org.eclipse.emf.databinding; >+ >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+public class FeaturePath { >+ private EStructuralFeature[] featurePath; >+ >+ private FeaturePath(EStructuralFeature[] featurePath) { >+ this.featurePath = featurePath; >+ } >+ >+ public EStructuralFeature[] getFeaturePath() { >+ return featurePath; >+ } >+ >+ public static FeaturePath fromList(EStructuralFeature... featurePath) { >+ return new FeaturePath(featurePath); >+ } >+} >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 propertyDescriptor >+ */ >+ 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,99 @@ >+/******************************************************************************* >+ * 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.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.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public class EMFMapProperty extends SimpleMapProperty { >+ private EStructuralFeature eStructuralFeature; >+ >+ private final Class<?> keyType; >+ private final Class<?> valueType; >+ >+ /** >+ * @param propertyDescriptor >+ * @param keyType >+ * @param valueType >+ */ >+ public EMFMapProperty(EStructuralFeature eStructuralFeature, >+ Class<?> keyType, Class<?> valueType) { >+ this.eStructuralFeature = eStructuralFeature; >+ this.keyType = keyType; >+ this.valueType = valueType; >+ } >+ >+ protected EStructuralFeature getFeature() { >+ return eStructuralFeature; >+ } >+ >+ public Object getKeyType() { >+ return keyType; >+ } >+ >+ public Object getValueType() { >+ return valueType; >+ } >+ >+ 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$ >+ >+ if (keyType != null || valueType != null) >+ s += "<" + EMFPropertyHelper.shortClassName(keyType) + ", " //$NON-NLS-1$ //$NON-NLS-2$ >+ + EMFPropertyHelper.shortClassName(valueType) + ">"; //$NON-NLS-1$ >+ return s; >+ } >+} >Index: src/org/eclipse/emf/databinding/internal/EMFSetPropertyDecorator.java >=================================================================== >RCS file: src/org/eclipse/emf/databinding/internal/EMFSetPropertyDecorator.java >diff -N src/org/eclipse/emf/databinding/internal/EMFSetPropertyDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/databinding/internal/EMFSetPropertyDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+/******************************************************************************* >+ * 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.masterdetail.IObservableFactory; >+import org.eclipse.core.databinding.observable.set.IObservableSet; >+import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.core.databinding.property.set.ISetProperty; >+import org.eclipse.core.databinding.property.set.SetProperty; >+import org.eclipse.emf.databinding.EMFProperties; >+import org.eclipse.emf.databinding.FeaturePath; >+import org.eclipse.emf.databinding.IEMFMapProperty; >+import org.eclipse.emf.databinding.IEMFSetProperty; >+import org.eclipse.emf.databinding.IEMFValueProperty; >+import org.eclipse.emf.ecore.EStructuralFeature; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public class EMFSetPropertyDecorator extends SetProperty implements >+ IEMFSetProperty { >+ private final ISetProperty delegate; >+ private final EStructuralFeature eStructuralFeature; >+ >+ /** >+ * @param delegate >+ * @param propertyDescriptor >+ */ >+ public EMFSetPropertyDecorator(ISetProperty delegate, >+ EStructuralFeature eStructuralFeature) { >+ this.delegate = delegate; >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ public EStructuralFeature getStructuralFeature() { >+ return eStructuralFeature; >+ } >+ >+ public Object getElementType() { >+ return delegate.getElementType(); >+ } >+ >+ 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 IObservableSet observe(Object source) { >+ return new EMFObservableSetDecorator(delegate.observe(source), >+ eStructuralFeature); >+ } >+ >+ public IObservableSet observe(Realm realm, Object source) { >+ return new EMFObservableSetDecorator(delegate.observe(realm, source), >+ eStructuralFeature); >+ } >+ >+ public IObservableFactory setFactory() { >+ return delegate.setFactory(); >+ } >+ >+ public IObservableFactory setFactory(Realm realm) { >+ return delegate.setFactory(realm); >+ } >+ >+ public IObservableSet observeDetail(IObservableValue master) { >+ return new EMFObservableSetDecorator(delegate.observeDetail(master), >+ eStructuralFeature); >+ } >+ >+ public String toString() { >+ return delegate.toString(); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 262160
:
123633
|
124701
|
125052
|
125836
|
125841
|
132310
|
132579
|
132670
|
134185
|
134272
|
134465
|
134529
|
134710
|
136365
|
136370