This is the definition,Menu Contributions/Toggle Button Command.
Use the RegistryToggleState has two reasons:
- It implements IExecutableExtension. So you can specify the default values in the plugin.xml.
- It extends PersistentState, so it can remember the value between Eclipse sessions. So if the user had checked/unchecked the menu, restarts Eclipse, he will get the same state as he left before - all this, you get without even your plugin being loaded.
<command
categoryId="lear.IPDetector.category"
id="lear.IPDetector.commands.startDectectCommand"
name="Start Dectect">
<state
id="org.eclipse.ui.commands.toggleState">
<class
class="org.eclipse.ui.handlers.RegistryToggleState">
<parameter
name="default"
value="false">
</parameter>
<parameter
name="persisted"
value="false">
</parameter>
</class>
</state>
</command>
本文介绍了Eclipse中如何使用RegistryToggleState实现菜单项的状态管理,包括如何在plugin.xml中指定默认值及如何在不同会话间保持状态,还探讨了不希望在会话间保留状态的配置方式。

被折叠的 条评论
为什么被折叠?



