开发者

How to order actions in menus in Eclipse RCP

If I add action within an extension point thus:

    <action
           class="com.mycompany.MyAction"
           id="mycompany.myaction.MyAction"
开发者_开发问答           menubarPath="actions"
    />

How can I control its ordering programatically? It looks like they are simply ordered alphabetically according to their ID. I don't want to have to give them names such as '001-z', '002-a', just to get 'z' to appear before 'a'. It would also be a nightmare re-ordering them later.


You should not use actions for the menu. Try commands instead. See here: http://www.vogella.de/articles/RichClientPlatform/article.html#commands_menu

If you want to order them use: ?after=....

 <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:org.eclipse.ui.main.menu?after=fileMenu">
         <menu
               id="myMenu"
....


The ordering of the actions under the same menubarpath is not properly defined. (see https://bugs.eclipse.org/91122 for more details or PluginActionBuilder.contributeMenuAction() if you need to see the code)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜