diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java index 1f251d283317..dedb0115464f 100644 --- a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java +++ b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java @@ -204,16 +204,27 @@ public class IdeaApplication { }, ModalityState.NON_MODAL); } - private void updatePlugins(boolean showConfirmation) { - final CheckForUpdateResult checkForUpdateResult = UpdateChecker.checkForUpdates(); + private void updatePlugins(final boolean showConfirmation) { + final Application app = ApplicationManager.getApplication(); + app.executeOnPooledThread(new Runnable() { + @Override + public void run() { + final CheckForUpdateResult checkForUpdateResult = UpdateChecker.checkForUpdates(); - final List updatedPlugins = UpdateChecker.updatePlugins(false, null); - if (checkForUpdateResult.hasNewBuildInSelectedChannel()) { - UpdateChecker.showUpdateInfoDialog(true, checkForUpdateResult.getUpdatedChannel(), updatedPlugins); - } - else if (updatedPlugins != null) { - UpdateChecker.showNoUpdatesDialog(true, updatedPlugins, showConfirmation); - } + final List updatedPlugins = UpdateChecker.updatePlugins(false, null); + app.invokeLater(new Runnable() { + @Override + public void run() { + if (checkForUpdateResult.hasNewBuildInSelectedChannel()) { + UpdateChecker.showUpdateInfoDialog(true, checkForUpdateResult.getUpdatedChannel(), updatedPlugins); + } + else if (updatedPlugins != null) { + UpdateChecker.showNoUpdatesDialog(true, updatedPlugins, showConfirmation); + } + } + }); + } + }); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java index 9cbdd80be9a3..e8578b64a569 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/CheckForUpdateAction.java @@ -17,8 +17,15 @@ package com.intellij.openapi.updateSettings.impl; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.SystemInfo; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -30,34 +37,37 @@ public class CheckForUpdateAction extends AnAction implements DumbAware { } public void actionPerformed(AnActionEvent e) { - actionPerformed(true, null); + Project project = e.getData(PlatformDataKeys.PROJECT); + actionPerformed(project, true, null); } - public static void actionPerformed(final boolean enableLink, final @Nullable UpdateSettingsConfigurable settingsConfigurable) { - final CheckForUpdateResult result = UpdateChecker.checkForUpdates(); - - final List updatedPlugins = UpdateChecker.updatePlugins(true, settingsConfigurable); - - - if (result.getState() == UpdateStrategy.State.CONNECTION_ERROR) { - UpdateChecker.showConnectionErrorDialog(); - return; - } - - if (result.getState() != UpdateStrategy.State.LOADED) { - //not a connection error... something happened but user has nothing to do with it - return; - } - - if (result.hasNewBuildInSelectedChannel()) { - //information about new channel could be there - UpdateSettings.getInstance().LAST_TIME_CHECKED = System.currentTimeMillis(); - UpdateChecker.showUpdateInfoDialog(enableLink, result.getUpdatedChannel(), updatedPlugins); - }else{ - //information about new channel could be there - UpdateChecker.showNoUpdatesDialog(enableLink, updatedPlugins, true); - } + public static void actionPerformed(Project project, final boolean enableLink, final @Nullable UpdateSettingsConfigurable settingsConfigurable) { + ProgressManager.getInstance().run(new Task.Backgroundable(project, "Checking for updates", false) { + @Override + public void run(@NotNull ProgressIndicator indicator) { + final CheckForUpdateResult result = UpdateChecker.checkForUpdates(); + final List updatedPlugins = UpdateChecker.updatePlugins(true, settingsConfigurable); + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + if (result.getState() == UpdateStrategy.State.CONNECTION_ERROR) { + UpdateChecker.showConnectionErrorDialog(); + return; + } + if (result.hasNewBuildInSelectedChannel()) { + //information about new channel could be there + UpdateSettings.getInstance().LAST_TIME_CHECKED = System.currentTimeMillis(); + UpdateChecker.showUpdateInfoDialog(enableLink, result.getUpdatedChannel(), updatedPlugins); + } + else { + //information about new channel could be there + UpdateChecker.showNoUpdatesDialog(enableLink, updatedPlugins, true); + } + } + }); + } + }); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java index 8b62851ebd24..eacb72bc189c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java @@ -15,17 +15,19 @@ */ package com.intellij.openapi.updateSettings.impl; +import com.intellij.ide.DataManager; import com.intellij.ide.IdeBundle; +import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationInfo; import com.intellij.openapi.options.BaseConfigurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; +import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.InputValidator; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.NonEmptyInputValidator; import com.intellij.openapi.util.IconLoader; import com.intellij.ui.CollectionComboBoxModel; -import com.intellij.ui.EnumComboBoxModel; import com.intellij.ui.ListUtil; import com.intellij.ui.components.JBList; import com.intellij.util.ArrayUtil; @@ -138,7 +140,8 @@ public class UpdateSettingsConfigurable extends BaseConfigurable implements Sear myBtnCheckNow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - CheckForUpdateAction.actionPerformed(false, UpdateSettingsConfigurable.this); + Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myBtnCheckNow)); + CheckForUpdateAction.actionPerformed(project, false, UpdateSettingsConfigurable.this); updateLastCheckedLabel(); } });