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
Hi,

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

Hi,

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

regards,


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
Hi,

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

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].

[1]
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.gmp/org.eclipse.gmf.runtime/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/parts/DiagramEditorWithFlyOutPalette.java?view=markup&revision=1.13&root=Modeling_Project

[2]
http://git.eclipse.org/c/gef/org.eclipse.gef.git/tree/org.eclipse.gef/src/org/eclipse/gef/ui/palette/PaletteViewerProvider.java

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

@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
PaletteViewer viewer = getEditDomain().getPaletteViewer();
viewer.setContextMenu(new PaletteContextMenuProvider(viewer) {
@Override
public void buildContextMenu(IMenuManager menu) {
super.buildContextMenu(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?

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


Current Time: Tue Sep 24 19:39:25 GMT 2024

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

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

Back to the top