Exemple #1
0
    public boolean canCloseProject(final Project project) {
      assert project != null;
      if (!project.equals(myProject)) {
        return true;
      }
      if (shouldAskUser()) {
        int result =
            Messages.showOkCancelDialog(
                myProject,
                CompilerBundle.message("warning.compiler.running.on.project.close"),
                CompilerBundle.message("compiler.running.dialog.title"),
                Messages.getQuestionIcon());
        if (result != 0) {
          return false; // veto closing
        }
        myUserAcceptedCancel = true;

        final MessageBusConnection connection = project.getMessageBus().connect();
        connection.subscribe(
            CompilerTopics.COMPILATION_STATUS,
            new CompilationStatusAdapter() {
              public void compilationFinished(
                  boolean aborted, int errors, int warnings, final CompileContext compileContext) {
                connection.disconnect();
                ProjectUtil.closeAndDispose(project);
              }
            });
        cancel();
        return false; // cancel compiler and let it finish, after compilation close the project, but
                      // currently - veto closing
      }
      return !myIndicator.isRunning();
    }
Exemple #2
0
 public void contentRemoveQuery(ContentManagerEvent event) {
   if (event.getContent() == myContent) {
     if (!myIndicator.isCanceled() && shouldAskUser()) {
       int result =
           Messages.showOkCancelDialog(
               myProject,
               CompilerBundle.message("warning.compiler.running.on.toolwindow.close"),
               CompilerBundle.message("compiler.running.dialog.title"),
               Messages.getQuestionIcon());
       if (result != 0) {
         event.consume(); // veto closing
       }
       myUserAcceptedCancel = true;
     }
   }
 }