mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
logEvent replaced with explicit notifications with different groupIds
This commit is contained in:
@@ -29,7 +29,8 @@ import com.intellij.compiler.make.DependencyCache;
|
||||
import com.intellij.compiler.progress.CompilerTask;
|
||||
import com.intellij.diagnostic.IdeErrorsDialog;
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.notification.NotificationDisplayType;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.Result;
|
||||
@@ -70,7 +71,10 @@ import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.newvfs.ManagingFS;
|
||||
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
import com.intellij.openapi.wm.*;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.util.*;
|
||||
@@ -88,6 +92,8 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class CompileDriver {
|
||||
private static final NotificationGroup NOTIFICATION_GROUP = new NotificationGroup("Compiler", NotificationDisplayType.NONE, true);
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.CompileDriver");
|
||||
// to be used in tests only for debug output
|
||||
public static volatile boolean ourDebugMode = false;
|
||||
@@ -551,7 +557,7 @@ public class CompileDriver {
|
||||
if (_status == ExitStatus.UP_TO_DATE) {
|
||||
logMessage = "Compilation: all files are up to date";
|
||||
}
|
||||
Notifications.Bus.logEvent(logMessage, messageType.toNotificationType(), myProject);
|
||||
NOTIFICATION_GROUP.createNotification(logMessage, messageType.toNotificationType()).notify(myProject);
|
||||
}
|
||||
if (_status != ExitStatus.UP_TO_DATE && compileContext.getMessageCount(null) > 0) {
|
||||
compileContext.addMessage(CompilerMessageCategory.INFORMATION, statusMessage, null, -1, -1);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.notification;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -109,4 +110,8 @@ public class Notification {
|
||||
public Balloon getBalloon() {
|
||||
return myBalloonRef == null ? null : myBalloonRef.get();
|
||||
}
|
||||
|
||||
public void notify(@Nullable Project project) {
|
||||
Notifications.Bus.notify(this, project);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,10 +70,6 @@ public interface Notifications {
|
||||
notify(notification, null);
|
||||
}
|
||||
|
||||
public static void logEvent(@NotNull String text, NotificationType type, @Nullable final Project project) {
|
||||
notify(new Notification(LOG_ONLY_GROUP_ID, "", text, type), project);
|
||||
}
|
||||
|
||||
public static void notify(@NotNull final Notification notification, @Nullable final Project project) {
|
||||
invoke(project, new Processor<MessageBus>() {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.notification;
|
||||
|
||||
import com.intellij.notification.impl.NotificationSettings;
|
||||
import com.intellij.notification.impl.NotificationsConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class NotificationGroup {
|
||||
private final String myDisplayId;
|
||||
|
||||
public NotificationGroup(String displayId, NotificationDisplayType defaultDisplayType, boolean logByDefault) {
|
||||
myDisplayId = displayId;
|
||||
|
||||
NotificationsConfiguration.getNotificationsConfiguration().registerDefaultSettings(new NotificationSettings(displayId, defaultDisplayType, logByDefault));
|
||||
}
|
||||
|
||||
public Notification createNotification(@NotNull final String content, @NotNull final NotificationType type) {
|
||||
return createNotification("", content, type, null);
|
||||
}
|
||||
|
||||
public Notification createNotification(@NotNull final String title, @NotNull final String content, @NotNull final NotificationType type, @Nullable NotificationListener listener) {
|
||||
return new Notification(myDisplayId, title, content, type, listener);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,8 @@ package com.intellij.execution.testframework;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.configurations.RuntimeConfiguration;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.notification.NotificationDisplayType;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.application.Application;
|
||||
@@ -31,7 +32,6 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.impl.ToolWindowManagerImpl;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.ui.SystemNotifications;
|
||||
@@ -45,6 +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);
|
||||
@NonNls private static final String ICONS_ROOT = "/runConfigurations/";
|
||||
|
||||
public static final Color PASSED_COLOR = new Color(0, 128, 0);
|
||||
@@ -125,7 +126,7 @@ public class TestsUIUtil {
|
||||
if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) {
|
||||
toolWindowManager.notifyByBalloon(testRunDebugId, type, balloonText, null, null);
|
||||
} else {
|
||||
Notifications.Bus.logEvent(balloonText, type.toNotificationType(), project);
|
||||
NOTIFICATION_GROUP.createNotification(balloonText, type.toNotificationType()).notify(project);
|
||||
}
|
||||
SystemNotifications.getInstance().notify("TestRunner", title, text);
|
||||
}
|
||||
|
||||
+7
-12
@@ -19,8 +19,9 @@ import com.intellij.history.Label;
|
||||
import com.intellij.history.LocalHistory;
|
||||
import com.intellij.history.LocalHistoryAction;
|
||||
import com.intellij.ide.errorTreeView.HotfixData;
|
||||
import com.intellij.notification.NotificationDisplayType;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -61,6 +62,7 @@ import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
||||
private static final NotificationGroup NOTIFICATION_GROUP = new NotificationGroup("VCS Update", NotificationDisplayType.NONE, true);
|
||||
private final boolean myAlwaysVisible;
|
||||
private final static Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.update.AbstractCommonUpdateAction");
|
||||
|
||||
@@ -195,14 +197,6 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean containsParent(FilePath[] array, FilePath file) {
|
||||
for (FilePath virtualFile : array) {
|
||||
if (virtualFile == file) continue;
|
||||
if (VfsUtil.isAncestor(virtualFile.getIOFile(), file.getIOFile(), false)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private FilePath[] filterRoots(FilePath[] roots, VcsContext vcsContext) {
|
||||
final ArrayList<FilePath> result = new ArrayList<FilePath>();
|
||||
@@ -350,7 +344,7 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
suspendIfNeeded();
|
||||
try {
|
||||
runImpl(indicator);
|
||||
runImpl();
|
||||
} catch (Throwable t) {
|
||||
releaseIfNeeded();
|
||||
if (t instanceof Error) {
|
||||
@@ -362,7 +356,7 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
||||
}
|
||||
}
|
||||
|
||||
private void runImpl(@NotNull final ProgressIndicator indicator) {
|
||||
private void runImpl() {
|
||||
ProjectManagerEx.getInstanceEx().blockReloadingProjectOnExternalChanges();
|
||||
myProjectLevelVcsManager.startBackgroundVcsOperation();
|
||||
|
||||
@@ -462,7 +456,8 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
||||
if (text.length() > 0) {
|
||||
log += ": " + text.toString();
|
||||
}
|
||||
Notifications.Bus.logEvent(log, NotificationType.INFORMATION, myProject);
|
||||
NOTIFICATION_GROUP.createNotification(log, NotificationType.INFORMATION).notify(myProject);
|
||||
|
||||
return new NotificationInfo("VCS Update", title, log, true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user