Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Disable/Remove SVN context menu items appearing in DiagramEditor
icon4.gif  Disable/Remove SVN context menu items appearing in DiagramEditor [message #1695819] Tue, 19 May 2015 14:17 Go to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 31
Registered: August 2012
Hi ,

I have recently upgraded my code from graphiti version 0.9 to 0.11.

I have handled changes to migrate my code base to new version.
After migration I now see new context menu items realted to Logviewer/ SVN such as :Open with Log Viewer,Validate, Team,Comapre with,Replace with etc. along with my custom context menu options as in attached image.

I want to remove the this extra context menu options.
I already use the following code to remove Delete,Update and Remove context menu items in my ToolBehaviour provider class.

public IContextButtonPadData getContextButtonPad(
			final IPictogramElementContext context_) {
		final IContextButtonPadData data = super.getContextButtonPad(context_);
		final PictogramElement pe = context_.getPictogramElement();

		// Set the generic context buttons
		// default remove,delete and update buttons on context pad are removed
		setGenericContextButtons(data, pe, 0);
		return data;


I do not get from where this extra options are added and how do I remove those context menu options?

[Updated on: Wed, 20 May 2015 06:58]

Report message to a moderator

Re: Disable/Remove SVN context menu items appearing in DiagramEditor [message #1695901 is a reply to message #1695819] Wed, 20 May 2015 08:14 Go to previous message
Jerome Sivadier is currently offline Jerome SivadierFriend
Messages: 15
Registered: May 2015
Junior Member
Hello Saniya,

There are several ways to customize the context menu. The first one is to use the ToolBehavior as you mentioned but several menu options can be added automatically by Eclipse as the "Team" ones.
To deal with these problems you can either customize the context menu provider or delegate the menu management to your ActionBarContributor.

If you want to customize the context menu provider, you need to override the DiagramBehavior#createContextMenuProvider ( with a class which can extend DiagramEditorContextMenuProvider, see the method #buildContextMenu() (

If you want to delegate the management to your ActionBarContributor you can make your custom DiagramEditor class implement IMenuListener, then create a context menu for the graphical viewer and implement the "menuAboutToShow" method accordingly. Below are my own implementations of the two methods mentioned previously.

public class EditorPopupBarManager extends MenuManager implements IMenuListener2 {
	public EditorPopupBarManager(String text, IMenuListener primaryMenuListener) {
	 * Location for the contribution
	public static final String POPUP_LOCATION = "";
	private void initContribution() {
	public void dispose() {
		// release the contribution manager
		IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getService(IMenuService.class);
	public void menuAboutToShow(IMenuManager manager) {
		// add new
		IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getService(IMenuService.class);
		menuService.populateContributionManager(this, POPUP_LOCATION);
	public void menuAboutToHide(IMenuManager manager) {

  * Creates a context menu for the given graphical viewer
  * @param graphicalViewer a graphical viewer
protected void createContextMenuFor(GraphicalViewer graphicalViewer) {
	MenuManager contextMenu = new EditorPopupBarManager("#PopUp", this);
	Menu menu = contextMenu.createContextMenu(graphicalViewer.getControl());

public void menuAboutToShow(IMenuManager menu) {
	// Call the action bar's menu about to show method

To use the second method you will need to have somehow a "getActionBarContributor()" method returning the ActionBarContributor linked with your Editor Smile.

I do not know which method is the best, or if there are other methods but I use the second one in my project.


[Updated on: Wed, 20 May 2015 08:23]

Report message to a moderator

Previous Topic:Example/Tutorial for Non-Emf model in Graphiti
Next Topic:child shape inside parent shape
Goto Forum:

Current Time: Fri Jan 28 10:54:36 GMT 2022

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

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

Back to the top