Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Zest5: getting the model node from the displayed node
Zest5: getting the model node from the displayed node [message #1783560] Wed, 14 March 2018 07:15 Go to next message
Dominique Marcadet is currently offline Dominique MarcadetFriend
Messages: 14
Registered: January 2013
Junior Member
Hello,
My graph model is implemented as an IGraphContentProvider, it is displayed with Zest (Oxygen release version).
I want to know which node is selected (the node given by my provider, I call it modelNode), I was thinking that it is a common use case, but I didn't find an easy way to do it.

There was a IFXOnClickPolicy in Gef4, I don't see it anymore in current version.

Here is my current design:
I follow the advice given in this forum, that is: I create a new MyModule class that extends ZestFxModule and override the #bindNodePartAdapters() method to attach my handler.
In my handler, The #click(MouseEvent e) give me access to the org.eclipse.gef.zest.fx.parts.NodePart object with getHost()

The NodePart is created by ZestFxContentPartFactory.createContentPart() when the content is a graphNode, an instance of org.eclipse.gef.graph.Node (no links is kept between the NodePart and the graphNode, but we could have it by subclassing the Factory)

The graphNode itself is created by ZestContentViewer.createNode() who has access to my modelNode (given by my IGraphContentProvider) but if the ZestContentViewer maintains a map (called contentNodeMap) from modelNode to graphNode, I need the reverse; Again, I need to subclass to viewer to keep this needed link.

So my question is: is there a simple way to get from the mouse click to my modelNode ?

Regards,
Dominique
Re: Zest5: getting the model node from the displayed node [message #1783948 is a reply to message #1783560] Tue, 20 March 2018 15:43 Go to previous messageGo to next message
Dominique Marcadet is currently offline Dominique MarcadetFriend
Messages: 14
Registered: January 2013
Junior Member
Hello,

I have simplified my design, here is it for anyone interested.

Quote:
I follow the advice given in this forum, that is: I create a new MyModule class that extends ZestFxModule and override the #bindNodePartAdapters() method to attach my handler.
In my handler, The #click(MouseEvent e) give me access to the org.eclipse.gef.zest.fx.parts.NodePart object with getHost()


There is already an attached handler (FocusAndSelectOnClickHandler), we can benefit from it because y using Viewer.addSelectionChangedListener().

Quote:

The NodePart is created by ZestFxContentPartFactory.createContentPart() when the content is a graphNode, an instance of org.eclipse.gef.graph.Node (no links is kept between the NodePart and the graphNode, but we could have it by subclassing the Factory)


The graphNode is set as the primary content of the contentPart, so the above is not needed. Moreover, the registered listener receives directly the graphNode in the selection (it get it of course with the primary content, that's how I discover this).

Quote:

The graphNode itself is created by ZestContentViewer.createNode() who has access to my modelNode (given by my IGraphContentProvider) but if the ZestContentViewer maintains a map (called contentNodeMap) from modelNode to graphNode, I need the reverse; Again, I need to subclass to viewer to keep this needed link.


I didn't find a better way, so I have added a nodeContentMap in my viewer subclass.

Regards,
Dominique
Re: Zest5: getting the model node from the displayed node [message #1785835 is a reply to message #1783948] Fri, 20 April 2018 11:59 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 163
Registered: March 2015
Senior Member
Hi Dominique,

you are right w.r.t. the node-content-map. Subclassing ZestContentViewer is an adequate solution. I created https://bugs.eclipse.org/bugs/show_bug.cgi?id=533870 to keep track of the issue.

The IFXOnClickHander interface was simply renamed to IOnClickHandler. You can still register custom handlers via the module. However, as you figured already, the selection can be reused.

regards,
Matthias
Previous Topic:how to test view in GEF MVC
Next Topic:[GEF5] Hover Feedback parts and zoom
Goto Forum:
  


Current Time: Wed Sep 26 04:53:38 GMT 2018

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

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

Back to the top