fix race condition: IDEA-88912 Ant completion message not always displayed

This commit is contained in:
Eugene Zhuravlev
2012-07-20 17:18:08 +02:00
parent be89d60142
commit 93e7c66a89
2 changed files with 14 additions and 13 deletions
@@ -781,10 +781,7 @@ public final class AntBuildMessageView extends JPanel implements DataProvider, O
return myWarningCount;
}
void buildFinished(boolean isProgressAborted,
long buildTimeInMilliseconds,
@NotNull final AntBuildListener antBuildListener,
OutputPacketProcessor dispatcher) {
void buildFinished(boolean isProgressAborted, long buildTimeInMilliseconds, @NotNull final AntBuildListener antBuildListener, OutputPacketProcessor dispatcher) {
final boolean aborted = isProgressAborted || myIsAborted;
final String message = getFinishStatusText(aborted, buildTimeInMilliseconds);
@@ -800,12 +797,12 @@ public final class AntBuildMessageView extends JPanel implements DataProvider, O
}
}
});
if (!myIsOutputPaused) {
new OutputFlusher().doFlush();
myTreeView.scrollToLastMessage();
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
//noinspection SSBasedInspection
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (!myIsOutputPaused) {
new OutputFlusher().doFlush();
}
final AntBuildFileBase buildFile = myBuildFile;
if (buildFile != null) {
if (getErrorCount() == 0 && buildFile.isViewClosedWhenNoErrors()) {
@@ -818,7 +815,9 @@ public final class AntBuildMessageView extends JPanel implements DataProvider, O
myTreeView.scrollToStatus();
}
}
else {
myTreeView.scrollToLastMessage();
}
VirtualFileManager.getInstance().refresh(true, new Runnable() {
public void run() {
antBuildListener.buildFinished(aborted ? AntBuildListener.ABORTED : AntBuildListener.FINISHED_SUCCESSFULLY, getErrorCount());
@@ -176,15 +176,17 @@ public final class ExecutionHandler {
final long buildTime = System.currentTimeMillis() - startTime;
checkCancelTask.cancel();
parser.setStopped(true);
final OutputPacketProcessor dispatcher = handler.getErr().getEventsDispatcher();
errorView.buildFinished(progress != null && progress.isCanceled(), buildTime, antBuildListener, dispatcher);
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
if (project.isDisposed()) return;
if (project.isDisposed()) {
return;
}
errorView.removeProgressPanel();
ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
if (toolWindow != null) { // can be null if project is closed
toolWindow.activate(null, false);
final OutputPacketProcessor dispatcher = handler.getErr().getEventsDispatcher();
errorView.buildFinished(progress != null && progress.isCanceled(), buildTime, antBuildListener, dispatcher);
}
}
}, ModalityState.NON_MODAL);