开发者

How to detect the Menu Listener in eclipse through plug-in development

I developed a menu named MyMenu in eclipse as plug-in development. I want to detect a listener as soon as we click on the MyMenu but I did not get any succes开发者_如何转开发s while using/implementing MenuListener. What is the way to achieve the same


If you are talking about adding a main menu item in a workbench window (similar to File or Edit) you cannot do it through SWT without breaking API. 3 options are available:

1) if you are writing an RCP app, you get to create the ActionBarAdvisor which gets first crack at filling in the main menu bar. You use MenuManagers and IContributionItems to fill in the MenuManagers. Both ActionContributionItems and CommandContributionItems are API.

2) Use plugin.xml and contribute to org.eclipse.ui.menus extension point. You can contribute commands to it statically. You can also use the dynamic element to contribute a CompoundContributionItem. A CompoundContributionItem is called every time the menu is about to show, so that dynamic items (like the 4 most recently open files section in the File menu) can be added. You can see some examples of this in the org.eclipse.example.commands plugin and matching presentation at https://github.com/paulweb515/commandsEclipseCon2011

3) use the org.eclipse.ui.actionSets extension point. This is no longer under development, and is deprecated in Eclipse 4.x.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜