开发者

How to enable an eclipse MenuItem from Java Code if it is being disabled from Plugin.xml

开发者 https://www.devze.com 2023-03-03 21:43 出处:网络
I have created a MenuItem and made it disable in Plugin.xml. <开发者_运维技巧;enableFor = false>

I have created a MenuItem and made it disable in Plugin.xml.

<开发者_运维技巧;enableFor = false>

Now I want to enable the above MenuItem but only THROUGH JAVA or business logic. How to do?


If you are using objectContributions or actionSets, your IActionDelegate can set the menu item enablement in the run(IAction) or selectionChanged(IAction, ISelection) method.

If you are using commands and handlers (recommended), then you can write an enabledWhen core expression [1]. You can declaratively use any of the variables provided, and you can write a PropertyTester [2] to programmatically provide the enabled state.

[1] http://wiki.eclipse.org/Command_Core_Expressions
[2] http://wiki.eclipse.org/Platform_Expression_Framework

0

精彩评论

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

关注公众号