title: Intellij IDEA plugin - PersistentStateComponent loadState not called
body: <p>I am trying to develop a plugin for Intellij IDEA, I am working with SDK 129.451.</p>
  
  <p>The issue I have is that I can't persist the user data like some list items he can input in the plugin and have the data back after the IDE restarts..</p>
  
  <p>I am using PersistentStateComponent to persist the data, the <code>getState()</code> method seems to be called but the <code>loadState()</code> method doesn't.</p>
  
  <p><strong>Here is a sample class that extends PersistentStateComponent:</strong></p>
  
  <pre><code>    @State(name = "Test", storages = {@Storage(file = StoragePathMacros.APP_CONFIG+"/other.xml"
  )})
  public class Test implements PersistentStateComponent&lt;Element&gt; {
  
      String ceva;
  
      public Test() {
          ceva = "sad";
          System.out.println("constr");
      }
  
      public String getCeva() {
          return ceva;
      }
  
      public void setCeva(String ceva) {
          this.ceva = ceva;
      }
  
      public void loadState(Element state) {
          System.out.println("cstate load");
  
          ceva = (String) state.getContent().get(0);
  
      }
  
      public Element getState() {
          System.out.println("cstate retu");
          Element configurationsElement = new Element("testtt");
          configurationsElement.addContent(ceva);
          return configurationsElement;
  
      }
  }
  </code></pre>
  
  <p><strong>Also I added this class in plugin.xml here:</strong></p>
  
  <pre><code>&lt;extensions defaultExtensionNs="com.intellij"&gt;
      &lt;applicationService serviceImplementation="ro.catalin.prata.testflightuploader.controller.Test"/&gt;
      &lt;!-- Add your extensions here --&gt;
      &lt;toolWindow id="TF Uploader"   secondary="true" icon="/general/add.png" anchor="right"
                  factoryClass="ro.catalin.prata.testflightuploader.view.TFUploader"&gt;
      &lt;/toolWindow&gt;
  &lt;/extensions&gt;
  </code></pre>
  
  <p><strong>And I also have a tool window class:</strong></p>
  
  <pre><code>public class TFUploader implements ToolWindowFactory {
  
      private JButton buttonAction;
      private ToolWindow myToolWindow;
  
      final Test test = ServiceManager.getService(Test.class);
  
      public TFUploader() {
  
          // I assume it should print the saved string but it doesn't
          System.out.println(test.getCeva());
  
          buttonAction.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  // if I click a button I am setting some new value to the string I want to save
                  test.setCeva(test.getCeva() + "-dddddd+");
  
              }
          });
  
  }
  </code></pre>
  
  <p>Ok so, if I close the app or minimize it, the getState method gets called as I expected.. but when I open the app, the loadState method doesn't get called.. can somebody help me how I can solve this?</p>
  
  <p>I already read <a href="http://confluence.jetbrains.com/display/IDEADEV/Persisting+State+of+Components" rel="nofollow noreferrer">this</a> but it doesn't seem to help me to much. Also I want to use <code>PersistentStateComponent</code> as I want to save objects more complex than a simple String.</p>
  
  <p>Thank you in advance!</p>