clear the status bar when the event log is open

This commit is contained in:
peter
2011-06-17 19:10:20 +02:00
parent ac9e6f0702
commit c356ee775c
3 changed files with 24 additions and 14 deletions
@@ -93,7 +93,7 @@ public class EventLog implements Notifications {
return getLogModel(project).getStatusMessage();
}
public static Pair<String, Boolean> formatForLog(final Notification notification) {
public static Pair<String, Boolean> formatForLog(@NotNull final Notification notification) {
boolean showLink = notification.getListener() != null;
String content = notification.getContent();
String mainText = notification.getTitle();
@@ -61,6 +61,8 @@ public class LogModel {
void setStatusMessage(@Nullable Notification statusMessage) {
synchronized (myNotifications) {
if (myStatusMessage == statusMessage) return;
myStatusMessage = statusMessage;
}
StatusBar.Info.set("", myProject, EventLog.LOG_REQUESTOR);
@@ -78,6 +80,7 @@ public class LogModel {
removeNotification(notification);
}
}
setStatusToImportant();
}
public ArrayList<Notification> getNotifications() {
@@ -98,15 +101,18 @@ public class LogModel {
}
if (notification == getStatusMessage() && notification.isImportant()) {
ArrayList<Notification> notifications = getNotifications();
Collections.reverse(notifications);
setStatusMessage(ContainerUtil.find(notifications, new Condition<Notification>() {
@Override
public boolean value(Notification notification) {
return notification.isImportant();
}
}));
setStatusToImportant();
}
}
private void setStatusToImportant() {
ArrayList<Notification> notifications = getNotifications();
Collections.reverse(notifications);
setStatusMessage(ContainerUtil.find(notifications, new Condition<Notification>() {
@Override
public boolean value(Notification notification) {
return notification.isImportant();
}
}));
}
}
@@ -105,7 +105,7 @@ class StatusPanel extends JPanel {
final Project project = getActiveProject();
final Notification statusMessage = EventLog.getStatusMessage(project);
myLogMode = logAllowed && StringUtil.isEmpty(nonLogText) && statusMessage != null && project != null;
myLogMode = logAllowed && StringUtil.isEmpty(nonLogText) && project != null;
myShowLog.setVisible(myLogMode);
@@ -113,10 +113,14 @@ class StatusPanel extends JPanel {
new Runnable() {
@Override
public void run() {
assert statusMessage != null;
String text = EventLog.formatForLog(statusMessage).first;
if (myDirty || System.currentTimeMillis() - statusMessage.getCreationTime() >= DateFormatUtil.MINUTE) {
text += " (" + StringUtil.decapitalize(DateFormatUtil.formatPrettyDateTime(statusMessage.getCreationTime())) + ")";
String text;
if (statusMessage != null) {
text = EventLog.formatForLog(statusMessage).first;
if (myDirty || System.currentTimeMillis() - statusMessage.getCreationTime() >= DateFormatUtil.MINUTE) {
text += " (" + StringUtil.decapitalize(DateFormatUtil.formatPrettyDateTime(statusMessage.getCreationTime())) + ")";
}
} else {
text = "";
}
myTextPanel.setText(text);
myLogAlarm.addRequest(this, 30000);