コード例 #1
0
ファイル: AppTest.java プロジェクト: Turbo87/intellij-plugins
  private void openAndWait(VirtualFile file, @Nullable String relativePath)
      throws InterruptedException, IOException {
    semaphore.down();

    DesignerApplicationManager.getInstance()
        .renderDocument(myModule, Tests.virtualToPsi(myProject, file));
    await();
  }
コード例 #2
0
ファイル: AppTest.java プロジェクト: Turbo87/intellij-plugins
 @Override
 protected void tearDown() throws Exception {
   try {
     super.tearDown();
     if (getName().equals("testCloseAndOpenProject")) {
       callClientAssert("close");
     }
   } finally {
     DesignerApplicationManager.getInstance().disposeApplication();
     StringRegistry.getInstance().reset();
   }
 }
コード例 #3
0
ファイル: AppTest.java プロジェクト: Turbo87/intellij-plugins
  private void renderAndWait(VirtualFile file) throws InterruptedException {
    semaphore.down();
    AsyncResult<DocumentInfo> result =
        DesignerApplicationManager.getInstance()
            .renderDocument(myModule, Tests.virtualToPsi(myProject, file));

    result.doWhenProcessed(
        new Runnable() {
          @Override
          public void run() {
            semaphore.up();
          }
        });

    await();
  }
コード例 #4
0
  private void render(final boolean isSlow, final boolean clearPreviousOnError) {
    if (!toolWindowVisible) {
      return;
    }

    final VirtualFile file = toolWindowForm.getFile();
    if (file == null) {
      return;
    }

    toolWindowForm.getPreviewPanel().clearCannotRender();

    if (isSlow) {
      toolWindowForm.getPreviewPanel().getLoadingDecorator().startLoading(false);
      loadingDecoratorStarted++;
    }

    toolWindowForm.waitingForGetDocument = true;
    XmlFile xmlFile = (XmlFile) PsiManager.getInstance(project).findFile(file);
    LogMessageUtil.LOG.assertTrue(xmlFile != null);
    AsyncResult<BufferedImage> result =
        DesignerApplicationManager.getInstance().getDocumentImage(xmlFile);
    result.doWhenDone(
        new QueuedAsyncResultHandler<BufferedImage>() {
          @Override
          protected boolean isExpired() {
            return toolWindowForm == null || !file.equals(toolWindowForm.getFile());
          }

          @Override
          public void process(final BufferedImage image) {
            UIUtil.invokeLaterIfNeeded(
                new Runnable() {
                  @Override
                  public void run() {
                    toolWindowForm.getPreviewPanel().setImage(image);
                  }
                });
          }
        });

    result.doWhenProcessed(
        new Runnable() {
          @Override
          public void run() {
            toolWindowForm.waitingForGetDocument = false;
            if (isSlow && --loadingDecoratorStarted == 0 && toolWindowForm != null) {
              toolWindowForm.getPreviewPanel().getLoadingDecorator().stopLoading();
            }
          }
        });

    result.doWhenRejected(
        new Runnable() {
          @Override
          public void run() {
            if (clearPreviousOnError) {
              toolWindowForm.getPreviewPanel().setImage(null);
            }
            UIUtil.invokeLaterIfNeeded(
                new Runnable() {
                  @Override
                  public void run() {
                    toolWindowForm.getPreviewPanel().showCannotRender();
                  }
                });
          }
        });
  }