Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 321083

Summary: [Commands] Value of persisted RegistryToggleState is null
Product: [Eclipse Project] Platform Reporter: Eric Jain <eric.jain>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: RESOLVED WORKSFORME QA Contact: Prakash Rangaraj <prakash>
Severity: normal    
Priority: P3 CC: pwebster
Version: 3.5.2   
Target Milestone: 3.7   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Eric Jain CLA 2010-07-27 21:43:17 EDT
Build Identifier: 20100617-1415

I have a toggleable command that is defined like so:

      <command
         defaultHandler="..."
            id="toggleTest"
            name="Test">
         <state
               id="org.eclipse.ui.commands.toggleState">
            <class
                  class="org.eclipse.ui.handlers.RegistryToggleState">
               <parameter
                     name="persisted"
                     value="true">
               </parameter>
               <parameter
                     name="default"
                     value="false">
               </parameter>
            </class>
         </state>
      </command>

This works fine, and the state of the command appears (in the UI) to be persisted across application restarts.

However, when I attempt to read the state after restarting, the code fails at the assertion (with an AssertionError, not a NullPointerException) regardless of the prior state:

  Command cmd = ((ICommandService) PlatformUI.getWorkbench()
    .getService(ICommandService.class)).getCommand("toggleTest");
  assert cmd.getState(RegistryToggleState.STATE_ID).getValue() != null;


Reproducible: Always
Comment 1 Prakash Rangaraj CLA 2010-09-28 14:19:12 EDT
Eric, 

   Where are you reading the state? Is it during the workbench startup? Can you attach the stack trace?
Comment 2 Eric Jain CLA 2010-09-28 21:16:42 EDT
The state was being read in a ViewPart.createPartControl. But I'm no longer able to reproduce this issue with Eclipse 3.6.1.
Comment 3 Prakash Rangaraj CLA 2010-09-28 23:42:26 EDT
(In reply to comment #2)
> The state was being read in a ViewPart.createPartControl. But I'm no longer
> able to reproduce this issue with Eclipse 3.6.1.

   Thanks. Closing this bug. If you are able to reproduce again, please attach the stacktrace and reopen the bug