Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Adding new context menu option to a palette entry(Adding new context menu option to palette entry)
Adding new context menu option to a palette entry [message #839964] Mon, 09 April 2012 13:36 Go to next message
ganesh ram is currently offline ganesh ramFriend
Messages: 26
Registered: January 2012
Junior Member

Suppose i have a palette on my GMF diagram, and have nodes A and B on that.
I want to be able to right click on nodeA on the palette, and display a "View" option on the context menu, selecting on the "View" option would pop up some info on NodeA.

How could i accomplish this ?
Pls help.
Re: Adding new context menu option to a palette entry [message #880262 is a reply to message #839964] Fri, 01 June 2012 18:10 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member


you should take a look to XXXDiagramEditor.configurePaletteViewer() and override PaletteContextMenuProvider()


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Adding new context menu option to a palette entry [message #881444 is a reply to message #880262] Mon, 04 June 2012 15:11 Go to previous message
Manuel Ihlenfeld is currently offline Manuel IhlenfeldFriend
Messages: 6
Registered: June 2012
Junior Member

in my generated diagram editor XXXDiagramEditor.configurePaletteViewer()
never gets called (tried call hierarchy and a breakpoint on both
XXXDiagramEditor.configurePaletteViewer() and

However, i've found out that the palette viewer is configured by the
PaletteViewerProvider created and returned by
DiagramEditorWithFlyoutPalette#createPaletteViewerProvider() [1, lines 153
and 171]. This method creates an anonymous subclass of
PaletteViewerProvider consisting of quite a lot of code. I would need to
duplicate that code in order to override
PaletteViewerProvider#configurePaletteViewer(PaletteViewer) which sets the
context menu on the given palette viewer [2, line 51].



To avoid duplicating the code I might override
XXXDiagramEditor#createPartControl(.) to set the context menu on the
palette viewer:

public void createPartControl(Composite parent) {
PaletteViewer viewer = getEditDomain().getPaletteViewer();
viewer.setContextMenu(new PaletteContextMenuProvider(viewer) {
public void buildContextMenu(IMenuManager menu) {

Although it works, I would prefer overriding
XXXDiagramEditor.configurePaletteViewer(). Can anyone check whether this
method gets invoked, please?

Additionally, it would be nice if we could extend the palette context menu
using an extension point. Does GMF provide an extension point for that
purpose already?

Previous Topic:hide specific model elements
Next Topic:how to show EClass,EEnum and EDataType in ecore digram?
Goto Forum:

Current Time: Sun Oct 25 18:04:18 GMT 2020

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

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

Back to the top