diff --git a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java index c5bf0309b5c7..fbd344ad95db 100644 --- a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java +++ b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -51,7 +51,6 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.vcs.changes.RefreshablePanel; import com.intellij.ui.AbstractTitledSeparatorWithIcon; import com.intellij.ui.ListCellRendererWrapper; -import com.intellij.util.ExceptionUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -428,7 +427,7 @@ public class InitialConfigurationDialog extends DialogWrapper { CreateLauncherScriptAction.createLauncherScript(pathName); } catch (Exception e) { - Messages.showErrorDialog(ExceptionUtil.getNonEmptyMessage(e, "Internal error"), "Launcher Script Creation Failed"); + CreateLauncherScriptAction.reportFailure(e, getProject()); } } @@ -440,7 +439,7 @@ public class InitialConfigurationDialog extends DialogWrapper { CreateDesktopEntryAction.createDesktopEntry(globalEntry); } catch (Exception e) { - Messages.showErrorDialog(ExceptionUtil.getNonEmptyMessage(e, "Internal error"), "Desktop Entry Creation Failed"); + CreateDesktopEntryAction.reportFailure(e, getProject()); } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java b/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java index daf9e736b8a7..44e8ba93d74d 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -23,9 +23,7 @@ import com.intellij.notification.Notification; import com.intellij.notification.NotificationType; import com.intellij.notification.Notifications; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.application.ApplicationBundle; -import com.intellij.openapi.application.ApplicationNamesInfo; -import com.intellij.openapi.application.PathManager; +import com.intellij.openapi.application.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; @@ -83,17 +81,17 @@ public class CreateDesktopEntryAction extends DumbAwareAction { createDesktopEntry(globalEntry); - 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()); + final String message = ApplicationBundle.message("desktop.entry.success", ApplicationNamesInfo.getInstance().getProductName()); + ApplicationManager.getApplication().invokeLater(new Runnable() { + public void run() { + Notifications.Bus.notify( + new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Desktop Entry Created", message, NotificationType.INFORMATION), + getProject()); + } + }, ModalityState.NON_MODAL); } catch (Exception e) { - LOG.warn(e); - String message = ExceptionUtil.getNonEmptyMessage(e, "Internal error"); - Notifications.Bus.notify( - new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Desktop Entry Creation Failed", message, NotificationType.ERROR), - getProject()); + reportFailure(e, getProject()); } } }); @@ -115,6 +113,19 @@ public class CreateDesktopEntryAction extends DumbAwareAction { } } + public static void reportFailure(@NotNull Exception e, @Nullable final Project project) { + LOG.warn(e); + final String message = ExceptionUtil.getNonEmptyMessage(e, "Internal error"); + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + Notifications.Bus.notify( + new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Desktop Entry Creation Failed", message, NotificationType.ERROR), + project); + } + }, ModalityState.NON_MODAL); + } + private static void check() throws ExecutionException, InterruptedException { int result = new GeneralCommandLine("which", "xdg-desktop-menu").createProcess().waitFor(); if (result != 0) throw new RuntimeException(ApplicationBundle.message("desktop.entry.xdg.missing")); diff --git a/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java b/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java index b624510b6cb2..28b3fa2a1e25 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -23,9 +23,7 @@ import com.intellij.notification.Notification; import com.intellij.notification.NotificationType; import com.intellij.notification.Notifications; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.application.ApplicationBundle; -import com.intellij.openapi.application.ApplicationNamesInfo; -import com.intellij.openapi.application.PathManager; +import com.intellij.openapi.application.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; @@ -35,6 +33,7 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ExceptionUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; @@ -101,11 +100,7 @@ public class CreateLauncherScriptAction extends DumbAwareAction { createLauncherScript(target.getAbsolutePath()); } catch (Exception e) { - LOG.warn(e); - String message = ExceptionUtil.getNonEmptyMessage(e, "Internal error"); - Notifications.Bus.notify( - new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Launcher Script Creation Failed", message, NotificationType.ERROR), - project); + reportFailure(e, project); } } @@ -145,6 +140,19 @@ public class CreateLauncherScriptAction extends DumbAwareAction { } } + public static void reportFailure(@NotNull Exception e, @Nullable final Project project) { + LOG.warn(e); + final String message = ExceptionUtil.getNonEmptyMessage(e, "Internal error"); + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + Notifications.Bus.notify( + new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Launcher Script Creation Failed", message, NotificationType.ERROR), + project); + } + }, ModalityState.NON_MODAL); + } + private static File createLauncherScriptFile() throws IOException, ExecutionException { String runPath = PathManager.getHomePath(); String productName = ApplicationNamesInfo.getInstance().getProductName().toLowerCase(Locale.US);