toggle style menu contribution ,which is not persisted

来源:互联网 发布:笔记本电脑怎么用淘宝 编辑:程序博客网 时间:2024/05/16 19:45

This is the definition,Menu Contributions/Toggle Button Command.

Use the RegistryToggleState has two reasons:

  1. It implements IExecutableExtension. So you can specify the default values in the plugin.xml.
  2. 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.
But sometimes you don't want the state to be remembered between sessions,so yon can do this like:

<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>



原创粉丝点击