EMF intrinsic validation: Fixed wrong detection of circular containment

Fix:
 - call to EMF validators now always uses a new context map
 - custom label provider class is reused
diff --git a/plugins/org.eclipse.app4mc.amalthea.validations.sim/src/org/eclipse/app4mc/amalthea/validations/sim/basic/SimSupportedModelElements.java b/plugins/org.eclipse.app4mc.amalthea.validations.sim/src/org/eclipse/app4mc/amalthea/validations/sim/basic/SimSupportedModelElements.java
index 619768b..8d29ee7 100644
--- a/plugins/org.eclipse.app4mc.amalthea.validations.sim/src/org/eclipse/app4mc/amalthea/validations/sim/basic/SimSupportedModelElements.java
+++ b/plugins/org.eclipse.app4mc.amalthea.validations.sim/src/org/eclipse/app4mc/amalthea/validations/sim/basic/SimSupportedModelElements.java
@@ -106,15 +106,15 @@
 import org.eclipse.emf.ecore.EcorePackage;
 
 /**
- * Checks that the model elements are supported in APP4MCsim.
+ * Checks that the model elements are supported in APP4MC.sim.
  *
  * <ul>
- * <li>Checks that the model elements are supported in APP4MCsim</li>
+ * <li>Checks that the model elements are supported in APP4MC.sim</li>
  * </ul>
  */
 
 @Validation(id = "Sim-supported-model-elements", checks = {
-		"Checks that the model elements are supported in APP4MCsim" })
+		"Checks that the model elements are supported in APP4MC.sim" })
 
 public class SimSupportedModelElements extends AmaltheaValidation {
 
@@ -150,7 +150,7 @@
 	/**
 	 * This set is automatically filled to contain the union of the sets of model
 	 * elements that are implicitly or explicitly transformed and are, therefore,
-	 * white-listed for APP4MCsim
+	 * white-listed for APP4MC.sim
 	 */
 	private static final Set<Class<?>> WHITE_LISTED_ELEMENTS = Stream
 			.concat(EXPLICITLY_TRANSFORMED_ELEMENTS.stream(), IMPLICITLY_TRANSFORMED_ELEMENTS.stream())
@@ -207,7 +207,7 @@
 				}
 			}
 
-			// check if it is the "usage" of a white-listed scheduleingParameters
+			// check if it is the "usage" of a white-listed schedulingParameter
 			if (eObject instanceof Map.Entry<?, ?>
 					&& ((Map.Entry<?, ?>) eObject).getKey() instanceof SchedulingParameterDefinition) {
 				String paramName = ((SchedulingParameterDefinition) ((Map.Entry<?, ?>) eObject).getKey()).getName();
@@ -217,7 +217,7 @@
 				}
 			}
 
-			addIssue(results, eObject, null, objectInfo(eObject) + ": Model element not supported in APP4MCsim");
+			addIssue(results, eObject, null, objectInfo(eObject) + ": Model element not supported in APP4MC.sim");
 
 		}
 	}
diff --git a/plugins/org.eclipse.app4mc.amalthea.validations.standard/src/org/eclipse/app4mc/amalthea/validations/standard/emf/AmEmfIntrinsic.java b/plugins/org.eclipse.app4mc.amalthea.validations.standard/src/org/eclipse/app4mc/amalthea/validations/standard/emf/AmEmfIntrinsic.java
index ffbd9cc..1d0e5f5 100644
--- a/plugins/org.eclipse.app4mc.amalthea.validations.standard/src/org/eclipse/app4mc/amalthea/validations/standard/emf/AmEmfIntrinsic.java
+++ b/plugins/org.eclipse.app4mc.amalthea.validations.standard/src/org/eclipse/app4mc/amalthea/validations/standard/emf/AmEmfIntrinsic.java
@@ -17,6 +17,7 @@
 
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 import org.eclipse.app4mc.amalthea.model.AmaltheaPackage;
@@ -36,6 +37,7 @@
 import org.eclipse.emf.ecore.EPackage;
 import org.eclipse.emf.ecore.EStructuralFeature;
 import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.ecore.EValidator.SubstitutionLabelProvider;
 import org.eclipse.emf.ecore.EcorePackage;
 import org.eclipse.emf.ecore.util.EcoreUtil;
 
@@ -50,7 +52,7 @@
 
 public class AmEmfIntrinsic implements IValidation {
 
-	private static final HashMap<Object, Object> CONTEXT = createContextMap();
+	private static final SubstitutionLabelProvider LABEL_PROVIDER = createCustomLabelProvider();
 
 	@Override
 	public EPackage getEPackage() {
@@ -66,10 +68,13 @@
 	public void validate(final EObject eObject, final List<ValidationDiagnostic> resultList) {
 		if (eObject.eClass().eContainer() == getEPackage()) {
 
-			BasicDiagnostic diagnostics = new BasicDiagnostic();
+			final BasicDiagnostic diagnostics = new BasicDiagnostic();
 
+			final Map<Object, Object> context = new HashMap<>();
+			context.put(EValidator.SubstitutionLabelProvider.class, LABEL_PROVIDER);
+			
 			// call standard EMF validator
-			boolean valid = AmaltheaValidator.INSTANCE.validate(eObject.eClass(), eObject, diagnostics, CONTEXT);
+			boolean valid = AmaltheaValidator.INSTANCE.validate(eObject.eClass(), eObject, diagnostics, context);
 
 			if (!valid) {
 				for (final Diagnostic emfDiagnostic : diagnostics.getChildren()) {
@@ -84,14 +89,15 @@
 							.map(EStructuralFeature.class::cast)
 							.findFirst().orElse(null);
 
-					final String subMessages =  emfDiagnostic.getChildren().stream()
+					final String subMessages = emfDiagnostic.getChildren().isEmpty() ? "" :
+							emfDiagnostic.getChildren().stream()
 							.map(Diagnostic::getMessage)
 							.map(String::trim)
 							.collect(Collectors.joining(", ", " => ", ""));
 
 					final String message = emfDiagnostic.getMessage()
 								+ objectOrContainerInfo(problematicObject)
-								+ (subMessages.equals(" => ") ? "" : subMessages);
+								+ subMessages;
 
 					ValidationDiagnostic result = new ValidationDiagnostic(message, problematicObject, problematicFeature);
 					result.setSeverityLevel(getSeverity(emfDiagnostic));
@@ -112,30 +118,6 @@
 
 	}
 
-	private static HashMap<Object, Object> createContextMap() {
-		final HashMap<Object, Object> map = new HashMap<>();
-
-		map.put(EValidator.SubstitutionLabelProvider.class, new EValidator.SubstitutionLabelProvider() {
-			@Override
-			public String getFeatureLabel(final EStructuralFeature eStructuralFeature) {
-				return eStructuralFeature.getName();
-			}
-
-			@Override
-			public String getObjectLabel(final EObject eObject) {
-				final String s1 = eObject.eClass().getName();
-				final String s2 = (eObject instanceof INamed) ? " " + ((INamed) eObject).getName() : "";
-				return s1 + s2;
-			}
-
-			@Override
-			public String getValueLabel(final EDataType eDataType, final Object value) {
-				return EcoreUtil.convertToString(eDataType, value);
-			}
-		});
-		return map;
-	}
-
 	private String objectOrContainerInfo(final EObject object) {
 		if (object != null) {
 
@@ -156,4 +138,25 @@
 		return !(s == null || s.isEmpty());
 	}
 
+	private static SubstitutionLabelProvider createCustomLabelProvider() {
+		return new EValidator.SubstitutionLabelProvider() {
+			@Override
+			public String getFeatureLabel(final EStructuralFeature eStructuralFeature) {
+				return eStructuralFeature.getName();
+			}
+	
+			@Override
+			public String getObjectLabel(final EObject eObject) {
+				final String s1 = eObject.eClass().getName();
+				final String s2 = (eObject instanceof INamed) ? " " + ((INamed) eObject).getName() : "";
+				return s1 + s2;
+			}
+	
+			@Override
+			public String getValueLabel(final EDataType eDataType, final Object value) {
+				return EcoreUtil.convertToString(eDataType, value); // default
+			}
+		};
+	}
+
 }
diff --git a/plugins/org.eclipse.app4mc.validation.help/docu/user_validation.textile b/plugins/org.eclipse.app4mc.validation.help/docu/user_validation.textile
index b2138d3..f56c5fa 100644
--- a/plugins/org.eclipse.app4mc.validation.help/docu/user_validation.textile
+++ b/plugins/org.eclipse.app4mc.validation.help/docu/user_validation.textile
@@ -157,7 +157,7 @@
 *** Mean must not be greater than the upper bound
 *** Mean must not be less than the lower bound
 ** Sim-supported-model-elements (WARNING - EObject)
-*** Checks that the model elements are supported in APP4MCsim
+*** Checks that the model elements are supported in APP4MC.sim
 p{padding: 10px; background: #fafafa; border: 1px solid #888; border-radius: 5px}. @org.eclipse.app4mc.amalthea.validations.sim.SimHardwareProfile@<br/>
 **Hardware Validations (APP4MC.sim)**
 * Validations: