@Override 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 != Messages.OK) { return false; // veto closing } myUserAcceptedCancel = true; final MessageBusConnection connection = project.getMessageBus().connect(); connection.subscribe( CompilerTopics.COMPILATION_STATUS, new CompilationStatusAdapter() { @Override 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(); }
@Override public String getDescription(BuildArtifactsBeforeRunTask task) { final List<ArtifactPointer> pointers = task.getArtifactPointers(); if (pointers.isEmpty()) { return CompilerBundle.message("build.artifacts.before.run.description.empty"); } if (pointers.size() == 1) { return CompilerBundle.message( "build.artifacts.before.run.description.single", pointers.get(0).getName()); } return CompilerBundle.message( "build.artifacts.before.run.description.multiple", pointers.size()); }
@Override 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 != Messages.OK) { event.consume(); // veto closing } myUserAcceptedCancel = true; } } }
@Override public String getName() { return CompilerBundle.message("build.artifacts.before.run.description.empty"); }