txt book

Tuesday, May 04, 2010

Add a new entry or modify the existing context menu of GMF editor

I want to add a new context menu entry to one of my diagram object. And I made it.The method is in GMF tutorial 3.
The further requirement is to combine the entry to the existing context menus. E.g. my "edit" options are part of the existing "edit" group.
The point is to find out the existing menus' ids.
So I take a look at the class "DiagramEditorContextMenuProvider" and print the menu ids out in the method "buildContextMenu". Here are the results:

umlAddGroup,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginSeparator(id=umlAddGroup)
addGroup,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginSeparator(id=addGroup)
navigateGroup,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginSeparator(id=navigateGroup)
navigateMenu,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginMenuManager@f65ce5
fileGroup,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginSeparator(id=fileGroup)
fileMenu,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginMenuManager@4cc81c
editGroup,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginSeparator(id=editGroup)
editMenu,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginMenuManager@e5ddd0
deleteFromDiagramAction,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginActionContributionItem(id=deleteFromDiagramAction)
deleteFromModelAction,org.eclipse.jface.action.ActionContributionItem(id=deleteFromModelAction)
findGroup,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginSeparator(id=findGroup)
filterFormatGroup,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginSeparator(id=filterFormatGroup)
selectMenu,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginMenuManager@145959c
toolbarArrangeAllAction,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginActionContributionItem(id=toolbarArrangeAllAction)
filtersMenu,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginMenuManager@1616dd6
viewGroup,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginSeparator(id=viewGroup)
restGroup,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginSeparator(id=restGroup)
additions,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginSeparator(id=additions)
propertiesGroup,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginSeparator(id=propertiesGroup)
showPropertiesViewAction,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginActionContributionItem(id=showPropertiesViewAction)
properties,org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider$PluginActionContributionItem(id=properties)


Now we know that the path of the edit entry is editMenu/editGroup.

Also, you can remove the unused menu entries in the method "buildContextMenu".
E.g. I do something like this:
menu.remove("fileGroup");
menu.remove("fileMenu");
Then all the file group is gone.

No comments:

Post a Comment