Code generation problems reporting (display error / waring on model elements and in problems view) [message #1753721] |
Thu, 09 February 2017 05:34  |
Eclipse User |
|
|
|
Hi All,
We are building a DSML editor on top of the papyrus editor. This editor performs automatic DSL code generation on diagram save action (overriding CoreMultiDiagramEditor.doSave(IProgressMonitor)).
Of course, during code generation, errors or warnings can be generated (invalid model structure, invalid data in the model, etc...). These are collected, each with an attached URI reference to the model EObject that is the source of the problem.
Now that we have this list of issues, we would like to present it to the user in the "usual" way:
- Display the typical error or warning badge on top of corresponding graphical object
- Add an entry in the Problems view (double-clicking on this entry, opens the corresponding editor)
I have gone through the Papyrus wiki, but I am failing to connect the dots.
What would be the best / most straightforward way to do this? (Is it possible to plug into some of the mechanisms used to report model validation issues?)
Thanks in advance,
Lionel
[Updated on: Fri, 10 February 2017 03:02] by Moderator
|
|
|
|
Re: Code generation problems reporting (display error / waring on model elements and in problems vie [message #1754231 is a reply to message #1753820] |
Wed, 15 February 2017 10:07  |
Eclipse User |
|
|
|
Hi Ansgar,
Thanks a lot for your answer.
I would rather not duplicate as OCL constraints whatever the code generator already detects almost for free, as a side effect of its actions. So programmatic creation of validation markers appears to be a better option in this specific case.
I implemented the EValidator markers as you suggested, and it works fine (nice and easy! ).
However, double-clicking on a problem in the Problems View opens the model editor. Is there a way I can make it open the proper tab of my multi-tabbed editor? (extension point to handle the link?)
For the record (in case someone tries to do the same):
In order to be able to selectively delete my markers before each code generation round, I initially tried to "subtype" EValidator.MARKER:
<extension point="org.eclipse.core.resources.markers" id="codegenmarker" name="DSL Code Generation">
<super type="org.eclipse.emf.ecore.diagnostic"/>
<persistent value="true"/>
</extension>
Unfortunately, although Problems were correctly displayed in the Problems view, the diagram editor did not display the Warning/Error badges over the icons. Il looks like the editor is strict about the marker type and does not check for IMarker.isSubtypeOf(EValidator.MARKER). Workaround was to use actual EValidator.MARKERs and flag them with a custom attribute, to recognize mine. It is not as clean as subtyping and does not allow one to control the value displayed in "Type" column of Problems view, though.
Lionel
[Updated on: Wed, 15 February 2017 10:08] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03015 seconds