问题
I have defined an Exit command to display on my File menu. However another plug-in is contributing a Open File item on the File menu and this is appearing AFTER my Exit command. I want my Exit command to appear last on the File menu.
I've tried specifying locationURI menu:file?after=org.eclipse.ui.openLocalFile
but then my Exit menu item does not display at all. I think this might be because org.eclipse.ui.openLocalFile has not been loaded yet.
I've also tried specifying locationURI menu:file?after=additions
but the Open File menu item still displays after mine.
How can I get the menu item order to be Open File and then my Exit command?
回答1:
You need to put some of the proper group markers in your File menu when you create it. The order of operations is:
ActionBarAdvisor
createsMenuManagers
programaticallyorg.eclipse.ui.menus
are applied- legacy action extensions are applied (like actionSets)
Open File says it has a menubarPath="file/new.ext". So however you create your File menu, you must add a group marker for new.ext. The group markers will allow you to control the contribution order.
See org.eclipse.ui.internal.ide.WorkbenchActionBuilder
in org.eclipse.ui.ide for an example of the group markers the eclipse IDE includes.
回答2:
I know that this question has been answered but I had similar problem and I solved it by specifing the ID for each command that I add to menu. Then I would use that ID in "after" or "before" query. I noticed that you tried something similar but you used the "commandId" instead of the actuall "id".
来源:https://stackoverflow.com/questions/6211166/how-to-make-my-menu-contribution-appear-after-a-plug-in-menu-contribution