简体   繁体   中英

How to rename the eclipse plugin menu programmatically

I am developing an eclipse plugin.I have given my menu,sub menu names and plugin id in plugin.xml .

I want to dynamically rename my plugin id as well my menu and sub menu name.I came across this SOF link .I am using the below code.

     MenuManager menuManager = ((WorkbenchWindow)window).getMenuManager();

     Menu menu = menuManager.getMenu();

     String itemId = "plugin_menu_id";

     IContributionItem item = menuManager.find(itemId);

     System.out.println("item.getId() --> " + item.getId());
     //gives the plugin_menu_id      

     System.out.println( "menu.getItemCount() ==> "+ menu.getItemCount());
     //gives no of menus in eclipse

But unfortunately I am unable to find an option to rename the menu from IContributionItem . So is there any other way to modify things in eclipse plugin?

I found a temporary solution .Instead of using a MenuManager,I created a dynamic menu using Actions Framework instead of Command Framework though the former is deprecated.

So each time , I create a Menu,I am able to change the Menu name,icon etc.

I am searching for an equivalent in the Command Framework and will post as soon as I found that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM