Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Code generation problems reporting (display error / waring on model elements and in problems view)
icon5.gif  Code generation problems reporting (display error / waring on model elements and in problems view) [message #1753721] Thu, 09 February 2017 10:34 Go to next message
Lionel C.Friend
Messages: 2
Registered: February 2017
Junior Member
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 08:02]

Report message to a moderator

Re: Code generation problems reporting (display error / waring on model elements and in problems vie [message #1753820 is a reply to message #1753721] Fri, 10 February 2017 12:19 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 229
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Hi Lionel,

you should write your own validation rules. Some of these could be associated with the constraints attached to stereotypes. In this case, the constraints can be specified using OCL or Java, as shown here.
You can find an example of profile based validation rules in the context of the Papyrus-RT project. Another source might be validation tutorial.

If your code generator determines errors and warnings in its own way, you can also create associated validation markers programmatically using the IFile method createMarker. Look at the interface EValidator for marker type and attributes, e.g. the marker must have an URI attribute.

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 15:07 Go to previous message
Lionel C.Friend
Messages: 2
Registered: February 2017
Junior Member
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! Smile).

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 15:08]

Report message to a moderator

Previous Topic:Multiple Inheritance in UML Profile
Next Topic:All In One Update Site
Goto Forum:
  


Current Time: Tue Jan 28 13:57:21 GMT 2020

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

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

Back to the top