|
|
|
Re: Setup task validation [message #1791155 is a reply to message #1791151] |
Mon, 25 June 2018 10:11 |
Ed Merks Messages: 33133 Registered: July 2009 |
Senior Member |
|
|
A rather complicated example is org.eclipse.emf.ecore.util.EcoreValidator.validateEClassifier_WellFormedInstanceTypeName(EClassifier, DiagnosticChain, Map<Object, Object>) where it validates that the classifier's instance type name is well formed. The key point is providing the appropriate information about the feature involved in the diagnostic that you create. E.g., for this example the diagnostic is created like this: BasicDiagnostic diagnosic =
createDiagnostic
(Diagnostic.ERROR,
DIAGNOSTIC_SOURCE,
WELL_FORMED_INSTANCE_TYPE_NAME,
"_UI_EClassifierInstanceTypeNameNotWellFormed_diagnostic",
new Object[] { getValueLabel(EcorePackage.Literals.ESTRING, instanceTypeName, context) },
new Object[] { eClassifier, EcorePackage.Literals.ECLASSIFIER__INSTANCE_TYPE_NAME },
context); Note in particular that the feature is specified in the associated objects after the instance object with the problem, i.e., in this case, the eClassifier has the problem and it's specifically the instanceTypeName feature that holds the problematic value (and it is referenced via the package metadata as "EcorePackage.Literals.ECLASSIFIER__INSTANCE_TYPE_NAME" in this case.
This information is used specifically in org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage.ExtendedPropertySheetEntry.find(Diagnostic, Object) to determine if the property descriptor for a specific feature has an associated diagnostic for that feature. It uses a contains test so you could specific multiple features in the diagnostic.
Note that as in this Ecore example, the named constraint still needs to be defined on the containing EClass of the EAttribute whose value you want to validate.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.01815 seconds