Constraints on diagrams creation. [message #1832037] |
Mon, 07 September 2020 07:53 |
Alberto Debiasi Messages: 84 Registered: March 2018 |
Member |
|
|
I'm trying to implement the following constraint:
"Only Block Definition Diagrams are allowed. If the user creates a different diagram, an error should appear."
First, I tried with the extension point "org.eclipse.emf.validation.constraintProviders" specifying as package "http://www.eclipse.org/emf/2002/Ecore" and as Target "EObject".
For unknown reasons, with this approach, the defined constraint explores all the elements of the model (blocks, ports, connetions, ...) but not the diagrams.
Then, I tried with the extension point "org.polarsys.chess.resourceListener" implementing the method "transactionAboutToCommit(ResourceSetChangeEvent event)".
With this approach, the creation diagram event is detected and the error is displayed, but a new diagram icon still appears in Model Explorer.
Do you have any suggestions?
Many thanks,
Alberto
|
|
|
Re: Constraints on diagrams creation. [message #1832162 is a reply to message #1832037] |
Thu, 10 September 2020 13:14 |
|
Hello Alberto,
yes the EMF validation is only used to check the semantic part of the model, so UML and the applied profile.
I'm not really surprised you get a such result with a ResourceSetListener, but I have no idea how to fix this trouble.
To my mind, the best way to implement this behavior is to duplicate the SysML architecture file (for SysmL 1.4, the file is https://git.eclipse.org/c/papyrus/org.eclipse.papyrus-sysml.git/tree/gui/org.eclipse.papyrus.sysml14.architecture/resources/sysml14.architecture.
So one you create your own sysml architecture plugin and file. You need to change the creation command registered for the diagram creation in order to be able to refuse the diagram creation.
To be honest, I didn't test this solution, but I think it will work.
Warning, with this solution, you are creating a new DSML specializing SysML, you might to change the Architecture Language of your existing model (in ModelExplorer view -> Right click -> Switch Architecture Context)
|
|
|
|
Powered by
FUDForum. Page generated in 0.02597 seconds