mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
remove invokeLater around notifications, as they have no threading requirements
This commit is contained in:
@@ -29,7 +29,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.xdebugger.impl.XDebugSessionImpl;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -72,15 +71,8 @@ public class InterruptThreadAction extends DebuggerAction{
|
||||
}
|
||||
if (unsupported) {
|
||||
final Project project = debugProcess.getProject();
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (!project.isDisposed()) {
|
||||
XDebugSessionImpl.NOTIFICATION_GROUP
|
||||
.createNotification("Thread operation 'interrupt' is not supported by VM", MessageType.INFO).notify(project);
|
||||
}
|
||||
}
|
||||
});
|
||||
XDebugSessionImpl.NOTIFICATION_GROUP
|
||||
.createNotification("Thread operation 'interrupt' is not supported by VM", MessageType.INFO).notify(project);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -82,13 +82,9 @@ public class CreateDesktopEntryAction extends DumbAwareAction {
|
||||
createDesktopEntry(globalEntry);
|
||||
|
||||
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);
|
||||
Notifications.Bus.notify(
|
||||
new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Desktop Entry Created", message, NotificationType.INFORMATION),
|
||||
getProject());
|
||||
}
|
||||
catch (Exception e) {
|
||||
reportFailure(e, getProject());
|
||||
@@ -116,14 +112,9 @@ 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);
|
||||
Notifications.Bus.notify(
|
||||
new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Desktop Entry Creation Failed", message, NotificationType.ERROR),
|
||||
project);
|
||||
}
|
||||
|
||||
private static void check() throws ExecutionException, InterruptedException {
|
||||
|
||||
@@ -143,14 +143,9 @@ 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);
|
||||
Notifications.Bus.notify(
|
||||
new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Launcher Script Creation Failed", message, NotificationType.ERROR),
|
||||
project);
|
||||
}
|
||||
|
||||
private static File createLauncherScriptFile() throws IOException, ExecutionException {
|
||||
|
||||
+13
-22
@@ -80,7 +80,7 @@ public class UpdateCheckerComponent implements ApplicationComponent {
|
||||
if (!ConfigImportHelper.isFirstSession()) {
|
||||
String title = IdeBundle.message("update.notifications.title");
|
||||
String message = IdeBundle.message("update.channel.enforced", ChannelStatus.EAP);
|
||||
notify(app, UpdateChecker.NOTIFICATIONS.createNotification(title, message, NotificationType.INFORMATION, null));
|
||||
UpdateChecker.NOTIFICATIONS.createNotification(title, message, NotificationType.INFORMATION, null).notify(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,18 +97,18 @@ public class UpdateCheckerComponent implements ApplicationComponent {
|
||||
boolean tooOld = !SystemInfo.isJavaVersionAtLeast("1.7");
|
||||
String title = IdeBundle.message("update.notifications.title");
|
||||
String message = IdeBundle.message(tooOld ? "update.sni.not.available.message" : "update.sni.disabled.message");
|
||||
notify(app, UpdateChecker.NOTIFICATIONS.createNotification(title, message, NotificationType.WARNING, new NotificationListener.Adapter() {
|
||||
@Override
|
||||
protected void hyperlinkActivated(@NotNull Notification notification1, @NotNull HyperlinkEvent e) {
|
||||
notification1.expire();
|
||||
app.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(null, UpdateSettingsConfigurable.class);
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
}
|
||||
}));
|
||||
UpdateChecker.NOTIFICATIONS.createNotification(title, message, NotificationType.WARNING, new NotificationListener.Adapter() {
|
||||
@Override
|
||||
protected void hyperlinkActivated(@NotNull Notification notification1, @NotNull HyperlinkEvent e) {
|
||||
notification1.expire();
|
||||
app.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(null, UpdateSettingsConfigurable.class);
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
}
|
||||
}).notify(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,15 +138,6 @@ public class UpdateCheckerComponent implements ApplicationComponent {
|
||||
myCheckForUpdatesAlarm.addRequest(myCheckRunnable, interval);
|
||||
}
|
||||
|
||||
private static void notify(Application app, final Notification notification) {
|
||||
app.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
notification.notify(null);
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
PluginsAdvertiser.ensureDeleted();
|
||||
|
||||
+16
-22
@@ -20,7 +20,6 @@ import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
@@ -209,28 +208,23 @@ public class EclipseImportBuilder extends ProjectImportBuilder<String> implement
|
||||
return false;
|
||||
}
|
||||
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
if (!naturesNames.isEmpty()) {
|
||||
final String title = "Unknown Natures Detected";
|
||||
final String naturesByProject;
|
||||
if (oneProjectToConvert) {
|
||||
naturesByProject = naturesNames.values().iterator().next();
|
||||
}
|
||||
else {
|
||||
naturesByProject = StringUtil.join(naturesNames.keySet(), new Function<String, String>() {
|
||||
@Override
|
||||
public String fun(String projectPath) {
|
||||
return projectPath + "(" + naturesNames.get(projectPath) + ")";
|
||||
}
|
||||
}, "<br>");
|
||||
}
|
||||
Notifications.Bus.notify(new Notification(title, title, "Imported projects contain unknown natures:<br>" + naturesByProject + "<br>" +
|
||||
"Some settings may be lost after import.", NotificationType.WARNING));
|
||||
}
|
||||
if (!naturesNames.isEmpty()) {
|
||||
final String title = "Unknown Natures Detected";
|
||||
final String naturesByProject;
|
||||
if (oneProjectToConvert) {
|
||||
naturesByProject = naturesNames.values().iterator().next();
|
||||
}
|
||||
};
|
||||
ApplicationManager.getApplication().invokeLater(runnable, ModalityState.NON_MODAL);
|
||||
else {
|
||||
naturesByProject = StringUtil.join(naturesNames.keySet(), new Function<String, String>() {
|
||||
@Override
|
||||
public String fun(String projectPath) {
|
||||
return projectPath + "(" + naturesNames.get(projectPath) + ")";
|
||||
}
|
||||
}, "<br>");
|
||||
}
|
||||
Notifications.Bus.notify(new Notification(title, title, "Imported projects contain unknown natures:<br>" + naturesByProject + "<br>" +
|
||||
"Some settings may be lost after import.", NotificationType.WARNING));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-7
@@ -20,7 +20,6 @@ import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.AppUIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -46,12 +45,7 @@ public class GradleNotification {
|
||||
@NotNull final String message,
|
||||
@NotNull final NotificationType type,
|
||||
@Nullable final NotificationListener listener) {
|
||||
AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NOTIFICATION_GROUP.createNotification(title, message, type, listener).notify(myProject);
|
||||
}
|
||||
});
|
||||
NOTIFICATION_GROUP.createNotification(title, message, type, listener).notify(myProject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-6
@@ -252,12 +252,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent
|
||||
@NotNull final NotificationGroup group,
|
||||
@NotNull final NotificationType type,
|
||||
@Nullable final NotificationListener listener) {
|
||||
AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
group.createNotification(title, message, type, listener).notify(myProject);
|
||||
}
|
||||
});
|
||||
group.createNotification(title, message, type, listener).notify(myProject);
|
||||
}
|
||||
|
||||
private void initMavenized() {
|
||||
|
||||
+5
-11
@@ -37,7 +37,6 @@ import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
import org.jetbrains.idea.maven.project.ProjectBundle;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -98,16 +97,11 @@ public class MavenAttachSourcesProvider implements AttachSourcesProvider {
|
||||
}
|
||||
message.append("</html>");
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Notifications.Bus.notify(new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP,
|
||||
"Cannot download sources",
|
||||
message.toString(),
|
||||
NotificationType.WARNING),
|
||||
psiFile.getProject());
|
||||
}
|
||||
});
|
||||
Notifications.Bus.notify(new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP,
|
||||
"Cannot download sources",
|
||||
message.toString(),
|
||||
NotificationType.WARNING),
|
||||
psiFile.getProject());
|
||||
}
|
||||
|
||||
if (downloadResult.resolvedSources.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user