Search in sources :

Example 26 with Notification

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

the class ExternalSystemNotificationManager method showNotification.

public void showNotification(@NotNull final ProjectSystemId externalSystemId, @NotNull final NotificationData notificationData) {
    myUpdater.submit(() -> {
        if (myProject.isDisposed())
            return;
        final Application app = ApplicationManager.getApplication();
        Runnable action = () -> {
            if (!initializedExternalSystem.contains(externalSystemId)) {
                app.runWriteAction(() -> {
                    if (myProject.isDisposed())
                        return;
                    ExternalSystemUtil.ensureToolWindowContentInitialized(myProject, externalSystemId);
                    initializedExternalSystem.add(externalSystemId);
                });
            }
            if (myProject.isDisposed())
                return;
            NotificationGroup group;
            if (notificationData.getBalloonGroup() == null) {
                ExternalProjectsView externalProjectsView = ExternalProjectsManager.getInstance(myProject).getExternalProjectsView(externalSystemId);
                group = externalProjectsView instanceof ExternalProjectsViewImpl ? ((ExternalProjectsViewImpl) externalProjectsView).getNotificationGroup() : null;
            } else {
                final NotificationGroup registeredGroup = NotificationGroup.findRegisteredGroup(notificationData.getBalloonGroup());
                group = registeredGroup != null ? registeredGroup : NotificationGroup.balloonGroup(notificationData.getBalloonGroup());
            }
            if (group == null)
                return;
            final Notification notification = group.createNotification(notificationData.getTitle(), notificationData.getMessage(), notificationData.getNotificationCategory().getNotificationType(), notificationData.getListener());
            myNotifications.add(notification);
            if (notificationData.isBalloonNotification()) {
                applyNotification(notification);
            } else {
                addMessage(notification, externalSystemId, notificationData);
            }
        };
        app.invokeLater(action, ModalityState.defaultModalityState(), myProject.getDisposed());
    });
}
Also used : ExternalProjectsViewImpl(com.intellij.openapi.externalSystem.view.ExternalProjectsViewImpl) ExternalProjectsView(com.intellij.openapi.externalSystem.view.ExternalProjectsView) NotificationGroup(com.intellij.notification.NotificationGroup) Application(com.intellij.openapi.application.Application) Notification(com.intellij.notification.Notification)

Example 27 with Notification

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

the class JBViewport method notify.

private static Notification notify(String message) {
    Notification notification = NOTIFICATION_GROUP.createNotification(message, NotificationType.INFORMATION);
    notification.notify(null);
    Timer timer = new Timer(NOTIFICATION_TIMEOUT, event -> notification.expire());
    timer.setRepeats(false);
    timer.start();
    return notification;
}
Also used : Timer(javax.swing.Timer) Notification(com.intellij.notification.Notification)

Example 28 with Notification

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

the class CreateDesktopEntryAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent event) {
    if (!isAvailable())
        return;
    Project project = event.getProject();
    CreateDesktopEntryDialog dialog = new CreateDesktopEntryDialog(project);
    if (!dialog.showAndGet()) {
        return;
    }
    final boolean globalEntry = dialog.myGlobalEntryCheckBox.isSelected();
    ProgressManager.getInstance().run(new Task.Backgroundable(project, ApplicationBundle.message("desktop.entry.title")) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            try {
                indicator.setIndeterminate(true);
                createDesktopEntry(globalEntry);
                final String message = ApplicationBundle.message("desktop.entry.success", ApplicationNamesInfo.getInstance().getProductName());
                Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Desktop Entry Created", message, NotificationType.INFORMATION), getProject());
            } catch (Exception e) {
                reportFailure(e, getProject());
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) Notification(com.intellij.notification.Notification) ExecutionException(com.intellij.execution.ExecutionException) IOException(java.io.IOException)

Example 29 with Notification

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

the class PluginManager method reportPluginError.

public static void reportPluginError() {
    if (myPluginError != null) {
        String title = IdeBundle.message("title.plugin.error");
        Notifications.Bus.notify(new Notification(title, title, myPluginError, NotificationType.ERROR, new NotificationListener() {

            @SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod")
            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                notification.expire();
                String description = event.getDescription();
                if (EDIT.equals(description)) {
                    PluginManagerConfigurable configurable = new PluginManagerConfigurable(PluginManagerUISettings.getInstance());
                    IdeFrame ideFrame = WindowManagerEx.getInstanceEx().findFrameFor(null);
                    ShowSettingsUtil.getInstance().editConfigurable((JFrame) ideFrame, configurable);
                    return;
                }
                List<String> disabledPlugins = getDisabledPlugins();
                if (myPlugins2Disable != null && DISABLE.equals(description)) {
                    for (String pluginId : myPlugins2Disable) {
                        if (!disabledPlugins.contains(pluginId)) {
                            disabledPlugins.add(pluginId);
                        }
                    }
                } else if (myPlugins2Enable != null && ENABLE.equals(description)) {
                    disabledPlugins.removeAll(myPlugins2Enable);
                    PluginManagerMain.notifyPluginsUpdated(null);
                }
                try {
                    saveDisabledPlugins(disabledPlugins, false);
                } catch (IOException ignore) {
                }
                myPlugins2Enable = null;
                myPlugins2Disable = null;
            }
        }));
        myPluginError = null;
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) IOException(java.io.IOException) NotNull(org.jetbrains.annotations.NotNull) IdeFrame(com.intellij.openapi.wm.IdeFrame) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 30 with Notification

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

the class StartupManagerImpl method checkFsSanity.

private void checkFsSanity() {
    try {
        String path = myProject.getProjectFilePath();
        if (path == null || FileUtil.isAncestor(PathManager.getConfigPath(), path, true)) {
            return;
        }
        if (ProjectKt.isDirectoryBased(myProject)) {
            path = PathUtil.getParentPath(path);
        }
        boolean expected = SystemInfo.isFileSystemCaseSensitive, actual = FileUtil.isFileSystemCaseSensitive(path);
        LOG.info(path + " case-sensitivity: expected=" + expected + " actual=" + actual);
        if (actual != expected) {
            // IDE=true -> FS=false -> prefix='in'
            int prefix = expected ? 1 : 0;
            String title = ApplicationBundle.message("fs.case.sensitivity.mismatch.title");
            String text = ApplicationBundle.message("fs.case.sensitivity.mismatch.message", prefix);
            Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, title, text, NotificationType.WARNING, NotificationListener.URL_OPENING_LISTENER), myProject);
        }
    } catch (FileNotFoundException e) {
        LOG.warn(e);
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) Notification(com.intellij.notification.Notification)

Aggregations

Notification (com.intellij.notification.Notification)108 HyperlinkEvent (javax.swing.event.HyperlinkEvent)34 NotNull (org.jetbrains.annotations.NotNull)34 NotificationListener (com.intellij.notification.NotificationListener)33 Project (com.intellij.openapi.project.Project)19 IOException (java.io.IOException)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 File (java.io.File)8 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)7 Nullable (org.jetbrains.annotations.Nullable)7 Module (com.intellij.openapi.module.Module)6 Task (com.intellij.openapi.progress.Task)6 ExecutionException (com.intellij.execution.ExecutionException)4 NotificationType (com.intellij.notification.NotificationType)4 Application (com.intellij.openapi.application.Application)3 Library (com.intellij.openapi.roots.libraries.Library)3 ActionCallback (com.intellij.openapi.util.ActionCallback)3 ArrayList (java.util.ArrayList)3 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)2 NotificationAction (com.intellij.notification.NotificationAction)2