diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FacetLibrariesValidatorImpl.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FacetLibrariesValidatorImpl.java index cb568d1c4e1c..9a091a3d8389 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FacetLibrariesValidatorImpl.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/FacetLibrariesValidatorImpl.java @@ -90,9 +90,8 @@ public class FacetLibrariesValidatorImpl extends FacetLibrariesValidator { LibraryInfo[] missingLibraries = info.getLibraryInfos(); VirtualFile baseDir = myContext.getModule().getProject().getBaseDir(); final String baseDirPath = baseDir != null ? baseDir.getPath() : ""; - LibraryCompositionSettings libraryCompositionSettings = new LibraryCompositionSettings(missingLibraries, - myDescription.getDefaultLibraryName(), baseDirPath, - myDescription.getDefaultLibraryName(), null); + LibraryCompositionSettings libraryCompositionSettings = new LibraryCompositionSettings(missingLibraries, + myDescription.getDefaultLibraryName(), baseDirPath); return new ValidationResult(missingJars, new LibrariesQuickFix(libraryCompositionSettings)); } @@ -131,18 +130,8 @@ public class FacetLibrariesValidatorImpl extends FacetLibrariesValidator { } public void run(final JComponent place) { - LibraryDownloadingMirrorsMap mirrorsMap = new LibraryDownloadingMirrorsMap(); - for (LibraryInfo libraryInfo : myLibrarySettings.getLibraryInfos()) { - LibraryDownloadInfo downloadingInfo = libraryInfo.getDownloadingInfo(); - if (downloadingInfo != null) { - RemoteRepositoryInfo repositoryInfo = downloadingInfo.getRemoteRepository(); - if (repositoryInfo != null) { - mirrorsMap.registerRepository(repositoryInfo); - } - } - } LibraryOptionsPanel panel = new LibraryOptionsPanel(myLibrarySettings, myContext.getLibrariesContainer(), false); - LibraryCompositionDialog dialog = new LibraryCompositionDialog(place, panel, mirrorsMap); + LibraryCompositionDialog dialog = new LibraryCompositionDialog(place, panel); dialog.show(); onChange(); } @@ -150,14 +139,11 @@ public class FacetLibrariesValidatorImpl extends FacetLibrariesValidator { private class LibraryCompositionDialog extends DialogWrapper { private final LibraryOptionsPanel myPanel; - private final LibraryDownloadingMirrorsMap myMirrorsMap; - private LibraryCompositionDialog(final JComponent parent, final LibraryOptionsPanel panel, - final LibraryDownloadingMirrorsMap mirrorsMap) { + private LibraryCompositionDialog(final JComponent parent, final LibraryOptionsPanel panel) { super(parent, true); setTitle(IdeBundle.message("specify.libraries.dialog.title")); myPanel = panel; - myMirrorsMap = mirrorsMap; init(); } @@ -169,7 +155,7 @@ public class FacetLibrariesValidatorImpl extends FacetLibrariesValidator { myPanel.apply(); final LibraryCompositionSettings settings = myPanel.getSettings(); final LibrariesContainer librariesContainer = myContext.getLibrariesContainer(); - if (settings.downloadFiles(myMirrorsMap, myPanel.getMainPanel(), false)) { + if (settings.downloadFiles(myPanel.getMainPanel(), false)) { ModifiableRootModel rootModel = myContext.getModifiableRootModel(); if (rootModel == null) { final ModifiableRootModel model = ModuleRootManager.getInstance(myContext.getModule()).getModifiableModel(); diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java index d0e2c70d3f08..718b96ade000 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java @@ -39,12 +39,10 @@ public class LibraryCompositionSettings implements Disposable { @NonNls private static final String DEFAULT_LIB_FOLDER = "lib"; private final LibraryInfo[] myLibraryInfos; private final String myBaseDirectoryForDownloadedFiles; - private final String myTitle; private String myDirectoryForDownloadedLibrariesPath; private boolean myDownloadLibraries = true; private LibrariesContainer.LibraryLevel myLibraryLevel = LibrariesContainer.LibraryLevel.PROJECT; private String myLibraryName; - private final Icon myIcon; private boolean myDownloadSources = true; private boolean myDownloadJavadocs = true; private NewLibraryEditor myLibraryEditor; @@ -52,13 +50,10 @@ public class LibraryCompositionSettings implements Disposable { public LibraryCompositionSettings(final @NotNull LibraryInfo[] libraryInfos, final @NotNull String defaultLibraryName, - final @NotNull String baseDirectoryForDownloadedFiles, - final String title, @Nullable Icon icon) { + final @NotNull String baseDirectoryForDownloadedFiles) { myLibraryInfos = libraryInfos; myBaseDirectoryForDownloadedFiles = baseDirectoryForDownloadedFiles; - myTitle = title; myLibraryName = defaultLibraryName; - myIcon = icon; } public void addFilesToLibrary(VirtualFile[] files, OrderRootType orderRootType) { @@ -109,11 +104,7 @@ public class LibraryCompositionSettings implements Disposable { return myDirectoryForDownloadedLibrariesPath; } - public String getTitle() { - return myTitle; - } - - public boolean downloadFiles(final @NotNull LibraryDownloadingMirrorsMap mirrorsMap, final @NotNull JComponent parent, boolean all) { + public boolean downloadFiles(final @NotNull JComponent parent, boolean all) { if (myDownloadLibraries) { RequiredLibrariesInfo requiredLibraries = new RequiredLibrariesInfo(getLibraryInfos()); @@ -123,8 +114,7 @@ public class LibraryCompositionSettings implements Disposable { LibraryDownloadInfo[] downloadingInfos = LibraryDownloader.getDownloadingInfos(info.getLibraryInfos()); if (downloadingInfos.length > 0) { LibraryDownloader downloader = new LibraryDownloader(downloadingInfos, null, parent, - getDirectoryForDownloadedLibrariesPath(), myLibraryName, - mirrorsMap); + getDirectoryForDownloadedLibrariesPath(), myLibraryName); VirtualFile[] files = downloader.download(); if (files.length != downloadingInfos.length) { return false; @@ -155,10 +145,6 @@ public class LibraryCompositionSettings implements Disposable { return myLibraryName; } - public Icon getIcon() { - return myIcon; - } - @Nullable public Library addLibraries(final @NotNull ModifiableRootModel rootModel, final @NotNull List addedLibraries, final @Nullable LibrariesContainer librariesContainer) { diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryDownloader.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryDownloader.java index 78fd324c8109..4d0441987b22 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryDownloader.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryDownloader.java @@ -42,7 +42,6 @@ import com.intellij.util.io.UrlConnectionUtil; import com.intellij.util.net.HttpConfigurable; import com.intellij.util.net.IOExceptionDialog; import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -61,32 +60,18 @@ public class LibraryDownloader { @NonNls private static final String LIB_SCHEMA = "lib://"; private LibraryDownloadInfo[] myLibraryInfos; - private final LibraryDownloadingMirrorsMap myMirrorsMap; private JComponent myParent; private @Nullable Project myProject; private String myDirectoryForDownloadedLibrariesPath; private final @Nullable String myLibraryPresentableName; - public LibraryDownloader(final LibraryDownloadInfo[] libraryInfos, final @Nullable Project project, JComponent parent, @Nullable String directoryForDownloadedLibrariesPath, - @Nullable String libraryPresentableName, - final LibraryDownloadingMirrorsMap mirrorsMap) { + public LibraryDownloader(final LibraryDownloadInfo[] libraryInfos, final @Nullable Project project, JComponent parent, + @Nullable String directoryForDownloadedLibrariesPath, @Nullable String libraryPresentableName) { myProject = project; myLibraryInfos = libraryInfos; myParent = parent; myDirectoryForDownloadedLibrariesPath = directoryForDownloadedLibrariesPath; myLibraryPresentableName = libraryPresentableName; - myMirrorsMap = mirrorsMap; - } - - public LibraryDownloader(final LibraryDownloadInfo[] libraryInfos, final @Nullable Project project, @NotNull JComponent parent) { - this(libraryInfos, project, parent, null, null, new LibraryDownloadingMirrorsMap()); - } - - public LibraryDownloader(final LibraryDownloadInfo[] libraryInfos, final @NotNull Project project) { - myLibraryInfos = libraryInfos; - myProject = project; - myLibraryPresentableName = null; - myMirrorsMap = new LibraryDownloadingMirrorsMap(); } public VirtualFile[] download() { @@ -169,7 +154,7 @@ public class LibraryDownloader { if (exception instanceof IOException) { String message = IdeBundle.message("error.library.download.failed", exception.getMessage()); if (currentLibrary.get() != null) { - message += ": " + myMirrorsMap.getDownloadingUrl(currentLibrary.get()); + message += ": " + currentLibrary.get().getDownloadUrl(); } final boolean tryAgain = IOExceptionDialog.showErrorDialog(IdeBundle.message("progress.download.libraries.title"), message); if (tryAgain) { @@ -258,8 +243,8 @@ public class LibraryDownloader { private boolean download(final LibraryDownloadInfo libraryInfo, final long existingFileSize, final List> downloadedFiles) throws IOException { final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); - final String presentableUrl = myMirrorsMap.getPresentableUrl(libraryInfo); - final String url = myMirrorsMap.getDownloadingUrl(libraryInfo); + final String presentableUrl = libraryInfo.getPresentableUrl(); + final String url = libraryInfo.getDownloadUrl(); if (url.startsWith(LIB_SCHEMA)) { indicator.setText2(IdeBundle.message("progress.locate.jar.text", getExpectedFileName(libraryInfo))); final String path = url.substring(LIB_SCHEMA.length()).replace('/', File.separatorChar); diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryDownloadingMirrorsMap.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryDownloadingMirrorsMap.java deleted file mode 100644 index 0af391222522..000000000000 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryDownloadingMirrorsMap.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2000-2009 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.facet.impl.ui.libraries; - -import com.intellij.facet.ui.libraries.LibraryDownloadInfo; -import com.intellij.facet.ui.libraries.RemoteRepositoryInfo; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ArrayList; - -/** - * @author nik - */ -public class LibraryDownloadingMirrorsMap { - private final Map myMirrors = new HashMap(); - - public LibraryDownloadingMirrorsMap() { - } - - public LibraryDownloadingMirrorsMap(RemoteRepositoryInfo[] remoteRepositories) { - for (RemoteRepositoryInfo remoteRepository : remoteRepositories) { - registerRepository(remoteRepository); - } - } - - public void registerRepository(final RemoteRepositoryInfo remoteRepository) { - if (!myMirrors.containsKey(remoteRepository)) { - myMirrors.put(remoteRepository, remoteRepository.getDefaultMirror()); - } - } - - public LibraryDownloadingMirrorsMap(LibraryDownloadInfo[] libraryDownloadInfos) { - for (LibraryDownloadInfo downloadInfo : libraryDownloadInfos) { - RemoteRepositoryInfo remoteRepository = downloadInfo.getRemoteRepository(); - if (remoteRepository != null) { - registerRepository(remoteRepository); - } - } - } - - public List getRemoteRepositories() { - return new ArrayList(myMirrors.keySet()); - } - - public String getDownloadingUrl(LibraryDownloadInfo downloadInfo) { - String mirror = getSelectedMirror(downloadInfo); - if (mirror != null) { - return downloadInfo.getDownloadUrl(mirror); - } - return downloadInfo.getDownloadUrl(); - } - - @Nullable - private String getSelectedMirror(@NotNull LibraryDownloadInfo downloadInfo) { - RemoteRepositoryInfo remoteRepository = downloadInfo.getRemoteRepository(); - return remoteRepository != null ? myMirrors.get(remoteRepository) : null; - } - - public String getSelectedMirror(@NotNull RemoteRepositoryInfo remoteRepository) { - return myMirrors.get(remoteRepository); - } - - public String getPresentableUrl(LibraryDownloadInfo downloadInfo) { - String mirror = getSelectedMirror(downloadInfo); - if (mirror != null) { - return downloadInfo.getPresentableUrl(mirror); - } - return downloadInfo.getPresentableUrl(); - } - - public void setMirror(final RemoteRepositoryInfo remoteRepository, String mirror) { - if (mirror == null) return; - - mirror = mirror.trim(); - if (!mirror.endsWith("/")) { - mirror += "/"; - } - myMirrors.put(remoteRepository, mirror); - } - - public LibraryDownloadingMirrorsMap createCopy() { - LibraryDownloadingMirrorsMap mirrorsMap = new LibraryDownloadingMirrorsMap(); - mirrorsMap.myMirrors.putAll(myMirrors); - return mirrorsMap; - } -} diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java index 26476b5bdfda..33083e7565f0 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java @@ -17,12 +17,8 @@ package com.intellij.ide.util.newProjectWizard; import com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings; -import com.intellij.facet.impl.ui.libraries.LibraryDownloadingMirrorsMap; import com.intellij.facet.impl.ui.libraries.LibraryOptionsPanel; import com.intellij.facet.ui.FacetBasedFrameworkSupportProvider; -import com.intellij.facet.ui.libraries.LibraryDownloadInfo; -import com.intellij.facet.ui.libraries.LibraryInfo; -import com.intellij.facet.ui.libraries.RemoteRepositoryInfo; import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable; import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurableListener; import com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider; @@ -72,7 +68,6 @@ public class AddSupportForFrameworksPanel implements Disposable { private final LibrariesContainer myLibrariesContainer; private final Computable myBaseDirForLibrariesGetter; private final List myProviders; - private final LibraryDownloadingMirrorsMap myMirrorsMap; private final FrameworkSupportModelImpl myModel; private final JPanel myOptionsPanel; private final FrameworksTree myFrameworksTree; @@ -86,7 +81,6 @@ public class AddSupportForFrameworksPanel implements Disposable { myProviders = providers; myModel = new FrameworkSupportModelImpl(myLibrariesContainer.getProject(), builder); createNodes(); - myMirrorsMap = createMirrorsMap(); final Splitter splitter = new Splitter(false, 0.30f, 0.1f, 0.7f); myFrameworksTree = new FrameworksTree(myGroups) { @@ -131,7 +125,7 @@ public class AddSupportForFrameworksPanel implements Disposable { myLastSelectedNode = selectedNode; if (selectedNode != null) { - selectedNode.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap); + selectedNode.getLibraryCompositionOptionsPanel(myLibrariesContainer); } } } @@ -142,7 +136,7 @@ public class AddSupportForFrameworksPanel implements Disposable { private void applyLibraryOptionsForSelected() { if (myLastSelectedNode != null) { - final LibraryOptionsPanel optionsPanel = myLastSelectedNode.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap); + final LibraryOptionsPanel optionsPanel = myLastSelectedNode.getLibraryCompositionOptionsPanel(myLibrariesContainer); if (optionsPanel != null) { optionsPanel.apply(); } @@ -197,7 +191,7 @@ public class AddSupportForFrameworksPanel implements Disposable { } private void addLibrariesOptionsPanel(FrameworkSupportNode node, JPanel librariesOptionsPanelWrapper) { - final LibraryOptionsPanel libraryOptionsPanel = node.getLibraryCompositionOptionsPanel(myLibrariesContainer, myMirrorsMap); + final LibraryOptionsPanel libraryOptionsPanel = node.getLibraryCompositionOptionsPanel(myLibrariesContainer); if (libraryOptionsPanel != null) { JComponent separator = SeparatorFactory.createSeparator("Libraries", null); separator.setBorder(IdeBorderFactory.createEmptyBorder(5, 0, 5, 5)); @@ -210,29 +204,6 @@ public class AddSupportForFrameworksPanel implements Disposable { ((CardLayout)myOptionsPanel.getLayout()).show(myOptionsPanel, cardName); } - private LibraryDownloadingMirrorsMap createMirrorsMap() { - List repositoryInfos = getRemoteRepositories(); - return new LibraryDownloadingMirrorsMap(repositoryInfos.toArray(new RemoteRepositoryInfo[repositoryInfos.size()])); - } - - private List getRemoteRepositories() { - List repositoryInfos = new ArrayList(); - List frameworkNodes = getFrameworkNodes(false); - for (FrameworkSupportNode node : frameworkNodes) { - LibraryInfo[] libraries = node.getLibraries(); - for (LibraryInfo library : libraries) { - LibraryDownloadInfo downloadInfo = library.getDownloadingInfo(); - if (downloadInfo != null) { - RemoteRepositoryInfo repository = downloadInfo.getRemoteRepository(); - if (repository != null) { - repositoryInfos.add(repository); - } - } - } - } - return repositoryInfos; - } - private List getLibrariesCompositionSettingsList() { List list = new ArrayList(); List selected = getFrameworkNodes(true); @@ -249,7 +220,7 @@ public class AddSupportForFrameworksPanel implements Disposable { applyLibraryOptionsForSelected(); List list = getLibrariesCompositionSettingsList(); for (LibraryCompositionSettings compositionSettings : list) { - if (!compositionSettings.downloadFiles(myMirrorsMap, myMainPanel, true)) return false; + if (!compositionSettings.downloadFiles(myMainPanel, true)) return false; } return true; } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNode.java index 28f06bdd6410..2d5c1db0e884 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNode.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNode.java @@ -16,7 +16,6 @@ package com.intellij.ide.util.newProjectWizard; import com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings; -import com.intellij.facet.impl.ui.libraries.LibraryDownloadingMirrorsMap; import com.intellij.facet.impl.ui.libraries.LibraryOptionsPanel; import com.intellij.facet.ui.libraries.LibraryInfo; import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable; @@ -75,8 +74,7 @@ public class FrameworkSupportNode extends CheckedTreeNode { } @Nullable - public LibraryOptionsPanel getLibraryCompositionOptionsPanel(LibrariesContainer librariesContainer, - LibraryDownloadingMirrorsMap mirrorsMap) { + public LibraryOptionsPanel getLibraryCompositionOptionsPanel(LibrariesContainer librariesContainer) { final LibraryCompositionSettings libraryCompositionSettings = getLibraryCompositionSettings(); if (myLibraryCompositionOptionsPanel == null || !myLibraryCompositionOptionsPanel.getSettings().equals(libraryCompositionSettings)) { if (libraryCompositionSettings != null) { @@ -124,8 +122,8 @@ public class FrameworkSupportNode extends CheckedTreeNode { if (myLibraryCompositionSettings == null || isObsolete(myLibraryCompositionSettings)) { final LibraryInfo[] libraries = getLibraries(); if (libraries.length != 0) { - myLibraryCompositionSettings = new LibraryCompositionSettings(libraries, myConfigurable.getSelectedVersion().getLibraryName(), myBaseDirForLibrariesGetter.compute(), - "Libraries", myProvider.getIcon()); + myLibraryCompositionSettings = new LibraryCompositionSettings(libraries, myConfigurable.getSelectedVersion().getLibraryName(), myBaseDirForLibrariesGetter.compute() + ); Disposer.register(myConfigurable, myLibraryCompositionSettings); } else {