Bug 548922 - EnumComboViewerSWTRenderer only works for the root object
of the view model context
Change-Id: I4b2d05fda27a6f1f6817dd84a72da5fe0204db6e
Signed-off-by: Eugen Neufeld <eneufeld@eclipsesource.com>
diff --git a/bundles/org.eclipse.emf.ecp.view.core.swt/src/org/eclipse/emf/ecp/view/internal/core/swt/renderer/EnumComboViewerSWTRenderer.java b/bundles/org.eclipse.emf.ecp.view.core.swt/src/org/eclipse/emf/ecp/view/internal/core/swt/renderer/EnumComboViewerSWTRenderer.java
index 915c5e7..a2855c5 100644
--- a/bundles/org.eclipse.emf.ecp.view.core.swt/src/org/eclipse/emf/ecp/view/internal/core/swt/renderer/EnumComboViewerSWTRenderer.java
+++ b/bundles/org.eclipse.emf.ecp.view.core.swt/src/org/eclipse/emf/ecp/view/internal/core/swt/renderer/EnumComboViewerSWTRenderer.java
@@ -194,22 +194,24 @@
*/
protected IObservableValue<Collection<?>> getAvailableChoicesValue() throws DatabindingFailedException {
if (availableChoicesValue == null) {
- final EObject domainObject = getViewModelContext().getDomainModel();
-
// It makes no sense to use this renderer with a different kind of property than this
final IEMFObservable emfObservable = (IEMFObservable) getModelValue();
+
+ // the domain object must be the same as the object of the feature
+ final EObject domainObject = (EObject) emfObservable.getObserved();
+
final EStructuralFeature feature = emfObservable.getStructuralFeature();
final Optional<IItemPropertySource> propertySource = EMFUtils.adapt(domainObject,
IItemPropertySource.class);
final Optional<IItemPropertyDescriptor> propertyDescriptor = propertySource
- .map(source -> source.getPropertyDescriptor(domainObject, feature.getName()));
+ .map(source -> source.getPropertyDescriptor(domainObject, feature));
availableChoicesValue = new ComputedValue<Collection<?>>(Collection.class) {
+ // maybe better subscribe to all changes in the current context and update?
private final Optional<IChangeNotifier> changeNotifier = propertySource
.filter(IChangeNotifier.class::isInstance).map(IChangeNotifier.class::cast);
private final INotifyChangedListener listener = __ -> getRealm().exec(this::makeDirty);
-
{
changeNotifier.ifPresent(cn -> cn.addListener(listener));
}
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/icons/full/ctool16/CreateSimpleTestObject_inner_InnerObject.gif b/tests/org.eclipse.emf.ecp.view.core.swt.tests/icons/full/ctool16/CreateSimpleTestObject_inner_InnerObject.gif
new file mode 100644
index 0000000..7cb2132
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/icons/full/ctool16/CreateSimpleTestObject_inner_InnerObject.gif
Binary files differ
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/icons/full/obj16/InnerObject.gif b/tests/org.eclipse.emf.ecp.view.core.swt.tests/icons/full/obj16/InnerObject.gif
new file mode 100644
index 0000000..c3370c7
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/icons/full/obj16/InnerObject.gif
Binary files differ
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/model/test.ecore b/tests/org.eclipse.emf.ecp.view.core.swt.tests/model/test.ecore
index 6acb4b5..1fe2981 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/model/test.ecore
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/model/test.ecore
@@ -5,6 +5,8 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="date" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="xmlDate" eType="#//XMLDate"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="myEnum" eType="#//TestEnum"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="inner" eType="#//InnerObject"
+ containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="TestEnum" instanceTypeName="TestEnum">
<eLiterals name="a">
@@ -17,4 +19,7 @@
<eLiterals name="d" value="3" literal="d"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EDataType" name="XMLDate" instanceClassName="javax.xml.datatype.XMLGregorianCalendar"/>
+ <eClassifiers xsi:type="ecore:EClass" name="InnerObject">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="myEnum" eType="#//TestEnum"/>
+ </eClassifiers>
</ecore:EPackage>
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/model/test.genmodel b/tests/org.eclipse.emf.ecp.view.core.swt.tests/model/test.genmodel
index 8f3c261..4e1e79d 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/model/test.genmodel
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/model/test.genmodel
@@ -4,7 +4,7 @@
modelDirectory="/org.eclipse.emf.ecp.view.core.swt.tests/src" editDirectory="/org.eclipse.emf.ecp.view.core.swt.tests/src"
modelPluginID="org.eclipse.emf.ecp.view.core.swt.tests" modelName="Test" nonNLSMarkers="true"
rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" codeFormatting="true"
- importerID="org.eclipse.emf.importer.ecore" complianceLevel="5.0" copyrightFields="false"
+ importerID="org.eclipse.emf.importer.ecore" complianceLevel="8.0" copyrightFields="false"
editPluginID="org.eclipse.emf.ecp.view.core.swt.tests" operationReflection="true"
importOrganizing="true" cleanup="true">
<foreignModel>test.ecore</foreignModel>
@@ -23,6 +23,10 @@
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute test.ecore#//SimpleTestObject/date"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute test.ecore#//SimpleTestObject/xmlDate"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute test.ecore#//SimpleTestObject/myEnum"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//SimpleTestObject/inner"/>
+ </genClasses>
+ <genClasses ecoreClass="test.ecore#//InnerObject">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute test.ecore#//InnerObject/myEnum"/>
</genClasses>
</genPackages>
</genmodel:GenModel>
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/plugin.properties b/tests/org.eclipse.emf.ecp.view.core.swt.tests/plugin.properties
index a89a4f6..d11858f 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/plugin.properties
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/plugin.properties
@@ -20,3 +20,6 @@
_UI_TestEnum_b_literal = b
_UI_TestEnum_c_literal = c
_UI_TestEnum_d_literal = d
+_UI_InnerObject_type = Inner Object
+_UI_SimpleTestObject_inner_feature = Inner
+_UI_InnerObject_myEnum_feature = My Enum
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/InnerObject.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/InnerObject.java
new file mode 100644
index 0000000..4c81a32
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/InnerObject.java
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2011-2019 EclipseSource Muenchen GmbH and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Eugen Neufeld - initial API and implementation
+ * Lucas Koehler - extension for EnumComboViewerRenderer_PTest
+ */
+package org.eclipse.emf.ecp.view.core.swt.test.model;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Inner Object</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * </p>
+ * <ul>
+ * <li>{@link org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject#getMyEnum <em>My Enum</em>}</li>
+ * </ul>
+ *
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage#getInnerObject()
+ * @model
+ * @generated
+ */
+public interface InnerObject extends EObject {
+ /**
+ * Returns the value of the '<em><b>My Enum</b></em>' attribute.
+ * The literals are from the enumeration {@link org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>My Enum</em>' attribute.
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum
+ * @see #setMyEnum(TestEnum)
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage#getInnerObject_MyEnum()
+ * @model dataType="org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum"
+ * @generated
+ */
+ TestEnum getMyEnum();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject#getMyEnum <em>My
+ * Enum</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @param value the new value of the '<em>My Enum</em>' attribute.
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum
+ * @see #getMyEnum()
+ * @generated
+ */
+ void setMyEnum(TestEnum value);
+
+} // InnerObject
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/SimpleTestObject.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/SimpleTestObject.java
index 28d200b..fd9379d 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/SimpleTestObject.java
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/SimpleTestObject.java
@@ -32,6 +32,7 @@
* <li>{@link org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject#getDate <em>Date</em>}</li>
* <li>{@link org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject#getXmlDate <em>Xml Date</em>}</li>
* <li>{@link org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject#getMyEnum <em>My Enum</em>}</li>
+ * <li>{@link org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject#getInner <em>Inner</em>}</li>
* </ul>
*
* @see org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage#getSimpleTestObject()
@@ -128,4 +129,29 @@
*/
void setMyEnum(TestEnum value);
+ /**
+ * Returns the value of the '<em><b>Inner</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>Inner</em>' containment reference.
+ * @see #setInner(InnerObject)
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage#getSimpleTestObject_Inner()
+ * @model containment="true"
+ * @generated
+ */
+ InnerObject getInner();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject#getInner
+ * <em>Inner</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @param value the new value of the '<em>Inner</em>' containment reference.
+ * @see #getInner()
+ * @generated
+ */
+ void setInner(InnerObject value);
+
} // SimpleTestObject
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/TestFactory.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/TestFactory.java
index 567255d..c37f2ca 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/TestFactory.java
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/TestFactory.java
@@ -46,6 +46,16 @@
SimpleTestObject createSimpleTestObject();
/**
+ * Returns a new object of class '<em>Inner Object</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @return a new object of class '<em>Inner Object</em>'.
+ * @generated
+ */
+ InnerObject createInnerObject();
+
+ /**
* Returns the package supported by this factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/TestPackage.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/TestPackage.java
index 68ea335..8df3e44 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/TestPackage.java
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/TestPackage.java
@@ -19,6 +19,7 @@
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
/**
* <!-- begin-user-doc -->
@@ -117,6 +118,16 @@
int SIMPLE_TEST_OBJECT__MY_ENUM = 2;
/**
+ * The feature id for the '<em><b>Inner</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int SIMPLE_TEST_OBJECT__INNER = 3;
+
+ /**
* The number of structural features of the '<em>Simple Test Object</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -124,7 +135,7 @@
* @generated
* @ordered
*/
- int SIMPLE_TEST_OBJECT_FEATURE_COUNT = 3;
+ int SIMPLE_TEST_OBJECT_FEATURE_COUNT = 4;
/**
* The number of operations of the '<em>Simple Test Object</em>' class.
@@ -137,6 +148,48 @@
int SIMPLE_TEST_OBJECT_OPERATION_COUNT = 0;
/**
+ * The meta object id for the '{@link org.eclipse.emf.ecp.view.core.swt.test.model.impl.InnerObjectImpl <em>Inner
+ * Object</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.impl.InnerObjectImpl
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.impl.TestPackageImpl#getInnerObject()
+ * @generated
+ */
+ int INNER_OBJECT = 1;
+
+ /**
+ * The feature id for the '<em><b>My Enum</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int INNER_OBJECT__MY_ENUM = 0;
+
+ /**
+ * The number of structural features of the '<em>Inner Object</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int INNER_OBJECT_FEATURE_COUNT = 1;
+
+ /**
+ * The number of operations of the '<em>Inner Object</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int INNER_OBJECT_OPERATION_COUNT = 0;
+
+ /**
* The meta object id for the '{@link org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum <em>Enum</em>}' enum.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -145,7 +198,7 @@
* @see org.eclipse.emf.ecp.view.core.swt.test.model.impl.TestPackageImpl#getTestEnum()
* @generated
*/
- int TEST_ENUM = 1;
+ int TEST_ENUM = 2;
/**
* The meta object id for the '<em>XML Date</em>' data type.
@@ -156,7 +209,7 @@
* @see org.eclipse.emf.ecp.view.core.swt.test.model.impl.TestPackageImpl#getXMLDate()
* @generated
*/
- int XML_DATE = 2;
+ int XML_DATE = 3;
/**
* Returns the meta object for class '{@link org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject
@@ -210,6 +263,44 @@
EAttribute getSimpleTestObject_MyEnum();
/**
+ * Returns the meta object for the containment reference
+ * '{@link org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject#getInner <em>Inner</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @return the meta object for the containment reference '<em>Inner</em>'.
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject#getInner()
+ * @see #getSimpleTestObject()
+ * @generated
+ */
+ EReference getSimpleTestObject_Inner();
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject <em>Inner
+ * Object</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @return the meta object for class '<em>Inner Object</em>'.
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject
+ * @generated
+ */
+ EClass getInnerObject();
+
+ /**
+ * Returns the meta object for the attribute
+ * '{@link org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject#getMyEnum <em>My Enum</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @return the meta object for the attribute '<em>My Enum</em>'.
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject#getMyEnum()
+ * @see #getInnerObject()
+ * @generated
+ */
+ EAttribute getInnerObject_MyEnum();
+
+ /**
* Returns the meta object for enum '{@link org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum <em>Enum</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -298,6 +389,36 @@
EAttribute SIMPLE_TEST_OBJECT__MY_ENUM = eINSTANCE.getSimpleTestObject_MyEnum();
/**
+ * The meta object literal for the '<em><b>Inner</b></em>' containment reference feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EReference SIMPLE_TEST_OBJECT__INNER = eINSTANCE.getSimpleTestObject_Inner();
+
+ /**
+ * The meta object literal for the '{@link org.eclipse.emf.ecp.view.core.swt.test.model.impl.InnerObjectImpl
+ * <em>Inner Object</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.impl.InnerObjectImpl
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.impl.TestPackageImpl#getInnerObject()
+ * @generated
+ */
+ EClass INNER_OBJECT = eINSTANCE.getInnerObject();
+
+ /**
+ * The meta object literal for the '<em><b>My Enum</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ EAttribute INNER_OBJECT__MY_ENUM = eINSTANCE.getInnerObject_MyEnum();
+
+ /**
* The meta object literal for the '{@link org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum <em>Enum</em>}'
* enum.
* <!-- begin-user-doc -->
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/InnerObjectImpl.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/InnerObjectImpl.java
new file mode 100644
index 0000000..c17532c
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/InnerObjectImpl.java
@@ -0,0 +1,179 @@
+/**
+ * Copyright (c) 2011-2019 EclipseSource Muenchen GmbH and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Eugen Neufeld - initial API and implementation
+ * Lucas Koehler - extension for EnumComboViewerRenderer_PTest
+ */
+package org.eclipse.emf.ecp.view.core.swt.test.model.impl;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
+import org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject;
+import org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum;
+import org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Inner Object</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * </p>
+ * <ul>
+ * <li>{@link org.eclipse.emf.ecp.view.core.swt.test.model.impl.InnerObjectImpl#getMyEnum <em>My Enum</em>}</li>
+ * </ul>
+ *
+ * @generated
+ */
+public class InnerObjectImpl extends MinimalEObjectImpl.Container implements InnerObject {
+ /**
+ * The cached value of the '{@link #getMyEnum() <em>My Enum</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @see #getMyEnum()
+ * @generated
+ * @ordered
+ */
+ protected TestEnum myEnum;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected InnerObjectImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return TestPackage.Literals.INNER_OBJECT;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public TestEnum getMyEnum() {
+ return myEnum;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public void setMyEnum(TestEnum newMyEnum) {
+ final TestEnum oldMyEnum = myEnum;
+ myEnum = newMyEnum == null ? null : newMyEnum;
+ if (eNotificationRequired()) {
+ eNotify(
+ new ENotificationImpl(this, Notification.SET, TestPackage.INNER_OBJECT__MY_ENUM, oldMyEnum, myEnum));
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case TestPackage.INNER_OBJECT__MY_ENUM:
+ return getMyEnum();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case TestPackage.INNER_OBJECT__MY_ENUM:
+ setMyEnum((TestEnum) newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case TestPackage.INNER_OBJECT__MY_ENUM:
+ setMyEnum((TestEnum) null);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case TestPackage.INNER_OBJECT__MY_ENUM:
+ return myEnum != null;
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy()) {
+ return super.toString();
+ }
+
+ final StringBuilder result = new StringBuilder(super.toString());
+ result.append(" (myEnum: "); //$NON-NLS-1$
+ result.append(myEnum);
+ result.append(')');
+ return result.toString();
+ }
+
+} // InnerObjectImpl
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/SimpleTestObjectImpl.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/SimpleTestObjectImpl.java
index 0618638..e062f3e 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/SimpleTestObjectImpl.java
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/SimpleTestObjectImpl.java
@@ -19,9 +19,12 @@
import javax.xml.datatype.XMLGregorianCalendar;
import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
+import org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject;
import org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject;
import org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum;
import org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage;
@@ -37,6 +40,7 @@
* <li>{@link org.eclipse.emf.ecp.view.core.swt.test.model.impl.SimpleTestObjectImpl#getDate <em>Date</em>}</li>
* <li>{@link org.eclipse.emf.ecp.view.core.swt.test.model.impl.SimpleTestObjectImpl#getXmlDate <em>Xml Date</em>}</li>
* <li>{@link org.eclipse.emf.ecp.view.core.swt.test.model.impl.SimpleTestObjectImpl#getMyEnum <em>My Enum</em>}</li>
+ * <li>{@link org.eclipse.emf.ecp.view.core.swt.test.model.impl.SimpleTestObjectImpl#getInner <em>Inner</em>}</li>
* </ul>
*
* @generated
@@ -98,6 +102,17 @@
protected TestEnum myEnum;
/**
+ * The cached value of the '{@link #getInner() <em>Inner</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @see #getInner()
+ * @generated
+ * @ordered
+ */
+ protected InnerObject inner;
+
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
@@ -205,6 +220,81 @@
* @generated
*/
@Override
+ public InnerObject getInner() {
+ return inner;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public NotificationChain basicSetInner(InnerObject newInner, NotificationChain msgs) {
+ final InnerObject oldInner = inner;
+ inner = newInner;
+ if (eNotificationRequired()) {
+ final ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
+ TestPackage.SIMPLE_TEST_OBJECT__INNER, oldInner, newInner);
+ if (msgs == null) {
+ msgs = notification;
+ } else {
+ msgs.add(notification);
+ }
+ }
+ return msgs;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public void setInner(InnerObject newInner) {
+ if (newInner != inner) {
+ NotificationChain msgs = null;
+ if (inner != null) {
+ msgs = ((InternalEObject) inner).eInverseRemove(this,
+ EOPPOSITE_FEATURE_BASE - TestPackage.SIMPLE_TEST_OBJECT__INNER, null, msgs);
+ }
+ if (newInner != null) {
+ msgs = ((InternalEObject) newInner).eInverseAdd(this,
+ EOPPOSITE_FEATURE_BASE - TestPackage.SIMPLE_TEST_OBJECT__INNER, null, msgs);
+ }
+ msgs = basicSetInner(newInner, msgs);
+ if (msgs != null) {
+ msgs.dispatch();
+ }
+ } else if (eNotificationRequired()) {
+ eNotify(new ENotificationImpl(this, Notification.SET, TestPackage.SIMPLE_TEST_OBJECT__INNER, newInner,
+ newInner));
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case TestPackage.SIMPLE_TEST_OBJECT__INNER:
+ return basicSetInner(null, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case TestPackage.SIMPLE_TEST_OBJECT__DATE:
@@ -213,6 +303,8 @@
return getXmlDate();
case TestPackage.SIMPLE_TEST_OBJECT__MY_ENUM:
return getMyEnum();
+ case TestPackage.SIMPLE_TEST_OBJECT__INNER:
+ return getInner();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -235,6 +327,9 @@
case TestPackage.SIMPLE_TEST_OBJECT__MY_ENUM:
setMyEnum((TestEnum) newValue);
return;
+ case TestPackage.SIMPLE_TEST_OBJECT__INNER:
+ setInner((InnerObject) newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -257,6 +352,9 @@
case TestPackage.SIMPLE_TEST_OBJECT__MY_ENUM:
setMyEnum((TestEnum) null);
return;
+ case TestPackage.SIMPLE_TEST_OBJECT__INNER:
+ setInner((InnerObject) null);
+ return;
}
super.eUnset(featureID);
}
@@ -276,6 +374,8 @@
return XML_DATE_EDEFAULT == null ? xmlDate != null : !XML_DATE_EDEFAULT.equals(xmlDate);
case TestPackage.SIMPLE_TEST_OBJECT__MY_ENUM:
return myEnum != null;
+ case TestPackage.SIMPLE_TEST_OBJECT__INNER:
+ return inner != null;
}
return super.eIsSet(featureID);
}
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/TestFactoryImpl.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/TestFactoryImpl.java
index 5ef231b..f670a91 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/TestFactoryImpl.java
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/TestFactoryImpl.java
@@ -22,6 +22,7 @@
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject;
import org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject;
import org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum;
import org.eclipse.emf.ecp.view.core.swt.test.model.TestFactory;
@@ -77,6 +78,8 @@
switch (eClass.getClassifierID()) {
case TestPackage.SIMPLE_TEST_OBJECT:
return createSimpleTestObject();
+ case TestPackage.INNER_OBJECT:
+ return createInnerObject();
default:
throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -136,6 +139,18 @@
*
* @generated
*/
+ @Override
+ public InnerObject createInnerObject() {
+ final InnerObjectImpl innerObject = new InnerObjectImpl();
+ return innerObject;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
public TestEnum createTestEnumFromString(EDataType eDataType, String initialValue) {
final TestEnum result = TestEnum.get(initialValue);
if (result == null) {
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/TestPackageImpl.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/TestPackageImpl.java
index db9da91..7bd5258 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/TestPackageImpl.java
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/impl/TestPackageImpl.java
@@ -21,7 +21,9 @@
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.impl.EPackageImpl;
+import org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject;
import org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject;
import org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum;
import org.eclipse.emf.ecp.view.core.swt.test.model.TestFactory;
@@ -49,6 +51,14 @@
*
* @generated
*/
+ private EClass innerObjectEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
private EEnum testEnumEEnum = null;
/**
@@ -177,6 +187,39 @@
* @generated
*/
@Override
+ public EReference getSimpleTestObject_Inner() {
+ return (EReference) simpleTestObjectEClass.getEStructuralFeatures().get(3);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public EClass getInnerObject() {
+ return innerObjectEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public EAttribute getInnerObject_MyEnum() {
+ return (EAttribute) innerObjectEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
public EEnum getTestEnum() {
return testEnumEEnum;
}
@@ -230,6 +273,10 @@
createEAttribute(simpleTestObjectEClass, SIMPLE_TEST_OBJECT__DATE);
createEAttribute(simpleTestObjectEClass, SIMPLE_TEST_OBJECT__XML_DATE);
createEAttribute(simpleTestObjectEClass, SIMPLE_TEST_OBJECT__MY_ENUM);
+ createEReference(simpleTestObjectEClass, SIMPLE_TEST_OBJECT__INNER);
+
+ innerObjectEClass = createEClass(INNER_OBJECT);
+ createEAttribute(innerObjectEClass, INNER_OBJECT__MY_ENUM);
// Create enums
testEnumEEnum = createEEnum(TEST_ENUM);
@@ -280,6 +327,14 @@
!IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getSimpleTestObject_MyEnum(), getTestEnum(), "myEnum", null, 0, 1, SimpleTestObject.class, //$NON-NLS-1$
!IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getSimpleTestObject_Inner(), getInnerObject(), null, "inner", null, 0, 1, //$NON-NLS-1$
+ SimpleTestObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES,
+ !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(innerObjectEClass, InnerObject.class, "InnerObject", !IS_ABSTRACT, !IS_INTERFACE, //$NON-NLS-1$
+ IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getInnerObject_MyEnum(), getTestEnum(), "myEnum", null, 0, 1, InnerObject.class, //$NON-NLS-1$
+ !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// Initialize enums and add enum literals
initEEnum(testEnumEEnum, TestEnum.class, "TestEnum"); //$NON-NLS-1$
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/provider/InnerObjectItemProvider.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/provider/InnerObjectItemProvider.java
new file mode 100644
index 0000000..22539f7
--- /dev/null
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/provider/InnerObjectItemProvider.java
@@ -0,0 +1,187 @@
+/**
+ * Copyright (c) 2011-2019 EclipseSource Muenchen GmbH and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Eugen Neufeld - initial API and implementation
+ * Lucas Koehler - extension for EnumComboViewerRenderer_PTest
+ */
+package org.eclipse.emf.ecp.view.core.swt.test.model.provider;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.Enumerator;
+import org.eclipse.emf.common.util.ResourceLocator;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject;
+import org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum;
+import org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage;
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+
+/**
+ * This is the item provider adapter for a {@link org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject} object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+public class InnerObjectItemProvider
+ extends ItemProviderAdapter
+ implements
+ IEditingDomainItemProvider,
+ IStructuredItemContentProvider,
+ ITreeItemContentProvider,
+ IItemLabelProvider,
+ IItemPropertySource {
+ /**
+ * This constructs an instance from a factory and a notifier.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public InnerObjectItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ addMyEnumPropertyDescriptor(object);
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This adds a property descriptor for the My Enum feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated NOT
+ */
+ protected void addMyEnumPropertyDescriptor(Object object) {
+ itemPropertyDescriptors
+ .add(new ItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_InnerObject_myEnum_feature"), //$NON-NLS-1$
+ getString("_UI_PropertyDescriptor_description", "_UI_InnerObject_myEnum_feature", //$NON-NLS-1$//$NON-NLS-2$
+ "_UI_InnerObject_type"), //$NON-NLS-1$
+ TestPackage.Literals.INNER_OBJECT__MY_ENUM,
+ true,
+ false,
+ false,
+ ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
+ null,
+ null) {
+ @Override
+ public Collection<?> getChoiceOfValues(Object object) {
+ final Set<Enumerator> set = TestPackage.Literals.TEST_ENUM.getELiterals().stream()
+ .map(EEnumLiteral::getInstance).collect(Collectors.toSet());
+ set.remove(TestEnum.D);
+ return set;
+ }
+ });
+ }
+
+ /**
+ * This returns InnerObject.gif.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object, getResourceLocator().getImage("full/obj16/InnerObject")); //$NON-NLS-1$
+ }
+
+ /**
+ * This returns the label text for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ final TestEnum labelValue = ((InnerObject) object).getMyEnum();
+ final String label = labelValue == null ? null : labelValue.toString();
+ return label == null || label.length() == 0 ? getString("_UI_InnerObject_type") : //$NON-NLS-1$
+ getString("_UI_InnerObject_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to update any cached
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(InnerObject.class)) {
+ case TestPackage.INNER_OBJECT__MY_ENUM:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
+ * that can be created under this object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+ }
+
+ /**
+ * Return the resource locator for this item provider's resources.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public ResourceLocator getResourceLocator() {
+ return TestEditPlugin.INSTANCE;
+ }
+
+}
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/provider/SimpleTestObjectItemProvider.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/provider/SimpleTestObjectItemProvider.java
index 6d95b97..adf2451 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/provider/SimpleTestObjectItemProvider.java
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/provider/SimpleTestObjectItemProvider.java
@@ -25,14 +25,17 @@
import org.eclipse.emf.common.util.Enumerator;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject;
import org.eclipse.emf.ecp.view.core.swt.test.model.TestEnum;
+import org.eclipse.emf.ecp.view.core.swt.test.model.TestFactory;
import org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
@@ -48,9 +51,7 @@
public class SimpleTestObjectItemProvider
extends ItemProviderAdapter
implements
- IEditingDomainItemProvider,
- ITreeItemContentProvider,
- IItemLabelProvider,
+ IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider,
IItemPropertySource {
/**
* This constructs an instance from a factory and a notifier.
@@ -161,6 +162,38 @@
}
/**
+ * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
+ * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
+ * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
+ if (childrenFeatures == null) {
+ super.getChildrenFeatures(object);
+ childrenFeatures.add(TestPackage.Literals.SIMPLE_TEST_OBJECT__INNER);
+ }
+ return childrenFeatures;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected EStructuralFeature getChildFeature(Object object, Object child) {
+ // Check the type of the specified child object and return the proper feature to use for
+ // adding (see {@link AddCommand}) it as a child.
+
+ return super.getChildFeature(object, child);
+ }
+
+ /**
* This returns SimpleTestObject.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -205,6 +238,9 @@
case TestPackage.SIMPLE_TEST_OBJECT__MY_ENUM:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
+ case TestPackage.SIMPLE_TEST_OBJECT__INNER:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
+ return;
}
super.notifyChanged(notification);
}
@@ -220,6 +256,9 @@
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
+
+ newChildDescriptors.add(createChildParameter(TestPackage.Literals.SIMPLE_TEST_OBJECT__INNER,
+ TestFactory.eINSTANCE.createInnerObject()));
}
/**
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/provider/TestItemProviderAdapterFactory.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/provider/TestItemProviderAdapterFactory.java
index a758963..c74dcc3 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/provider/TestItemProviderAdapterFactory.java
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/provider/TestItemProviderAdapterFactory.java
@@ -115,6 +115,32 @@
}
/**
+ * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject}
+ * instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected InnerObjectItemProvider innerObjectItemProvider;
+
+ /**
+ * This creates an adapter for a {@link org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public Adapter createInnerObjectAdapter() {
+ if (innerObjectItemProvider == null) {
+ innerObjectItemProvider = new InnerObjectItemProvider(this);
+ }
+
+ return innerObjectItemProvider;
+ }
+
+ /**
* This returns the root adapter factory that contains this factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -231,6 +257,9 @@
if (simpleTestObjectItemProvider != null) {
simpleTestObjectItemProvider.dispose();
}
+ if (innerObjectItemProvider != null) {
+ innerObjectItemProvider.dispose();
+ }
}
}
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/util/TestAdapterFactory.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/util/TestAdapterFactory.java
index 7b6348c..c4bf294 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/util/TestAdapterFactory.java
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/util/TestAdapterFactory.java
@@ -18,6 +18,7 @@
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject;
import org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject;
import org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage;
@@ -88,6 +89,11 @@
}
@Override
+ public Adapter caseInnerObject(InnerObject object) {
+ return createInnerObjectAdapter();
+ }
+
+ @Override
public Adapter defaultCase(EObject object) {
return createEObjectAdapter();
}
@@ -124,6 +130,22 @@
}
/**
+ * Creates a new adapter for an object of class '{@link org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject
+ * <em>Inner Object</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ *
+ * @return the new adapter.
+ * @see org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject
+ * @generated
+ */
+ public Adapter createInnerObjectAdapter() {
+ return null;
+ }
+
+ /**
* Creates a new adapter for the default case.
* <!-- begin-user-doc -->
* This default implementation returns null.
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/util/TestSwitch.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/util/TestSwitch.java
index 8ec9a17..08d2b07 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/util/TestSwitch.java
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/core/swt/test/model/util/TestSwitch.java
@@ -17,6 +17,7 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.util.Switch;
+import org.eclipse.emf.ecp.view.core.swt.test.model.InnerObject;
import org.eclipse.emf.ecp.view.core.swt.test.model.SimpleTestObject;
import org.eclipse.emf.ecp.view.core.swt.test.model.TestPackage;
@@ -91,6 +92,14 @@
}
return result;
}
+ case TestPackage.INNER_OBJECT: {
+ final InnerObject innerObject = (InnerObject) theEObject;
+ T result = caseInnerObject(innerObject);
+ if (result == null) {
+ result = defaultCase(theEObject);
+ }
+ return result;
+ }
default:
return defaultCase(theEObject);
}
@@ -113,6 +122,22 @@
}
/**
+ * Returns the result of interpreting the object as an instance of '<em>Inner Object</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Inner Object</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseInnerObject(InnerObject object) {
+ return null;
+ }
+
+ /**
* Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
diff --git a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/internal/core/swt/renderer/EnumComboViewerRenderer_PTest.java b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/internal/core/swt/renderer/EnumComboViewerRenderer_PTest.java
index cd0a6d0..e7d4a3e 100644
--- a/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/internal/core/swt/renderer/EnumComboViewerRenderer_PTest.java
+++ b/tests/org.eclipse.emf.ecp.view.core.swt.tests/src/org/eclipse/emf/ecp/view/internal/core/swt/renderer/EnumComboViewerRenderer_PTest.java
@@ -97,12 +97,14 @@
editSupport = mock(EMFFormsEditSupport.class);
domainObject = TestFactory.eINSTANCE.createSimpleTestObject();
+ domainObject.setInner(TestFactory.eINSTANCE.createInnerObject());
setup();
final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(domainObject);
observableValue = EMFEditProperties
- .value(editingDomain, TestPackage.Literals.SIMPLE_TEST_OBJECT__MY_ENUM).observe(domainObject);
+ .value(editingDomain, TestPackage.Literals.INNER_OBJECT__MY_ENUM)
+ .observe(domainObject.getInner());
setRenderer(new EnumComboViewerSWTRenderer(getvControl(), getContext(), reportService, getDatabindingService(),
getLabelProvider(),
@@ -118,7 +120,7 @@
@Override
protected void mockControl() throws DatabindingFailedException {
- super.mockControl(domainObject, TestPackage.eINSTANCE.getSimpleTestObject_MyEnum());
+ super.mockControl(domainObject, TestPackage.eINSTANCE.getInnerObject_MyEnum());
}
@Test
@@ -166,7 +168,7 @@
NoPropertyDescriptorFoundExeption, DatabindingFailedException {
final TestEnum changedValue = TestEnum.C;
- domainObject.setMyEnum(TestEnum.B);
+ domainObject.getInner().setMyEnum(TestEnum.B);
final Combo combo = setUpDatabindingTest(observableValue);
combo.select(1); // TestEnum.C
combo.notifyListeners(SWT.Selection, new Event());
@@ -269,7 +271,7 @@
// A is filtered by annotation and D is filtered by the property descriptor,
// so we can only use B and C for testing
- domainObject.setMyEnum(TestEnum.B);
+ domainObject.getInner().setMyEnum(TestEnum.B);
renderControl(new SWTGridCell(0, 2, getRenderer()));
final EnumComboViewerSWTRenderer enumRenderer = (EnumComboViewerSWTRenderer) getRenderer();
@@ -284,7 +286,7 @@
final List<Throwable> thrown = new ArrayList<>(valuesToSet.length);
for (final TestEnum valueToSet : valuesToSet) {
final CompletableFuture<?> asyncUpdate = CompletableFuture.runAsync(
- () -> domainObject.setMyEnum(valueToSet))
+ () -> domainObject.getInner().setMyEnum(valueToSet))
.exceptionally(x -> {
thrown.add(x);
return null;