diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginHostsConfigurable.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginHostsConfigurable.java index cd475ca6b940..b02f4a68d161 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginHostsConfigurable.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginHostsConfigurable.java @@ -18,18 +18,18 @@ package com.intellij.ide.plugins; import com.intellij.ide.IdeBundle; import com.intellij.openapi.options.BaseConfigurable; import com.intellij.openapi.options.ConfigurationException; -import com.intellij.openapi.options.SearchableConfigurable; +import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.ui.InputValidator; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.NonEmptyInputValidator; import com.intellij.openapi.updateSettings.impl.PluginDownloader; import com.intellij.openapi.updateSettings.impl.UpdateChecker; import com.intellij.openapi.updateSettings.impl.UpdateSettings; +import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.openapi.vfs.ex.http.HttpFileSystem; import com.intellij.ui.ListUtil; import com.intellij.ui.components.JBList; import com.intellij.util.ArrayUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -41,7 +41,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -public class PluginHostsConfigurable extends BaseConfigurable implements SearchableConfigurable { +public class PluginHostsConfigurable extends BaseConfigurable { private CustomPluginRepositoriesPanel myUpdatesSettingsPanel; public JComponent createComponent() { @@ -83,16 +83,6 @@ public class PluginHostsConfigurable extends BaseConfigurable implements Searcha myUpdatesSettingsPanel = null; } - @NotNull - public String getId() { - return "custom.repositories"; - } - - @Nullable - public Runnable enableSearch(String option) { - return null; - } - public Collection getPluginsHosts() { return myUpdatesSettingsPanel.getPluginsHosts(); } @@ -126,9 +116,9 @@ public class PluginHostsConfigurable extends BaseConfigurable implements Searcha Messages.getQuestionIcon(), "", new NonEmptyInputValidator()); dlg.show(); - final String input = dlg.getInputString(); + String input = dlg.getInputString(); if (input != null) { - ((DefaultListModel)myUrlsList.getModel()).addElement(input); + ((DefaultListModel)myUrlsList.getModel()).addElement(correctRepositoryRule(input)); } } }); @@ -168,6 +158,8 @@ public class PluginHostsConfigurable extends BaseConfigurable implements Searcha } + + public List getPluginsHosts() { final List result = new ArrayList(); for (int i = 0; i < myUrlsList.getModel().getSize(); i++) { @@ -185,6 +177,14 @@ public class PluginHostsConfigurable extends BaseConfigurable implements Searcha } } + private static String correctRepositoryRule(String input) { + String protocol = VirtualFileManager.extractProtocol(input); + if (protocol == null) { + input = VirtualFileManager.constructUrl(HttpFileSystem.PROTOCOL, input); + } + return input; + } + public static class HostMessages extends Messages { public static class InputHostDialog extends InputDialog { @@ -201,17 +201,29 @@ public class PluginHostsConfigurable extends BaseConfigurable implements Searcha final Action[] actions = super.createActions(); return ArrayUtil.append(actions, new AbstractAction("Check Now") { public void actionPerformed(final ActionEvent e) { - try { - if (UpdateChecker.checkPluginsHost(getTextField().getText(), new ArrayList())) { - showInfoMessage(myField, "Plugins Host was successfully checked", "Check Plugins Host"); + final boolean [] result = new boolean[1]; + final Exception [] ex = new Exception[1]; + if (ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { + @Override + public void run() { + try { + result[0] = UpdateChecker.checkPluginsHost(correctRepositoryRule(getTextField().getText()), new ArrayList()); + } + catch (Exception e1) { + ex[0] = e1; + } + } + }, "Checking plugins repository...", true, null, getPreferredFocusedComponent())) { + if (ex[0] != null) { + showErrorDialog(myField, "Connection failed: " + ex[0].getMessage()); + } + else if (result[0]) { + showInfoMessage(myField, "Plugins repository was successfully checked", "Check Plugins Repository"); } else { showErrorDialog(myField, "Plugin descriptions contain some errors. Please, check idea.log for details."); } } - catch (Exception e1) { - showErrorDialog(myField, "Connection failed: " + e1.getMessage()); - } } }); } diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index 04d7e8d5ba21..ed9d1eb955ec 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -1015,11 +1015,11 @@ project.new.wizard.project.identification=project project.new.wizard.module.identification=module changelist.todo.title={0} Changelist hierarchy.scope.test=Test -update.plugin.host.url.message=Plugin Host URL -update.no.update.hosts=No plugin hosts configured -update.edit.plugin.host.title=Edit plugin host -update.add.new.plugin.host.title=Add new plugin host -update.plugin.hosts.title=Plugin Hosts +update.plugin.host.url.message=Plugin repository URL +update.no.update.hosts=No plugin repositories configured +update.edit.plugin.host.title=Edit plugin repository URL +update.add.new.plugin.host.title=Add new plugin repository URL +update.plugin.hosts.title=Plugin Repositories update.uploading.plugin.progress.title=Updating Plugins update.downloading.patch.progress.title=Downloading Patch file file.structure.toggle.show.inherited=&Show inherited members