Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Validate model before saving
Validate model before saving [message #1281110] Mon, 31 March 2014 11:20 Go to next message
Chris Apfelbeck is currently offline Chris ApfelbeckFriend
Messages: 1
Registered: March 2014
Junior Member
Hi all,

I'm developing a Graphiti plugin for Petri nets, and I want to implement a validation against certain criteria (no deadlocks, etc.).

I want the plugin to check the edited model for these criteria when the user wants to save the model. If the criteria are not matched, some kind of message should pop up and the save action should be cancelled.

So I need a "hook" to some kind of pre-save listener from where I can validate the model and if the validation fails, signal Eclipse to cancel the save action.

Any ideas how to realize this?


I already stumbled upon the so called FileModificationValidator [1], which is originally intended to be used only in team plugins (i.e. if you're working with repositories).

However, if I register my own validator via the according extension point, I get an error that only "exactly 0 or 1 validators may be registered". I don't really know why I get this error, as I am only registering 1 validator.


I'd be really glad for any ideas or hints on how to possibly realize this.
Thanks in advance,
Chris


[1] http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2FresAdv_hooks.htm
Re: Validate model before saving [message #1282401 is a reply to message #1281110] Wed, 02 April 2014 08:44 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Chris,

I do not have experience with the FileModificationValidator so I cannot
comment on this.

Usually, in Eclipse you would do such validations using a project builder
(also incremental) that can validate all changed files and post potential
errors to the user. And unsually, you would not prevent saving the editor
alos with errors. I would also recommend this fro usability perspective.

However, if you wnat to check a single diagram file on save and really like
to prevent saving, have you tried to override doSave in DiagramEditor? Have
a look at the documentation in ISaveablePart.doSave, it explains how
cancellation should be implemented.

Michael
Re: Validate model before saving [message #1283352 is a reply to message #1282401] Thu, 03 April 2014 10:19 Go to previous message
Soeren M is currently offline Soeren MFriend
Messages: 77
Registered: September 2011
Member
To be honest, I have to agree with Michael.
I dont think that the validation before saving is usability friendly.
The idea is good, but the greater the pn is the longer your algorithms will take to compute the correct validation.

I hope you are familiar with pns, validation and their complexity (wrt. runtime), if not I strongly recommend to get in touch with that at first...
Previous Topic:Graphiti Export diagram as jpg
Next Topic:Changing the default color and default size of components in Graphiti Diagram editor
Goto Forum:
  


Current Time: Fri Apr 26 15:53:00 GMT 2024

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

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

Back to the top