Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [gef-dev] Policy problem with part parent hierarchy

Hi Matthias,

Thank you for your quick response. After sending my message, I tried some things and ended implementing what was your suggestion #2 and it seems to work. 
I was not aware of the AbstractInteractionPolicy#isRegistered API and may be able to use it in the future.

Thanks again! :)

David Dubrow

On Mar 3, 2017, at 9:37 AM, Wienand, Matthias <matthias.wienand@xxxxxxxxx> wrote:

Hi David,

there are two possible solutions to your problem:

1) You can use the AbstractInteractionPolicy#isRegistered(EventTarget) and #isRegisteredForHost(EventTarget) methods to guard interaction policies from performing changes when another interaction policy is adapted to the part that is registered as the controller for the event target. This can be tested when the interaction policy is initialized (i.e. startDrag(), startScroll(), etc. is called). Then, you can set a flag "invalid" if the policy should not perform changes, e.g. "if (!isRegisteredForHost(event.getTarget())) invalid = true; else invalid = false; if (invalid) return;". The test "if (invalid) return;" can be included in all other callback methods. This is the approach implemented by the default policies.

2) You can replace the DefaultTargetPolicyResolver and provide an implementation that better matches your use case, e.g. return only the "closest" policy that can be found. This is also the recommended approach, if you want to exclude visuals from triggering interaction policies.

Best regards,

2017-03-03 15:15 GMT+01:00 David Dubrow <ddubrow@xxxxxxxxxxxxx>:
I am working on an visual editor based on GEF MVC and have run across a problem I’m not sure how to resolve.
I have just added the concept of visual containers. Containers are just like any other visual object except they can also have children.
The problem is that when I select a child of a container, the policy resolver finds the same policy (TranslateSelectedOnDragPolicy in this case) for both the child part and its parents. This causes the same policy to be initialized multiple times which fails the check uninitialized test in the policy.
In reality however, it does not make sense that the parent’s policy be used in the case when only the child is selected, but I can’t figure out how to dynamically select the correct policy based on the current part parent structure.

Thanks for any help!

David Dubrow

gef-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Matthias Wienand

Telefon: +49 231 9860 202
Telefax: +49 231 9860 211
Mobil:   +49 152 26802283


itemis AG
Niederlassung Lünen
Am Brambusch 15-24
44536 Lünen

Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Jens Wagener (Vors.), Wolfgang Neuhaus, Dr. Georg Pietrek, Jens Trompeter
Aufsichtsrat: Prof. Dr. Burkhard Igel (Vors.), Michael Neuhaus, Jennifer Fiorentino
gef-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top