diff options
Diffstat (limited to 'plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/validation/IEValidatorProvider.java')
-rw-r--r-- | plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/validation/IEValidatorProvider.java | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/validation/IEValidatorProvider.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/validation/IEValidatorProvider.java index fb380c0d1..c69b67513 100644 --- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/validation/IEValidatorProvider.java +++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/validation/IEValidatorProvider.java @@ -10,9 +10,15 @@ */ package org.eclipse.uml2.uml.validation; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; 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.util.Diagnostician; import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.util.UMLUtil; import org.eclipse.uml2.uml.util.UMLValidator; /** @@ -31,6 +37,19 @@ public interface IEValidatorProvider { */ EValidator getEValidator(EPackage ePackage); + /** + * Obtains an appropriate substitution-label provider for presentation of + * element names in validation of elements of the specified {@code ePackage} + * . + * + * @param ePackage + * a package for which to obtain a substitution-label provider + * + * @return a suitable provider, or @{code null} if none could be found + */ + EValidator.SubstitutionLabelProvider getSubstitutionLabelProvider( + EPackage ePackage); + // // Nested types // @@ -45,11 +64,40 @@ public interface IEValidatorProvider { public EValidator getEValidator(EPackage ePackage) { return EValidator.Registry.INSTANCE.getEValidator(ePackage); } + + public SubstitutionLabelProvider getSubstitutionLabelProvider( + EPackage ePackage) { + + return new EValidator.SubstitutionLabelProvider() { + + public String getObjectLabel(EObject eObject) { + String result = UMLUtil.getQualifiedText(eObject); + + if ((result == null) || (result.length() == 0)) { + result = Diagnostician.INSTANCE.getObjectLabel(eObject); + } + + return result; + } + + public String getFeatureLabel( + EStructuralFeature eStructuralFeature) { + + return Diagnostician.INSTANCE + .getFeatureLabel(eStructuralFeature); + } + + public String getValueLabel(EDataType eDataType, Object value) { + return Diagnostician.INSTANCE.getValueLabel(eDataType, + value); + } + }; + } } /** - * The UML {@link EValidator} maps the UML package to the standard UML - * validator. For other packageos, uses the validator registry to look up + * The UML {@link IEValidatorProvider} maps the UML package to the standard UML + * validator. For other packages, uses the validator registry to look up * whatever validator is there. */ class UML |