'add framework support' ui imporved & FrameworkSupportProvider moved to open api

This commit is contained in:
Nikolay Chashnikov
2009-09-18 10:32:46 +04:00
parent d6eab791b2
commit abe0170ced
33 changed files with 763 additions and 540 deletions
@@ -1,126 +0,0 @@
/*
* Copyright 2000-2007 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.ui.libraries;
import com.intellij.openapi.util.Comparing;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public class LibraryDownloadInfo {
private final RemoteRepositoryInfo myRemoteRepository;
private final String myRelativeDownloadUrl;
private final String myFileNamePrefix;
private final String myFileNameSuffix;
@Nullable private final String myPresentableUrl;
public LibraryDownloadInfo(final @NotNull RemoteRepositoryInfo remoteRepository,
final @NotNull @NonNls String relativeDownloadUrl,
final @NotNull @NonNls String fileNamePrefix,
final @NotNull @NonNls String fileNameSuffix) {
myRemoteRepository = remoteRepository;
myRelativeDownloadUrl = relativeDownloadUrl;
myFileNamePrefix = fileNamePrefix;
myFileNameSuffix = fileNameSuffix;
myPresentableUrl = null;
}
public LibraryDownloadInfo(final @NotNull String downloadUrl, final @Nullable String presentableUrl,
@NotNull @NonNls String fileNamePrefix, @NotNull @NonNls String fileNameSuffix) {
myRemoteRepository = null;
myRelativeDownloadUrl = downloadUrl;
myFileNamePrefix = fileNamePrefix;
myFileNameSuffix = fileNameSuffix;
myPresentableUrl = presentableUrl != null ? presentableUrl : downloadUrl;
}
public LibraryDownloadInfo(final @NotNull String downloadUrl, final @Nullable String presentableUrl,
@NotNull @NonNls String fileNamePrefix) {
this(downloadUrl, presentableUrl, fileNamePrefix, ".jar");
}
public LibraryDownloadInfo(final @NotNull String downloadUrl, @NotNull @NonNls String fileNamePrefix) {
this(downloadUrl, null, fileNamePrefix);
}
@NotNull
public String getDownloadUrl() {
return myRemoteRepository != null ? getDownloadUrl(myRemoteRepository.getDefaultMirror()) : myRelativeDownloadUrl;
}
@NotNull
public String getDownloadUrl(String mirror) {
return mirror + myRelativeDownloadUrl;
}
@Nullable
public RemoteRepositoryInfo getRemoteRepository() {
return myRemoteRepository;
}
@NotNull
public String getFileNamePrefix() {
return myFileNamePrefix;
}
@NotNull
public String getFileNameSuffix() {
return myFileNameSuffix;
}
@NotNull
public String getPresentableUrl() {
return myPresentableUrl != null ? myPresentableUrl
: myRemoteRepository != null ? myRemoteRepository.getDefaultMirror() : myRelativeDownloadUrl;
}
@NotNull
public String getPresentableUrl(String mirror) {
return myPresentableUrl != null ? myPresentableUrl : mirror;
}
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final LibraryDownloadInfo that = (LibraryDownloadInfo)o;
if (!myFileNamePrefix.equals(that.myFileNamePrefix)) return false;
if (!myFileNameSuffix.equals(that.myFileNameSuffix)) return false;
if (!Comparing.equal(myPresentableUrl, that.myPresentableUrl)) return false;
if (!myRelativeDownloadUrl.equals(that.myRelativeDownloadUrl)) return false;
if (!Comparing.equal(myRemoteRepository, that.myRemoteRepository)) return false;
return true;
}
public int hashCode() {
int result;
result = myRemoteRepository.hashCode();
result = 31 * result + myRelativeDownloadUrl.hashCode();
result = 31 * result + myFileNamePrefix.hashCode();
result = 31 * result + myFileNameSuffix.hashCode();
if (myPresentableUrl != null) {
result = 31 * result + myPresentableUrl.hashCode();
}
return result;
}
}
@@ -1,90 +0,0 @@
/*
* Copyright 2000-2007 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.ui.libraries;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
/**
* @author nik
*/
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[] myRequiredClasses;
public LibraryInfo(final @NonNls String presentableName, final @Nullable @NonNls String version,
final @Nullable @NonNls String downloadingUrl,
final @Nullable String presentableUrl, final @NonNls String... requiredClasses) {
myPresentableName = presentableName;
myRequiredClasses = requiredClasses;
if (downloadingUrl != null) {
int dot = presentableName.lastIndexOf('.');
String prefix = presentableName.substring(0, dot);
String suffix = presentableName.substring(dot);
myDownloadInfo = new LibraryDownloadInfo(downloadingUrl, presentableUrl, prefix, suffix);
}
else {
myDownloadInfo = null;
}
}
public LibraryInfo(final @NonNls String presentableName, final @Nullable LibraryDownloadInfo downloadInfo, String... requiredClasses) {
myPresentableName = presentableName;
myRequiredClasses = requiredClasses;
myDownloadInfo = downloadInfo;
}
@NonNls
public String getPresentableName() {
return myPresentableName;
}
@NonNls
public String[] getRequiredClasses() {
return myRequiredClasses;
}
@Nullable
public LibraryDownloadInfo getDownloadingInfo() {
return myDownloadInfo;
}
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
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 (!Arrays.equals(myRequiredClasses, that.myRequiredClasses)) return false;
return true;
}
public int hashCode() {
int result;
result = (myDownloadInfo != null ? myDownloadInfo.hashCode() : 0);
result = 31 * result + myPresentableName.hashCode();
result = 31 * result + Arrays.hashCode(myRequiredClasses);
return result;
}
}
@@ -1,50 +0,0 @@
/*
* Copyright 2000-2007 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.ui.libraries;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import com.intellij.ide.IdeBundle;
/**
* @author nik
*/
public class MavenLibraryUtil {
@NonNls private static final String[] MAVEN_MIRRORS = {
"http://www.ibiblio.org/maven2/",
"http://repo1.maven.org/maven2/",
};
private static final RemoteRepositoryInfo MAVEN = new RemoteRepositoryInfo("maven", IdeBundle.message("maven.repository.presentable.name"), MAVEN_MIRRORS);
private MavenLibraryUtil() {
}
public static LibraryInfo createSubMavenJarInfo(@NonNls String project, @NonNls String jarName, @NonNls String version, @NonNls String... requiredClasses) {
return createMavenJarInfo(jarName, version, project, requiredClasses);
}
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",
jarName, ".jar");
return new LibraryInfo(jarName+ ".jar", downloadInfo, requiredClasses);
}
public static LibraryInfo createMavenJarInfo(@NonNls String jarName, @NonNls String version, @NotNull @NonNls String... requiredClasses) {
return createMavenJarInfo(jarName, version, jarName, requiredClasses);
}
}
@@ -1,52 +0,0 @@
package com.intellij.facet.ui.libraries;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import com.intellij.openapi.diagnostic.Logger;
/**
* @author nik
*/
public class RemoteRepositoryInfo {
private static final Logger LOG = Logger.getInstance("#com.intellij.facet.ui.libraries.RemoteRepositoryInfo");
private final String myId;
private final String myPresentableName;
private final String[] myMirrors;
public RemoteRepositoryInfo(@NotNull @NonNls String id, final @NotNull @Nls String presentableName, final @NotNull @NonNls String[] mirrors) {
myId = id;
LOG.assertTrue(mirrors.length > 0);
myPresentableName = presentableName;
myMirrors = mirrors;
}
public String getId() {
return myId;
}
public String getPresentableName() {
return myPresentableName;
}
public String[] getMirrors() {
return myMirrors;
}
public String getDefaultMirror() {
return myMirrors[0];
}
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final RemoteRepositoryInfo that = (RemoteRepositoryInfo)o;
return myId.equals(that.myId);
}
public int hashCode() {
return myId.hashCode();
}
}