diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/api/CompilerPerfTestAction.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/api/CompilerPerfTestAction.java index 21613c035731..57f4168cef8c 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/api/CompilerPerfTestAction.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/api/CompilerPerfTestAction.java @@ -60,7 +60,7 @@ public class CompilerPerfTestAction extends AnAction { } final long finish = System.currentTimeMillis(); //System.out.println("Compiled with " + - // compiler.getPresentableName() + + // compiler.getName() + // " in " + // TimeUnit.MILLISECONDS.toMinutes(finish - start) + "m" +TimeUnit.MILLISECONDS.toSeconds((finish - start)%60000) + "s" + // " with " + diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java index 6478aefeb3a4..75192eabbff3 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java @@ -52,7 +52,7 @@ public class DownloadingOptionsDialog extends DialogWrapper { myFilesList.setModel(new CollectionListModel(ContainerUtil.map2Array(settings.getLibraryInfos(), new Function() { @Override public Object fun(LibraryInfo libraryInfo) { - return new JCheckBox(libraryInfo.getPresentableName(), libraryInfo.isSelected()); + return new JCheckBox(libraryInfo.getName(), libraryInfo.isSelected()); } }))); myFilesToDownloadLabel.setLabelFor(myFilesList); diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/RequiredLibrariesInfo.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/RequiredLibrariesInfo.java index 979f35626dd6..b2452b050fe1 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/RequiredLibrariesInfo.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/RequiredLibrariesInfo.java @@ -73,7 +73,7 @@ public class RequiredLibrariesInfo { missedJarsText.append(", "); } - missedJarsText.append(libraryInfos[i].getPresentableName()); + missedJarsText.append(libraryInfos[i].getName()); } return missedJarsText.toString(); } diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibrariesConfigurationInfo.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibrariesConfigurationInfo.java deleted file mode 100644 index b898d1172a98..000000000000 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibrariesConfigurationInfo.java +++ /dev/null @@ -1,59 +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.versions; - -import com.intellij.util.xmlb.annotations.AbstractCollection; -import com.intellij.util.xmlb.annotations.Attribute; -import com.intellij.util.xmlb.annotations.Property; - -public class LibrariesConfigurationInfo { - - @Property(surroundWithTag = false) - @AbstractCollection(surroundWithTag = false) - public LibraryConfigurationInfo[] myInfos; - - @Attribute("default-version") - public String myDefaultVersion; - - @Attribute("default-ri") - public String myDefaultRI; - - @Attribute("default-download-url") - public String myDefaultDownloadUrl; - - @Attribute("default-presentation-url") - public String myDefaultPresentationUrl; - - public LibraryConfigurationInfo[] getLibraryConfigurationInfos() { - return myInfos; - } - - public String getDefaultVersion() { - return myDefaultVersion; - } - - public String getDefaultDownloadUrl() { - return myDefaultDownloadUrl; - } - - public String getDefaultPresentationUrl() { - return myDefaultPresentationUrl; - } - - public String getDefaultRI() { - return myDefaultRI; - } -} \ No newline at end of file diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibrariesConfigurationManager.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibrariesConfigurationManager.java deleted file mode 100644 index babd5cfb94ab..000000000000 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibrariesConfigurationManager.java +++ /dev/null @@ -1,123 +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.versions; - -import com.intellij.facet.ui.libraries.LibraryInfo; -import com.intellij.openapi.Disposable; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.ArrayUtil; -import com.intellij.util.containers.HashMap; -import com.intellij.util.xmlb.XmlSerializer; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class LibrariesConfigurationManager implements Disposable { - - private static final String STRING_DELIMITER = ","; - private static final String RI_TEMPLATE = "$RI$"; - private static final String VERSION_TEMPLATE = "$VERSION$"; - - @NotNull - public static Map> getLibraries(final URL... urls) { - final Map> versionLibs = new HashMap>(); - - for (URL url : urls) { - final LibrariesConfigurationInfo libs = XmlSerializer.deserialize(url, LibrariesConfigurationInfo.class); - - assert libs != null; - assert libs.getLibraryConfigurationInfos() != null; - - final String defaultVersion = libs.getDefaultVersion(); - final String defaultRI = libs.getDefaultRI(); - final String defaultDownloadUrl = libs.getDefaultDownloadUrl(); - final String defaultPresentationUrl = libs.getDefaultPresentationUrl(); - - - for (LibraryConfigurationInfo libInfo : libs.getLibraryConfigurationInfos()) { - String[] libInfoVersions = getSplitted(libInfo.getVersion()); - - if (libInfoVersions.length == 0) { - addVersionLibrary(null, versionLibs, defaultVersion, defaultRI, defaultDownloadUrl, defaultPresentationUrl, libInfo); - } else { - for (String infoVersion : libInfoVersions) { - addVersionLibrary(infoVersion.trim(), versionLibs, defaultVersion, defaultRI, defaultDownloadUrl, defaultPresentationUrl, libInfo); - } - } - } - } - return versionLibs; - } - - private static void addVersionLibrary(@Nullable String infoVersion, - Map> versionLibs, - String defaultVersion, - String defaultRI, - String defaultDownloadUrl, - String defaultPresentationUrl, - LibraryConfigurationInfo libInfo) { - final String version = choose(infoVersion, defaultVersion); - - assert !StringUtil.isEmptyOrSpaces(version); - - final String ri = choose(libInfo.getRI(), defaultRI); - final String downloadUrl = choose(libInfo.getDownloadUrl(), defaultDownloadUrl); - final String presentationdUrl = choose(libInfo.getPresentationdUrl(), defaultPresentationUrl); - - - final LibraryVersionInfo versionInfo = new LibraryVersionInfo(version, ri); - final LibraryInfo info = createLibraryInfo(downloadUrl, presentationdUrl, version, ri, libInfo); - - if (versionLibs.get(versionInfo) == null) versionLibs.put(versionInfo, new ArrayList()); - - versionLibs.get(versionInfo).add(info); - } - - @Nullable - private static String choose(@Nullable String str, @Nullable String defaultStr) { - return StringUtil.isEmptyOrSpaces(str) ? defaultStr : str; - } - - private static LibraryInfo createLibraryInfo(String downloadUrl, - String presentationdUrl, - String version, - String ri, - LibraryConfigurationInfo libInfo) { - - downloadUrl = downloadUrl.replace(VERSION_TEMPLATE, version); - if (ri != null) { - downloadUrl = downloadUrl.replace(RI_TEMPLATE, ri); - } - - String jarName = libInfo.getJarName(); - String jarVersion = libInfo.getJarVersion(); - return new LibraryInfo(jarName, jarVersion == null ? version : jarVersion, downloadUrl + jarName, presentationdUrl, getSplitted(libInfo.getRequiredClasses())); - } - - private static String[] getSplitted(@Nullable final String s) { - if (StringUtil.isEmptyOrSpaces(s)) return ArrayUtil.EMPTY_STRING_ARRAY; - - return ArrayUtil.toStringArray(StringUtil.split(s, STRING_DELIMITER)); - } - - public void dispose() { - - } -} \ No newline at end of file diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibraryConfigurationInfo.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibraryConfigurationInfo.java deleted file mode 100644 index 39f8cecd7492..000000000000 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibraryConfigurationInfo.java +++ /dev/null @@ -1,73 +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.versions; - -import com.intellij.util.xmlb.annotations.Attribute; -import com.intellij.util.xmlb.annotations.Tag; - -@Tag("lib") -public class LibraryConfigurationInfo { - - @Attribute("ri") - public String myRI; - - @Attribute("jar-name") - public String myJarName; - - @Attribute("version") - public String myVersion; - - @Attribute("download-url") - public String myDownloadUrl; - - @Attribute("presentation-url") - public String myPresentationdUrl; - - @Attribute("required-classes") - public String myRequiredClasses; - - @Attribute("jar-version") - public String myJarVersion; - - public String getRI() { - return myRI; - } - - public String getJarName() { - return myJarName; - } - - public String getVersion() { - return myVersion; - } - - public String getDownloadUrl() { - return myDownloadUrl; - } - - public String getPresentationdUrl() { - return myPresentationdUrl; - } - - public String getRequiredClasses() { - return myRequiredClasses; - } - - public String getJarVersion() { - return myJarVersion; - } -} \ No newline at end of file diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibraryVersionInfo.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibraryVersionInfo.java deleted file mode 100644 index 5d8a58a51212..000000000000 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/LibraryVersionInfo.java +++ /dev/null @@ -1,77 +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.versions; - -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.NotNull; - -public class LibraryVersionInfo { - @NotNull private String myVersion; - @Nullable private String myRI; - - - public LibraryVersionInfo(@NotNull String version) { - myVersion = version; - } - - public LibraryVersionInfo(@NotNull String version, @Nullable String RI) { - myVersion = version; - myRI = RI; - } - - @NotNull - public String getVersion() { - return myVersion; - } - - public void setVersion(@NotNull String version) { - myVersion = version; - } - - @Nullable - public String getRI() { - return myRI; - } - - public void setRI(@Nullable String RI) { - myRI = RI; - } - - @Override - public String toString() { - return myVersion; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - LibraryVersionInfo that = (LibraryVersionInfo)o; - - if (myRI != null ? !myRI.equals(that.myRI) : that.myRI != null) return false; - if (!myVersion.equals(that.myVersion)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = myVersion.hashCode(); - result = 31 * result + (myRI != null ? myRI.hashCode() : 0); - return result; - } -} diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/VersionsComponent.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/VersionsComponent.java index 4c44080e4903..6610cb9f79bb 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/VersionsComponent.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/versions/VersionsComponent.java @@ -15,6 +15,8 @@ */ package com.intellij.facet.impl.ui.libraries.versions; +import com.intellij.facet.frameworks.LibrariesDownloadAssistant; +import com.intellij.facet.frameworks.beans.Version; import com.intellij.facet.ui.libraries.FacetLibrariesValidator; import com.intellij.facet.ui.libraries.FacetLibrariesValidatorDescription; import com.intellij.facet.ui.libraries.LibraryInfo; @@ -49,7 +51,7 @@ public abstract class VersionsComponent { private final Map> myButtons = new HashMap>(); - private LibraryVersionInfo myCurrentVersion = null; + private Version myCurrentVersion = null; public VersionsComponent(@NotNull final Module module, FacetLibrariesValidator validator) { myModule = module; @@ -64,7 +66,7 @@ public abstract class VersionsComponent { } @Nullable - public LibraryVersionInfo getCurrentLibraryVersionInfo() { + public Version getCurrentVersion() { return myCurrentVersion; } @@ -105,20 +107,20 @@ public abstract class VersionsComponent { } @NotNull - protected abstract Map> getLibraries(); + protected abstract Version[] getLibraries(); @Nullable - private LibraryVersionInfo getCurrentVersion(@NotNull String currentRI) { + private Version getCurrentVersion(@NotNull String currentRI) { String detectionClass = getFacetDetectionClass(currentRI); if (detectionClass != null) { final String version = JarVersionDetectionUtil.detectJarVersion(detectionClass, myModule); if (version != null) { - LibraryVersionInfo approximatedVersion = null; - for (LibraryVersionInfo info : getLibraries().keySet()) { - if (version.equals(info.getVersion())) { + Version approximatedVersion = null; + for (Version info : getLibraries()) { + if (version.equals(info.getId())) { return info; } - if (version.contains(info.getVersion())) { + if (version.contains(info.getId())) { approximatedVersion = info; } } @@ -129,11 +131,11 @@ public abstract class VersionsComponent { return null; } - private List getSupportedVersions(@NotNull String ri) { - List versions = new ArrayList(); - for (Map.Entry> entry : getLibraries().entrySet()) { - if (ri.equals(entry.getKey().getRI())) { - versions.add(entry.getKey()); + private List getSupportedVersions(@NotNull String ri) { + List versions = new ArrayList(); + for (Version version : getLibraries()) { + if (ri.equals(version.getRI())) { + versions.add(version); } } @@ -143,7 +145,7 @@ public abstract class VersionsComponent { private void addSingletonReferenceImplementationUI(@NotNull final String ri) { JComboBox comboBox = createComboBox(ri); addToPanel(new JLabel(ri), comboBox); - LibraryVersionInfo version = getCurrentVersion(ri); + Version version = getCurrentVersion(ri); if (version != null) { comboBox.setSelectedItem(version); } @@ -178,7 +180,7 @@ public abstract class VersionsComponent { JComboBox comboBox = pair.second; comboBox.setEnabled(true); - LibraryVersionInfo currentVersion = getCurrentVersion(ri); + Version currentVersion = getCurrentVersion(ri); if (currentVersion != null) { comboBox.setSelectedItem(currentVersion); } @@ -203,7 +205,7 @@ public abstract class VersionsComponent { private JComboBox createComboBox(String ri) { final JComboBox comboBox = new JComboBox(); - List versions = getSupportedVersions(ri); + List versions = getSupportedVersions(ri); comboBox.setModel(new CollectionComboBoxModel(versions, null)); comboBox.addActionListener(new ActionListener() { @@ -216,7 +218,7 @@ public abstract class VersionsComponent { } private void updateCurrentVersion(JComboBox comboBox) { - final LibraryVersionInfo versionInfo = getSelectedVersion(comboBox); + final Version versionInfo = getSelectedVersion(comboBox); if (versionInfo != null) { myCurrentVersion = versionInfo; @@ -225,13 +227,13 @@ public abstract class VersionsComponent { } } - protected FacetLibrariesValidatorDescription getFacetLibrariesValidatorDescription(LibraryVersionInfo versionInfo) { - return new FacetLibrariesValidatorDescription(versionInfo.getVersion()) { + protected FacetLibrariesValidatorDescription getFacetLibrariesValidatorDescription(Version version) { + return new FacetLibrariesValidatorDescription(version.getId()) { @NonNls public String getDefaultLibraryName() { if (myCurrentVersion != null) { String ri = myCurrentVersion.getRI(); - String version = myCurrentVersion.getVersion(); + String version = myCurrentVersion.getId(); return StringUtil.isEmptyOrSpaces(ri) ? version : ri + "." + version; } @@ -242,19 +244,20 @@ public abstract class VersionsComponent { } @Nullable - private static LibraryVersionInfo getAppropriateVersion(List versions) { + private static Version getAppropriateVersion(List versions) { return versions.size() > 0 ? versions.get(0) : null; } - private LibraryInfo[] getRequiredLibraries(LibraryVersionInfo versionInfo) { - List libraryInfos = getLibraries().get(versionInfo); - return libraryInfos.toArray(new LibraryInfo[libraryInfos.size()]); + private static LibraryInfo[] getRequiredLibraries(Version version) { + final LibraryInfo[] infos = LibrariesDownloadAssistant.getLibraryInfos(version); + + return infos == null ? LibraryInfo.EMPTY_ARRAY : infos; } @Nullable - private static LibraryVersionInfo getSelectedVersion(@NotNull JComboBox comboBox) { + private static Version getSelectedVersion(@NotNull JComboBox comboBox) { final Object version = comboBox.getModel().getSelectedItem(); - return version instanceof LibraryVersionInfo ? (LibraryVersionInfo)version : null; + return version instanceof Version ? (Version)version : null; } @@ -269,8 +272,8 @@ public abstract class VersionsComponent { public Set getRIs() { Set ris = new HashSet(); - for (LibraryVersionInfo info : getLibraries().keySet()) { - String ri = info.getRI(); + for (Version version : getLibraries()) { + String ri = version.getRI(); if (!StringUtil.isEmptyOrSpaces(ri)) { ris.add(ri); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java index e2b35d0477be..52832d69a6a8 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java @@ -60,10 +60,10 @@ public class ModuleProjectStructureElement extends ProjectStructureElement { // final LibraryEx library = (LibraryEx)((LibraryOrderEntry)entry).getLibrary(); // if (library != null) { // if (!library.allPathsValid(OrderRootType.CLASSES)) { - // problemsHolder.registerError(ProjectBundle.message("project.roots.tooltip.library.misconfigured", entry.getPresentableName())); + // problemsHolder.registerError(ProjectBundle.message("project.roots.tooltip.library.misconfigured", entry.getName())); // } // else if (!library.allPathsValid(OrderRootType.SOURCES)) { - // problemsHolder.registerWarning(ProjectBundle.message("project.roots.tooltip.library.misconfigured", entry.getPresentableName())); + // problemsHolder.registerWarning(ProjectBundle.message("project.roots.tooltip.library.misconfigured", entry.getName())); // } // } //} diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/LibrariesDownloadAssistant.java b/platform/lang-api/src/com/intellij/facet/frameworks/LibrariesDownloadAssistant.java new file mode 100644 index 000000000000..185a37d799fd --- /dev/null +++ b/platform/lang-api/src/com/intellij/facet/frameworks/LibrariesDownloadAssistant.java @@ -0,0 +1,96 @@ +package com.intellij.facet.frameworks; + +import com.intellij.facet.frameworks.beans.DownloadJar; +import com.intellij.facet.frameworks.beans.Version; +import com.intellij.facet.frameworks.beans.Versions; +import com.intellij.facet.ui.libraries.LibraryInfo; +import com.intellij.openapi.util.Condition; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.HashSet; +import com.intellij.util.xmlb.XmlSerializer; +import org.jdom.Element; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.net.URL; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +public class LibrariesDownloadAssistant { + + private LibrariesDownloadAssistant() { + } + + // for local files + @NotNull + public static Version[] getVersions(@NotNull URL... urls) { + Set versions = new HashSet(); + for (URL url : urls) { + final Versions allVersions = XmlSerializer.deserialize(url, Versions.class); + if (allVersions != null) { + final Version[] vers = allVersions.getVersions(); + if (vers != null) { + versions.addAll(Arrays.asList(vers)); + } + } + } + + return versions.toArray(new Version[versions.size()]); + } + + // todo: will be connect to server + @Nullable + public static Version[] getVersions(@NotNull String groupId) { + final Versions allVersions = + XmlSerializer.deserialize(getRoot(groupId), Versions.class); + + return allVersions == null ? null : allVersions.getVersions(); + } + + private static Element getRoot(@NotNull final String groupId) { + return null; + } + + + @Nullable + public static Version findVersion(@NotNull final String versionId, @NotNull final URL... urls) { + return findVersion(getVersions(urls), versionId); + } + + @Nullable + public static Version findVersion(@NotNull final String groupId, @NotNull final String versionId) { + return findVersion(getVersions(groupId), versionId); + } + + @Nullable + public static Version findVersion(@Nullable Version[] versions, @NotNull final String versionId) { + return versions == null ? null : ContainerUtil.find(versions, new Condition() { + public boolean value(final Version springVersion) { + return versionId.equals(springVersion.getId()); + } + }); + } + + @NotNull + public static LibraryInfo[] getLibraryInfos(@NotNull final URL url, @NotNull final String versionId) { + final Version version = findVersion(getVersions(url), versionId); + return version != null ? getLibraryInfos(version) :LibraryInfo.EMPTY_ARRAY; + } + + @NotNull + public static LibraryInfo[] getLibraryInfos(@Nullable Version version) { + if (version == null) return LibraryInfo.EMPTY_ARRAY; + + final List infos = ContainerUtil.mapNotNull(version.getJars(), new Function() { + @Override + public LibraryInfo fun(DownloadJar downloadJar) { + final String downloadUrl = downloadJar.getDownloadUrl(); + return new LibraryInfo(downloadJar.getName(), downloadUrl, downloadUrl, downloadJar.getRequiredClasses()); + } + }); + + return infos.toArray(new LibraryInfo[infos.size()]); + } +} diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/beans/DownloadJar.java b/platform/lang-api/src/com/intellij/facet/frameworks/beans/DownloadJar.java new file mode 100644 index 000000000000..529802e27d77 --- /dev/null +++ b/platform/lang-api/src/com/intellij/facet/frameworks/beans/DownloadJar.java @@ -0,0 +1,80 @@ +/* + * Copyright 2000-2010 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.frameworks.beans; + +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.xmlb.annotations.AbstractCollection; +import com.intellij.util.xmlb.annotations.Attribute; +import com.intellij.util.xmlb.annotations.Property; +import com.intellij.util.xmlb.annotations.Tag; + +import java.util.List; + +@Tag("jar") +public class DownloadJar { + + @Property(surroundWithTag = false) + @AbstractCollection(surroundWithTag = false) + public RequiredClass[] myRequiredClasses; + + @Attribute("name") + public String myName; + + @Attribute("url") + public String myDownloadUrl; + + @Attribute("presentation") + public String myPresentation; + + @Attribute("md5") + public String myMD5; + + public String getName() { + return myName; + } + + public String getDownloadUrl() { + return myDownloadUrl; + } + + public String getPresentation() { + return myPresentation; + } + + public String getMD5() { + return myMD5; + } + + @Override + public String toString() { + return myName; + } + + public String[] getRequiredClasses() { + if (myRequiredClasses == null) return new String[0]; + + final List classes = ContainerUtil.mapNotNull(myRequiredClasses, new Function() { + @Override + public String fun(RequiredClass requiredClass) { + return requiredClass.getFqn(); + } + }); + + return classes.toArray(new String[classes.size()]); + } +} \ No newline at end of file diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/beans/RequiredClass.java b/platform/lang-api/src/com/intellij/facet/frameworks/beans/RequiredClass.java new file mode 100644 index 000000000000..8afc157bce11 --- /dev/null +++ b/platform/lang-api/src/com/intellij/facet/frameworks/beans/RequiredClass.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2010 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.frameworks.beans; + +import com.intellij.util.xmlb.annotations.Attribute; +import com.intellij.util.xmlb.annotations.Tag; + +@Tag("required-class") +public class RequiredClass { + + @Attribute("fqn") + public String myFqn; + + public String getFqn() { + return myFqn; + } +} \ No newline at end of file diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/beans/Version.java b/platform/lang-api/src/com/intellij/facet/frameworks/beans/Version.java new file mode 100644 index 000000000000..b94f807964dd --- /dev/null +++ b/platform/lang-api/src/com/intellij/facet/frameworks/beans/Version.java @@ -0,0 +1,38 @@ +package com.intellij.facet.frameworks.beans; + +import com.intellij.util.xmlb.annotations.AbstractCollection; +import com.intellij.util.xmlb.annotations.Attribute; +import com.intellij.util.xmlb.annotations.Property; +import com.intellij.util.xmlb.annotations.Tag; + +@Tag("version") +public class Version { + public static final Version[] EMPTY_ARRAY = new Version[0]; + + @Property(surroundWithTag = false) + @AbstractCollection(surroundWithTag = false) + public DownloadJar[] myJars; + + @Attribute("id") + public String myId; + + @Attribute("ri") + public String myRI; // optional attribute "reference implementation" + + public String getRI() { + return myRI; + } + + public DownloadJar[] getJars() { + return myJars; + } + + public String getId() { + return myId; + } + + @Override + public String toString() { + return myId; + } +} \ No newline at end of file diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/beans/Versions.java b/platform/lang-api/src/com/intellij/facet/frameworks/beans/Versions.java new file mode 100644 index 000000000000..5c05a51d5f37 --- /dev/null +++ b/platform/lang-api/src/com/intellij/facet/frameworks/beans/Versions.java @@ -0,0 +1,15 @@ +package com.intellij.facet.frameworks.beans; + +import com.intellij.util.xmlb.annotations.AbstractCollection; +import com.intellij.util.xmlb.annotations.Property; + +public class Versions { + + @Property(surroundWithTag = false) + @AbstractCollection(surroundWithTag = false) + public Version[] myVersions; + + public Version[] getVersions() { + return myVersions; + } +} \ No newline at end of file diff --git a/platform/lang-api/src/com/intellij/facet/ui/libraries/LibraryInfo.java b/platform/lang-api/src/com/intellij/facet/ui/libraries/LibraryInfo.java index 47fbaae8918c..a123c248258c 100644 --- a/platform/lang-api/src/com/intellij/facet/ui/libraries/LibraryInfo.java +++ b/platform/lang-api/src/com/intellij/facet/ui/libraries/LibraryInfo.java @@ -28,19 +28,19 @@ public class LibraryInfo { public static final LibraryInfo[] EMPTY_ARRAY = new LibraryInfo[0]; private @Nullable final LibraryDownloadInfo myDownloadInfo; - private @NonNls final String myPresentableName; + private @NonNls final String myName; private @NonNls final String[] myRequiredClasses; private boolean mySelected = true; - public LibraryInfo(final @NonNls String presentableName, final @Nullable @NonNls String version, - final @Nullable @NonNls String downloadingUrl, + public LibraryInfo(final @NonNls String name, + final @Nullable @NonNls String downloadingUrl, final @Nullable String presentableUrl, final @NonNls String... requiredClasses) { - myPresentableName = presentableName; + myName = name; myRequiredClasses = requiredClasses; if (downloadingUrl != null) { - int dot = presentableName.lastIndexOf('.'); - String prefix = presentableName.substring(0, dot); - String suffix = presentableName.substring(dot); + int dot = name.lastIndexOf('.'); + String prefix = name.substring(0, dot); + String suffix = name.substring(dot); myDownloadInfo = new LibraryDownloadInfo(downloadingUrl, presentableUrl, prefix, suffix); } else { @@ -48,15 +48,15 @@ public class LibraryInfo { } } - public LibraryInfo(final @NonNls String presentableName, final @Nullable LibraryDownloadInfo downloadInfo, String... requiredClasses) { - myPresentableName = presentableName; + public LibraryInfo(final @NonNls String name, final @Nullable LibraryDownloadInfo downloadInfo, String... requiredClasses) { + myName = name; myRequiredClasses = requiredClasses; myDownloadInfo = downloadInfo; } @NonNls - public String getPresentableName() { - return myPresentableName; + public String getName() { + return myName; } @NonNls @@ -76,7 +76,7 @@ public class LibraryInfo { final LibraryInfo that = (LibraryInfo)o; if (myDownloadInfo != null ? !myDownloadInfo.equals(that.myDownloadInfo) : that.myDownloadInfo != null) return false; - if (!myPresentableName.equals(that.myPresentableName)) return false; + if (!myName.equals(that.myName)) return false; if (!Arrays.equals(myRequiredClasses, that.myRequiredClasses)) return false; return true; @@ -85,14 +85,14 @@ public class LibraryInfo { public int hashCode() { int result; result = (myDownloadInfo != null ? myDownloadInfo.hashCode() : 0); - result = 31 * result + myPresentableName.hashCode(); + result = 31 * result + myName.hashCode(); result = 31 * result + Arrays.hashCode(myRequiredClasses); return result; } @Override public String toString() { - return getPresentableName(); + return getName(); } public boolean isSelected() { diff --git a/platform/lang-api/src/com/intellij/facet/ui/libraries/MavenLibraryUtil.java b/platform/lang-api/src/com/intellij/facet/ui/libraries/MavenLibraryUtil.java index e7b51f1fa2fe..6761a0576f8f 100644 --- a/platform/lang-api/src/com/intellij/facet/ui/libraries/MavenLibraryUtil.java +++ b/platform/lang-api/src/com/intellij/facet/ui/libraries/MavenLibraryUtil.java @@ -20,9 +20,9 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import com.intellij.ide.IdeBundle; -/** - * @author nik - */ + +@Deprecated +// see LibrariesDownloadAssistant public class MavenLibraryUtil { @NonNls private static final String[] MAVEN_MIRRORS = { "http://repo1.maven.org/maven2/", @@ -33,10 +33,12 @@ public class MavenLibraryUtil { private MavenLibraryUtil() { } + @Deprecated // see LibrariesDownloadAssistant public static LibraryInfo createSubMavenJarInfo(@NonNls String project, @NonNls String jarName, @NonNls String version, @NonNls String... requiredClasses) { return createMavenJarInfo(jarName, version, project, requiredClasses); } + @Deprecated // see LibrariesDownloadAssistant private static LibraryInfo createMavenJarInfo(final String jarName, final String version, final String downloadingPrefix, final String... requiredClasses) { LibraryDownloadInfo downloadInfo = new LibraryDownloadInfo(MAVEN, downloadingPrefix + "/" + jarName + "/" + version + "/" + jarName + "-" + version + ".jar", @@ -44,6 +46,7 @@ public class MavenLibraryUtil { return new LibraryInfo(jarName+ ".jar", downloadInfo, requiredClasses); } + @Deprecated // see LibrariesDownloadAssistant public static LibraryInfo createMavenJarInfo(@NonNls String jarName, @NonNls String version, @NotNull @NonNls String... requiredClasses) { return createMavenJarInfo(jarName, version, jarName, requiredClasses); }