Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » What is the best approach to implement a palette with a tree view(trial available for replacing default palette with a tree-based one)
What is the best approach to implement a palette with a tree view [message #1730970] Sun, 01 May 2016 08:01 Go to next message
Erwin De Ley is currently offline Erwin De LeyFriend
Messages: 52
Registered: August 2013
Member
For Triquetrum the palette contents are defined through extensions that are interpreted to create our CreationFeature implementations and the palette hierarchy. In this way, anybody is able to extend our editor with extra workflow components.

The underlying Ptolemy II framework already comes with many tens of components, so we need to be able to provide a palette with a potentially large number of entries, and organized in several levels of hierarchical groups.

For the moment we're still using the default palette view with drawers and tool entries, but this is not sufficient. It only allows a single level of groups, and when you have a large nr of groups the drawers take up too much screen space leaving almost no space left for showing/browsing the actual entries.

A palette tree view would be much better to handle our situation.
Can someone advise on the best approach to implement that in a Graphiti editor?

The palette in a Graphiti editor is defined through several "model" layers, via org.eclipse.gef.palette.PaletteEntry and org.eclipse.graphiti.palette.IPaletteEntry that are then used to construct a PaletteViewer with the standard edit parts for drawers and tools etc.

So I could imagine 3 possible approaches :
1. disable the standard editor palette completely and implement a totally new palette view ourselves, including the DnD, linking to selected editor etc.
(this is the approach I've taken before in the Triq-predecessor Passerelle)
2. build on GEF, i.e. replacing the default Graphiti approach, extending their model and using our own view representation
3. try to plug in a palette tree view on an extended Graphiti palette model and mechanisms

(One problem with options 2 and 3 is that the PaletteGroup class does not allow nesting groups, not in GEF nor in its Graphiti counterpart, so we need to extend the palette model structure with an own nestable group entry.)

Ideally I would like to try option 3 as :
- I would assume this would allow me to reuse existing palette control features as much as possible
- it might end up being of interest for other Graphiti users

But I could not identify the right way for either 2 or 3 yet...

Any advice, examples would be extremely welcome!

thanks,
erwin

[Updated on: Tue, 03 May 2016 18:16]

Report message to a moderator

Re: What is the best approach to implement a palette with a tree view [message #1731170 is a reply to message #1730970] Tue, 03 May 2016 10:04 Go to previous messageGo to next message
Erwin De Ley is currently offline Erwin De LeyFriend
Messages: 52
Registered: August 2013
Member
I've been trying to go for option 3, but have been hitting different issues related to the design in GEF for PaletteViewer and PaletteViewerProvider. So I guess the issues also would hit approach 2.

PaletteViewer is tightly linked (inherits from) to GraphicalViewerImpl and all that goes with that about figures, canvas, graphical EditParts etc.
And TreeViewers don't fit with that as they're not based on graphical components.

I'm trying to build a PaletteViewer subclass that bridges to Tree views but couldn't get it working yet... (and it involves hacks to hide some CLassCastExceptions during the view initialization etc).

So I'm starting to fear I will need to stick to a complete separate dvp track, i.e. option 1 again...

erwin
Re: What is the best approach to implement a palette with a tree view [message #1731245 is a reply to message #1731170] Tue, 03 May 2016 18:14 Go to previous messageGo to next message
Erwin De Ley is currently offline Erwin De LeyFriend
Messages: 52
Registered: August 2013
Member
Got something working, more-or-less reusing Graphiti palette construction mechanisms :
- added a PaletteTreeNode subclass of PaletteDrawer, that accepts nested containers
- TriqPaletteBehavior constructs the Palette node/entry hierarchy based on registered extensions
- PaletteTreeViewer extends the default GEF PaletteViewer, replacing its graphical control etc by a Tree with PaletteEntryEditParts in a hierarchy of PaletteTreeNodeEditParts. This duplicates the features of TreeViewer with some hacks to bypass expected class casts on graphical controls.
- copied some TreeViewerTransfer hidden classes from GEF without fully understanding what they're meant for Wink

See attached screenshot for the current state. It's functional but needs some more improvements (a filter/search field on top, disabling palette settings context menu, making tree nodes more recognizable ...)

Code available at https://github.com/eclipse/triquetrum/tree/erwin/ft/1/extensible-palette/org.eclipse.triquetrum.workflow.editor/src/main/java/org/eclipse/triquetrum/workflow/editor/palette (not yet on master)

Reviews are VERY welcome!

Is there an interest to provide this in a more reusable way?

cheers
erwin
Re: What is the best approach to implement a palette with a tree view [message #1731457 is a reply to message #1731245] Thu, 05 May 2016 13:22 Go to previous messageGo to next message
Roel Heirman is currently offline Roel HeirmanFriend
Messages: 5
Registered: May 2016
Junior Member
Wow, good job and thanks for sharing. I am also trying to extend the palette functionality, although with a completely different purpose. In the code I read:
* TODO : react on dynamically registered extra palette contributions, registered in a running workbench.
That's exactly what I'm also trying to achieve. If you find a solution, I would greatly appreciate it if you would share it with me Smile
Re: What is the best approach to implement a palette with a tree view [message #1731501 is a reply to message #1731457] Fri, 06 May 2016 09:29 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1932
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Erwin,

so far there were no requests to completly exchange the palette, at least none that I woukd remember.

Could you come up with some issues in Graphiti where we could do something that would ease exchanging the palette? As it seems there is more interest and if there are things to improve we should surely do that.

Thanks,
Michael

Re: What is the best approach to implement a palette with a tree view [message #1731663 is a reply to message #1731501] Mon, 09 May 2016 06:27 Go to previous messageGo to next message
Erwin De Ley is currently offline Erwin De LeyFriend
Messages: 52
Registered: August 2013
Member
Michael, I'll try to define some suggestions, thanks. Part of the story is certainly on the level of GEF.
The fact that the GEF palette inherits from a GraphicalViewer blocks easy reuse of tradition JFace viewers etc.

Roel, I'll certainly post the solution here when available. For the moment I'm not working on that, but on trying to integrate (features of) FilteredTree in the palette, and on not getting it working yet Wink .
Re: What is the best approach to implement a palette with a tree view [message #1732072 is a reply to message #1731663] Thu, 12 May 2016 12:50 Go to previous messageGo to next message
Erwin De Ley is currently offline Erwin De LeyFriend
Messages: 52
Registered: August 2013
Member
I've got a FilteredTree working in the palette. I've tried to describe the approach in http://eclipse.github.io/triquetrum/FilteredTree_Palette_in_Triquetrum/.

Roel, I've given up on the automated dynamic registration. I.e. in Triquetrum the palette is built up from bundles registering extension implementations.
And it seems when you install new software in an eclipse RCP, the installed features only become active after a workbench restart anyway.
And then the palette shows the additions already.

Or were you thinking about another situation?

cheers
erwin
Re: What is the best approach to implement a palette with a tree view [message #1732098 is a reply to message #1732072] Thu, 12 May 2016 14:55 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1932
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Erwin,

great, thanks for providing this detailed description. Having to use all these hacks is ugly, but given the fact that there will be no more development on GEF 3 we can only hope that it will be easier in GEF 4 and that we as Graphiti somehow find the time to migrate to it.

Michael
Previous Topic:[SOLVED!!!]I have a question on DirectEditingFeature
Next Topic:Scrollable figures
Goto Forum:
  


Current Time: Mon Nov 04 08:39:12 GMT 2024

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

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

Back to the top