开发者

How to control the visibility of a popup menu programmatically?

开发者 https://www.devze.com 2023-02-06 21:50 出处:网络
I\'m extendi开发者_运维百科ng Eclipse using the Eclipse plugin infrastructure, and I\'ve come into a problem:

I'm extendi开发者_运维百科ng Eclipse using the Eclipse plugin infrastructure, and I've come into a problem:

I would like to control the visibility of a popup menu depending on the value of an preference variable. So, I must control it programmatically or by adding an parameter in the plugin.xml.

Please help me.

Best regards. Imen.


If you use org.eclipse.ui.popupMenu, you cannot directly control the state, as Eclipse may show the item as enabled until you try to use it -- only then will your plugin get enabled, and evaluate its visibility. A better way is to use the org.eclipse.ui.menus extension, which has finer control (but also more overhead in terms of what you need to configure):

Contribution visibility

A command's enabled state is controlled by a combination of the command is handled and if so, the handler's enabled state. Menu contributions can use core expressions to control the command's visibility in menus and toolbars.

0

精彩评论

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