Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Abort Save(How to prevent or abort saving)
Abort Save [message #1749737] Sat, 10 December 2016 15:03 Go to next message
Philipp Faller is currently offline Philipp FallerFriend
Messages: 3
Registered: November 2016
Junior Member
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 09:41 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 470
Registered: March 2011
Location: Paris Saclay, France
Senior Member
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 14:38 Go to previous message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 470
Registered: March 2011
Location: Paris Saclay, France
Senior Member
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 Oct 05 13:02:08 GMT 2024

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

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

Back to the top