mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-5089 Twitter Bootstrap Template
This commit is contained in:
+36
-10
@@ -7,6 +7,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.platform.templates.github.*;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -89,19 +90,44 @@ public abstract class AbstractGithubTagDownloadedProjectGenerator extends WebPro
|
||||
}
|
||||
}
|
||||
if (brokenZip) {
|
||||
GithubDownloadUtil.downloadContentToFileWithProgressSynchronously(
|
||||
project,
|
||||
tag.getZipballUrl(),
|
||||
getTitle(),
|
||||
zipArchiveFile,
|
||||
getGithubUserName(),
|
||||
getGithubRepositoryName()
|
||||
);
|
||||
LOG.info("Downloaded " + zipArchiveFile.getAbsolutePath() + " of size " + zipArchiveFile.length() + " bytes");
|
||||
ZipUtil.unzipWithProgressSynchronously(project, getTitle(), zipArchiveFile, extractToDir);
|
||||
String primaryUrl = getPrimaryZipArchiveUrlForDownload(tag);
|
||||
boolean downloaded = false;
|
||||
if (primaryUrl != null) {
|
||||
try {
|
||||
downloadAndUnzip(project, primaryUrl, zipArchiveFile, extractToDir, false);
|
||||
downloaded = true;
|
||||
} catch (GeneratorException e) {
|
||||
LOG.info("Can't download " + primaryUrl, e);
|
||||
FileUtil.delete(zipArchiveFile);
|
||||
}
|
||||
}
|
||||
if (!downloaded) {
|
||||
downloadAndUnzip(project, tag.getZipballUrl(), zipArchiveFile, extractToDir, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void downloadAndUnzip(@Nullable Project project,
|
||||
@NotNull String url,
|
||||
@NotNull File zipArchiveFile,
|
||||
@NotNull File extractToDir,
|
||||
boolean retryOnError) throws GeneratorException {
|
||||
GithubDownloadUtil.downloadContentToFileWithProgressSynchronously(
|
||||
project,
|
||||
url,
|
||||
getTitle(),
|
||||
zipArchiveFile,
|
||||
getGithubUserName(),
|
||||
getGithubRepositoryName(),
|
||||
retryOnError
|
||||
);
|
||||
LOG.info("Downloaded " + zipArchiveFile.getAbsolutePath() + " of size " + zipArchiveFile.length() + " bytes");
|
||||
ZipUtil.unzipWithProgressSynchronously(project, getTitle(), zipArchiveFile, extractToDir);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract String getPrimaryZipArchiveUrlForDownload(@NotNull GithubTagInfo tag);
|
||||
|
||||
@NotNull
|
||||
private File getCacheFile(@NotNull GithubTagInfo tag) {
|
||||
String fileName = tag.getName() + ".zip";
|
||||
|
||||
+5
-1
@@ -53,7 +53,8 @@ public class GithubDownloadUtil {
|
||||
@NotNull String progressTitle,
|
||||
@NotNull final File outputFile,
|
||||
@NotNull final String userName,
|
||||
@NotNull final String repositoryName) throws GeneratorException
|
||||
@NotNull final String repositoryName,
|
||||
final boolean retryOnError) throws GeneratorException
|
||||
{
|
||||
Outcome<File> outcome = DownloadUtil.provideDataWithProgressSynchronously(
|
||||
project,
|
||||
@@ -69,6 +70,9 @@ public class GithubDownloadUtil {
|
||||
}, new Producer<Boolean>() {
|
||||
@Override
|
||||
public Boolean produce() {
|
||||
if (!retryOnError) {
|
||||
return false;
|
||||
}
|
||||
return IOExceptionDialog.showErrorDialog("Download Error", "Can not download '" + url + "'");
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -165,6 +165,12 @@ public class GithubProjectGeneratorPeer implements WebProjectGenerator.Generator
|
||||
return v2.compareTo(v1);
|
||||
}
|
||||
});
|
||||
for (GithubTagInfo tag : sortedTags) {
|
||||
tag.setRecentTag(false);
|
||||
}
|
||||
if (!sortedTags.isEmpty()) {
|
||||
sortedTags.get(0).setRecentTag(true);
|
||||
}
|
||||
return sortedTags;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ public class GithubTagInfo {
|
||||
private final String myName;
|
||||
private final String myZipballUrl;
|
||||
private Version myVersion;
|
||||
private boolean myRecentTag = false;
|
||||
|
||||
public GithubTagInfo(@NotNull String name, @NotNull String zipballUrl) {
|
||||
myName = name;
|
||||
@@ -30,6 +31,14 @@ public class GithubTagInfo {
|
||||
return myZipballUrl;
|
||||
}
|
||||
|
||||
public void setRecentTag(boolean recentTag) {
|
||||
myRecentTag = recentTag;
|
||||
}
|
||||
|
||||
public boolean isRecentTag() {
|
||||
return myRecentTag;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Version getVersion() {
|
||||
if (myVersion == null) {
|
||||
|
||||
Reference in New Issue
Block a user