Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Oomph » Setup task validation(How to provide better feedback for live validation)
Setup task validation [message #1791142] Mon, 25 June 2018 06:32 Go to next message
Matthias Fromme is currently offline Matthias FrommeFriend
Messages: 22
Registered: December 2011
Location: Germany
Junior Member
Hello,

is it possible to validate the content of a custom setup task to provide early feedback during setup model creation? If so, are there any examples that show how to do that?

I would like to check if the content of the fields of the setup tasks is valid and if all required fields are provided.
This cannot be done simply using multiplicities, since it depends on dynamical entered values of other fields if a field is available.

Regards,
Matthias
Re: Setup task validation [message #1791145 is a reply to message #1791142] Mon, 25 June 2018 07:05 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
You can apply normal EMF validation as explained for example in http://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.emf.doc%2Freferences%2Foverview%2FEMF.Validation.html .

Oomph's core setup model also contains an example:

  <eClassifiers xsi:type="ecore:EDataType" name="Filter" instanceClassName="java.lang.String">
    <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
      <details key="constraints" value="WellformedFilterExpression"/>
    </eAnnotations>
  </eClassifiers>


You can find the implementation of this constraint in org.eclipse.oomph.setup.util.SetupValidator.validateFilter_WellformedFilterExpression(String, DiagnosticChain, Map<Object, Object>).


Re: Setup task validation [message #1791151 is a reply to message #1791145] Mon, 25 June 2018 09:34 Go to previous messageGo to next message
Matthias Fromme is currently offline Matthias FrommeFriend
Messages: 22
Registered: December 2011
Location: Germany
Junior Member
Hello,

generally this works, but im not sure how to define constraints for a specific attribute of a class, so that the resulting errors are shown at the correct location (at the attribute in the the properties view) and not just for the instance of the class.
Is this possible?

Regards,
Matthias
Re: Setup task validation [message #1791155 is a reply to message #1791151] Mon, 25 June 2018 10:11 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
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/
Re: Setup task validation [message #1791311 is a reply to message #1791155] Thu, 28 June 2018 04:55 Go to previous message
Matthias Fromme is currently offline Matthias FrommeFriend
Messages: 22
Registered: December 2011
Location: Germany
Junior Member
Works very well!
Thank you very much.
Previous Topic:Upgrades all eclipse versions at once
Next Topic:How to be in the "Github Projects" project list ?
Goto Forum:
  


Current Time: Thu Apr 18 02:59:35 GMT 2024

Powered by FUDForum. Page generated in 0.01815 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top