explicit logging notifications instead of implicit together with in toolwindow balloons, take 1

This commit is contained in:
peter
2011-06-07 20:35:41 +02:00
parent 4823e484a7
commit a7d9689948
13 changed files with 51 additions and 62 deletions
@@ -552,13 +552,10 @@ public class CompileDriver {
final MessageType messageType = errorCount > 0 ? MessageType.ERROR : warningCount > 0 ? MessageType.WARNING : MessageType.INFO;
if (duration > ONE_MINUTE_MS) {
ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.MESSAGES_WINDOW, messageType, statusMessage);
} else {
String logMessage = statusMessage;
if (_status == ExitStatus.UP_TO_DATE) {
logMessage = "Compilation: all files are up to date";
}
NOTIFICATION_GROUP.createNotification(logMessage, messageType.toNotificationType()).notify(myProject);
}
NOTIFICATION_GROUP.createNotification(_status == ExitStatus.UP_TO_DATE ? "Compilation: all files are up to date" : statusMessage, messageType).notify(myProject);
if (_status != ExitStatus.UP_TO_DATE && compileContext.getMessageCount(null) > 0) {
compileContext.addMessage(CompilerMessageCategory.INFORMATION, statusMessage, null, -1, -1);
}
@@ -20,6 +20,9 @@ import com.intellij.debugger.DebuggerInvocationUtil;
import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.impl.HotSwapProgress;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.notification.NotificationDisplayType;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.progress.PerformInBackgroundOption;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
@@ -29,7 +32,6 @@ import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.ui.MessageCategory;
import gnu.trove.TIntObjectHashMap;
@@ -41,6 +43,8 @@ import java.util.Iterator;
import java.util.List;
public class HotSwapProgressImpl extends HotSwapProgress{
static final NotificationGroup NOTIFICATION_GROUP = new NotificationGroup("HotSwap", NotificationDisplayType.NONE, true);
TIntObjectHashMap<List<String>> myMessages = new TIntObjectHashMap<List<String>>();
private final ProgressIndicator myProgressIndicator;
private final ProgressWindow myProgressWindow;
@@ -73,14 +77,16 @@ public class HotSwapProgressImpl extends HotSwapProgress{
final List<String> errors = getMessages(MessageCategory.ERROR);
final List<String> warnings = getMessages(MessageCategory.WARNING);
if (errors.size() > 0) {
ToolWindowManager.getInstance(getProject()).notifyByBalloon(ToolWindowId.DEBUG, MessageType.ERROR, buildMessage(errors), null,
null);
WindowManager.getInstance().getStatusBar(getProject()).setInfo(DebuggerBundle.message("status.hot.swap.completed.with.errors"));
final String message = buildMessage(errors);
ToolWindowManager.getInstance(getProject()).notifyByBalloon(ToolWindowId.DEBUG, MessageType.ERROR, message, null, null);
NOTIFICATION_GROUP.createNotification(DebuggerBundle.message("status.hot.swap.completed.with.errors"), message,
NotificationType.ERROR, null).notify(getProject());
}
else if (warnings.size() > 0){
ToolWindowManager.getInstance(getProject()).notifyByBalloon(ToolWindowId.DEBUG, MessageType.WARNING, buildMessage(warnings),
Messages.getWarningIcon(), null);
WindowManager.getInstance().getStatusBar(getProject()).setInfo(DebuggerBundle.message("status.hot.swap.completed.with.warnings"));
final String message = buildMessage(warnings);
ToolWindowManager.getInstance(getProject()).notifyByBalloon(ToolWindowId.DEBUG, MessageType.WARNING, message, Messages.getWarningIcon(), null);
NOTIFICATION_GROUP.createNotification(DebuggerBundle.message("status.hot.swap.completed.with.warnings"),
message, NotificationType.WARNING, null).notify(getProject());
}
else if (myMessages.size() > 0){
final StringBuilder msg = StringBuilderSpinAllocator.alloc();
@@ -99,7 +105,7 @@ public class HotSwapProgressImpl extends HotSwapProgress{
}
final String message = msg.toString();
ToolWindowManager.getInstance(getProject()).notifyByBalloon(ToolWindowId.DEBUG, MessageType.INFO, message, null, null);
WindowManager.getInstance().getStatusBar(getProject()).setInfo(message);
NOTIFICATION_GROUP.createNotification(message, NotificationType.INFORMATION).notify(getProject());
}
finally {
StringBuilderSpinAllocator.dispose(msg);
@@ -21,6 +21,7 @@ import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.impl.HotSwapFile;
import com.intellij.debugger.impl.HotSwapManager;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
@@ -35,7 +36,6 @@ import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.messages.MessageBus;
@@ -138,7 +138,7 @@ public class HotSwapUIImpl extends HotSwapUI implements ProjectComponent{
public void run() {
final String message = DebuggerBundle.message("status.hotswap.uptodate");
ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.DEBUG, MessageType.INFO, message, null, null);
WindowManager.getInstance().getStatusBar(myProject).setInfo(message);
HotSwapProgressImpl.NOTIFICATION_GROUP.createNotification(message, NotificationType.INFORMATION).notify(myProject);
}
}, ModalityState.NON_MODAL);
return;
@@ -36,7 +36,6 @@ public interface Notifications {
Topic<Notifications> TOPIC = Topic.create("Notifications", Notifications.class, Topic.BroadcastDirection.NONE);
String SYSTEM_MESSAGES_GROUP_ID = "System Messages";
String LOG_ONLY_GROUP_ID = "Log Only";
void notify(@NotNull Notification notification);
void register(@NotNull final String groupDisplayType, @NotNull final NotificationDisplayType defaultDisplayType);
@@ -44,10 +43,6 @@ public interface Notifications {
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
class Bus {
static {
register(LOG_ONLY_GROUP_ID, NotificationDisplayType.NONE);
}
/**
* Registration is OPTIONAL: STICKY_BALLOON display type will be used by default.
*/
@@ -17,6 +17,7 @@ package com.intellij.notification;
import com.intellij.notification.impl.NotificationSettings;
import com.intellij.notification.impl.NotificationsConfiguration;
import com.intellij.openapi.ui.MessageType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -32,6 +33,14 @@ public class NotificationGroup {
NotificationsConfiguration.getNotificationsConfiguration().registerDefaultSettings(new NotificationSettings(displayId, defaultDisplayType, logByDefault));
}
public String getDisplayId() {
return myDisplayId;
}
public Notification createNotification(@NotNull final String content, @NotNull final MessageType type) {
return createNotification(content, type.toNotificationType());
}
public Notification createNotification(@NotNull final String content, @NotNull final NotificationType type) {
return createNotification("", content, type, null);
}
@@ -79,12 +79,7 @@ public class NotificationsConfiguration implements ApplicationComponent, Notific
}
private synchronized NotificationSettings[] _getAllSettings() {
final List<NotificationSettings> result = new ArrayList<NotificationSettings>();
for (String s : myIdToSettingsMap.keySet()) {
if (!Notifications.LOG_ONLY_GROUP_ID.equals(s)) {
result.add(myIdToSettingsMap.get(s));
}
}
final List<NotificationSettings> result = new ArrayList<NotificationSettings>(myIdToSettingsMap.values());
Collections.sort(result, new Comparator<NotificationSettings>() {
public int compare(NotificationSettings o1, NotificationSettings o2) {
@@ -154,5 +149,6 @@ public class NotificationsConfiguration implements ApplicationComponent, Notific
myIdToSettingsMap.put(id, settings);
}
}
_remove("Log Only");
}
}
@@ -20,9 +20,6 @@ import com.intellij.facet.ProjectFacetManager;
import com.intellij.facet.ProjectWideFacetListenersRegistry;
import com.intellij.ide.ui.LafManager;
import com.intellij.ide.ui.LafManagerListener;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.Notifications;
import com.intellij.notification.impl.NotificationsManagerImpl;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
@@ -72,7 +69,6 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.EventListenerList;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.*;
import java.awt.event.KeyEvent;
@@ -1280,7 +1276,6 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
if (existing != null) {
existing.hide();
}
Notifications.Bus.notify(createNotification(type, text, listener), myProject);
if (NotificationsManagerImpl.isEventLogVisible(myProject)) {
return;
@@ -1389,16 +1384,6 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
public static Notification createNotification(MessageType type, String text, @Nullable final HyperlinkListener listener) {
final NotificationListener notificationListener = listener == null ? null : new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
listener.hyperlinkUpdate(event);
}
};
return new Notification(Notifications.LOG_ONLY_GROUP_ID, "", text, type.toNotificationType(), notificationListener);
}
@Override
public Balloon getToolWindowBalloon(String id) {
return myWindow2Balloon.get(id);
@@ -16,6 +16,7 @@
package com.intellij.execution.testframework.sm.runner.ui;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.TestsUIUtil;
import com.intellij.execution.testframework.sm.SMTestsRunnerBundle;
import com.intellij.execution.testframework.sm.runner.SMTRunnerEventsAdapter;
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
@@ -137,6 +138,7 @@ public class SMTRunnerNotificationsHandler extends SMTRunnerEventsAdapter {
if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) {
toolWindowManager.notifyByBalloon(testRunDebugId, type, msg, null, null);
}
TestsUIUtil.NOTIFICATION_GROUP.createNotification(msg, type).notify(project);
}
});
}
@@ -45,7 +45,7 @@ import java.awt.image.BufferedImage;
import java.util.List;
public class TestsUIUtil {
private static final NotificationGroup NOTIFICATION_GROUP = new NotificationGroup("Test Runner", NotificationDisplayType.NONE, true);
public static final NotificationGroup NOTIFICATION_GROUP = new NotificationGroup("Test Runner", NotificationDisplayType.NONE, true);
@NonNls private static final String ICONS_ROOT = "/runConfigurations/";
public static final Color PASSED_COLOR = new Color(0, 128, 0);
@@ -125,9 +125,9 @@ public class TestsUIUtil {
if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) {
toolWindowManager.notifyByBalloon(testRunDebugId, type, balloonText, null, null);
} else {
NOTIFICATION_GROUP.createNotification(balloonText, type.toNotificationType()).notify(project);
}
NOTIFICATION_GROUP.createNotification(balloonText, type).notify(project);
SystemNotifications.getInstance().notify("TestRunner", title, text);
}
@@ -39,6 +39,7 @@ import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.changes.patch.ApplyPatchAction;
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
import com.intellij.openapi.vcs.update.AbstractCommonUpdateAction;
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -384,8 +385,9 @@ public class PatchApplier<BinaryType extends FilePatch> {
else if (status == ApplyPatchStatus.PARTIAL) {
showError(project, VcsBundle.message("patch.apply.partially.applied"), false);
} else if (ApplyPatchStatus.SUCCESS.equals(status)) {
ToolWindowManager.getInstance(project).notifyByBalloon(ChangesViewContentManager.TOOLWINDOW_ID, MessageType.INFO,
VcsBundle.message("patch.apply.success.applied.text"));
final String message = VcsBundle.message("patch.apply.success.applied.text");
ToolWindowManager.getInstance(project).notifyByBalloon(ChangesViewContentManager.TOOLWINDOW_ID, MessageType.INFO, message);
AbstractCommonUpdateAction.NOTIFICATION_GROUP.createNotification(message, MessageType.INFO).notify(project);
}
}
@@ -393,10 +395,6 @@ public class PatchApplier<BinaryType extends FilePatch> {
return myRemainingPatches;
}
public boolean hasRemainingPatches() {
return ! myRemainingPatches.isEmpty();
}
private boolean makeWritable(final List<VirtualFile> filesToMakeWritable) {
final VirtualFile[] fileArray = VfsUtil.toVirtualFileArray(filesToMakeWritable);
final ReadonlyStatusHandler.OperationStatus readonlyStatus = ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(fileArray);
@@ -23,6 +23,7 @@ import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
import com.intellij.openapi.vcs.update.AbstractCommonUpdateAction;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.WindowManager;
@@ -98,6 +99,8 @@ public class VcsBalloonProblemNotifier implements Runnable {
}
private void doForProject(@NotNull final Project project) {
AbstractCommonUpdateAction.NOTIFICATION_GROUP.createNotification(myMessage, myMessageType).notify(project);
final ToolWindowManager manager = ToolWindowManager.getInstance(project);
final String toolWindowId = (myShowOverChangesView ? ChangesViewContentManager.TOOLWINDOW_ID : ToolWindowId.VCS);
final boolean haveWindow = (! project.isDefault()) && (manager.getToolWindow(toolWindowId) != null);
@@ -62,7 +62,7 @@ import java.io.File;
import java.util.*;
public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
public static final NotificationGroup NOTIFICATION_GROUP = new NotificationGroup("VCS Update/Commit", NotificationDisplayType.NONE, true);
public static final NotificationGroup NOTIFICATION_GROUP = new NotificationGroup("Common Version Control Messages", NotificationDisplayType.NONE, true);
private final boolean myAlwaysVisible;
private final static Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.update.AbstractCommonUpdateAction");
@@ -54,13 +54,11 @@ import com.intellij.openapi.util.Getter;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiFile;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.PathUtil;
import com.intellij.util.net.NetUtils;
@@ -70,7 +68,6 @@ import com.theoryinpractice.testng.ui.TestNGResults;
import com.theoryinpractice.testng.ui.actions.RerunFailedTestsAction;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.testng.CommandLineArgs;
import org.testng.IDEATestNGListener;
import org.testng.RemoteTestNGStarter;
@@ -159,13 +156,14 @@ public class TestNGRunnableState extends JavaCommandLineState {
final TestNGResults resultsView = console.getResultsView();
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) {
toolWindowManager.notifyByBalloon(testRunDebugId,
resultsView == null || resultsView.getStatus() == MessageHelper.SKIPPED_TEST
? MessageType.WARNING
: (resultsView.getStatus() == MessageHelper.FAILED_TEST
? MessageType.ERROR
: MessageType.INFO),
resultsView == null ? "Tests were not started" : resultsView.getStatusLine(), null, null);
final MessageType type = resultsView == null || resultsView.getStatus() == MessageHelper.SKIPPED_TEST
? MessageType.WARNING
: (resultsView.getStatus() == MessageHelper.FAILED_TEST
? MessageType.ERROR
: MessageType.INFO);
final String message = resultsView == null ? "Tests were not started" : resultsView.getStatusLine();
toolWindowManager.notifyByBalloon(testRunDebugId, type, message, null, null);
TestsUIUtil.NOTIFICATION_GROUP.createNotification(message, type).notify(project);
}
}
});