From a468781dbf544da375d034dc9508401662800971 Mon Sep 17 00:00:00 2001 From: Simon Barner <barner@fortiss.org> Date: Mon, 29 Sep 2014 15:43:42 +0000 Subject: [PATCH] EStructuralFeatureValueProviderBase(EClass annotatedSpecificationEClass) - If there is only one EStructuralFeature in the annotation's EClass, registered it with the DEFAULT_KEY - This results in a more readable column heading (which is exactly the String returned by the user-supplied implementation of getAnnotationName(), instead of "<user-supplied String> : <EStructuralFeature name>" refs 1841 --- .../EStructuralFeatureValueProviderBase.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/valueprovider/EStructuralFeatureValueProviderBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/valueprovider/EStructuralFeatureValueProviderBase.java index 64f07050a..1967c708a 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/valueprovider/EStructuralFeatureValueProviderBase.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/valueprovider/EStructuralFeatureValueProviderBase.java @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EClassifier; @@ -121,10 +122,19 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp structuralFeatureMap = new HashMap<String, EStructuralFeature>(); - for(EStructuralFeature structuralFeature : (inheritedFeatures - ? annotatedSpecificationEClass.getEAllStructuralFeatures() - : annotatedSpecificationEClass.getEStructuralFeatures())) { - structuralFeatureMap.put(structuralFeature.getName(), structuralFeature); + EList<EStructuralFeature> featureList; + if(inheritedFeatures) { + featureList = annotatedSpecificationEClass.getEAllStructuralFeatures(); + } else { + featureList = annotatedSpecificationEClass.getEStructuralFeatures(); + } + + if(featureList.size() == 1) { + structuralFeatureMap.put(DEFAULT_KEY, featureList.get(0)); + } else { + for(EStructuralFeature structuralFeature : featureList) { + structuralFeatureMap.put(structuralFeature.getName(), structuralFeature); + } } handlesMultipleEstructuralFeatures = true; -- GitLab