mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't re-layout notification each time the status bar is cleared => more responsiveness
This commit is contained in:
@@ -117,7 +117,7 @@ public class EventLog implements Notifications {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Pair<Notification, Long> getStatusMessage(@Nullable Project project) {
|
||||
public static Trinity<Notification, String, Long> getStatusMessage(@Nullable Project project) {
|
||||
return getLogModel(project).getStatusMessage();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -36,8 +36,7 @@ import java.util.*;
|
||||
public class LogModel implements Disposable {
|
||||
private final List<Notification> myNotifications = new ArrayList<Notification>();
|
||||
private final Map<Notification, Long> myStamps = Collections.synchronizedMap(new WeakHashMap<Notification, Long>());
|
||||
private Notification myStatusMessage;
|
||||
private long myStatusTime;
|
||||
private Trinity<Notification, String, Long> myStatusMessage;
|
||||
private final Project myProject;
|
||||
final Map<Notification, Runnable> removeHandlers = new THashMap<Notification, Runnable>();
|
||||
|
||||
@@ -68,18 +67,17 @@ public class LogModel implements Disposable {
|
||||
|
||||
void setStatusMessage(@Nullable Notification statusMessage, long stamp) {
|
||||
synchronized (myNotifications) {
|
||||
if (myStatusMessage == statusMessage) return;
|
||||
if (myStatusMessage != null && myStatusMessage.first == statusMessage) return;
|
||||
|
||||
myStatusMessage = statusMessage;
|
||||
myStatusTime = stamp;
|
||||
myStatusMessage = statusMessage == null ? null : Trinity.create(statusMessage, EventLog.formatForLog(statusMessage, "").status, stamp);
|
||||
}
|
||||
StatusBar.Info.set("", myProject, EventLog.LOG_REQUESTOR);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Pair<Notification, Long> getStatusMessage() {
|
||||
Trinity<Notification, String, Long> getStatusMessage() {
|
||||
synchronized (myNotifications) {
|
||||
return myStatusMessage == null ? null : Pair.create(myStatusMessage, myStatusTime);
|
||||
return myStatusMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +111,7 @@ public class LogModel implements Disposable {
|
||||
UIUtil.invokeLaterIfNeeded(handler);
|
||||
}
|
||||
|
||||
Pair<Notification, Long> oldStatus = getStatusMessage();
|
||||
Trinity<Notification, String, Long> oldStatus = getStatusMessage();
|
||||
if (oldStatus != null && notification == oldStatus.first) {
|
||||
setStatusToImportant();
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
@@ -152,7 +152,7 @@ class StatusPanel extends JPanel {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
final Project project = getActiveProject();
|
||||
final Pair<Notification, Long> statusMessage = EventLog.getStatusMessage(project);
|
||||
final Trinity<Notification, String, Long> statusMessage = EventLog.getStatusMessage(project);
|
||||
final Alarm alarm = getAlarm();
|
||||
myLogMode = StringUtil.isEmpty(nonLogText) && statusMessage != null && alarm != null;
|
||||
|
||||
@@ -166,10 +166,10 @@ class StatusPanel extends JPanel {
|
||||
@Override
|
||||
public void run() {
|
||||
assert statusMessage != null;
|
||||
String text = EventLog.formatForLog(statusMessage.first, "").status;
|
||||
if (myDirty || System.currentTimeMillis() - statusMessage.second >= DateFormatUtil.MINUTE) {
|
||||
String text = statusMessage.second;
|
||||
if (myDirty || System.currentTimeMillis() - statusMessage.third >= DateFormatUtil.MINUTE) {
|
||||
myTimeStart = text.length() + 1;
|
||||
text += " (" + StringUtil.decapitalize(DateFormatUtil.formatPrettyDateTime(statusMessage.second)) + ")";
|
||||
text += " (" + StringUtil.decapitalize(DateFormatUtil.formatPrettyDateTime(statusMessage.third)) + ")";
|
||||
} else {
|
||||
myTimeStart = -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user