Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Disable delete specific notes
Disable delete specific notes [message #1772535] Tue, 12 September 2017 07:21 Go to next message
Martin Jedlicka is currently offline Martin JedlickaFriend
Messages: 122
Registered: January 2016
Senior Member

How do I disable delete a specific notes inserted from the palette?
I create a note on the diagram programmatically, you do not want to allow the user to delete.

Is it possible?


Re: Disable delete specific notes [message #1772546 is a reply to message #1772535] Tue, 12 September 2017 09:02 Go to previous message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 556
Registered: July 2009
Senior Member

It's not directly possible from Sirius itself, as these notes are actually not really managed by Sirius but purely graphical elements inherited from GMF. It might be possible by using GMF's own extension points to override the normal reaction to "delete" requests. The general idea would be:
* Use the org.eclipse.gmf.runtime.diagram.ui.editpolicyProviders extension point from GMF to provide your own IEditPolicyProvider. It should target to only apply to notes on Sirius diagrams.
* In your IEditPolicyProvider, replace the EditPolicyRoles.SEMANTIC_ROLE with your own implementation that "traps" DestroyElementRequest to do nothing. The default behavior for notes is provided by org.eclipse.gmf.runtime.diagram.ui.internal.editpolicies.NonSemanticEditPolicy, which ends-up simply destroying the GMF View.

Two "tricky" aspects to be aware of with editpolicyProviders:
* make sure you set up the appropriate priority for your provider (configured in the plugin.xml);
* make sure your IEditPolicyProvider really only applies to your diagrams (using the provides() method), as this is a low-level GMF mechanism which otherwise can impact all GMF-based products (i.e other Sirius-based modelers, or even Papryus).


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
Previous Topic:[ANN] Sirius 5.0.2
Next Topic:Custom Validation Rules Output
Goto Forum:

Current Time: Mon Mar 01 05:28:26 GMT 2021

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

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

Back to the top