|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2008 Matthew Hall and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Matthew Hall - initial API and implementation (bug 195222) |
| 12 |
* Matthew Hall - bug 264307 |
| 13 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 14 |
* </copyright> |
| 15 |
* |
| 16 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 17 |
*/ |
| 18 |
package org.eclipse.emf.databinding.internal; |
| 19 |
|
| 20 |
import org.eclipse.core.databinding.observable.Realm; |
| 21 |
import org.eclipse.core.databinding.observable.list.IObservableList; |
| 22 |
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; |
| 23 |
import org.eclipse.core.databinding.observable.value.IObservableValue; |
| 24 |
import org.eclipse.core.databinding.property.list.IListProperty; |
| 25 |
import org.eclipse.core.databinding.property.list.ListProperty; |
| 26 |
import org.eclipse.emf.databinding.EMFProperties; |
| 27 |
import org.eclipse.emf.databinding.FeaturePath; |
| 28 |
import org.eclipse.emf.databinding.IEMFListProperty; |
| 29 |
import org.eclipse.emf.databinding.IEMFValueProperty; |
| 30 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 31 |
|
| 32 |
|
| 33 |
/** |
| 34 |
* @since 2.5 |
| 35 |
*/ |
| 36 |
public class EMFListPropertyDecorator extends ListProperty implements IEMFListProperty |
| 37 |
{ |
| 38 |
private final IListProperty delegate; |
| 39 |
private final EStructuralFeature eStructuralFeature; |
| 40 |
|
| 41 |
/** |
| 42 |
* @param delegate |
| 43 |
* @param eStructuralFeature |
| 44 |
*/ |
| 45 |
public EMFListPropertyDecorator(IListProperty delegate, EStructuralFeature eStructuralFeature) |
| 46 |
{ |
| 47 |
this.delegate = delegate; |
| 48 |
this.eStructuralFeature = eStructuralFeature; |
| 49 |
} |
| 50 |
|
| 51 |
public Object getElementType() |
| 52 |
{ |
| 53 |
return delegate.getElementType(); |
| 54 |
} |
| 55 |
|
| 56 |
public IEMFListProperty values(EStructuralFeature feature) |
| 57 |
{ |
| 58 |
return values(FeaturePath.fromList(feature)); |
| 59 |
} |
| 60 |
|
| 61 |
public IEMFListProperty values(FeaturePath featurePath) |
| 62 |
{ |
| 63 |
return values(EMFProperties.value(featurePath)); |
| 64 |
} |
| 65 |
|
| 66 |
public IEMFListProperty values(IEMFValueProperty property) |
| 67 |
{ |
| 68 |
return new EMFListPropertyDecorator(super.values(property), property.getStructuralFeature()); |
| 69 |
} |
| 70 |
|
| 71 |
public EStructuralFeature getStructuralFeature() |
| 72 |
{ |
| 73 |
return eStructuralFeature; |
| 74 |
} |
| 75 |
|
| 76 |
public IObservableList observe(Object source) |
| 77 |
{ |
| 78 |
return new EMFObservableListDecorator(delegate.observe(source), eStructuralFeature); |
| 79 |
} |
| 80 |
|
| 81 |
public IObservableList observe(Realm realm, Object source) |
| 82 |
{ |
| 83 |
return new EMFObservableListDecorator(delegate.observe(realm, source), eStructuralFeature); |
| 84 |
} |
| 85 |
|
| 86 |
public IObservableFactory listFactory() |
| 87 |
{ |
| 88 |
return delegate.listFactory(); |
| 89 |
} |
| 90 |
|
| 91 |
public IObservableFactory listFactory(Realm realm) |
| 92 |
{ |
| 93 |
return delegate.listFactory(realm); |
| 94 |
} |
| 95 |
|
| 96 |
public IObservableList observeDetail(IObservableValue master) |
| 97 |
{ |
| 98 |
return new EMFObservableListDecorator(delegate.observeDetail(master), eStructuralFeature); |
| 99 |
} |
| 100 |
|
| 101 |
public String toString() |
| 102 |
{ |
| 103 |
return delegate.toString(); |
| 104 |
} |
| 105 |
}
Index: src/org/eclipse/emf/databinding/internal/EMFObservableListDecorator.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2007 Brad Reynolds and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Brad Reynolds - initial API and implementation |
| 12 |
* Matthew Hall - bugs 208858, 246625 |
| 13 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 14 |
* </copyright> |
| 15 |
* |
| 16 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 17 |
*/ |
| 18 |
package org.eclipse.emf.databinding.internal; |
| 19 |
|
| 20 |
import org.eclipse.core.databinding.observable.IObservable; |
| 21 |
import org.eclipse.core.databinding.observable.IObserving; |
| 22 |
import org.eclipse.core.databinding.observable.list.DecoratingObservableList; |
| 23 |
import org.eclipse.core.databinding.observable.list.IObservableList; |
| 24 |
import org.eclipse.emf.databinding.IEMFObservable; |
| 25 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 26 |
|
| 27 |
|
| 28 |
/** |
| 29 |
* {@link IEMFObservable} decorator for an {@link IObservableList}. |
| 30 |
* @since 2.5 |
| 31 |
*/ |
| 32 |
public class EMFObservableListDecorator extends DecoratingObservableList implements IEMFObservable |
| 33 |
{ |
| 34 |
private EStructuralFeature eStructuralFeature; |
| 35 |
|
| 36 |
/** |
| 37 |
* @param decorated |
| 38 |
* @param eStructuralFeature |
| 39 |
*/ |
| 40 |
public EMFObservableListDecorator(IObservableList decorated, EStructuralFeature eStructuralFeature) |
| 41 |
{ |
| 42 |
super(decorated, true); |
| 43 |
this.eStructuralFeature = eStructuralFeature; |
| 44 |
} |
| 45 |
|
| 46 |
public synchronized void dispose() |
| 47 |
{ |
| 48 |
this.eStructuralFeature = null; |
| 49 |
super.dispose(); |
| 50 |
} |
| 51 |
|
| 52 |
public Object getObserved() |
| 53 |
{ |
| 54 |
IObservable decorated = getDecorated(); |
| 55 |
if (decorated instanceof IObserving) |
| 56 |
return ((IObserving)decorated).getObserved(); |
| 57 |
return null; |
| 58 |
} |
| 59 |
|
| 60 |
public EStructuralFeature getStructuralFeature() |
| 61 |
{ |
| 62 |
return eStructuralFeature; |
| 63 |
} |
| 64 |
}
Index: src/org/eclipse/emf/databinding/internal/Util.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2006 IBM Corporation and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* IBM Corporation - initial API and implementation |
| 12 |
* </copyright> |
| 13 |
* |
| 14 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 15 |
*/ |
| 16 |
package org.eclipse.emf.databinding.internal; |
| 17 |
|
| 18 |
/** |
| 19 |
* @since 2.5 |
| 20 |
*/ |
| 21 |
public class Util |
| 22 |
{ |
| 23 |
|
| 24 |
/** |
| 25 |
* Checks whether the two objects are <code>null</code> -- allowing for |
| 26 |
* <code>null</code>. |
| 27 |
* |
| 28 |
* @param left |
| 29 |
* The left object to compare; may be <code>null</code>. |
| 30 |
* @param right |
| 31 |
* The right object to compare; may be <code>null</code>. |
| 32 |
* @return <code>true</code> if the two objects are equivalent; |
| 33 |
* <code>false</code> otherwise. |
| 34 |
*/ |
| 35 |
public static final boolean equals(final Object left, final Object right) |
| 36 |
{ |
| 37 |
return left == null ? right == null : ((right != null) && left.equals(right)); |
| 38 |
} |
| 39 |
}
Index: src/org/eclipse/emf/databinding/internal/EMFValuePropertyDecorator.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2008 Matthew Hall and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Matthew Hall - initial API and implementation (bug 194734) |
| 12 |
* Matthew Hall - bugs 195222, 264307, 265561 |
| 13 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 14 |
* </copyright> |
| 15 |
* |
| 16 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 17 |
*/ |
| 18 |
package org.eclipse.emf.databinding.internal; |
| 19 |
|
| 20 |
import org.eclipse.core.databinding.observable.Realm; |
| 21 |
import org.eclipse.core.databinding.observable.list.IObservableList; |
| 22 |
import org.eclipse.core.databinding.observable.map.IObservableMap; |
| 23 |
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; |
| 24 |
import org.eclipse.core.databinding.observable.set.IObservableSet; |
| 25 |
import org.eclipse.core.databinding.observable.value.IObservableValue; |
| 26 |
import org.eclipse.core.databinding.property.value.IValueProperty; |
| 27 |
import org.eclipse.core.databinding.property.value.ValueProperty; |
| 28 |
import org.eclipse.emf.databinding.EMFProperties; |
| 29 |
import org.eclipse.emf.databinding.FeaturePath; |
| 30 |
import org.eclipse.emf.databinding.IEMFListProperty; |
| 31 |
import org.eclipse.emf.databinding.IEMFMapProperty; |
| 32 |
import org.eclipse.emf.databinding.IEMFValueProperty; |
| 33 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 34 |
|
| 35 |
|
| 36 |
/** |
| 37 |
* @since 2.5 |
| 38 |
*/ |
| 39 |
public class EMFValuePropertyDecorator extends ValueProperty implements IEMFValueProperty |
| 40 |
{ |
| 41 |
private final IValueProperty delegate; |
| 42 |
private final EStructuralFeature eStructuralFeature; |
| 43 |
|
| 44 |
/** |
| 45 |
* @param delegate |
| 46 |
* @param eStructuralFeature |
| 47 |
*/ |
| 48 |
public EMFValuePropertyDecorator(IValueProperty delegate, EStructuralFeature eStructuralFeature) |
| 49 |
{ |
| 50 |
this.delegate = delegate; |
| 51 |
this.eStructuralFeature = eStructuralFeature; |
| 52 |
} |
| 53 |
|
| 54 |
public EStructuralFeature getStructuralFeature() |
| 55 |
{ |
| 56 |
return eStructuralFeature; |
| 57 |
} |
| 58 |
|
| 59 |
public Object getValueType() |
| 60 |
{ |
| 61 |
return delegate.getValueType(); |
| 62 |
} |
| 63 |
|
| 64 |
public IEMFValueProperty value(EStructuralFeature feature) |
| 65 |
{ |
| 66 |
return value(FeaturePath.fromList(feature)); |
| 67 |
} |
| 68 |
|
| 69 |
public IEMFValueProperty value(FeaturePath featurePath) |
| 70 |
{ |
| 71 |
return value(EMFProperties.value(featurePath)); |
| 72 |
} |
| 73 |
|
| 74 |
public IEMFValueProperty value(IEMFValueProperty property) |
| 75 |
{ |
| 76 |
return new EMFValuePropertyDecorator(super.value(property), property.getStructuralFeature()); |
| 77 |
} |
| 78 |
|
| 79 |
public IEMFListProperty list(EStructuralFeature feature) |
| 80 |
{ |
| 81 |
return list(EMFProperties.list(feature)); |
| 82 |
} |
| 83 |
|
| 84 |
public IEMFListProperty list(IEMFListProperty property) |
| 85 |
{ |
| 86 |
return new EMFListPropertyDecorator(super.list(property), property.getStructuralFeature()); |
| 87 |
} |
| 88 |
|
| 89 |
public IEMFMapProperty map(EStructuralFeature feature) |
| 90 |
{ |
| 91 |
return map(EMFProperties.map(feature)); |
| 92 |
} |
| 93 |
|
| 94 |
public IEMFMapProperty map(IEMFMapProperty property) |
| 95 |
{ |
| 96 |
return new EMFMapPropertyDecorator(super.map(property), property.getStructuralFeature()); |
| 97 |
} |
| 98 |
|
| 99 |
public IObservableValue observe(Object source) |
| 100 |
{ |
| 101 |
return new EMFObservableValueDecorator(delegate.observe(source), eStructuralFeature); |
| 102 |
} |
| 103 |
|
| 104 |
public IObservableValue observe(Realm realm, Object source) |
| 105 |
{ |
| 106 |
return new EMFObservableValueDecorator(delegate.observe(realm, source), eStructuralFeature); |
| 107 |
} |
| 108 |
|
| 109 |
public IObservableFactory valueFactory() |
| 110 |
{ |
| 111 |
return delegate.valueFactory(); |
| 112 |
} |
| 113 |
|
| 114 |
public IObservableFactory valueFactory(Realm realm) |
| 115 |
{ |
| 116 |
return delegate.valueFactory(realm); |
| 117 |
} |
| 118 |
|
| 119 |
public IObservableValue observeDetail(IObservableValue master) |
| 120 |
{ |
| 121 |
return new EMFObservableValueDecorator(delegate.observeDetail(master), eStructuralFeature); |
| 122 |
} |
| 123 |
|
| 124 |
public IObservableList observeDetail(IObservableList master) |
| 125 |
{ |
| 126 |
return new EMFObservableListDecorator(delegate.observeDetail(master), eStructuralFeature); |
| 127 |
} |
| 128 |
|
| 129 |
public IObservableMap observeDetail(IObservableSet master) |
| 130 |
{ |
| 131 |
return new EMFObservableMapDecorator(delegate.observeDetail(master), eStructuralFeature); |
| 132 |
} |
| 133 |
|
| 134 |
public IObservableMap observeDetail(IObservableMap master) |
| 135 |
{ |
| 136 |
return new EMFObservableMapDecorator(delegate.observeDetail(master), eStructuralFeature); |
| 137 |
} |
| 138 |
|
| 139 |
public String toString() |
| 140 |
{ |
| 141 |
return delegate.toString(); |
| 142 |
} |
| 143 |
}
Index: src/org/eclipse/emf/databinding/internal/EMFObservableMapDecorator.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2008 Matthew Hall and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Matthew Hall - initial API and implementation (bug 221704) |
| 12 |
* Matthew Hall - bug 246625 |
| 13 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 14 |
* </copyright> |
| 15 |
* |
| 16 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 17 |
*/ |
| 18 |
package org.eclipse.emf.databinding.internal; |
| 19 |
|
| 20 |
import org.eclipse.core.databinding.observable.IObservable; |
| 21 |
import org.eclipse.core.databinding.observable.IObserving; |
| 22 |
import org.eclipse.core.databinding.observable.map.DecoratingObservableMap; |
| 23 |
import org.eclipse.core.databinding.observable.map.IObservableMap; |
| 24 |
import org.eclipse.emf.databinding.IEMFObservable; |
| 25 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 26 |
|
| 27 |
|
| 28 |
/** |
| 29 |
* {@link IEMFObservable} decorator for an {@link IObservableMap}. |
| 30 |
* |
| 31 |
* @since 2.5 |
| 32 |
*/ |
| 33 |
public class EMFObservableMapDecorator extends DecoratingObservableMap implements IEMFObservable |
| 34 |
{ |
| 35 |
private EStructuralFeature eStructuralFeature; |
| 36 |
|
| 37 |
/** |
| 38 |
* @param decorated |
| 39 |
* @param eStructuralFeature |
| 40 |
*/ |
| 41 |
public EMFObservableMapDecorator(IObservableMap decorated, EStructuralFeature eStructuralFeature) |
| 42 |
{ |
| 43 |
super(decorated, true); |
| 44 |
this.eStructuralFeature = eStructuralFeature; |
| 45 |
} |
| 46 |
|
| 47 |
public synchronized void dispose() |
| 48 |
{ |
| 49 |
this.eStructuralFeature = null; |
| 50 |
super.dispose(); |
| 51 |
} |
| 52 |
|
| 53 |
public Object getObserved() |
| 54 |
{ |
| 55 |
IObservable decorated = getDecorated(); |
| 56 |
if (decorated instanceof IObserving) |
| 57 |
return ((IObserving)decorated).getObserved(); |
| 58 |
return null; |
| 59 |
} |
| 60 |
|
| 61 |
public EStructuralFeature getStructuralFeature() |
| 62 |
{ |
| 63 |
return eStructuralFeature; |
| 64 |
} |
| 65 |
}
Index: src/org/eclipse/emf/databinding/internal/EMFListProperty.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2008 Matthew Hall and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Matthew Hall - initial API and implementation (bug 194734) |
| 12 |
* Matthew Hall - bugs 195222, 264307, 265561 |
| 13 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 14 |
* </copyright> |
| 15 |
* |
| 16 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 17 |
*/ |
| 18 |
package org.eclipse.emf.databinding.internal; |
| 19 |
|
| 20 |
import java.util.List; |
| 21 |
|
| 22 |
import org.eclipse.core.databinding.observable.list.ListDiff; |
| 23 |
import org.eclipse.core.databinding.property.INativePropertyListener; |
| 24 |
import org.eclipse.core.databinding.property.IProperty; |
| 25 |
import org.eclipse.core.databinding.property.ISimplePropertyListener; |
| 26 |
import org.eclipse.core.databinding.property.list.SimpleListProperty; |
| 27 |
import org.eclipse.emf.ecore.EObject; |
| 28 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 29 |
|
| 30 |
|
| 31 |
/** |
| 32 |
* @since 2.5 |
| 33 |
*/ |
| 34 |
public class EMFListProperty extends SimpleListProperty |
| 35 |
{ |
| 36 |
private EStructuralFeature eStructuralFeature; |
| 37 |
|
| 38 |
/** |
| 39 |
* @param eStructuralFeature |
| 40 |
*/ |
| 41 |
public EMFListProperty(EStructuralFeature eStructuralFeature) |
| 42 |
{ |
| 43 |
this.eStructuralFeature = eStructuralFeature; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* @return the feature |
| 48 |
*/ |
| 49 |
protected EStructuralFeature getFeature() |
| 50 |
{ |
| 51 |
return eStructuralFeature; |
| 52 |
} |
| 53 |
|
| 54 |
public Object getElementType() |
| 55 |
{ |
| 56 |
return eStructuralFeature; |
| 57 |
} |
| 58 |
|
| 59 |
protected List< ? > doGetList(Object source) |
| 60 |
{ |
| 61 |
EObject eObj = (EObject)source; |
| 62 |
return (List< ? >)eObj.eGet(eStructuralFeature); |
| 63 |
} |
| 64 |
|
| 65 |
@SuppressWarnings("unchecked") |
| 66 |
protected void doSetList(Object source, List list, ListDiff diff) |
| 67 |
{ |
| 68 |
List< ? > currentList = doGetList(source); |
| 69 |
diff.applyTo(currentList); |
| 70 |
} |
| 71 |
|
| 72 |
public INativePropertyListener adaptListener(final ISimplePropertyListener listener) |
| 73 |
{ |
| 74 |
return new EMFPropertyListener.EMFListPropertyListener() |
| 75 |
{ |
| 76 |
|
| 77 |
@Override |
| 78 |
protected EStructuralFeature getFeature() |
| 79 |
{ |
| 80 |
return eStructuralFeature; |
| 81 |
} |
| 82 |
|
| 83 |
@Override |
| 84 |
protected ISimplePropertyListener getListener() |
| 85 |
{ |
| 86 |
return listener; |
| 87 |
} |
| 88 |
|
| 89 |
@Override |
| 90 |
protected IProperty getOwner() |
| 91 |
{ |
| 92 |
return EMFListProperty.this; |
| 93 |
} |
| 94 |
}; |
| 95 |
} |
| 96 |
|
| 97 |
public String toString() |
| 98 |
{ |
| 99 |
String s = EMFPropertyHelper.propertyName(eStructuralFeature) + "[]"; //$NON-NLS-1$ |
| 100 |
s += "<" + EMFPropertyHelper.shortClassName(eStructuralFeature) + ">"; //$NON-NLS-1$//$NON-NLS-2$ |
| 101 |
return s; |
| 102 |
} |
| 103 |
|
| 104 |
}
Index: src/org/eclipse/emf/databinding/IEMFObservable.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2007 Brad Reynolds and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Brad Reynolds - initial API and implementation |
| 12 |
* Brad Reynolds - bug 147515 |
| 13 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 14 |
* </copyright> |
| 15 |
* |
| 16 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 17 |
*/ |
| 18 |
package org.eclipse.emf.databinding; |
| 19 |
|
| 20 |
import org.eclipse.core.databinding.observable.IObserving; |
| 21 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 22 |
|
| 23 |
|
| 24 |
/** |
| 25 |
* <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> |
| 26 |
* |
| 27 |
* Provides access to details of EObject observables. |
| 28 |
* <p> |
| 29 |
* This interface is not meant to be implemented by clients. |
| 30 |
* </p> |
| 31 |
* |
| 32 |
* @since 2.5 |
| 33 |
* @noextend This interface is not intended to be extended by clients. |
| 34 |
* @noimplement This interface is not intended to be implemented by clients. |
| 35 |
*/ |
| 36 |
public interface IEMFObservable extends IObserving |
| 37 |
{ |
| 38 |
/** |
| 39 |
* @return property descriptor of the property being observed, |
| 40 |
* <code>null</code> if the runtime time information was not |
| 41 |
* provided on construction of the observable |
| 42 |
*/ |
| 43 |
public EStructuralFeature getStructuralFeature(); |
| 44 |
}
Index: src/org/eclipse/emf/databinding/IEMFValueProperty.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2008 Matthew Hall and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Matthew Hall - initial API and implementation (bug 195222) |
| 12 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 13 |
* </copyright> |
| 14 |
* |
| 15 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 16 |
*/ |
| 17 |
package org.eclipse.emf.databinding; |
| 18 |
|
| 19 |
import org.eclipse.core.databinding.property.value.IValueProperty; |
| 20 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 21 |
|
| 22 |
|
| 23 |
/** |
| 24 |
* <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> |
| 25 |
* |
| 26 |
* An {@link IValueProperty} extension interface with convenience methods for |
| 27 |
* creating nested {@link EStructuralFeature} properties. |
| 28 |
* |
| 29 |
* @since 2.5 |
| 30 |
* @noextend This interface is not intended to be extended by clients. |
| 31 |
* @noimplement This interface is not intended to be implemented by clients. |
| 32 |
*/ |
| 33 |
public interface IEMFValueProperty extends IEMFProperty, IValueProperty |
| 34 |
{ |
| 35 |
/** |
| 36 |
* Returns a master-detail combination of this property and the specified |
| 37 |
* nested value feature. |
| 38 |
* |
| 39 |
* @param featurePath |
| 40 |
* the nested value property to observe. |
| 41 |
* @return a master-detail combination of this property and the specified |
| 42 |
* nested value feature. |
| 43 |
* @see #value(IEMFValueProperty) |
| 44 |
*/ |
| 45 |
public IEMFValueProperty value(FeaturePath featurePath); |
| 46 |
|
| 47 |
/** |
| 48 |
* Returns a master-detail combination of this property and the specified |
| 49 |
* value feature. |
| 50 |
* |
| 51 |
* @param feature |
| 52 |
* the nested value property to observe. |
| 53 |
* @return a master-detail combination of this property and the specified |
| 54 |
* value feature. |
| 55 |
* @see #value(IEMFValueProperty) |
| 56 |
*/ |
| 57 |
public IEMFValueProperty value(EStructuralFeature feature); |
| 58 |
|
| 59 |
/** |
| 60 |
* Returns a master-detail combination of this property and the specified |
| 61 |
* value property. The returned property will observe the specified detail |
| 62 |
* value property for the value of the master value property. |
| 63 |
* <p> |
| 64 |
* Example: |
| 65 |
* |
| 66 |
* <pre> |
| 67 |
* // Observes the Node-typed "parent" property of a Node object |
| 68 |
* IEMFValueProperty parent = EMFProperties.value(MyPackage.Literals.NODE_PARENT); |
| 69 |
* // Observes the string-typed "name" property of a Node object |
| 70 |
* IEMFValueProperty name = EMFProperties.value(MyPackage.Literals.NODE_NAME); |
| 71 |
* // Observes the name of the parent of a Node object. |
| 72 |
* IEMFValueProperty parentName = parent.value(name); |
| 73 |
* </pre> |
| 74 |
* |
| 75 |
* @param property |
| 76 |
* the detail property to observe |
| 77 |
* @return a master-detail combination of this property and the specified |
| 78 |
* value property. |
| 79 |
*/ |
| 80 |
public IEMFValueProperty value(IEMFValueProperty property); |
| 81 |
|
| 82 |
/** |
| 83 |
* Returns a master-detail combination of this property and the specified |
| 84 |
* list feature. |
| 85 |
* |
| 86 |
* @param feature |
| 87 |
* the list feature to observe |
| 88 |
* @return a master-detail combination of this property and the specified |
| 89 |
* list feature. |
| 90 |
* @see #list(IEMFListProperty) |
| 91 |
*/ |
| 92 |
public IEMFListProperty list(EStructuralFeature feature); |
| 93 |
|
| 94 |
/** |
| 95 |
* Returns a master-detail combination of this property and the specified |
| 96 |
* list property. The returned property will observe the specified list |
| 97 |
* property for the value of the master property. |
| 98 |
* <p> |
| 99 |
* Example: |
| 100 |
* |
| 101 |
* <pre> |
| 102 |
* // Observes the Node-typed "parent" property of a Node object. |
| 103 |
* IEMFValueProperty parent = EMFProperties.value(MyPackage.Literals.NODE_PARENT); |
| 104 |
* // Observes the List-typed "children" property of a Node object |
| 105 |
* // where the elements are Node objects |
| 106 |
* IEMFListProperty children = EMFProperties.list(MyPackage.Literals.NODE_CHILDREN); |
| 107 |
* // Observes the children of the parent (siblings) of a Node object. |
| 108 |
* IEMFListProperty siblings = parent.list(children); |
| 109 |
* </pre> |
| 110 |
* |
| 111 |
* @param property |
| 112 |
* the detail property to observe |
| 113 |
* @return a master-detail combination of this property and the specified |
| 114 |
* list property. |
| 115 |
*/ |
| 116 |
public IEMFListProperty list(IEMFListProperty property); |
| 117 |
|
| 118 |
/** |
| 119 |
* Returns a master-detail combination of this property and the specified |
| 120 |
* map feature. |
| 121 |
* |
| 122 |
* @param feature |
| 123 |
* the map property to observe |
| 124 |
* @return a master-detail combination of this property and the specified |
| 125 |
* map feature. |
| 126 |
* @see #map(IEMFMapProperty) |
| 127 |
*/ |
| 128 |
public IEMFMapProperty map(EStructuralFeature feature); |
| 129 |
|
| 130 |
/** |
| 131 |
* Returns a master-detail combination of this property and the specified |
| 132 |
* map property. The returned property will observe the specified map |
| 133 |
* property for the value of the master property. |
| 134 |
* <p> |
| 135 |
* Example: |
| 136 |
* |
| 137 |
* <pre> |
| 138 |
* // Observes the Contact-typed "supervisor" property of a |
| 139 |
* // Contact class |
| 140 |
* IEMFValueProperty supervisor = EMFProperties.value(MyPackage.Literals.CONTACT_SUPERVISOR); |
| 141 |
* // Observes the property "phoneNumbers" of a Contact object--a property mapping |
| 142 |
* // from PhoneNumberType to PhoneNumber "set-typed "children", |
| 143 |
* IEMFMapProperty phoneNumbers = EMFProperties.map(MyPackage.Literals.CONTACT_PHONENUMBERS); |
| 144 |
* // Observes the phone numbers of a contact's supervisor: |
| 145 |
* IEMFMapProperty supervisorPhoneNumbers = supervisor.map(phoneNumbers); |
| 146 |
* </pre> |
| 147 |
* |
| 148 |
* @param property |
| 149 |
* the detail property to observe |
| 150 |
* @return a master-detail combination of this property and the specified |
| 151 |
* map property. |
| 152 |
*/ |
| 153 |
public IEMFMapProperty map(IEMFMapProperty property); |
| 154 |
}
Index: src/org/eclipse/emf/databinding/internal/EMFValueProperty.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2008 Matthew Hall and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Matthew Hall - initial API and implementation (bug 194734) |
| 12 |
* Matthew Hall - bug 195222, 264307, 265561 |
| 13 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 14 |
* </copyright> |
| 15 |
* |
| 16 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 17 |
*/ |
| 18 |
package org.eclipse.emf.databinding.internal; |
| 19 |
|
| 20 |
import org.eclipse.core.databinding.property.INativePropertyListener; |
| 21 |
import org.eclipse.core.databinding.property.IProperty; |
| 22 |
import org.eclipse.core.databinding.property.ISimplePropertyListener; |
| 23 |
import org.eclipse.core.databinding.property.value.SimpleValueProperty; |
| 24 |
import org.eclipse.emf.ecore.EObject; |
| 25 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 26 |
import org.eclipse.emf.ecore.util.ExtendedMetaData; |
| 27 |
|
| 28 |
|
| 29 |
/** |
| 30 |
* @since 2.5 |
| 31 |
*/ |
| 32 |
public class EMFValueProperty extends SimpleValueProperty |
| 33 |
{ |
| 34 |
private final EStructuralFeature eStructuralFeature; |
| 35 |
|
| 36 |
/** |
| 37 |
* @param eStructuralFeature |
| 38 |
*/ |
| 39 |
public EMFValueProperty(EStructuralFeature eStructuralFeature) |
| 40 |
{ |
| 41 |
this.eStructuralFeature = eStructuralFeature; |
| 42 |
} |
| 43 |
|
| 44 |
public Object getValueType() |
| 45 |
{ |
| 46 |
return eStructuralFeature; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* @return the feature |
| 51 |
*/ |
| 52 |
protected EStructuralFeature getFeature() |
| 53 |
{ |
| 54 |
return eStructuralFeature; |
| 55 |
} |
| 56 |
|
| 57 |
protected Object doGetValue(Object source) |
| 58 |
{ |
| 59 |
EObject eObj = (EObject)source; |
| 60 |
return ExtendedMetaData.INSTANCE.getAffiliation(eObj.eClass(), eStructuralFeature) == null ? null : eObj.eGet(eStructuralFeature); |
| 61 |
} |
| 62 |
|
| 63 |
protected void doSetValue(Object source, Object value) |
| 64 |
{ |
| 65 |
EObject eObject = (EObject)source; |
| 66 |
eObject.eSet(eStructuralFeature, value); |
| 67 |
} |
| 68 |
|
| 69 |
public INativePropertyListener adaptListener(final ISimplePropertyListener listener) |
| 70 |
{ |
| 71 |
return new EMFPropertyListener.EMFValuePropertyListener() |
| 72 |
{ |
| 73 |
|
| 74 |
@Override |
| 75 |
protected IProperty getOwner() |
| 76 |
{ |
| 77 |
return EMFValueProperty.this; |
| 78 |
} |
| 79 |
|
| 80 |
@Override |
| 81 |
protected ISimplePropertyListener getListener() |
| 82 |
{ |
| 83 |
return listener; |
| 84 |
} |
| 85 |
|
| 86 |
@Override |
| 87 |
protected EStructuralFeature getFeature() |
| 88 |
{ |
| 89 |
return eStructuralFeature; |
| 90 |
} |
| 91 |
}; |
| 92 |
} |
| 93 |
|
| 94 |
public String toString() |
| 95 |
{ |
| 96 |
String s = EMFPropertyHelper.propertyName(eStructuralFeature); |
| 97 |
s += "<" + EMFPropertyHelper.shortClassName(eStructuralFeature) + ">"; //$NON-NLS-1$//$NON-NLS-2$ |
| 98 |
return s; |
| 99 |
} |
| 100 |
}
Index: src/org/eclipse/emf/databinding/internal/EMFObservableValueDecorator.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2007 Brad Reynolds and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Brad Reynolds - initial API and implementation |
| 12 |
* Matthew Hall - bug 246625 |
| 13 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 14 |
* </copyright> |
| 15 |
* |
| 16 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 17 |
*/ |
| 18 |
package org.eclipse.emf.databinding.internal; |
| 19 |
|
| 20 |
import org.eclipse.core.databinding.observable.IObservable; |
| 21 |
import org.eclipse.core.databinding.observable.IObserving; |
| 22 |
import org.eclipse.core.databinding.observable.value.DecoratingObservableValue; |
| 23 |
import org.eclipse.core.databinding.observable.value.IObservableValue; |
| 24 |
import org.eclipse.emf.databinding.IEMFObservable; |
| 25 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 26 |
|
| 27 |
|
| 28 |
/** |
| 29 |
* {@link IEMFObservable} decorator for an {@link IObservableValue}. |
| 30 |
* |
| 31 |
* @since 2.5 |
| 32 |
*/ |
| 33 |
public class EMFObservableValueDecorator extends DecoratingObservableValue implements IEMFObservable |
| 34 |
{ |
| 35 |
private EStructuralFeature eStructuralFeature; |
| 36 |
|
| 37 |
/** |
| 38 |
* @param decorated |
| 39 |
* @param eStructuralFeature |
| 40 |
*/ |
| 41 |
public EMFObservableValueDecorator(IObservableValue decorated, EStructuralFeature eStructuralFeature) |
| 42 |
{ |
| 43 |
super(decorated, true); |
| 44 |
this.eStructuralFeature = eStructuralFeature; |
| 45 |
} |
| 46 |
|
| 47 |
public synchronized void dispose() |
| 48 |
{ |
| 49 |
this.eStructuralFeature = null; |
| 50 |
super.dispose(); |
| 51 |
} |
| 52 |
|
| 53 |
public Object getObserved() |
| 54 |
{ |
| 55 |
IObservable decorated = getDecorated(); |
| 56 |
if (decorated instanceof IObserving) |
| 57 |
return ((IObserving)decorated).getObserved(); |
| 58 |
return null; |
| 59 |
} |
| 60 |
|
| 61 |
public EStructuralFeature getStructuralFeature() |
| 62 |
{ |
| 63 |
return eStructuralFeature; |
| 64 |
} |
| 65 |
}
Index: src/org/eclipse/emf/databinding/EMFProperties.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2008 Matthew Hall and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Matthew Hall - initial API and implementation (bug 194734) |
| 12 |
* Matthew Hall - bug 195222, 247997, 261843, 264307 |
| 13 |
* Hasan Ceylan - patch in bug 262160 |
| 14 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 15 |
* </copyright> |
| 16 |
* |
| 17 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 18 |
*/ |
| 19 |
package org.eclipse.emf.databinding; |
| 20 |
|
| 21 |
import org.eclipse.core.databinding.property.list.IListProperty; |
| 22 |
import org.eclipse.core.databinding.property.map.IMapProperty; |
| 23 |
import org.eclipse.core.databinding.property.value.IValueProperty; |
| 24 |
import org.eclipse.emf.databinding.internal.EMFListProperty; |
| 25 |
import org.eclipse.emf.databinding.internal.EMFListPropertyDecorator; |
| 26 |
import org.eclipse.emf.databinding.internal.EMFMapProperty; |
| 27 |
import org.eclipse.emf.databinding.internal.EMFMapPropertyDecorator; |
| 28 |
import org.eclipse.emf.databinding.internal.EMFValueProperty; |
| 29 |
import org.eclipse.emf.databinding.internal.EMFValuePropertyDecorator; |
| 30 |
import org.eclipse.emf.ecore.EObject; |
| 31 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 32 |
|
| 33 |
|
| 34 |
/** |
| 35 |
* <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> |
| 36 |
* |
| 37 |
* A factory to create property bound attributes for {@link EObject} |
| 38 |
* |
| 39 |
* @since 2.5 |
| 40 |
*/ |
| 41 |
public class EMFProperties |
| 42 |
{ |
| 43 |
/** |
| 44 |
* Debug constant to turn on/off debugging |
| 45 |
*/ |
| 46 |
public static final boolean DEBUG = false; |
| 47 |
|
| 48 |
/** |
| 49 |
* Returns a value property for the given {@link EStructuralFeature} |
| 50 |
* |
| 51 |
* @param feature |
| 52 |
* the feature instance the property is created for |
| 53 |
* @return a value property for the given {@link EStructuralFeature} |
| 54 |
*/ |
| 55 |
public static IEMFValueProperty value(EStructuralFeature feature) |
| 56 |
{ |
| 57 |
return value(FeaturePath.fromList(feature)); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Returns a value property for the given nested {@link EStructuralFeature} |
| 62 |
* feature like the <code>name</code> of a <code>person</code> |
| 63 |
* |
| 64 |
* @param featurePath |
| 65 |
* path to the feature |
| 66 |
* @return a value property for the given {@link FeaturePath} |
| 67 |
*/ |
| 68 |
public static IEMFValueProperty value(FeaturePath featurePath) |
| 69 |
{ |
| 70 |
IValueProperty property; |
| 71 |
property = new EMFValueProperty(featurePath.getFeaturePath()[0]); |
| 72 |
|
| 73 |
IEMFValueProperty featureProperty = new EMFValuePropertyDecorator(property, featurePath.getFeaturePath()[0]); |
| 74 |
|
| 75 |
for (int i = 1; i < featurePath.getFeaturePath().length; i++) |
| 76 |
{ |
| 77 |
featureProperty = featureProperty.value(featurePath.getFeaturePath()[i]); |
| 78 |
} |
| 79 |
|
| 80 |
return featureProperty; |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Returns multiple value properties for the given |
| 85 |
* {@link EStructuralFeature}s |
| 86 |
* |
| 87 |
* @param features |
| 88 |
* the feature instances the properties are created for |
| 89 |
* @return an array of properties for the given {@link EStructuralFeature}s |
| 90 |
*/ |
| 91 |
public static IEMFValueProperty[] values(EStructuralFeature... features) |
| 92 |
{ |
| 93 |
IEMFValueProperty[] properties = new IEMFValueProperty [features.length]; |
| 94 |
for (int i = 0; i < properties.length; i++) |
| 95 |
properties[i] = value(features[i]); |
| 96 |
return properties; |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Returns multiple value property for the given nested |
| 101 |
* {@link EStructuralFeature} features like the <code>name</code> of a |
| 102 |
* <code>person</code> |
| 103 |
* |
| 104 |
* @param featurePaths |
| 105 |
* path to the feature |
| 106 |
* @return an array of properties for the given {@link FeaturePath}s |
| 107 |
*/ |
| 108 |
public static IEMFValueProperty[] values(FeaturePath... featurePaths) |
| 109 |
{ |
| 110 |
IEMFValueProperty[] properties = new IEMFValueProperty [featurePaths.length]; |
| 111 |
for (int i = 0; i < properties.length; i++) |
| 112 |
properties[i] = value(featurePaths[i]); |
| 113 |
return properties; |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* Returns a list property for the given {@link EStructuralFeature} |
| 118 |
* |
| 119 |
* @param feature |
| 120 |
* the feature instance the property is created for |
| 121 |
* @return a list property for the given {@link EStructuralFeature} |
| 122 |
*/ |
| 123 |
public static IEMFListProperty list(EStructuralFeature feature) |
| 124 |
{ |
| 125 |
IListProperty property; |
| 126 |
property = new EMFListProperty(feature); |
| 127 |
return new EMFListPropertyDecorator(property, feature); |
| 128 |
} |
| 129 |
|
| 130 |
/** |
| 131 |
* Returns a map property for the given {@link EStructuralFeature}. Objects lacking the named property are treated the same as if the |
| 132 |
* property always contains an empty map. |
| 133 |
* |
| 134 |
* @param feature |
| 135 |
* the feature the property is created for |
| 136 |
* @return a map property for the given {@link EStructuralFeature} |
| 137 |
*/ |
| 138 |
public static IEMFMapProperty map(EStructuralFeature feature) |
| 139 |
{ |
| 140 |
IMapProperty property; |
| 141 |
property = new EMFMapProperty(feature); |
| 142 |
return new EMFMapPropertyDecorator(property, feature); |
| 143 |
} |
| 144 |
}
Index: src/org/eclipse/emf/databinding/FeaturePath.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2009 BestSolution.at and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 12 |
* </copyright> |
| 13 |
* |
| 14 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 15 |
*/ |
| 16 |
package org.eclipse.emf.databinding; |
| 17 |
|
| 18 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 19 |
|
| 20 |
|
| 21 |
/** |
| 22 |
* <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> |
| 23 |
* |
| 24 |
* Encapsulate a path to features also known as nested feature like person.name |
| 25 |
* |
| 26 |
* @since 2.5 |
| 27 |
* @noextend This interface is not intended to be extended by clients. |
| 28 |
* @noimplement This interface is not intended to be implemented by clients. |
| 29 |
*/ |
| 30 |
public class FeaturePath |
| 31 |
{ |
| 32 |
private EStructuralFeature[] featurePath; |
| 33 |
|
| 34 |
private FeaturePath(EStructuralFeature[] featurePath) |
| 35 |
{ |
| 36 |
this.featurePath = featurePath; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* @return the path to the feature from the local position |
| 41 |
*/ |
| 42 |
public EStructuralFeature[] getFeaturePath() |
| 43 |
{ |
| 44 |
return featurePath; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Create a feature path from the list of given features |
| 49 |
* |
| 50 |
* @param featurePath |
| 51 |
* the list of feature to go from the local instance to the |
| 52 |
* requested instance |
| 53 |
* @return the path constructed |
| 54 |
*/ |
| 55 |
public static FeaturePath fromList(EStructuralFeature... featurePath) |
| 56 |
{ |
| 57 |
return new FeaturePath(featurePath); |
| 58 |
} |
| 59 |
}
Index: src/org/eclipse/emf/databinding/IEMFProperty.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2008 Matthew Hall and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Matthew Hall - initial API and implementation (bug 194734) |
| 12 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 13 |
* </copyright> |
| 14 |
* |
| 15 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 16 |
*/ |
| 17 |
package org.eclipse.emf.databinding; |
| 18 |
|
| 19 |
import org.eclipse.core.databinding.property.IProperty; |
| 20 |
|
| 21 |
import org.eclipse.emf.ecore.EObject; |
| 22 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 23 |
|
| 24 |
|
| 25 |
/** |
| 26 |
* <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> |
| 27 |
* |
| 28 |
* An IProperty extension interface providing access to details of {@link EObject}s |
| 29 |
* |
| 30 |
* @since 2.5 |
| 31 |
* @noextend This interface is not intended to be extended by clients. |
| 32 |
* @noimplement This interface is not intended to be implemented by clients. |
| 33 |
*/ |
| 34 |
public interface IEMFProperty extends IProperty |
| 35 |
{ |
| 36 |
/** |
| 37 |
* Returns the descriptor of the {@link EStructuralFeature} being observed. |
| 38 |
* |
| 39 |
* @return the {@link EStructuralFeature} being observed |
| 40 |
*/ |
| 41 |
public EStructuralFeature getStructuralFeature(); |
| 42 |
}
Index: src/org/eclipse/emf/databinding/IEMFListProperty.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2008 Matthew Hall and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Matthew Hall - initial API and implementation (bug 195222) |
| 12 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 13 |
* </copyright> |
| 14 |
* |
| 15 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 16 |
*/ |
| 17 |
package org.eclipse.emf.databinding; |
| 18 |
|
| 19 |
import org.eclipse.core.databinding.property.list.IListProperty; |
| 20 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 21 |
|
| 22 |
|
| 23 |
/** |
| 24 |
* <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p> |
| 25 |
* |
| 26 |
* An {@link IListProperty} extension interface with convenience methods for |
| 27 |
* creating nested {@link EStructuralFeature}s |
| 28 |
* |
| 29 |
* @since 2.5 |
| 30 |
* @noextend This interface is not intended to be extended by clients. |
| 31 |
* @noimplement This interface is not intended to be implemented by clients. |
| 32 |
*/ |
| 33 |
public interface IEMFListProperty extends IEMFProperty, IListProperty |
| 34 |
{ |
| 35 |
/** |
| 36 |
* Returns a master-detail combination of this property and the specified |
| 37 |
* value nested feature. |
| 38 |
* |
| 39 |
* @param featurePath |
| 40 |
* the nested feature to observe |
| 41 |
* @return a nested combination of this property and the specified nested |
| 42 |
* feature. |
| 43 |
* @see #values(IEMFValueProperty) |
| 44 |
*/ |
| 45 |
public IEMFListProperty values(FeaturePath featurePath); |
| 46 |
|
| 47 |
/** |
| 48 |
* Returns a master-detail combination of this property and the specified |
| 49 |
* value property. |
| 50 |
* |
| 51 |
* @param feature |
| 52 |
* the feature |
| 53 |
* @return a nested combination of this property and the specified nested |
| 54 |
* feature. |
| 55 |
*/ |
| 56 |
public IEMFListProperty values(EStructuralFeature feature); |
| 57 |
|
| 58 |
/** |
| 59 |
* Returns a master-detail combination of this property and the specified |
| 60 |
* value property. The returned property will observe the specified value |
| 61 |
* property for all elements observed by this list property. |
| 62 |
* <p> |
| 63 |
* Example: |
| 64 |
* |
| 65 |
* <pre> |
| 66 |
* // Observes the list-typed "children" property of a Person object, |
| 67 |
* // where the elements are Person objects |
| 68 |
* IEMFListProperty children = EMFProperties |
| 69 |
* .list(MyPackage.Literals.PERSON_CHILDREN); |
| 70 |
* // Observes the string-typed "name" property of a Person object |
| 71 |
* IEMFValueProperty name = EMFProperties.value(MyPackage.Literals.PERSON_NAME); |
| 72 |
* // Observes the names of children of a Person object. |
| 73 |
* IEMFListProperty childrenNames = children.values(name); |
| 74 |
* </pre> |
| 75 |
* |
| 76 |
* @param property |
| 77 |
* the detail property to observe |
| 78 |
* @return a master-detail combination of this property and the specified |
| 79 |
* value property. |
| 80 |
*/ |
| 81 |
public IEMFListProperty values(IEMFValueProperty property); |
| 82 |
}
Index: src/org/eclipse/emf/databinding/internal/EMFPropertyListener.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2009 Tom Schindl and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 12 |
* </copyright> |
| 13 |
* |
| 14 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 15 |
*/ |
| 16 |
package org.eclipse.emf.databinding.internal; |
| 17 |
|
| 18 |
import java.util.Collection; |
| 19 |
import java.util.Map; |
| 20 |
|
| 21 |
import org.eclipse.core.databinding.observable.Diffs; |
| 22 |
import org.eclipse.core.databinding.observable.list.ListDiff; |
| 23 |
import org.eclipse.core.databinding.observable.list.ListDiffEntry; |
| 24 |
import org.eclipse.core.databinding.property.INativePropertyListener; |
| 25 |
import org.eclipse.core.databinding.property.IProperty; |
| 26 |
import org.eclipse.core.databinding.property.ISimplePropertyListener; |
| 27 |
import org.eclipse.core.databinding.property.SimplePropertyEvent; |
| 28 |
import org.eclipse.emf.common.notify.Notification; |
| 29 |
import org.eclipse.emf.common.notify.impl.AdapterImpl; |
| 30 |
import org.eclipse.emf.ecore.EObject; |
| 31 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 32 |
|
| 33 |
|
| 34 |
/** |
| 35 |
* @since 2.5 |
| 36 |
*/ |
| 37 |
public abstract class EMFPropertyListener extends AdapterImpl implements INativePropertyListener |
| 38 |
{ |
| 39 |
|
| 40 |
public void addTo(Object source) |
| 41 |
{ |
| 42 |
((EObject)source).eAdapters().add(this); |
| 43 |
} |
| 44 |
|
| 45 |
public void removeFrom(Object source) |
| 46 |
{ |
| 47 |
((EObject)source).eAdapters().remove(this); |
| 48 |
} |
| 49 |
|
| 50 |
@Override |
| 51 |
public abstract void notifyChanged(Notification msg); |
| 52 |
|
| 53 |
/** |
| 54 |
* @return the listener |
| 55 |
*/ |
| 56 |
protected abstract ISimplePropertyListener getListener(); |
| 57 |
|
| 58 |
/** |
| 59 |
* @return the feature |
| 60 |
*/ |
| 61 |
protected abstract EStructuralFeature getFeature(); |
| 62 |
|
| 63 |
/** |
| 64 |
* @return the owner property |
| 65 |
*/ |
| 66 |
protected abstract IProperty getOwner(); |
| 67 |
|
| 68 |
/** |
| 69 |
* |
| 70 |
*/ |
| 71 |
public abstract static class EMFListPropertyListener extends EMFPropertyListener |
| 72 |
{ |
| 73 |
@Override |
| 74 |
public void notifyChanged(Notification msg) |
| 75 |
{ |
| 76 |
if (getFeature() == msg.getFeature() && !msg.isTouch()) |
| 77 |
{ |
| 78 |
final ListDiff diff; |
| 79 |
switch (msg.getEventType()) |
| 80 |
{ |
| 81 |
case Notification.ADD: { |
| 82 |
diff = Diffs.createListDiff(Diffs.createListDiffEntry(msg.getPosition(), true, msg.getNewValue())); |
| 83 |
break; |
| 84 |
} |
| 85 |
case Notification.ADD_MANY: { |
| 86 |
Collection< ? > newValues = (Collection< ? >)msg.getNewValue(); |
| 87 |
ListDiffEntry[] listDiffEntries = new ListDiffEntry [newValues.size()]; |
| 88 |
int position = msg.getPosition(); |
| 89 |
int index = 0; |
| 90 |
for (Object newValue : newValues) |
| 91 |
{ |
| 92 |
listDiffEntries[index++] = Diffs.createListDiffEntry(position++, true, newValue); |
| 93 |
} |
| 94 |
diff = Diffs.createListDiff(listDiffEntries); |
| 95 |
break; |
| 96 |
} |
| 97 |
case Notification.REMOVE: { |
| 98 |
diff = Diffs.createListDiff(Diffs.createListDiffEntry(msg.getPosition(), false, msg.getOldValue())); |
| 99 |
break; |
| 100 |
} |
| 101 |
case Notification.REMOVE_MANY: { |
| 102 |
Collection< ? > oldValues = (Collection< ? >)msg.getOldValue(); |
| 103 |
ListDiffEntry[] listDiffEntries = new ListDiffEntry [oldValues.size()]; |
| 104 |
int position = msg.getPosition(); |
| 105 |
int index = 0; |
| 106 |
for (Object oldValue : oldValues) |
| 107 |
{ |
| 108 |
listDiffEntries[index++] = Diffs.createListDiffEntry(position++, false, oldValue); |
| 109 |
} |
| 110 |
diff = Diffs.createListDiff(listDiffEntries); |
| 111 |
break; |
| 112 |
} |
| 113 |
case Notification.SET: |
| 114 |
case Notification.RESOLVE: { |
| 115 |
ListDiffEntry[] listDiffEntries = new ListDiffEntry [2]; |
| 116 |
listDiffEntries[0] = Diffs.createListDiffEntry(msg.getPosition(), false, msg.getOldValue()); |
| 117 |
listDiffEntries[1] = Diffs.createListDiffEntry(msg.getPosition(), true, msg.getNewValue()); |
| 118 |
diff = Diffs.createListDiff(listDiffEntries); |
| 119 |
break; |
| 120 |
} |
| 121 |
case Notification.MOVE: { |
| 122 |
Object movedValue = msg.getNewValue(); |
| 123 |
ListDiffEntry[] listDiffEntries = new ListDiffEntry [2]; |
| 124 |
listDiffEntries[0] = Diffs.createListDiffEntry((Integer)msg.getOldValue(), false, movedValue); |
| 125 |
listDiffEntries[1] = Diffs.createListDiffEntry(msg.getPosition(), true, movedValue); |
| 126 |
diff = Diffs.createListDiff(listDiffEntries); |
| 127 |
break; |
| 128 |
} |
| 129 |
case Notification.UNSET: { |
| 130 |
// This just represents going back to the unset state, but |
| 131 |
// that doesn't affect the contents of the list. |
| 132 |
// |
| 133 |
return; |
| 134 |
} |
| 135 |
default: { |
| 136 |
throw new RuntimeException("unhandled case"); |
| 137 |
} |
| 138 |
} |
| 139 |
getListener().handleEvent((new SimplePropertyEvent(SimplePropertyEvent.CHANGE, msg.getNotifier(), getOwner(), diff))); |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
/** |
| 145 |
* |
| 146 |
*/ |
| 147 |
public abstract static class EMFMapPropertyListener extends EMFPropertyListener |
| 148 |
{ |
| 149 |
@Override |
| 150 |
public void notifyChanged(Notification msg) |
| 151 |
{ |
| 152 |
if (getFeature() == msg.getFeature() && !msg.isTouch()) |
| 153 |
{ |
| 154 |
getListener().handleEvent( |
| 155 |
new SimplePropertyEvent(SimplePropertyEvent.CHANGE, msg.getNotifier(), getOwner(), Diffs.computeMapDiff( |
| 156 |
(Map< ? , ? >)msg.getOldValue(), |
| 157 |
(Map< ? , ? >)msg.getNewValue()))); |
| 158 |
} |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
/** |
| 163 |
* |
| 164 |
*/ |
| 165 |
public abstract static class EMFValuePropertyListener extends EMFPropertyListener |
| 166 |
{ |
| 167 |
@Override |
| 168 |
public void notifyChanged(Notification msg) |
| 169 |
{ |
| 170 |
if (getFeature() == msg.getFeature() && !msg.isTouch()) |
| 171 |
{ |
| 172 |
getListener().handleEvent( |
| 173 |
new SimplePropertyEvent(SimplePropertyEvent.CHANGE, msg.getNotifier(), getOwner(), Diffs.createValueDiff( |
| 174 |
msg.getOldValue(), |
| 175 |
msg.getNewValue()))); |
| 176 |
} |
| 177 |
} |
| 178 |
} |
| 179 |
}
Index: src/org/eclipse/emf/databinding/internal/EMFMapPropertyDecorator.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2008 Matthew Hall and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Matthew Hall - initial API and implementation (bug 195222) |
| 12 |
* Matthew Hall - bug 264307 |
| 13 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 14 |
* </copyright> |
| 15 |
* |
| 16 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 17 |
*/ |
| 18 |
package org.eclipse.emf.databinding.internal; |
| 19 |
|
| 20 |
import org.eclipse.core.databinding.observable.Realm; |
| 21 |
import org.eclipse.core.databinding.observable.map.IObservableMap; |
| 22 |
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; |
| 23 |
import org.eclipse.core.databinding.observable.value.IObservableValue; |
| 24 |
import org.eclipse.core.databinding.property.map.IMapProperty; |
| 25 |
import org.eclipse.core.databinding.property.map.MapProperty; |
| 26 |
import org.eclipse.emf.databinding.EMFProperties; |
| 27 |
import org.eclipse.emf.databinding.FeaturePath; |
| 28 |
import org.eclipse.emf.databinding.IEMFMapProperty; |
| 29 |
import org.eclipse.emf.databinding.IEMFValueProperty; |
| 30 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 31 |
|
| 32 |
|
| 33 |
/** |
| 34 |
* @since 2.5 |
| 35 |
*/ |
| 36 |
public class EMFMapPropertyDecorator extends MapProperty implements IEMFMapProperty |
| 37 |
{ |
| 38 |
private final IMapProperty delegate; |
| 39 |
private final EStructuralFeature eStructuralFeature; |
| 40 |
|
| 41 |
/** |
| 42 |
* @param delegate |
| 43 |
* @param eStructuralFeature |
| 44 |
*/ |
| 45 |
public EMFMapPropertyDecorator(IMapProperty delegate, EStructuralFeature eStructuralFeature) |
| 46 |
{ |
| 47 |
this.delegate = delegate; |
| 48 |
this.eStructuralFeature = eStructuralFeature; |
| 49 |
} |
| 50 |
|
| 51 |
public EStructuralFeature getStructuralFeature() |
| 52 |
{ |
| 53 |
return eStructuralFeature; |
| 54 |
} |
| 55 |
|
| 56 |
public Object getKeyType() |
| 57 |
{ |
| 58 |
return delegate.getKeyType(); |
| 59 |
} |
| 60 |
|
| 61 |
public Object getValueType() |
| 62 |
{ |
| 63 |
return delegate.getValueType(); |
| 64 |
} |
| 65 |
|
| 66 |
public IEMFMapProperty values(EStructuralFeature feature) |
| 67 |
{ |
| 68 |
return values(FeaturePath.fromList(feature)); |
| 69 |
} |
| 70 |
|
| 71 |
public IEMFMapProperty values(FeaturePath featurePath) |
| 72 |
{ |
| 73 |
return values(EMFProperties.value(featurePath)); |
| 74 |
} |
| 75 |
|
| 76 |
public IEMFMapProperty values(IEMFValueProperty property) |
| 77 |
{ |
| 78 |
return new EMFMapPropertyDecorator(super.values(property), property.getStructuralFeature()); |
| 79 |
} |
| 80 |
|
| 81 |
public IObservableMap observe(Object source) |
| 82 |
{ |
| 83 |
return new EMFObservableMapDecorator(delegate.observe(source), eStructuralFeature); |
| 84 |
} |
| 85 |
|
| 86 |
public IObservableMap observe(Realm realm, Object source) |
| 87 |
{ |
| 88 |
return new EMFObservableMapDecorator(delegate.observe(realm, source), eStructuralFeature); |
| 89 |
} |
| 90 |
|
| 91 |
public IObservableFactory mapFactory() |
| 92 |
{ |
| 93 |
return delegate.mapFactory(); |
| 94 |
} |
| 95 |
|
| 96 |
public IObservableFactory mapFactory(Realm realm) |
| 97 |
{ |
| 98 |
return delegate.mapFactory(realm); |
| 99 |
} |
| 100 |
|
| 101 |
public IObservableMap observeDetail(IObservableValue master) |
| 102 |
{ |
| 103 |
return new EMFObservableMapDecorator(delegate.observeDetail(master), eStructuralFeature); |
| 104 |
} |
| 105 |
|
| 106 |
public String toString() |
| 107 |
{ |
| 108 |
return delegate.toString(); |
| 109 |
} |
| 110 |
}
Index: src/org/eclipse/emf/databinding/internal/EMFMapProperty.java |
|
Added
Link Here
|
| 1 |
/** |
| 2 |
* <copyright> |
| 3 |
* |
| 4 |
* Copyright (c) 2008 Matthew Hall and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
| 8 |
* http://www.eclipse.org/legal/epl-v10.html |
| 9 |
* |
| 10 |
* Contributors: |
| 11 |
* Matthew Hall - initial API and implementation (bug 194734) |
| 12 |
* Matthew Hall - bugs 195222, 264307, 265561 |
| 13 |
* Hasan Ceylan - patch in bug 262160 |
| 14 |
* Tom Schindl <tom.schindl@bestsolution.at> - port to EMF in 262160 |
| 15 |
* </copyright> |
| 16 |
* |
| 17 |
* $Id: EMFObservables.java,v 1.3 2008/04/22 13:36:00 emerks Exp $ |
| 18 |
*/ |
| 19 |
package org.eclipse.emf.databinding.internal; |
| 20 |
|
| 21 |
import java.util.Map; |
| 22 |
|
| 23 |
import org.eclipse.core.databinding.observable.map.MapDiff; |
| 24 |
import org.eclipse.core.databinding.property.INativePropertyListener; |
| 25 |
import org.eclipse.core.databinding.property.IProperty; |
| 26 |
import org.eclipse.core.databinding.property.ISimplePropertyListener; |
| 27 |
import org.eclipse.core.databinding.property.map.SimpleMapProperty; |
| 28 |
import org.eclipse.emf.ecore.EClass; |
| 29 |
import org.eclipse.emf.ecore.EObject; |
| 30 |
import org.eclipse.emf.ecore.EStructuralFeature; |
| 31 |
|
| 32 |
|
| 33 |
/** |
| 34 |
* @since 2.5 |
| 35 |
*/ |
| 36 |
public class EMFMapProperty extends SimpleMapProperty |
| 37 |
{ |
| 38 |
private EStructuralFeature eStructuralFeature; |
| 39 |
|
| 40 |
/** |
| 41 |
* @param eStructuralFeature |
| 42 |
*/ |
| 43 |
public EMFMapProperty(EStructuralFeature eStructuralFeature) |
| 44 |
{ |
| 45 |
this.eStructuralFeature = eStructuralFeature; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* @return the feature |
| 50 |
*/ |
| 51 |
protected EStructuralFeature getFeature() |
| 52 |
{ |
| 53 |
return eStructuralFeature; |
| 54 |
} |
| 55 |
|
| 56 |
public Object getKeyType() |
| 57 |
{ |
| 58 |
final EClass eType = (EClass)this.eStructuralFeature.getEType(); |
| 59 |
|
| 60 |
for (final EStructuralFeature feature : eType.getEAllStructuralFeatures()) |
| 61 |
{ |
| 62 |
if (feature.getName().equals("key")) |
| 63 |
{ |
| 64 |
return feature; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
return null; |
| 69 |
} |
| 70 |
|
| 71 |
public Object getValueType() |
| 72 |
{ |
| 73 |
final EClass eType = (EClass)this.eStructuralFeature.getEType(); |
| 74 |
|
| 75 |
for (final EStructuralFeature feature : eType.getEAllStructuralFeatures()) |
| 76 |
{ |
| 77 |
if (feature.getName().equals("value")) |
| 78 |
{ |
| 79 |
return feature; |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
return null; |
| 84 |
} |
| 85 |
|
| 86 |
protected Map< ? , ? > doGetMap(Object source) |
| 87 |
{ |
| 88 |
EObject eObj = (EObject)source; |
| 89 |
return (Map< ? , ? >)eObj.eGet(eStructuralFeature); |
| 90 |
} |
| 91 |
|
| 92 |
@SuppressWarnings("unchecked") |
| 93 |
protected void doSetMap(Object source, Map map, MapDiff diff) |
| 94 |
{ |
| 95 |
EObject eObject = (EObject)source; |
| 96 |
eObject.eSet(eStructuralFeature, map); |
| 97 |
} |
| 98 |
|
| 99 |
public INativePropertyListener adaptListener(final ISimplePropertyListener listener) |
| 100 |
{ |
| 101 |
return new EMFPropertyListener.EMFMapPropertyListener() |
| 102 |
{ |
| 103 |
|
| 104 |
@Override |
| 105 |
protected IProperty getOwner() |
| 106 |
{ |
| 107 |
return EMFMapProperty.this; |
| 108 |
} |
| 109 |
|
| 110 |
@Override |
| 111 |
protected ISimplePropertyListener getListener() |
| 112 |
{ |
| 113 |
return listener; |
| 114 |
} |
| 115 |
|
| 116 |
@Override |
| 117 |
protected EStructuralFeature getFeature() |
| 118 |
{ |
| 119 |
return eStructuralFeature; |
| 120 |
} |
| 121 |
}; |
| 122 |
} |
| 123 |
|
| 124 |
public String toString() |
| 125 |
{ |
| 126 |
String s = EMFPropertyHelper.propertyName(eStructuralFeature) + "{:}"; //$NON-NLS-1$ |
| 127 |
|
| 128 |
s += "<" + EMFPropertyHelper.shortClassName((EStructuralFeature)getKeyType()) + ", " //$NON-NLS-1$ //$NON-NLS-2$ |
| 129 |
+ EMFPropertyHelper.shortClassName((EStructuralFeature)getValueType()) + ">"; //$NON-NLS-1$ |
| 130 |
return s; |
| 131 |
} |
| 132 |
}
#P org.eclipse.emf.databinding.edit |