Skip to content
Snippets Groups Projects
Commit 6dd1d484 authored by Simon Barner's avatar Simon Barner
Browse files

- Change semantics of SUB_MODEL scope declaration to also include the element...

- Change semantics of SUB_MODEL scope declaration to also include the element to which the annotation is attached
- Preserve the current behavior (current element is not included) in STRICT_SUB_MODEL
refs 1841
parent b7009286
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
......@@ -36,6 +37,7 @@ import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.fortiss.tooling.base.ui.annotation.valueprovider.EStructuralFeatureDescriptor;
import org.fortiss.tooling.base.ui.annotation.valueprovider.EStructuralFeatureDescriptor.EReferenceScope;
import org.fortiss.tooling.kernel.model.INamedElement;
import org.fortiss.tooling.kernel.model.IProjectRootElement;
......@@ -93,13 +95,20 @@ public class ComboBoxLabelValueMapping {
root = getParentElement(modelElement, IProjectRootElement.class);
break;
case SUB_MODEL:
case STRICT_SUB_MODEL:
root = modelElement;
break;
default:
return;
}
EList<?> values = getChildrenWithType(root, eType.getInstanceClass());
EList<EObject> values = new BasicEList<EObject>();
if(eStructuralFeatureDescriptor.getEReferenceScope() == EReferenceScope.SUB_MODEL) {
values.add(root);
}
@SuppressWarnings("unchecked") Class<? extends EObject> instanceClass =
(Class<? extends EObject>)eType.getInstanceClass();
values.addAll(getChildrenWithType(root, instanceClass));
labelToValueMap = new TreeMap<String, Object>();
for(Object v : values) {
......
......@@ -47,9 +47,16 @@ public class EStructuralFeatureDescriptor {
/**
* Sub-model below the {@link IModelElement} to which the annotation is attached that
* contains the {@link EStructuralFeature} managed by this
* {@link EStructuralFeatureDescriptor}.
* {@link EStructuralFeatureDescriptor} (including the element itself)
*/
SUB_MODEL
SUB_MODEL,
/**
* Sub-model below the {@link IModelElement} to which the annotation is attached that
* contains the {@link EStructuralFeature} managed by this
* {@link EStructuralFeatureDescriptor} (NOT including the element itself)
*/
STRICT_SUB_MODEL
}
/** {@link EStructuralFeature} managed by this {@link EStructuralFeatureDescriptor}. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment