title: getActiveWorkbenchWindow() return null when I called it in postStartup() method
body: <p>I'm a newbie at GEF.
  So I'm trying to follow sample example in my project files.</p>
  
  <p>But when I tried to start my example, I got a NullPointerException.</p>
  
  <pre><code>at kr.co.hoony.test.ApplicationWorkbenchAdvisor.postStartup(ApplicationWorkbenchAdvisor.java:37)
  </code></pre>
  
  <p>And my code is like bellow.
  </p>
  
  <pre class="lang-java prettyprint-override"><code>@Override
  public void postStartup() {
  
              try {
  
                  IWorkbenchPage wbPage = PlatformUI.getWorkbench()
                          .getActiveWorkbenchWindow()
                          .getActivePage();
  
                  wbPage.openEditor(
                          new MyEditorInput("KSH"), 
                          MyGraphicalEditor.ID, 
                          false);
  
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
  
  }
  </code></pre>
  
  <p>So I tried to search, and I find one solution and I tried again like below.
  </p>
  
  <pre class="lang-java prettyprint-override"><code>@Override
  public void postStartup() {
  
      Display.getDefault().asyncExec(new Runnable() {
  
          @Override
          public void run() {
  
              try {
  
                  IWorkbenchPage wbPage = PlatformUI.getWorkbench()
                          .getActiveWorkbenchWindow()
                          .getActivePage();
  
                  wbPage.openEditor(
                          new MyEditorInput("KSH"), 
                          MyGraphicalEditor.ID, 
                          false);
  
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
          }
      });
  
  }
  </code></pre>
  
  <p>Then, there is no error message, but there is another problem.</p>
  
  <p>I want to show some label on active page, but it doesn't work.</p>
  
  <p>So I want to upload all codes that I write</p>
  
  <p>Block.java</p>
  
  <pre class="lang-java prettyprint-override"><code>package kr.co.hoony.test.example;
  
  public class Block {
  
      private String name;
      private String width;
  
      public Block() {
  
          this.name = "Block";
          this.width = "20";
  
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getWidth() {
          return width;
      }
  
      public void setWidth(String width) {
          this.width = width;
      }
  
  }
  </code></pre>
  
  <p>BlockEditPartFactory.java</p>
  
  <pre class="lang-java prettyprint-override"><code>package kr.co.hoony.test.example;
  
  import org.eclipse.gef.EditPart;
  import org.eclipse.gef.EditPartFactory;
  import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
  
  public class BlockEditPartFactory implements EditPartFactory {
  
      @Override
      public EditPart createEditPart(EditPart context, Object model) {
  
          AbstractGraphicalEditPart part = null;
  
          if(model instanceof Block){
              part = new BlockGrahpicalEditPart();
          }
  
          part.setModel(model);
          return part;
      }
  
  }
  </code></pre>
  
  <p>BlockFigure.java</p>
  
  <pre class="lang-java prettyprint-override"><code>package kr.co.hoony.test.example;
  
  
  
  
  
  import org.eclipse.draw2d.ColorConstants;
  import org.eclipse.draw2d.Figure;
  import org.eclipse.draw2d.Label;
  import org.eclipse.draw2d.LineBorder;
  import org.eclipse.draw2d.XYLayout;
  import org.eclipse.draw2d.geometry.Rectangle;
  
  public class BlockFigure extends Figure {
  
      private Label labelName = new Label();
      private Label labelWidth = new Label();
      private XYLayout layout;
  
      public BlockFigure() {
  
          layout = new XYLayout();
          setLayoutManager(layout);
  
          labelName.setForegroundColor(ColorConstants.blue);
          add(labelName);
          setConstraint(labelName, new Rectangle(5, 5, -1, -1));
  
          labelWidth.setForegroundColor(ColorConstants.green);
          add(labelWidth);
          setConstraint(labelWidth, new Rectangle(5, 5, -1, -1)); 
  
          setForegroundColor(ColorConstants.black);
          setBorder(new LineBorder(5));
      }
  
      public void setLabelName(Label labelName) {
          this.labelName = labelName;
      }
  
      public void setLabelWidth(Label labelWidth) {
          this.labelWidth = labelWidth;
      }
  
      public void setLayout(XYLayout layout) {
          this.layout = layout;
      }
  
  }
  </code></pre>
  
  <p>BlockGraphicalEditPart.java</p>
  
  <pre class="lang-java prettyprint-override"><code>package kr.co.hoony.test.example;
  
  import org.eclipse.draw2d.IFigure;
  import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
  
  public class BlockGrahpicalEditPart extends AbstractGraphicalEditPart {
  
      @Override
      protected IFigure createFigure() {
          IFigure figure = new BlockFigure();
          return figure;
      }
  
      @Override
      protected void createEditPolicies() {
          // TODO Auto-generated method stub
  
      }
  
  }
  </code></pre>
  
  <p>MyEditorInput.java</p>
  
  <pre class="lang-java prettyprint-override"><code>package kr.co.hoony.test.example;
  
  import org.eclipse.jface.resource.ImageDescriptor;
  import org.eclipse.ui.IEditorInput;
  import org.eclipse.ui.IPersistableElement;
  
  public class MyEditorInput implements IEditorInput {
  
      public String name = null;
  
      public MyEditorInput(String name){
          this.name = name;
      }
  
      @Override
      public Object getAdapter(Class adapter) {
          return null;
      }
  
      @Override
      public boolean exists() {
          return (this.name != null);
      }
  
      @Override
      public boolean equals(Object o) {
          if(!(o instanceof MyEditorInput))
              return false;
          return ((MyEditorInput)o).getName().equals(this.getName());
      }
  
      @Override
      public ImageDescriptor getImageDescriptor() {
          return ImageDescriptor.getMissingImageDescriptor();
      }
  
      @Override
      public String getName() {
          return this.name;
      }
  
      @Override
      public IPersistableElement getPersistable() {
          return null;
      }
  
      @Override
      public String getToolTipText() {
          return this.name;
      }
  
  }
  </code></pre>
  
  <p>MyGraphicalEditor.java</p>
  
  <pre class="lang-java prettyprint-override"><code>package kr.co.hoony.test.example;
  
  import org.eclipse.core.runtime.IProgressMonitor;
  import org.eclipse.gef.DefaultEditDomain;
  import org.eclipse.gef.ui.parts.GraphicalEditor;
  
  public class MyGraphicalEditor extends GraphicalEditor {
  
      public static final String ID = "kr.co.hoony.test.example.MyGraphicalEditor";
  
      public MyGraphicalEditor() {
          setEditDomain(new DefaultEditDomain(this));
      }
  
      @Override
      protected void initializeGraphicalViewer() {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void doSave(IProgressMonitor monitor) {
          // TODO Auto-generated method stub
  
      }
  
  }
  </code></pre>
  
  <p>I don't know the reason that make no effect of labels that I made.
  Is there anybody who tell me the point which I don't catch yet?</p>