Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Removing all edit policies at once ... (so that my OffscreenEditPartFactory gives me a minimalist viewer)
Removing all edit policies at once ... [message #1032884] Wed, 03 April 2013 11:09 Go to next message
Olivier Melois is currently offline Olivier Melois
Messages: 13
Registered: March 2012
Junior Member
Hello everyone,

I am trying to display a diagram in a viewer. The requirements are as follows :
-I should be able to double click on an EditPart to trigger some behavior (which I managed to do by creating a custom edit policy installed thanks to a custom edit policy provider)
-I should be able to select elements so that I can use menus from a right click (which is currently the case)
-When some features of a view change, the matching edit part should be refreshed accordingly (so that I can change colors dynamically, for instance).
-AND THAT'S IT

My problem is that I'd like to get rid of any unwanted behavior. Right now, by using the OffscreenEditPartFactory, the viewer I give me too many possible interactions : I can move stuff around (nodes and edges), I can select labels, when the mouse hovers an item, I get some tooltips ...

It is my understanding that all these behaviors are defined by edit policies. Thing is, apart from the ones I have defined myself, I'd like my diagram to be as
inflexible as it gets. My idea is to have my EditPolicyProvider uninstall all the edit policies from the edit part and then install the ones I truly want (I'd much rather work like this than "blacklisting" all the edit policies I don't want). Problem is : the "policies" attribute of the AbstractEditPart class is private, and sadly enough I don't know any way to retrieve the policies installed on an EditPart (event getting a list of keys would be great).

Does anyone have an idea ? Even if it's something completely different ? I don't want to re-code all the EditParts used in the diagrams I want to display ...

Thank you Smile
Re: Removing all edit policies at once ... [message #1033097 is a reply to message #1032884] Wed, 03 April 2013 17:15 Go to previous messageGo to next message
Thomas Beyer is currently offline Thomas Beyer
Messages: 55
Registered: February 2013
Member
Hi Olivier,

you could use
/**
	 * Used internally to iterate over the installed EditPolicies. While
	 * EditPolicy slots may be reserved with <code>null</code>, the iterator
	 * only returns the non-null ones.
	 * 
	 * @return an EditPolicyIterator
	 */
	protected final EditPolicyIterator getEditPolicyIterator() {
		return new EditPolicyIterator(policies);
	}

Since using this protected method means adapting generated code, you could use custom templates to modify all your editparts in the generation-chain.

Regards
Thomas
Re: Removing all edit policies at once ... [message #1033498 is a reply to message #1033097] Thu, 04 April 2013 05:33 Go to previous message
Olivier Melois is currently offline Olivier Melois
Messages: 13
Registered: March 2012
Junior Member
Hi Thomas, thank you for your answer

unfortunately, what I meant is : "I don't want to code my own edit part provider". I can't regenerate the edit parts, as I don't have the code. I just want to uninstall the edit policies, which I don't know how to do(without blacklisting every policy I happen to find).

The problem with the editPolicyIterator is that it won't let me iterate over the keys, which are necessary to uninstall the edit policies. I can access the getEditPolicyIterator method by using reflection but without the keys, having the edit policies is useless for my problem Sad

I'm thinking about creating an encapsulation class and code my own EditPartService (to encapsulate the editParts as they are created), in order to have a "installEditPolicyFix" which I'd use, while the "installEditPolicy" would do nothing. Problem is :using encapsulation would kill any behavior relying on the "instanceOf" mechanisms. I don't know if there is actually any ?

By the way, do the selection events occur thanks to a specific edit policy ? If that is the case, which one would that be ?

tl;dr : how can I generically uninstall all the edit policies from an edit part ?

Thank you for your time Smile ,
Olivier
Previous Topic:Multiple label in one node
Next Topic:Multiple Connection Labels
Goto Forum:
  


Current Time: Wed Jul 23 20:25:59 EDT 2014

Powered by FUDForum. Page generated in 0.01511 seconds