开发者

Eclipse Navigator contextMenu

开发者 https://www.devze.com 2023-02-16 12:52 出处:网络
开发者_C百科I\'m developing an eclipse product. I added a navigator view to the plugin and now I would like to customize its context menu by removing some of the default actions and by adding some cus

开发者_C百科I'm developing an eclipse product. I added a navigator view to the plugin and now I would like to customize its context menu by removing some of the default actions and by adding some custom actions.

How can I remove actions from the menu? And how can I add my actions?

Is there a way to create a context menu at all?


At the end i solved in this way:

  • I created a navigator viewer, which extend o.e.ui.navigator.viewer, and i provide a popupMenu specifying "allowPlatformContributions = false". Then i created as many insertionPoint as i need for my context menu. The actions i want eclipse to provide in the context menu are contained in group.new, group.edit, group.reorganize. The resulting xml is:

    <extension
         point="org.eclipse.ui.navigator.viewer">
     .....
      <viewer viewerId="...">
         <popupMenu
               allowsPlatformContributions="false">
            <insertionPoint
                  name="group.xvr.management"
                  separator="true">
            </insertionPoint>
            <insertionPoint
                  name="group.new"
                  separator="true">
            </insertionPoint>
            <insertionPoint
                  name="group.edit"
                  separator="true">
            </insertionPoint>
            <insertionPoint
                  name="group.reorganize">
            </insertionPoint>
            <insertionPoint
                  name="group.xvr.launch"
                  separator="true">
            </insertionPoint>
         </popupMenu>
         </viewer>
         ...
         </extension>
    

    the other two group names, group.xvr.launch and group.xvr.management, are custom placeholder for my actions.

  • then i extended o.e.ui.navigator.navigatorContent creating my custom content which i bind to the viewer. I added to the navigator content as many actionProvider as i need. In each one of them i override the method fillContextMenu to provide custom action to the context menu.

    @Override
    public void fillContextMenu(IMenuManager menu) {
        menu.appendToGroup("group.xvr.launch", new CommandContributionItem(new CommandContributionItemParameter(...)));
    menu.appendToGroup("group.xvr.launch", new CommandContributionItem(new CommandContributionItemParameter(...)));
    }
    


You need to extend o.e.ui.navigator.navigatorContent and provide an actionProvider.


hyou have to extend the navigator view, and override the context menu (should be the createPartControl Method). right now i don't have access to the eclipse source.

hope this helps.

0

精彩评论

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

关注公众号