title: PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() returns null
body: <p>I'm trying to get the active part in my eclipse plugin, using this code, but instead I get <code>null</code>:</p>
  
  
  
  <pre><code>PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
  </code></pre>
  
  <p>I found that I should put the above code in a thread, so I have changed my code to be:</p>
  
  
  
  <pre><code>PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
      @Override
      public void run() {
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
      }
  });
  </code></pre>
  
  <p>But I still get <code>null</code>!</p>
  
  <p>(When I use asyncExec it finds the active part, but the asyncExec does not match my need because I need the active part immediately.)</p>