Notifications improvements

This commit is contained in:
Alexey Pegov
2009-09-10 16:18:32 +04:00
parent 787aedd704
commit 4be960dce5
7 changed files with 70 additions and 79 deletions
@@ -37,14 +37,15 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.peer.PeerFactory;
import com.intellij.ui.*;
import com.intellij.ui.table.TableView;
import com.intellij.ui.tabs.BetterJTable;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.Icons;
import com.intellij.util.Processor;
import com.intellij.util.containers.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.ColumnInfo;
import com.intellij.util.ui.ListTableModel;
import com.intellij.openapi.ui.StripeTable;
import gnu.trove.THashMap;
import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
import org.intellij.plugins.intelliLang.inject.InjectorUtils;
@@ -105,7 +106,7 @@ public class InjectionsSettingsUI implements Configurable {
myInjectionsTable = new InjectionsTable(myInjections);
final JPanel tablePanel = new JPanel(new BorderLayout());
tablePanel.add(BetterJTable.createStripedJScrollPane(myInjectionsTable), BorderLayout.CENTER);
tablePanel.add(StripeTable.createScrollPane(myInjectionsTable), BorderLayout.CENTER);
//tablePanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
final DefaultActionGroup group = createActions();
@@ -17,6 +17,7 @@
package git4idea.vfs;
import com.intellij.ProjectTopics;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
@@ -44,6 +45,7 @@ import git4idea.i18n.GitBundle;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.event.HyperlinkEvent;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@@ -87,10 +89,13 @@ public class GitRootTracker implements VcsListener {
* If true, the notification is currently active and has not been dismissed yet.
*/
private final AtomicBoolean myNotificationPosted = new AtomicBoolean(false);
private Notification myNotification;
/**
* The invalid git roots
*/
private static final String GIT_INVALID_ROOTS_ID = "GIT_INVALID_ROOTS";
private static final String GIT_INVALID_ROOTS_ID = "Git";
/**
* The command listener
*/
@@ -265,30 +270,28 @@ public class GitRootTracker implements VcsListener {
if (!hasInvalidRoots) {
// all roots are correct
if (myNotificationPosted.compareAndSet(true, false)) {
final Notifications notifications = myProject.getMessageBus().syncPublisher(Notifications.TOPIC);
notifications.invalidateAll(GIT_INVALID_ROOTS_ID);
if (myNotification != null) {
if (!myNotification.isExpired()) {
myNotification.expire();
}
myNotification = null;
}
}
return;
}
if (myNotificationPosted.compareAndSet(false, true)) {
String title = GitBundle.message("root.tracker.message");
final Notifications notifications = myProject.getMessageBus().syncPublisher(Notifications.TOPIC);
notifications.notify(GIT_INVALID_ROOTS_ID, title, title, NotificationType.ERROR, new NotificationListener() {
@NotNull
public Continue perform() {
if (fixRoots()) {
myNotificationPosted.set(false);
return Continue.REMOVE;
myNotification = new Notification(GIT_INVALID_ROOTS_ID, "Invalid Git roots",
"<p>Some configured Git VCS roots are not under Git or have Git repsoitories in subdirectories without configured VCS root. <a href=\"\">Configure.</a></p>",
NotificationType.ERROR, new NotificationListener() {
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (fixRoots()) {
notification.expire();
}
}
else {
return Continue.LEAVE;
}
}
});
public Continue onRemove() {
return Continue.LEAVE;
}
});
Notifications.Bus.notify(myNotification, myProject);
}
}
});
@@ -15,9 +15,10 @@
*/
package org.jetbrains.plugins.groovy.dsl;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.Notifications;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.impl.NotificationsManager;
import com.intellij.notification.NotificationListener;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
@@ -52,6 +53,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import javax.swing.event.HyperlinkEvent;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
@@ -288,18 +290,17 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
}
final StackTraceElement[] elements = e.getStackTrace();
ApplicationManager.getApplication().getMessageBus().syncPublisher(NotificationsManager.TOPIC)
.notify("Groovy DSL parsing", "DSL descriptor execution error", e.getMessage(), NotificationType.ERROR, new NotificationListener() {
@NotNull
public Continue perform() {
suggestAnalyzeTrace(project, elements);
return Continue.REMOVE;
}
public Continue onRemove() {
return Continue.REMOVE;
}
});
ApplicationManager.getApplication().getMessageBus().syncPublisher(Notifications.TOPIC).notify(
new Notification("Groovy DSL parsing", "DSL descriptor execution error",
"<p>" + e.getMessage() + "</p><p><a href=\"\">Click here to investigate.</a></p>", NotificationType.ERROR, new NotificationListener() {
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
suggestAnalyzeTrace(project, elements);
notification.expire();
}
})
);
disableFile(vfile);
return null;
}
@@ -4,9 +4,9 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.LocalQuickFixProvider;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.Notifications;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.impl.NotificationsManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.io.FileUtil;
@@ -119,10 +119,7 @@ public class MavenModulePsiReference extends MavenPsiReference implements LocalQ
myWithParent ? id : null);
}
catch (IOException e) {
NotificationsManager.getNotificationsManager().notify("Cannot create a module",
e.getMessage(),
NotificationType.ERROR,
NotificationListener.REMOVE);
Notifications.Bus.notify(new Notification("Maven", "Cannot create a module", e.getMessage(), NotificationType.ERROR), project);
}
}
@@ -1,8 +1,8 @@
package org.jetbrains.idea.maven.project.actions;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.Notifications;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.impl.NotificationsManager;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.Result;
@@ -69,10 +69,7 @@ public abstract class MavenOpenOrCreateFilesAction extends MavenAction {
MavenUtil.runFileTemplate(project, newFile, getFileTemplate());
}
catch (IOException ex) {
NotificationsManager.getNotificationsManager().notify("Cannot create " + file.getName(),
ex.getMessage(),
NotificationType.ERROR,
NotificationListener.REMOVE);
Notifications.Bus.notify(new Notification("Maven", "Cannot create " + file.getName(), ex.getMessage(), NotificationType.ERROR), project);
}
}
}.execute();
@@ -5,9 +5,9 @@ import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.SourcePathsBuilder;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.Notifications;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.impl.NotificationsManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.command.WriteCommandAction;
@@ -31,13 +31,13 @@ import com.intellij.psi.xml.XmlElement;
import org.jetbrains.idea.maven.dom.MavenDomUtil;
import org.jetbrains.idea.maven.dom.model.MavenDomModule;
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
import org.jetbrains.idea.maven.execution.MavenRunner;
import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
import org.jetbrains.idea.maven.execution.MavenRunnerSettings;
import org.jetbrains.idea.maven.indices.ArchetypeInfo;
import org.jetbrains.idea.maven.project.MavenId;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
import org.jetbrains.idea.maven.execution.MavenRunner;
import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
import org.jetbrains.idea.maven.execution.MavenRunnerSettings;
import org.jetbrains.idea.maven.utils.MavenConstants;
import org.jetbrains.idea.maven.utils.MavenLog;
import org.jetbrains.idea.maven.utils.MavenUtil;
@@ -93,10 +93,8 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
}
catch (IOException e) {
MavenLog.LOG.warn(e);
NotificationsManager.getNotificationsManager().notify("Cannot create " + MavenConstants.POM_XML + " " + root.getPath(),
e.getMessage(),
NotificationType.ERROR,
NotificationListener.REMOVE);
Notifications.Bus.notify(new Notification("Maven", "Cannot create " + MavenConstants.POM_XML + " " + root.getPath(),
e.getMessage(), NotificationType.ERROR), project);
return;
}
@@ -34,10 +34,7 @@ package org.jetbrains.idea.svn;
import com.intellij.ide.FrameStateListener;
import com.intellij.ide.FrameStateManager;
import com.intellij.notification.NotificationDisplayType;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.notification.*;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
@@ -104,6 +101,7 @@ import org.tmatesoft.svn.util.SVNDebugLog;
import org.tmatesoft.svn.util.SVNDebugLogAdapter;
import org.tmatesoft.svn.util.SVNLogType;
import javax.swing.event.HyperlinkEvent;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.*;
@@ -337,32 +335,28 @@ public class SvnVcs extends AbstractVcs {
}
}
private final static String UPGRADE_SUBVERSION_FORMAT = "UPGRADE_SUBVERSION_FORMAT";
private final static String UPGRADE_SUBVERSION_FORMAT = "Subversion";
private void upgradeToRecentVersion(final SvnConfiguration.SvnSupportOptions supportOptions) {
if (! supportOptions.upgradeTo16Asked()) {
final SvnWorkingCopyChecker workingCopyChecker = new SvnWorkingCopyChecker();
if (workingCopyChecker.upgradeNeeded()) {
final Notifications notifications = myProject.getMessageBus().syncPublisher(Notifications.TOPIC);
notifications.register(UPGRADE_SUBVERSION_FORMAT, NotificationDisplayType.BALLOON, false);
final String title = SvnBundle.message("upgrade.format.to16.question.title");
notifications.notify(UPGRADE_SUBVERSION_FORMAT, title, title, NotificationType.INFORMATION, new NotificationListener() {
@NotNull
public Continue perform() {
final int upgradeAnswer = Messages.showYesNoDialog(SvnBundle.message("upgrade.format.to16.question.text",
SvnBundle.message("label.where.svn.format.can.be.changed.text", SvnBundle.message("action.show.svn.map.text"))),
SvnBundle.message("upgrade.format.to16.question.title"), Messages.getWarningIcon());
if (DialogWrapper.OK_EXIT_CODE == upgradeAnswer) {
workingCopyChecker.doUpgrade();
}
return Continue.REMOVE;
}
public Continue onRemove() {
return Continue.REMOVE;
}
});
Notifications.Bus.notify(new Notification(UPGRADE_SUBVERSION_FORMAT, SvnBundle.message("upgrade.format.to16.question.title"),
"Old format Subversion working copies <a href=\"\">could be upgraded to version 1.6</a>.",
NotificationType.INFORMATION, new NotificationListener() {
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
final int upgradeAnswer = Messages.showYesNoDialog(SvnBundle.message("upgrade.format.to16.question.text",
SvnBundle.message("label.where.svn.format.can.be.changed.text", SvnBundle.message("action.show.svn.map.text"))),
SvnBundle.message("upgrade.format.to16.question.title"), Messages.getWarningIcon());
if (DialogWrapper.OK_EXIT_CODE == upgradeAnswer) {
workingCopyChecker.doUpgrade();
}
notification.expire();
}
}));
}
}
}