Skip to main content



      Home
Home » Modeling » Papyrus » Abort Save(How to prevent or abort saving)
Abort Save [message #1749737] Sat, 10 December 2016 10:03 Go to next message
Eclipse UserFriend
It is important for my plug-in that the model is not saved in an inconsitent state.
(I am aware that it would be convenient for the user to save inconsitent models, but that's not possbile in this case.)

My current attempt is to use the EMF Validation Framework to define constraints.
Then I trigger the batch validation in an AboutToDoSaveListener. So far, this works.

But now my question is: how do I abort the saving, when I detect a violation of the constraints?

Or is there another way earlier in the lifecycle to prevent the model from being saved?
Re: Abort Save [message #1755125 is a reply to message #1749737] Tue, 28 February 2017 04:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi Philipp,

the save is done by the class "SaveAndDirtyService". It fires the "AboutToDoSave" listeners first and then the "DoSave" listeners. All listeners return void, i.e. there is currently no means that a listener can cancel/abort the save mechanism. This is arguably a limitation which prevents for instance your use case. Please post a bug demanding such a feature (with severity = enhancement) - though I can't promise whether/when it will be implemented.

Best regards

Ansgar
Re: Abort Save [message #1755156 is a reply to message #1755125] Tue, 28 February 2017 09:38 Go to previous message
Eclipse UserFriend
A colleague (thanks) made me aware that there is already a quite old bug related to validation & saving: Bug 293145 - [Constraints-Validation] Support to automatically validate the model when saving
The difference to your case is that save is still possible, even if validation errors exist. Of course, the tool should do that in general, since not being able to save might imply loosing work. But iit should be possible to tailor that in a specific case.
Previous Topic:Diagram fragmentation: "Create Submodel" from diagram
Next Topic:Display applied stereotype name CSS
Goto Forum:
  


Current Time: Sat Aug 30 06:21:24 EDT 2025

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

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

Back to the top