simpler VcsBalloonProblemNotifier

break dependency cycle
This commit is contained in:
Bas Leijdekkers
2011-08-18 17:56:51 +02:00
parent edbc16f974
commit f5e0dca40c
5 changed files with 13 additions and 29 deletions
@@ -38,7 +38,7 @@ import com.intellij.openapi.vcs.FilePathImpl;
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.update.AbstractCommonUpdateAction;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -384,7 +384,7 @@ public class PatchApplier<BinaryType extends FilePatch> {
showError(project, VcsBundle.message("patch.apply.partially.applied"), false);
} else if (ApplyPatchStatus.SUCCESS.equals(status)) {
final String message = VcsBundle.message("patch.apply.success.applied.text");
AbstractCommonUpdateAction.NOTIFICATION_GROUP.createNotification(message, MessageType.INFO).notify(project);
VcsBalloonProblemNotifier.NOTIFICATION_GROUP.createNotification(message, MessageType.INFO).notify(project);
}
}
@@ -37,7 +37,7 @@ import com.intellij.openapi.vcs.changes.actions.MoveChangesToAnotherListAction;
import com.intellij.openapi.vcs.changes.committed.CommittedChangesCache;
import com.intellij.openapi.vcs.checkin.CheckinEnvironment;
import com.intellij.openapi.vcs.checkin.CheckinHandler;
import com.intellij.openapi.vcs.update.AbstractCommonUpdateAction;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.openapi.vcs.update.RefreshVFsSynchronously;
import com.intellij.util.Consumer;
import com.intellij.util.NullableFunction;
@@ -136,7 +136,7 @@ public class CommitHelper {
text += ", " + failed + " " + StringUtil.pluralize("change", failed) + " failed to commit";
}
String content = StringUtil.isEmpty(myCommitMessage) ? text : text + ": " + myCommitMessage;
AbstractCommonUpdateAction.NOTIFICATION_GROUP.createNotification(content, NotificationType.INFORMATION).notify( myProject);
VcsBalloonProblemNotifier.NOTIFICATION_GROUP.createNotification(content, NotificationType.INFORMATION).notify( myProject);
return new NotificationInfo("VCS Commit", "VCS Commit Finished", text, true);
}
};
@@ -15,13 +15,12 @@
*/
package com.intellij.openapi.vcs.ui;
import com.intellij.notification.NotificationGroup;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.vcs.update.AbstractCommonUpdateAction;
import java.util.Collection;
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
/**
* Shows a notification balloon over one of version control related tool windows: Changes View or Version Control View.
@@ -29,6 +28,8 @@ import java.util.Collection;
* Use the special method or supply additional parameter to the constructor to show the balloon over the Version Control View.
*/
public class VcsBalloonProblemNotifier implements Runnable {
public static final NotificationGroup
NOTIFICATION_GROUP = NotificationGroup.toolWindowGroup("Common Version Control Messages", ChangesViewContentManager.TOOLWINDOW_ID, true);
private final Project myProject;
private final String myMessage;
private final MessageType myMessageType;
@@ -65,20 +66,11 @@ public class VcsBalloonProblemNotifier implements Runnable {
showErrorAction.run();
}
else {
ApplicationManager.getApplication().invokeLater(showErrorAction);
application.invokeLater(showErrorAction);
}
}
public void run() {
final Collection<Project> projects;
if (myProject != null) {
doForProject(myProject);
} else {
doForProject(null);
}
}
private void doForProject(final Project project) {
AbstractCommonUpdateAction.NOTIFICATION_GROUP.createNotification(myMessage, myMessageType).notify(project);
NOTIFICATION_GROUP.createNotification(myMessage, myMessageType).notify(myProject);
}
}
@@ -19,7 +19,6 @@ 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.NotificationGroup;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
@@ -44,7 +43,6 @@ import com.intellij.openapi.vcs.changes.VcsDirtyScopeManagerImpl;
import com.intellij.openapi.vcs.changes.committed.CommittedChangesAdapter;
import com.intellij.openapi.vcs.changes.committed.CommittedChangesCache;
import com.intellij.openapi.vcs.changes.committed.IntoSelfVirtualFileConvertor;
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
@@ -62,7 +60,6 @@ import java.io.File;
import java.util.*;
public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
public static final NotificationGroup NOTIFICATION_GROUP = NotificationGroup.toolWindowGroup("Common Version Control Messages", ChangesViewContentManager.TOOLWINDOW_ID, true);
private final boolean myAlwaysVisible;
private final static Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.update.AbstractCommonUpdateAction");
@@ -458,7 +455,7 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
if (text.length() > 0) {
log += ": " + text.toString();
}
NOTIFICATION_GROUP.createNotification(log, NotificationType.INFORMATION).notify(myProject);
VcsBalloonProblemNotifier.NOTIFICATION_GROUP.createNotification(log, NotificationType.INFORMATION).notify(myProject);
return new NotificationInfo("VCS Update", title, log, true);
}
@@ -26,7 +26,6 @@ import com.intellij.cvsSupport2.cvsIgnore.IgnoredFilesInfo;
import com.intellij.cvsSupport2.cvsIgnore.IgnoredFilesInfoImpl;
import com.intellij.cvsSupport2.errorHandling.ErrorRegistry;
import com.intellij.cvsSupport2.javacvsImpl.io.ReadWriteStatistics;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
@@ -293,12 +292,8 @@ public class CvsInfo {
}
public ThreeState silentLogin(boolean forceCheck) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
new VcsBalloonProblemNotifier(project, CvsBundle.message("message.error.invalid.cvs.root", getCvsRootAsString()),
MessageType.ERROR).run();
}
});
VcsBalloonProblemNotifier.showOverChangesView(
project, CvsBundle.message("message.error.invalid.cvs.root", getCvsRootAsString()), MessageType.ERROR);
return ThreeState.NO;
}