GEF5 Add multiple parts to Group [message #1802331] |
Wed, 06 February 2019 15:07 |
João Pedro Messages: 52 Registered: December 2014 |
Member |
|
|
My solution to have different outputs/inputs was to add smaller Nodes (Let's call them IO parts) close to the main center Node (let's call it Main Model part). These IO parts will then be selectable to connect amongst each other:
Now I'm having several issues since I'm trying to group several IO parts and 1 Main Model part and have the following behaviors:
-Drag the whole group together
-Be able to select individually each IO part
- Be able to double click on the Main Model part to open some settings (it can be as well a double click on the whole Group)
I can already drag the Group but not select each individual part... When I try to select, it gives a "Not yet initialized!" error:
!STACK 0
java.lang.IllegalStateException: Not yet initialized!
at org.eclipse.gef.mvc.fx.policies.AbstractPolicy.checkInitialized(AbstractPolicy.java:38)
at org.eclipse.gef.mvc.fx.policies.AbstractPolicy.commit(AbstractPolicy.java:59)
at org.eclipse.gef.mvc.fx.policies.TransformPolicy.commit(TransformPolicy.java:123)
at org.eclipse.gef.mvc.fx.handlers.AbstractHandler.commit(AbstractHandler.java:129)
at org.eclipse.gef.mvc.fx.handlers.TranslateSelectedOnDragHandler.endDrag(TranslateSelectedOnDragHandler.java:140)
at org.eclipse.gef.mvc.fx.gestures.ClickDragGesture.release(ClickDragGesture.java:471)
Can you guys give me some hints? I've been at this for days now and I feel that I'm close to achieving what I want but there's something missing... I also couldn't find any example that could help me.
Thanks.
[Updated on: Wed, 06 February 2019 16:16] Report message to a moderator
|
|
|
|
Re: GEF5 Add multiple parts to Group [message #1802906 is a reply to message #1802406] |
Mon, 18 February 2019 19:06 |
|
Hi Joao,
that looks pretty good already!
The IllegalStateException indicates that a policy is used (to perform some manipulation) that was already committed (Policy.commit()) or not yet initialized (Policy.init()).
Processing of inputs depends on the organisation of your part hierarchy (flat or nested), the visuals used (and their registration at visual-part-map), the gestures in-use (probably defaults), and the handlers used.
Note that handlers that both react to the same inputs might need to mutually exclude each other to work properly (i.e. you drag an input but it belongs to the whole group => "TranslateGroupOnDragHandler" needs to exclude that interaction explicitly).
Best regards,
Matthias
[Updated on: Mon, 18 February 2019 19:08] Report message to a moderator
|
|
|
|
Re: GEF5 Add multiple parts to Group [message #1803197 is a reply to message #1803099] |
Mon, 25 February 2019 09:15 |
|
Hi Joao,
the individual transforms of the parts should not be shared. If the child parts are inserted into the visual of their parent part, they will move along with their parent automatically.
TranslateSelectedOnDragHandler will translate all parts in SelectionModel that have a TransformPolicy. Since you do not want this behaviour, you could subclass TranslateSelectedOnDragHandler, for example TranslateGroupOnChildDragHandler that will translate the GroupPart but is registered for a ChildPart.
Best regards,
Matthias
|
|
|
Re: GEF5 Add multiple parts to Group [message #1803280 is a reply to message #1803197] |
Tue, 26 February 2019 09:19 |
Patrick Muscat Messages: 14 Registered: May 2018 |
Junior Member |
|
|
Hello,
The parent/child relation between boxes and ports should do what you want. In our diagram we have three levels of parts: boxes/groups/ports where our boxes are your Group and our ports are your IO (in our model, groups are drawn to show synchronization between input ports streams).
- when selecting a box, all children (groups and ports) follow the move
- when selecting a group, all ports inside the group of ports follow the move (and with coordinate constraint stay inside the box
- and finally, ports can be moved inside their parent group of ports
Children follow mouse drag of their parent even if they are not selected. Another solution would be to use anchored/anchorage mechanism.
In the configure method of the module we call bind methods for each level:
bindNodePartAdapters(AdapterMaps.getAdapterMapBinder(binder(), NodePart.class);
bindPortGroupPartAdapters(AdapterMaps.getAdapterMapBinder(binder(), PortGroupPart.class));
bindPortPartAdapters(AdapterMaps.getAdapterMapBinder(binder(), PortPart.class));
then, in these methods we decide to add or not bindings to Policies, for example, Nodes (the boxes) are deletable (DeletionPolicy), moveable (TransformPolicy), resizeable (ResizePolicy) when groups of ports are not moveable nor resizeable (they follow the parent box) and ports are only moveable inside their parent group of ports.
[Updated on: Tue, 26 February 2019 09:37] Report message to a moderator
|
|
|
|
|
Re: GEF5 Add multiple parts to Group [message #1803356 is a reply to message #1803346] |
Wed, 27 February 2019 10:26 |
João Pedro Messages: 52 Registered: December 2014 |
Member |
|
|
Quote:
If one of them is moving twice faster it is because two TransformPolicy are applied on the same Part by two different handlers in the same "drag" event.
Yep, that's what's happening.
Quote:
Another solution would be to activate only one handler which acts on the groupPart and the childPart simultaneously by customizing the getTargetParts method.
Exactly Patrick! I followed the second suggestion as shown in my previous post and changed getTargetParts. Still, I'm missing something. Maybe it's because I'm using 2 different handlers, one for the GroupPart and other for the ChildPart....
[Updated on: Wed, 27 February 2019 10:26] Report message to a moderator
|
|
|
|
Re: GEF5 Add multiple parts to Group [message #1803390 is a reply to message #1803358] |
Wed, 27 February 2019 19:10 |
|
Hi Joao,
it might be working already, but by returning the parent as the host, you basically take out the child's transform policy. If you would not bind it in the first place, you would (most probably) get the same behavior.
I have to say I really like the explanations given by Patrick, so I encourage you to try a simpler setup inspired by those, e.g. have the ports immoveable by omitting TransformPolicy from ChildPart.
However, maybe it does make sense to revisit this later-on after working more with different handlers.
Best regards,
Matthias
|
|
|
Powered by
FUDForum. Page generated in 0.03622 seconds