Search in sources :

Example 16 with NotificationListener

use of com.intellij.notification.NotificationListener in project intellij-community by JetBrains.

the class GitUntrackedFilesHelper method notifyUntrackedFilesOverwrittenBy.

/**
   * Displays notification about {@code untracked files would be overwritten by checkout} error.
   * Clicking on the link in the notification opens a simple dialog with the list of these files.
   * @param root
   * @param relativePaths
   * @param operation   the name of the Git operation that caused the error: {@code rebase, merge, checkout}.
   * @param description the content of the notification or null if the default content is to be used.
   */
public static void notifyUntrackedFilesOverwrittenBy(@NotNull final Project project, @NotNull final VirtualFile root, @NotNull Collection<String> relativePaths, @NotNull final String operation, @Nullable String description) {
    final String notificationTitle = StringUtil.capitalize(operation) + " failed";
    final String notificationDesc = description == null ? createUntrackedFilesOverwrittenDescription(operation, true) : description;
    final Collection<String> absolutePaths = GitUtil.toAbsolute(root, relativePaths);
    final List<VirtualFile> untrackedFiles = ContainerUtil.mapNotNull(absolutePaths, new Function<String, VirtualFile>() {

        @Override
        public VirtualFile fun(String absolutePath) {
            return GitUtil.findRefreshFileOrLog(absolutePath);
        }
    });
    VcsNotifier.getInstance(project).notifyError(notificationTitle, notificationDesc, new NotificationListener() {

        @Override
        public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
            if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                final String dialogDesc = createUntrackedFilesOverwrittenDescription(operation, false);
                String title = "Untracked Files Preventing " + StringUtil.capitalize(operation);
                if (untrackedFiles.isEmpty()) {
                    GitUtil.showPathsInDialog(project, absolutePaths, title, dialogDesc);
                } else {
                    DialogWrapper dialog;
                    dialog = new UntrackedFilesDialog(project, untrackedFiles, dialogDesc);
                    dialog.setTitle(title);
                    dialog.show();
                }
            }
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HyperlinkEvent(javax.swing.event.HyperlinkEvent) Notification(com.intellij.notification.Notification) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) NotificationListener(com.intellij.notification.NotificationListener)

Example 17 with NotificationListener

use of com.intellij.notification.NotificationListener in project intellij-community by JetBrains.

the class ConfigurationErrorEvent method process.

@Override
public void process(@NotNull final TestEventXmlView xml) throws TestEventXmlView.XmlParserException {
    final String errorTitle = xml.getEventTitle();
    final String configurationErrorMsg = xml.getEventMessage();
    final boolean openSettings = xml.isEventOpenSettings();
    final Project project = getProject();
    assert project != null;
    final String message = openSettings ? String.format("<br>\n%s<br><br>\n\n<a href=\"Gradle settings\">Open gradle settings</a>", configurationErrorMsg) : String.format("<br>\n%s", configurationErrorMsg);
    GradleNotification.getInstance(project).showBalloon(errorTitle, message, NotificationType.WARNING, new NotificationListener() {

        @Override
        public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
            notification.expire();
            if ("Gradle settings".equals(event.getDescription())) {
                ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID);
                assert manager instanceof GradleManager;
                GradleManager gradleManager = (GradleManager) manager;
                Configurable configurable = gradleManager.getConfigurable(project);
                ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
            } else {
                BrowserUtil.browse(event.getDescription());
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ExternalSystemManager(com.intellij.openapi.externalSystem.ExternalSystemManager) GradleManager(org.jetbrains.plugins.gradle.GradleManager) Configurable(com.intellij.openapi.options.Configurable) GradleNotification(org.jetbrains.plugins.gradle.service.project.GradleNotification) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 18 with NotificationListener

use of com.intellij.notification.NotificationListener in project android by JetBrains.

the class InstantRunNotificationTask method showIrBrokenForSecondaryUsersNotification.

private static void showIrBrokenForSecondaryUsersNotification(@NotNull Project project) {
    NotificationListener l = (notification, event) -> {
        if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
            return;
        }
        String description = event.getDescription();
        if ("learnmore".equals(description)) {
            BrowserUtil.browse("http://developers.android.com/r/studio-ui/run-with-work-profile.html", project);
        }
    };
    InstantRunManager.NOTIFICATION_GROUP.createNotification("", AndroidBundle.message("instant.run.notification.ir.broken.for.secondary.user"), NotificationType.INFORMATION, l).notify(project);
}
Also used : AndroidBundle(org.jetbrains.android.util.AndroidBundle) LaunchStatus(com.android.tools.idea.run.util.LaunchStatus) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) HyperlinkEvent(javax.swing.event.HyperlinkEvent) IDevice(com.android.ddmlib.IDevice) Language(org.intellij.lang.annotations.Language) HashSet(com.intellij.util.containers.HashSet) Set(java.util.Set) BrowserUtil(com.intellij.ide.BrowserUtil) com.android.tools.idea.fd(com.android.tools.idea.fd) ConsolePrinter(com.android.tools.idea.run.ConsolePrinter) NotificationListener(com.intellij.notification.NotificationListener) NotificationType(com.intellij.notification.NotificationType) Nullable(org.jetbrains.annotations.Nullable) GuardedBy(com.android.annotations.concurrency.GuardedBy) RestartActivityAction(com.android.tools.idea.fd.actions.RestartActivityAction) Project(com.intellij.openapi.project.Project) NotNull(org.jetbrains.annotations.NotNull) NotificationListener(com.intellij.notification.NotificationListener)

Example 19 with NotificationListener

use of com.intellij.notification.NotificationListener in project android by JetBrains.

the class AndroidGradleNotification method showBalloon.

public void showBalloon(@NotNull String title, @NotNull String text, @NotNull NotificationType type, @NotNull NotificationGroup group, @NotNull NotificationHyperlink... hyperlinks) {
    NotificationListener notificationListener = new CustomNotificationListener(myProject, hyperlinks);
    String newText = addHyperlinksToText(text, hyperlinks);
    showBalloon(title, newText, type, group, notificationListener);
}
Also used : CustomNotificationListener(com.android.tools.idea.gradle.project.sync.hyperlink.CustomNotificationListener) NotificationListener(com.intellij.notification.NotificationListener) CustomNotificationListener(com.android.tools.idea.gradle.project.sync.hyperlink.CustomNotificationListener)

Example 20 with NotificationListener

use of com.intellij.notification.NotificationListener in project intellij-plugins by JetBrains.

the class FlexmojosImporter method doShowFlexConfigWarning.

private synchronized void doShowFlexConfigWarning(final Project project) {
    final NotificationListener listener = new NotificationListener() {

        public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull final HyperlinkEvent event) {
            Messages.showWarningDialog(project, FlexBundle.message("flexmojos.warning.detailed"), FlexBundle.message("flexmojos.project.import"));
            notification.expire();
        }
    };
    myFlexConfigNotification = new Notification("Maven", FlexBundle.message("flexmojos.project.import"), FlexBundle.message("flexmojos.warning.short"), NotificationType.WARNING, listener);
    myFlexConfigNotification.notify(project);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Aggregations

NotificationListener (com.intellij.notification.NotificationListener)36 HyperlinkEvent (javax.swing.event.HyperlinkEvent)28 Notification (com.intellij.notification.Notification)26 NotNull (org.jetbrains.annotations.NotNull)23 Project (com.intellij.openapi.project.Project)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 GuardedBy (com.android.annotations.concurrency.GuardedBy)2 IDevice (com.android.ddmlib.IDevice)2 com.android.tools.idea.fd (com.android.tools.idea.fd)2 RestartActivityAction (com.android.tools.idea.fd.actions.RestartActivityAction)2 ConsolePrinter (com.android.tools.idea.run.ConsolePrinter)2 LaunchStatus (com.android.tools.idea.run.util.LaunchStatus)2 BrowserUtil (com.intellij.ide.BrowserUtil)2 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)2 NotificationType (com.intellij.notification.NotificationType)2 ShowSettingsUtil (com.intellij.openapi.options.ShowSettingsUtil)2 MultiMap (com.intellij.util.containers.MultiMap)2 File (java.io.File)2 Set (java.util.Set)2 Nullable (org.jetbrains.annotations.Nullable)2