diff --git a/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java b/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java index 55e5fbbb9487..e4fe9911030c 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java +++ b/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java @@ -100,7 +100,7 @@ public class JarRepositoryManager { final String copyTo = dialog.getDirectoryPath(); final NewLibraryConfiguration config = resolveAndDownload( - project, coord, attachSources, attachJavaDoc, copyTo, RemoteRepositoryDescription.DEFAULT_REPOSITORIES + project, coord, attachSources, attachJavaDoc, copyTo, RemoteRepositoriesConfiguration.getInstance(project).getRepositories() ); if (config == null) { Messages.showErrorDialog(parentComponent, "No files were downloaded for " + coord, CommonBundle.getErrorTitle()); @@ -184,7 +184,7 @@ public class JarRepositoryManager { final JpsMavenRepositoryLibraryDescriptor libDescriptor = new JpsMavenRepositoryLibraryDescriptor(libraryProps.getGroupId(), libraryProps.getArtifactId(), libraryProps.getVersion()); if (libDescriptor.getMavenId() != null) { if (repositories == null || repositories.isEmpty()) { - repositories = RepositoryLibraryDescription.findDescription(libDescriptor).getRemoteRepositories(); + repositories = RemoteRepositoriesConfiguration.getInstance(project).getRepositories(); } if (!repositories.isEmpty()) { final EnumSet kinds = EnumSet.of(ArtifactKind.ARTIFACT); @@ -235,7 +235,7 @@ public class JarRepositoryManager { public static void loadDependenciesAsync(Project project, JpsMavenRepositoryLibraryDescriptor desc, final Set artifactKinds, @Nullable List repos, @Nullable String copyTo, Consumer> resultProcessor) { if (repos == null || repos.isEmpty()) { - repos = RepositoryLibraryDescription.findDescription(desc).getRemoteRepositories(); + repos = RemoteRepositoriesConfiguration.getInstance(project).getRepositories(); } submitBackgroundJob( project, "Resolving Maven dependencies...", newOrderRootResolveJob(desc, artifactKinds, repos, copyTo).andThen( @@ -247,7 +247,7 @@ public class JarRepositoryManager { } public static void getAvailableVersionsAsync(Project project, RepositoryLibraryDescription libraryDescription, Consumer> resultProcessor) { - final List repos = libraryDescription.getRemoteRepositories(); + final List repos = RemoteRepositoriesConfiguration.getInstance(project).getRepositories(); submitBackgroundJob(project, "Looking up available versions for " + libraryDescription.getDisplayName(), new VersionResolveJob(libraryDescription, repos) .andThen( versions -> { @@ -259,7 +259,7 @@ public class JarRepositoryManager { @NotNull public static Future> getAvailableVersions(Project project, RepositoryLibraryDescription libraryDescription) { - final List repos = libraryDescription.getRemoteRepositories(); + final List repos = RemoteRepositoriesConfiguration.getInstance(project).getRepositories(); return submitBackgroundJob(project, "Looking up available versions for " + libraryDescription.getDisplayName(), new VersionResolveJob(libraryDescription, repos)); } @@ -292,7 +292,7 @@ public class JarRepositoryManager { public void run(@NotNull ProgressIndicator indicator) { final List> resultList = new ArrayList<>(); try { - for (String serviceUrl : MavenRepositoryServicesManager.getServiceUrls()) { + for (String serviceUrl : MavenRepositoryServicesManager.getServiceUrls(project)) { try { final List artifacts = MavenRepositoryServicesManager.findArtifacts(template, serviceUrl); if (!artifacts.isEmpty()) { diff --git a/java/idea-ui/src/com/intellij/jarRepository/settings/RemoteRepositoriesConfigurable.form b/java/idea-ui/src/com/intellij/jarRepository/settings/RemoteRepositoriesConfigurable.form new file mode 100644 index 000000000000..8c45e8bbbec1 --- /dev/null +++ b/java/idea-ui/src/com/intellij/jarRepository/settings/RemoteRepositoriesConfigurable.form @@ -0,0 +1,173 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/java/idea-ui/src/com/intellij/jarRepository/settings/RemoteRepositoriesConfigurable.java b/java/idea-ui/src/com/intellij/jarRepository/settings/RemoteRepositoriesConfigurable.java new file mode 100644 index 000000000000..5131e6a2b055 --- /dev/null +++ b/java/idea-ui/src/com/intellij/jarRepository/settings/RemoteRepositoriesConfigurable.java @@ -0,0 +1,253 @@ +/* + * Copyright 2000-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.jarRepository.settings; + +import com.intellij.jarRepository.JarRepositoryManager; +import com.intellij.jarRepository.RemoteRepositoriesConfiguration; +import com.intellij.jarRepository.RemoteRepositoryDescription; +import com.intellij.jarRepository.services.MavenRepositoryServicesManager; +import com.intellij.openapi.options.BaseConfigurable; +import com.intellij.openapi.options.Configurable; +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.util.text.StringUtil; +import com.intellij.ui.CollectionListModel; +import com.intellij.ui.ListUtil; +import com.intellij.ui.components.JBList; +import com.intellij.util.SmartList; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.*; + +public class RemoteRepositoriesConfigurable extends BaseConfigurable implements SearchableConfigurable, Configurable.NoScroll { + + private JPanel myMainPanel; + + private JBList myServiceList; + private JButton myAddServiceButton; + private JButton myEditServiceButton; + private JButton myRemoveServiceButton; + private JButton myTestServiceButton; + + private JBList myJarRepositoryList; + private JButton myAddRepoButton; + private JButton myEditRepoButton; + private JButton myRemoveRepoButton; + private JButton myResetToDefaultReposButton; + private JButton myResetToDefaultServicesButton; + + private final Project myProject; + private final CollectionListModel myServicesModel = new CollectionListModel<>(); + private final CollectionListModel myReposModel = new CollectionListModel<>(); + + public RemoteRepositoriesConfigurable(Project project) { + myProject = project; + configControls(); + } + + @Override + public boolean isModified() { + return isServiceListModified() || isRepoListModified(); + } + + private boolean isServiceListModified() { + return !myServicesModel.getItems().equals(MavenRepositoryServicesManager.getInstance(myProject).getUrls()); + } + + private boolean isRepoListModified() { + final List urls = new SmartList<>(); + for (RemoteRepositoryDescription repository : RemoteRepositoriesConfiguration.getInstance(myProject).getRepositories()) { + urls.add(repository.getUrl()); + } + return !myReposModel.getItems().equals(urls); + } + + private void configControls() { + setupListControls( + myServiceList, myServicesModel, myAddServiceButton, myEditServiceButton, myRemoveServiceButton, + "Artifactory or Nexus Service URL", "Service URL", "No services" + ); + setupListControls( + myJarRepositoryList, myReposModel, myAddRepoButton, myEditRepoButton, myRemoveRepoButton, + "Maven Repository URL", "maven Repository URL", "No remote repositories" + ); + + ListUtil.disableWhenNoSelection(myTestServiceButton, myServiceList); + myTestServiceButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final String value = myServiceList.getSelectedValue(); + if (!StringUtil.isEmpty(value)) { + myTestServiceButton.setEnabled(false); + JarRepositoryManager.searchRepositories(myProject, Collections.singletonList(value), infos -> { + myTestServiceButton.setEnabled(true); + if (infos.isEmpty()) { + Messages.showMessageDialog("No repositories found", "Service Connection Failed", Messages.getWarningIcon()); + } + else { + final StringBuilder sb = new StringBuilder(); + sb.append(infos.size()).append(infos.size() == 1 ? "repository" : " repositories").append(" found"); + //for (MavenRepositoryInfo info : infos) { + // sb.append("\n "); + // sb.append(info.getId()).append(" (").append(info.getName()).append(")").append(": ").append(info.getUrl()); + //} + Messages.showMessageDialog(sb.toString(), "Service Connection Successful", Messages.getInformationIcon()); + } + return true; + }); + } + } + }); + myResetToDefaultReposButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + resetReposModel(RemoteRepositoryDescription.DEFAULT_REPOSITORIES); + } + }); + myResetToDefaultServicesButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + resetServicesModel(MavenRepositoryServicesManager.DEFAULT_SERVICES); + } + }); + } + + private static void setupListControls(final JBList list, + final CollectionListModel model, + final JButton addButton, + final JButton editButton, + final JButton removeButton, + final String modificationDialogTitle, + final String modificationDialogHint, + final String emptyListHint) { + list.setModel(model); + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + addButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final String value = list.getSelectedValue(); + final String text = Messages.showInputDialog( + modificationDialogTitle, "Add" + " " + modificationDialogHint, Messages.getQuestionIcon(), value == null ? "https://" : value, new URLInputVaslidator() + ); + if (StringUtil.isNotEmpty(text)) { + model.add(text); + list.setSelectedValue(text, true); + } + } + }); + editButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final int index = list.getSelectedIndex(); + final String text = Messages.showInputDialog( + modificationDialogTitle, "Edit" + " " + modificationDialogHint, Messages.getQuestionIcon(), model.getElementAt(index), new URLInputVaslidator() + ); + if (StringUtil.isNotEmpty(text)) { + model.setElementAt(text, index); + } + } + }); + ListUtil.addRemoveListener(removeButton, list); + ListUtil.disableWhenNoSelection(editButton, list); + list.getEmptyText().setText(emptyListHint); + } + + + public String getDisplayName() { + return "Remote Jar Repositories"; + } + + public String getHelpTopic() { + return ""; // todo + } + + @NotNull + public String getId() { + return getClass().getName(); + } + + public JComponent createComponent() { + return myMainPanel; + } + + public void apply() throws ConfigurationException { + MavenRepositoryServicesManager.getInstance(myProject).setUrls(myServicesModel.getItems()); + + final Map defaultRepos = new HashMap<>(); + for (RemoteRepositoryDescription repository : RemoteRepositoryDescription.DEFAULT_REPOSITORIES) { + defaultRepos.put(repository.getUrl(), repository); + } + final List descriptions = new SmartList<>(); + for (String url : myReposModel.getItems()) { + final RemoteRepositoryDescription def = defaultRepos.get(url); + if (def != null) { + descriptions.add(def); + } + else { + final UUID uuid = UUID.randomUUID(); + descriptions.add(new RemoteRepositoryDescription(uuid.toString(), uuid.toString(), url)); + } + } + RemoteRepositoriesConfiguration.getInstance(myProject).setRepositories(descriptions); + } + + public void reset() { + resetServicesModel(MavenRepositoryServicesManager.getInstance(myProject).getUrls()); + resetReposModel(RemoteRepositoriesConfiguration.getInstance(myProject).getRepositories()); + } + + private void resetServicesModel(final List urls) { + myServicesModel.removeAll(); + myServicesModel.add(urls); + } + + private void resetReposModel(final List repositories) { + myReposModel.removeAll(); + final List repos = new SmartList<>(); + for (RemoteRepositoryDescription description : repositories) { + repos.add(description.getUrl()); + } + myReposModel.add(repos); + } + + public void disposeUIResources() { + } + + private static final class URLInputVaslidator implements InputValidator { + @Override + public boolean checkInput(String inputString) { + try { + return StringUtil.isNotEmpty(new URL(inputString).getHost()); + } + catch (MalformedURLException e) { + return false; + } + } + + @Override + public boolean canClose(String inputString) { + return checkInput(inputString); + } + } +} diff --git a/java/java-impl/src/com/intellij/jarRepository/RemoteRepositoriesConfiguration.java b/java/java-impl/src/com/intellij/jarRepository/RemoteRepositoriesConfiguration.java new file mode 100644 index 000000000000..190c4a3f88a5 --- /dev/null +++ b/java/java-impl/src/com/intellij/jarRepository/RemoteRepositoriesConfiguration.java @@ -0,0 +1,174 @@ +/* + * Copyright 2000-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.jarRepository; + +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; +import com.intellij.openapi.project.Project; +import com.intellij.util.SmartList; +import com.intellij.util.xmlb.annotations.AbstractCollection; +import com.intellij.util.xmlb.annotations.Property; +import com.intellij.util.xmlb.annotations.Tag; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +/** + * @author Eugene Zhuravlev + * Date: 24-Apr-17 + */ +@State(name = "RemoteRepositoriesConfiguration", storages = @Storage("jarRepositories.xml")) +public class RemoteRepositoriesConfiguration implements PersistentStateComponent { + private final List myRepositories = new SmartList<>(); + + public RemoteRepositoriesConfiguration() { + this(RemoteRepositoryDescription.DEFAULT_REPOSITORIES); + } + + public RemoteRepositoriesConfiguration(Collection repos) { + myRepositories.addAll(repos); + } + + @NotNull + public static RemoteRepositoriesConfiguration getInstance(Project project) { + return ServiceManager.getService(project, RemoteRepositoriesConfiguration.class); + } + + @NotNull + public List getRepositories() { + return Collections.unmodifiableList(myRepositories); + } + + public void resetToDefault() { + setRepositories(Collections.emptyList()); + } + + public void setRepositories(@NotNull List repos) { + myRepositories.clear(); + myRepositories.addAll(repos.isEmpty()? RemoteRepositoryDescription.DEFAULT_REPOSITORIES : repos); + } + + @Nullable + @Override + public RemoteRepositoriesConfiguration.State getState() { + return new State(myRepositories); + } + + @Override + public void loadState(RemoteRepositoriesConfiguration.State state) { + final List loaded = new SmartList<>(); + if (state.data != null) { + for (State.Repo repo : state.data) { + loaded.add(new RemoteRepositoryDescription(repo.id, repo.name, repo.url)); + } + } + setRepositories(loaded); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + RemoteRepositoriesConfiguration that = (RemoteRepositoriesConfiguration)o; + + if (!myRepositories.equals(that.myRepositories)) return false; + + return true; + } + + @Override + public int hashCode() { + return myRepositories.hashCode(); + } + + static class State { + @Tag("remote-repository") + static class Repo{ + public String id; + public String name; + public String url; + + public Repo() { + } + + public Repo(String id, String name, String url) { + this.id = id; + this.name = name; + this.url = url; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Repo repo = (Repo)o; + + if (id != null ? !id.equals(repo.id) : repo.id != null) return false; + if (name != null ? !name.equals(repo.name) : repo.name != null) return false; + if (url != null ? !url.equals(repo.url) : repo.url != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (name != null ? name.hashCode() : 0); + result = 31 * result + (url != null ? url.hashCode() : 0); + return result; + } + } + + @NotNull + @Property(surroundWithTag = false) + @AbstractCollection(surroundWithTag = false, elementTypes = Repo.class) + public final List data = new SmartList<>(); + + public State() { + this(RemoteRepositoryDescription.DEFAULT_REPOSITORIES); + } + + public State(List repos) { + for (RemoteRepositoryDescription repository : repos) { + data.add(new Repo(repository.getId(), repository.getName(), repository.getUrl())); + } + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + State state = (State)o; + + if (!data.equals(state.data)) return false; + + return true; + } + + @Override + public int hashCode() { + return data.hashCode(); + } + } +} diff --git a/java/java-impl/src/com/intellij/jarRepository/services/MavenRepositoryServicesManager.java b/java/java-impl/src/com/intellij/jarRepository/services/MavenRepositoryServicesManager.java index 8d7e862ba8ae..425984ed9241 100644 --- a/java/java-impl/src/com/intellij/jarRepository/services/MavenRepositoryServicesManager.java +++ b/java/java-impl/src/com/intellij/jarRepository/services/MavenRepositoryServicesManager.java @@ -24,6 +24,7 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.project.Project; import com.intellij.util.ArrayUtil; import com.intellij.util.SmartList; import com.intellij.util.xmlb.annotations.AbstractCollection; @@ -32,6 +33,8 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; /** @@ -45,15 +48,21 @@ public class MavenRepositoryServicesManager implements PersistentStateComponent< private static final Logger LOG = Logger.getInstance("#com.intellij.repository.services.MavenRepositoryServicesManager"); private final List myUrls = new ArrayList<>(); + public static final List DEFAULT_SERVICES = Collections.unmodifiableList(Arrays.asList( + "https://oss.sonatype.org/service/local/", + "http://repo.jfrog.org/artifactory/api/", + "https://repository.jboss.org/nexus/service/local/" + )); + public MavenRepositoryServicesManager() { - myUrls.add("https://oss.sonatype.org/service/local/"); - myUrls.add("http://repo.jfrog.org/artifactory/api/"); - myUrls.add("https://repository.jboss.org/nexus/service/local/"); + for (String s : DEFAULT_SERVICES) { + myUrls.add(s); + } } @NotNull - public static MavenRepositoryServicesManager getInstance() { - return ServiceManager.getService(MavenRepositoryServicesManager.class); + public static MavenRepositoryServicesManager getInstance(Project project) { + return ServiceManager.getService(project, MavenRepositoryServicesManager.class); } @NotNull @@ -61,8 +70,8 @@ public class MavenRepositoryServicesManager implements PersistentStateComponent< return new MavenRepositoryService[]{new NexusRepositoryService(), new ArtifactoryRepositoryService()}; } - public static String[] getServiceUrls() { - return ArrayUtil.toStringArray(getInstance().getUrls()); + public static String[] getServiceUrls(final Project project) { + return ArrayUtil.toStringArray(getInstance(project).getUrls()); } @NotNull diff --git a/java/openapi/src/org/jetbrains/idea/maven/utils/library/RepositoryLibraryDescription.java b/java/openapi/src/org/jetbrains/idea/maven/utils/library/RepositoryLibraryDescription.java index f5a0aef9f95c..8cbe3dd40523 100644 --- a/java/openapi/src/org/jetbrains/idea/maven/utils/library/RepositoryLibraryDescription.java +++ b/java/openapi/src/org/jetbrains/idea/maven/utils/library/RepositoryLibraryDescription.java @@ -15,7 +15,6 @@ */ package org.jetbrains.idea.maven.utils.library; -import com.intellij.jarRepository.RemoteRepositoryDescription; import com.intellij.jarRepository.RepositoryLibraryDefinition; import com.intellij.openapi.roots.DependencyScope; import com.intellij.util.containers.HashMap; @@ -26,7 +25,6 @@ import org.jetbrains.jps.model.library.JpsMavenRepositoryLibraryDescriptor; import javax.swing.*; import java.util.Collections; -import java.util.List; import java.util.Map; public class RepositoryLibraryDescription { @@ -107,11 +105,6 @@ public class RepositoryLibraryDescription { return null; } - @NotNull - public List getRemoteRepositories() { - return RemoteRepositoryDescription.DEFAULT_REPOSITORIES; - } - // One library could have more then one description - for ex. in different plugins // In this case heaviest description will be used public int getWeight() { diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/dependencies/DependencyResolvingBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/dependencies/DependencyResolvingBuilder.java index 788be2cbbe42..e5596a3f934e 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/dependencies/DependencyResolvingBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/dependencies/DependencyResolvingBuilder.java @@ -18,10 +18,12 @@ package org.jetbrains.jps.incremental.dependencies; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.SmartHashSet; import gnu.trove.THashMap; import gnu.trove.THashSet; +import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.transfer.TransferCancelledException; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.maven.aether.ArtifactRepositoryManager; @@ -35,6 +37,8 @@ import org.jetbrains.jps.incremental.messages.BuildMessage; import org.jetbrains.jps.incremental.messages.CompilerMessage; import org.jetbrains.jps.incremental.messages.ProgressMessage; import org.jetbrains.jps.model.JpsSimpleElement; +import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryDescription; +import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryService; import org.jetbrains.jps.model.library.*; import org.jetbrains.jps.model.module.JpsDependencyElement; import org.jetbrains.jps.model.module.JpsLibraryDependency; @@ -244,7 +248,13 @@ public class DependencyResolvingBuilder extends ModuleLevelBuilder{ private static ArtifactRepositoryManager getRepositoryManager(final CompileContext context) { ArtifactRepositoryManager manager = MANAGER_KEY.get(context); if (manager == null) { - manager = new ArtifactRepositoryManager(getLocalRepoDir(context), new ProgressConsumer() { + + final List repositories = new SmartList<>(); + for (JpsRemoteRepositoryDescription repo : JpsRemoteRepositoryService.getInstance().getOrCreateRemoteRepositoriesConfiguration(context.getProjectDescriptor().getProject()) + .getRepositories()) { + repositories.add(ArtifactRepositoryManager.createRemoteRepository(repo.getId(), repo.getUrl())); + } + manager = new ArtifactRepositoryManager(getLocalRepoDir(context), repositories, new ProgressConsumer() { public void consume(String message) { context.processMessage(new ProgressMessage(message)); } diff --git a/jps/model-api/src/org/jetbrains/jps/model/jarRepository/JpsRemoteRepositoriesConfiguration.java b/jps/model-api/src/org/jetbrains/jps/model/jarRepository/JpsRemoteRepositoriesConfiguration.java new file mode 100644 index 000000000000..0749d71a8857 --- /dev/null +++ b/jps/model-api/src/org/jetbrains/jps/model/jarRepository/JpsRemoteRepositoriesConfiguration.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.jps.model.jarRepository; + +import org.jetbrains.jps.model.JpsElement; + +import java.util.List; + +/** + * @author Eugene Zhuravlev + * Date: 25-Apr-17 + */ +public interface JpsRemoteRepositoriesConfiguration extends JpsElement { + List getRepositories(); + void setRepositories(List repositories); +} diff --git a/jps/model-api/src/org/jetbrains/jps/model/jarRepository/JpsRemoteRepositoryDescription.java b/jps/model-api/src/org/jetbrains/jps/model/jarRepository/JpsRemoteRepositoryDescription.java new file mode 100644 index 000000000000..f710d61b8a76 --- /dev/null +++ b/jps/model-api/src/org/jetbrains/jps/model/jarRepository/JpsRemoteRepositoryDescription.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.jps.model.jarRepository; + +/** + * @author Eugene Zhuravlev + * Date: 25-Apr-17 + */ +public class JpsRemoteRepositoryDescription { + private final String myId; + private final String myName; + private final String myUrl; + + public JpsRemoteRepositoryDescription(String id, String name, String url) { + myId = id; + myName = name; + myUrl = url; + } + + public String getId() { + return myId; + } + + public String getName() { + return myName; + } + + public String getUrl() { + return myUrl; + } +} diff --git a/jps/model-api/src/org/jetbrains/jps/model/jarRepository/JpsRemoteRepositoryService.java b/jps/model-api/src/org/jetbrains/jps/model/jarRepository/JpsRemoteRepositoryService.java new file mode 100644 index 000000000000..5969e5675d17 --- /dev/null +++ b/jps/model-api/src/org/jetbrains/jps/model/jarRepository/JpsRemoteRepositoryService.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.jps.model.jarRepository; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jps.model.JpsProject; +import org.jetbrains.jps.service.JpsServiceManager; + +/** + * @author Eugene Zhuravlev + * Date: 25-Apr-17 + */ +public abstract class JpsRemoteRepositoryService { + public static JpsRemoteRepositoryService getInstance() { + return JpsServiceManager.getInstance().getService(JpsRemoteRepositoryService.class); + } + + @Nullable + public abstract JpsRemoteRepositoriesConfiguration getRemoteRepositoriesConfiguration(@NotNull JpsProject project); + + @NotNull + public abstract JpsRemoteRepositoriesConfiguration getOrCreateRemoteRepositoriesConfiguration(@NotNull JpsProject project); +} diff --git a/jps/model-impl/src/META-INF/services/org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryService b/jps/model-impl/src/META-INF/services/org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryService new file mode 100644 index 000000000000..94dc7982755c --- /dev/null +++ b/jps/model-impl/src/META-INF/services/org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryService @@ -0,0 +1,16 @@ +# +# Copyright 2000-2017 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +org.jetbrains.jps.model.jarRepository.impl.JpsRemoteRepositoryServiceImpl \ No newline at end of file diff --git a/jps/model-impl/src/org/jetbrains/jps/model/jarRepository/impl/JpsRemoteRepositoriesConfigurationImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/jarRepository/impl/JpsRemoteRepositoriesConfigurationImpl.java new file mode 100644 index 000000000000..a77355cfd38e --- /dev/null +++ b/jps/model-impl/src/org/jetbrains/jps/model/jarRepository/impl/JpsRemoteRepositoriesConfigurationImpl.java @@ -0,0 +1,71 @@ +/* + * Copyright 2000-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.jps.model.jarRepository.impl; + +import com.intellij.util.SmartList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.model.JpsElementChildRole; +import org.jetbrains.jps.model.ex.JpsElementBase; +import org.jetbrains.jps.model.ex.JpsElementChildRoleBase; +import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoriesConfiguration; +import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryDescription; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * @author Eugene Zhuravlev + * Date: 25-Apr-17 + */ +public class JpsRemoteRepositoriesConfigurationImpl extends JpsElementBase implements JpsRemoteRepositoriesConfiguration{ + public static final JpsElementChildRole ROLE = JpsElementChildRoleBase.create("remote repositories configuration"); + + private final List myRepositories = new SmartList<>(); + + public JpsRemoteRepositoriesConfigurationImpl() { + this(Arrays.asList( // defaults + new JpsRemoteRepositoryDescription("central", "Maven Central repository", "https://repo1.maven.org/maven2"), + new JpsRemoteRepositoryDescription("jboss.community", "JBoss Community repository", "https://repository.jboss.org/nexus/content/repositories/public/") + )); + } + + public JpsRemoteRepositoriesConfigurationImpl(List repositories) { + myRepositories.addAll(repositories); + } + + @NotNull + @Override + public JpsRemoteRepositoriesConfigurationImpl createCopy() { + return new JpsRemoteRepositoriesConfigurationImpl(myRepositories); + } + + @Override + public void applyChanges(@NotNull JpsRemoteRepositoriesConfigurationImpl modified) { + setRepositories(modified.getRepositories()); + } + + @Override + public List getRepositories() { + return Collections.unmodifiableList(myRepositories); + } + + @Override + public void setRepositories(List repositories) { + myRepositories.clear(); + myRepositories.addAll(repositories); + } +} diff --git a/jps/model-impl/src/org/jetbrains/jps/model/jarRepository/impl/JpsRemoteRepositoryServiceImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/jarRepository/impl/JpsRemoteRepositoryServiceImpl.java new file mode 100644 index 000000000000..65d0ff8c88cc --- /dev/null +++ b/jps/model-impl/src/org/jetbrains/jps/model/jarRepository/impl/JpsRemoteRepositoryServiceImpl.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.jps.model.jarRepository.impl; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jps.model.JpsProject; +import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoriesConfiguration; +import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryService; + +/** + * @author Eugene Zhuravlev + * Date: 25-Apr-17 + */ +public class JpsRemoteRepositoryServiceImpl extends JpsRemoteRepositoryService { + @Nullable + @Override + public JpsRemoteRepositoriesConfiguration getRemoteRepositoriesConfiguration(@NotNull JpsProject project) { + return project.getContainer().getChild(JpsRemoteRepositoriesConfigurationImpl.ROLE); + } + + @NotNull + @Override + public JpsRemoteRepositoriesConfiguration getOrCreateRemoteRepositoriesConfiguration(@NotNull JpsProject project) { + JpsRemoteRepositoriesConfiguration config = getRemoteRepositoriesConfiguration(project); + if (config == null) { + config = project.getContainer().setChild(JpsRemoteRepositoriesConfigurationImpl.ROLE, new JpsRemoteRepositoriesConfigurationImpl()); + } + return config; + } +} diff --git a/jps/model-serialization/src/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelSerializerExtension b/jps/model-serialization/src/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelSerializerExtension index b68edbaed243..2c11f586c759 100644 --- a/jps/model-serialization/src/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelSerializerExtension +++ b/jps/model-serialization/src/META-INF/services/org.jetbrains.jps.model.serialization.JpsModelSerializerExtension @@ -1,2 +1,3 @@ org.jetbrains.jps.model.serialization.java.JpsJavaModelSerializerExtension -org.jetbrains.jps.model.serialization.JpsEncodingModelSerializerExtension \ No newline at end of file +org.jetbrains.jps.model.serialization.JpsEncodingModelSerializerExtension +org.jetbrains.jps.model.serialization.jarRepository.JpsRemoteRepositoriesModelSerializerExtension \ No newline at end of file diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/jarRepository/JpsRemoteRepositoriesConfigurationSerializer.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/jarRepository/JpsRemoteRepositoriesConfigurationSerializer.java new file mode 100644 index 000000000000..6b607a4feb79 --- /dev/null +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/jarRepository/JpsRemoteRepositoriesConfigurationSerializer.java @@ -0,0 +1,79 @@ +/* + * Copyright 2000-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.jps.model.serialization.jarRepository; + +import com.intellij.util.SmartList; +import org.jdom.Element; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.model.JpsProject; +import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoriesConfiguration; +import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryDescription; +import org.jetbrains.jps.model.jarRepository.JpsRemoteRepositoryService; +import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer; + +import java.util.List; + +/** + * @author Eugene Zhuravlev + * Date: 25-Apr-17 + */ +public class JpsRemoteRepositoriesConfigurationSerializer extends JpsProjectExtensionSerializer { + private static final String ELEMENT_TAG = "remote-repository"; + private static final String OPTION_TAG = "option"; + private static final String ID_PROPERTY = "id"; + private static final String NAME_PROPERTY = "name"; + private static final String URL_PROPERTY = "url"; + + public JpsRemoteRepositoriesConfigurationSerializer() { + super("jarRepositories.xml", "RemoteRepositoriesConfiguration"); + } + + @Override + public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) { + final List result = new SmartList<>(); + final List children = componentTag.getChildren(ELEMENT_TAG); + for (Element repoElement : children) { + String id = null; + String name = null; + String url = null; + for (Element element : repoElement.getChildren(OPTION_TAG)) { + final String option = element.getAttributeValue("name"); + final String optionValue = element.getAttributeValue("value"); + if (ID_PROPERTY.equals(option)) { + id = optionValue; + } + else if (NAME_PROPERTY.equals(option)) { + name = optionValue == null? "" : optionValue; + } + else if (URL_PROPERTY.equals(option)) { + url = optionValue; + } + } + if (id != null && url != null) { + result.add(new JpsRemoteRepositoryDescription(id, name, url)); + } + } + final JpsRemoteRepositoriesConfiguration config = JpsRemoteRepositoryService.getInstance().getOrCreateRemoteRepositoriesConfiguration(project); + if (!result.isEmpty()) { + config.setRepositories(result); + } + } + + @Override + public void saveExtension(@NotNull JpsProject project, @NotNull Element componentTag) { + // not supported + } +} diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/jarRepository/JpsRemoteRepositoriesModelSerializerExtension.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/jarRepository/JpsRemoteRepositoriesModelSerializerExtension.java new file mode 100644 index 000000000000..424af8420543 --- /dev/null +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/jarRepository/JpsRemoteRepositoriesModelSerializerExtension.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.jps.model.serialization.jarRepository; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension; +import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer; + +import java.util.Collections; +import java.util.List; + +/** + * @author Eugene Zhuravlev + * Date: 26-Apr-17 + */ +public class JpsRemoteRepositoriesModelSerializerExtension extends JpsModelSerializerExtension{ + private static final JpsRemoteRepositoriesConfigurationSerializer SERIALIZER_IMPL = new JpsRemoteRepositoriesConfigurationSerializer(); + + @NotNull + @Override + public List getProjectExtensionSerializers() { + return Collections.singletonList(SERIALIZER_IMPL); + } +} diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.form b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.form index 04121606c77a..fcfd3f1d0e29 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.form +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.form @@ -1,9 +1,9 @@
- + - + @@ -58,84 +58,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.java index 4c1742c1ec2a..f10551e2b4d5 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenRepositoriesConfigurable.java @@ -16,21 +16,13 @@ package org.jetbrains.idea.maven.indices; import com.intellij.icons.AllIcons; -import com.intellij.jarRepository.JarRepositoryManager; -import com.intellij.jarRepository.services.MavenRepositoryServicesManager; import com.intellij.openapi.options.BaseConfigurable; import com.intellij.openapi.options.Configurable; 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.util.Disposer; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.ui.CollectionListModel; import com.intellij.ui.JBColor; -import com.intellij.ui.ListUtil; -import com.intellij.ui.components.JBList; import com.intellij.ui.table.JBTable; import com.intellij.util.text.DateFormatUtil; import com.intellij.util.ui.AnimatedIcon; @@ -48,10 +40,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; -import java.net.MalformedURLException; -import java.net.URL; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public class MavenRepositoriesConfigurable extends BaseConfigurable implements SearchableConfigurable, Configurable.NoScroll { @@ -60,68 +49,22 @@ public class MavenRepositoriesConfigurable extends BaseConfigurable implements S private JPanel myMainPanel; private JBTable myIndicesTable; private JButton myUpdateButton; - private JButton myRemoveButton; - private JButton myAddButton; - private JBList myServiceList; - private JButton myTestButton; - private JButton myEditButton; private AnimatedIcon myUpdatingIcon; private Timer myRepaintTimer; private ActionListener myTimerListener; - private final Project myProject; - private final CollectionListModel myModel = new CollectionListModel<>(); public MavenRepositoriesConfigurable(Project project) { - myProject = project; myManager = MavenProjectIndicesManager.getInstance(project); configControls(); } @Override public boolean isModified() { - return !myModel.getItems().equals(MavenRepositoryServicesManager.getInstance().getUrls()); + return false; } private void configControls() { - myServiceList.setModel(myModel); - myServiceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - myAddButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final String value = (String)myServiceList.getSelectedValue(); - final String text = Messages.showInputDialog("Artifactory or Nexus Service URL", "Add Service URL", Messages.getQuestionIcon(), - value == null ? "http://" : value, new URLInputVaslidator()); - if (StringUtil.isNotEmpty(text)) { - myModel.add(text); - myServiceList.setSelectedValue(text, true); - } - } - }); - myEditButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final int index = myServiceList.getSelectedIndex(); - final String text = Messages.showInputDialog("Artifactory or Nexus Service URL", "Edit Service URL", Messages.getQuestionIcon(), - myModel.getElementAt(index), new URLInputVaslidator()); - if (StringUtil.isNotEmpty(text)) { - myModel.setElementAt(text, index); - } - } - }); - ListUtil.addRemoveListener(myRemoveButton, myServiceList); - ListUtil.disableWhenNoSelection(myTestButton, myServiceList); - ListUtil.disableWhenNoSelection(myEditButton, myServiceList); - myTestButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final String value = (String)myServiceList.getSelectedValue(); - if (value != null) { - testServiceConnection(value); - } - } - }); - myUpdateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doUpdateIndex(); @@ -149,32 +92,11 @@ public class MavenRepositoriesConfigurable extends BaseConfigurable implements S myIndicesTable.setDefaultRenderer(MavenIndicesManager.IndexUpdatingState.class, new MyIconCellRenderer()); - myServiceList.getEmptyText().setText("No services"); myIndicesTable.getEmptyText().setText("No remote repositories"); updateButtonsState(); } - private void testServiceConnection(String url) { - myTestButton.setEnabled(false); - JarRepositoryManager.searchRepositories(myProject, Collections.singletonList(url), infos -> { - myTestButton.setEnabled(true); - if (infos.isEmpty()) { - Messages.showMessageDialog("No repositories found", "Service Connection Failed", Messages.getWarningIcon()); - } - else { - final StringBuilder sb = new StringBuilder(); - sb.append(infos.size()).append(infos.size() == 1 ? "repository" : " repositories").append(" found"); - //for (MavenRepositoryInfo info : infos) { - // sb.append("\n "); - // sb.append(info.getId()).append(" (").append(info.getName()).append(")").append(": ").append(info.getUrl()); - //} - Messages.showMessageDialog(sb.toString(), "Service Connection Successful", Messages.getInformationIcon()); - } - return true; - }); - } - private void updateButtonsState() { boolean hasSelection = !myIndicesTable.getSelectionModel().isSelectionEmpty(); myUpdateButton.setEnabled(hasSelection); @@ -226,13 +148,9 @@ public class MavenRepositoriesConfigurable extends BaseConfigurable implements S } public void apply() throws ConfigurationException { - MavenRepositoryServicesManager.getInstance().setUrls(myModel.getItems()); } public void reset() { - myModel.removeAll(); - myModel.add(MavenRepositoryServicesManager.getInstance().getUrls()); - myIndicesTable.setModel(new MyTableModel(myManager.getIndices())); myIndicesTable.getColumnModel().getColumn(0).setPreferredWidth(400); myIndicesTable.getColumnModel().getColumn(1).setPreferredWidth(50); @@ -368,22 +286,4 @@ public class MavenRepositoriesConfigurable extends BaseConfigurable implements S } } } - - private static class URLInputVaslidator implements InputValidator { - @Override - public boolean checkInput(String inputString) { - try { - final URL url = new URL(inputString); - return StringUtil.isNotEmpty(url.getHost()); - } - catch (MalformedURLException e) { - return false; - } - } - - @Override - public boolean canClose(String inputString) { - return checkInput(inputString); - } - } } diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index e4a5888d60b2..464a8311e3cb 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -1945,8 +1945,10 @@ - + + +