use of com.intellij.platform.templates.github.GithubTagInfo in project intellij-community by JetBrains.
the class GithubProjectGeneratorPeer method createSortedTagList.
@NotNull
private static List<GithubTagInfo> createSortedTagList(@NotNull Collection<GithubTagInfo> tags) {
List<GithubTagInfo> sortedTags = ContainerUtil.newArrayList(tags);
Collections.sort(sortedTags, (tag1, tag2) -> {
GithubTagInfo.Version v1 = tag1.getVersion();
GithubTagInfo.Version v2 = tag2.getVersion();
return v2.compareTo(v1);
});
for (GithubTagInfo tag : sortedTags) {
tag.setRecentTag(false);
}
if (!sortedTags.isEmpty()) {
sortedTags.get(0).setRecentTag(true);
}
return sortedTags;
}
use of com.intellij.platform.templates.github.GithubTagInfo in project intellij-community by JetBrains.
the class GithubTagListProvider method getCachedTags.
@Nullable
public ImmutableSet<GithubTagInfo> getCachedTags() {
ApplicationManager.getApplication().assertIsDispatchThread();
File cacheFile = getTagsCacheFile();
if (cacheFile.isFile()) {
try {
ImmutableSet<GithubTagInfo> tags = readTagsFromFile(cacheFile);
LOG.info(getGeneratorName() + "tag info list has been successfully read from cache file " + cacheFile.getAbsolutePath());
return tags;
} catch (GeneratorException e) {
LOG.warn("Can't read cache file " + cacheFile.getAbsolutePath(), e);
}
}
return null;
}
use of com.intellij.platform.templates.github.GithubTagInfo in project intellij-community by JetBrains.
the class GithubTagListProvider method toGithubTagList.
@NotNull
private static ImmutableSet<GithubTagInfo> toGithubTagList(@NotNull JsonElement jsonElement) throws GeneratorException {
if (jsonElement instanceof JsonArray) {
JsonArray array = (JsonArray) jsonElement;
ImmutableSet.Builder<GithubTagInfo> tags = ImmutableSet.builder();
for (JsonElement element : array) {
if (element instanceof JsonObject) {
JsonObject obj = (JsonObject) element;
JsonElement nameElement = obj.get("name");
String name = null;
if (nameElement != null) {
name = nameElement.getAsString();
}
String zipball = null;
JsonElement zipballElement = obj.get("zipball_url");
if (zipballElement != null) {
zipball = zipballElement.getAsString();
}
if (name != null && zipball != null) {
tags.add(new GithubTagInfo(name, zipball));
}
} else {
throw new GeneratorException("Unexpected child element " + element.getClass().getName());
}
}
return tags.build();
} else {
throw new GeneratorException("jsonElement is expected be instance of " + JsonArray.class.getName());
}
}
use of com.intellij.platform.templates.github.GithubTagInfo in project intellij-community by JetBrains.
the class GithubProjectGeneratorPeer method validate.
@Override
@Nullable
public ValidationInfo validate() {
GithubTagInfo tag = myReloadableComboBoxPanel.getSelectedValue();
if (tag != null) {
return null;
}
String errorMessage = StringUtil.notNullize(myReloadableComboBoxPanel.getErrorComponent().getText());
if (errorMessage.isEmpty()) {
errorMessage = "Versions have not been loaded yet.";
}
return new ValidationInfo(errorMessage);
}
Aggregations