public void setDesignDocument(final DesignDocument newDesignDocument) {
    IOUtils.runInAWTNoBlocking(
        new Runnable() {
          public void run() {
            if (designDocument != null) {
              ScreenAccessController accessController =
                  designDocument
                      .getListenerManager()
                      .getAccessController(ScreenAccessController.class);
              if (accessController != null) accessController.hideNotify();
            }
            toolbar.removeAll();
            visual.removeAll();

            designDocument = newDesignDocument;

            final ScreenAccessController accessController =
                designDocument != null
                    ? designDocument
                        .getListenerManager()
                        .getAccessController(ScreenAccessController.class)
                    : null;
            if (accessController != null) {
              accessController.showNotify();
              final DataObjectContext context =
                  ProjectUtils.getDataObjectContextForDocument(designDocument);
              if (context != null) {
                designDocument
                    .getTransactionManager()
                    .readAccess(
                        new Runnable() {
                          public void run() {
                            accessController.setScreenSize(
                                MidpProjectPropertiesSupport.getDeviceScreenSizeFromProject(
                                    context));
                          }
                        });
              }
              visual.add(new JScrollPane(accessController.getMainPanel()), BorderLayout.CENTER);

              JToolBar.Separator separator = new JToolBar.Separator();
              separator.setOrientation(JSeparator.VERTICAL);
              toolbar.add(separator);

              toolbar.add(accessController.getToolBar());
            } else {
              visual.add(loadingPanel, BorderLayout.CENTER);
            }
            toolbar.validate();
            visual.validate();
          }
        });
  }
 public void setScreenSize(final Dimension deviceScreenSize) {
   IOUtils.runInAWTNoBlocking(
       new Runnable() {
         public void run() {
           if (designDocument != null) {
             designDocument
                 .getTransactionManager()
                 .readAccess(
                     new Runnable() {
                       public void run() {
                         ScreenAccessController accessController =
                             designDocument
                                 .getListenerManager()
                                 .getAccessController(ScreenAccessController.class);
                         if (accessController != null)
                           accessController.setScreenSize(deviceScreenSize);
                       }
                     });
           }
         }
       });
 }