mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (more common code extracted; dispose condition; wording)
This commit is contained in:
@@ -24,10 +24,9 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.StatusBarEx;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
@@ -50,45 +49,38 @@ public class RefreshProgress extends ProgressIndicatorBase {
|
||||
@Override
|
||||
public void start() {
|
||||
super.start();
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
multiplex(true);
|
||||
}
|
||||
});
|
||||
updateIndicators(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
super.stop();
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
updateIndicators(false);
|
||||
}
|
||||
|
||||
private void updateIndicators(final boolean start) {
|
||||
// wrapping in invokeLater here reduces the number of events posted to EDT in case of multiple IDE frames
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
multiplex(false);
|
||||
if (ApplicationManager.getApplication().isDisposed()) return;
|
||||
|
||||
WindowManager windowManager = WindowManager.getInstance();
|
||||
if (windowManager == null) return;
|
||||
|
||||
Project[] projects = ProjectManager.getInstance().getOpenProjects();
|
||||
if (projects.length == 0) projects = NULL_ARRAY;
|
||||
for (Project project : projects) {
|
||||
StatusBarEx statusBar = (StatusBarEx)windowManager.getStatusBar(project);
|
||||
if (statusBar != null) {
|
||||
if (start) {
|
||||
statusBar.startRefreshIndication(myMessage);
|
||||
}
|
||||
else {
|
||||
statusBar.stopRefreshIndication();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void multiplex(boolean start) {
|
||||
if (ApplicationManager.getApplication().isDisposed()) return;
|
||||
|
||||
WindowManager windowManager = WindowManager.getInstance();
|
||||
if (windowManager == null) return;
|
||||
|
||||
Project[] projects = ProjectManager.getInstance().getOpenProjects();
|
||||
if (projects.length == 0) projects = NULL_ARRAY;
|
||||
for (Project project : projects) {
|
||||
StatusBarEx statusBar = (StatusBarEx)windowManager.getStatusBar(project);
|
||||
if (statusBar != null) {
|
||||
if (start) {
|
||||
statusBar.startRefreshIndication(myMessage);
|
||||
}
|
||||
else {
|
||||
statusBar.stopRefreshIndication();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,8 +56,8 @@ public class RefreshQueueImpl extends RefreshQueue {
|
||||
}
|
||||
else {
|
||||
if (((ApplicationEx)app).holdsReadLock()) {
|
||||
LOG.error("Do not call synchronous refresh from inside read action except for event dispatch thread. " +
|
||||
"This will eventually cause deadlock if there are any events to fire");
|
||||
LOG.error("Do not call synchronous refresh under read lock (except from EDT) - " +
|
||||
"this will cause a deadlock if there are any events to fire.");
|
||||
return;
|
||||
}
|
||||
queueSession(session, ModalityState.defaultModalityState());
|
||||
@@ -82,14 +82,13 @@ public class RefreshQueueImpl extends RefreshQueue {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
final Application app = ApplicationManager.getApplication();
|
||||
Application app = ApplicationManager.getApplication();
|
||||
app.invokeLater(new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (app.isDisposed()) return;
|
||||
session.fireEvents(false);
|
||||
}
|
||||
}, modality);
|
||||
}, modality, app.getDisposed());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user