use of com.intellij.platform.ProjectTemplate in project intellij-community by JetBrains.
the class ArchivedTemplatesFactory method createTemplates.
@NotNull
@Override
public ProjectTemplate[] createTemplates(@Nullable String group, WizardContext context) {
// myGroups contains only not-null keys
if (!CUSTOM_GROUP.equals(group)) {
return ProjectTemplate.EMPTY_ARRAY;
}
List<ProjectTemplate> templates = null;
URL url = getCustomTemplatesURL();
try {
for (String child : UrlUtil.getChildrenRelativePaths(url)) {
if (child.endsWith(ZIP)) {
if (templates == null) {
templates = new SmartList<>();
}
templates.add(new LocalArchivedTemplate(new URL(url.toExternalForm() + '/' + child), ClassLoader.getSystemClassLoader()));
}
}
} catch (IOException e) {
LOG.error(e);
}
return ContainerUtil.isEmpty(templates) ? ProjectTemplate.EMPTY_ARRAY : templates.toArray(new ProjectTemplate[templates.size()]);
}
use of com.intellij.platform.ProjectTemplate in project intellij-community by JetBrains.
the class ProjectTemplateList method updateSelection.
private void updateSelection() {
myDescriptionPane.setText("");
ProjectTemplate template = getSelectedTemplate();
if (template != null) {
String description = template.getDescription();
if (StringUtil.isNotEmpty(description)) {
description = "<html><body><font " + (SystemInfo.isMac ? "" : "face=\"Verdana\" size=\"-1\"") + '>' + description + "</font></body></html>";
myDescriptionPane.setText(description);
}
}
}
use of com.intellij.platform.ProjectTemplate in project intellij-community by JetBrains.
the class ProjectTypeStep method loadLocalTemplates.
private MultiMap<String, ProjectTemplate> loadLocalTemplates() {
ConcurrentMultiMap<String, ProjectTemplate> map = new ConcurrentMultiMap<>();
ProjectTemplateEP[] extensions = ProjectTemplateEP.EP_NAME.getExtensions();
for (ProjectTemplateEP ep : extensions) {
ClassLoader classLoader = ep.getLoaderForClass();
URL url = classLoader.getResource(ep.templatePath);
if (url != null) {
try {
LocalArchivedTemplate template = new LocalArchivedTemplate(url, classLoader);
if (ep.category) {
TemplateBasedCategory category = new TemplateBasedCategory(template, ep.projectType);
myTemplatesMap.putValue(new TemplatesGroup(category), template);
} else {
map.putValue(ep.projectType, template);
}
} catch (Exception e) {
LOG.error("Error loading template from URL " + ep.templatePath, e);
}
} else {
LOG.error("Can't find resource for project template " + ep.templatePath);
}
}
return map;
}
use of com.intellij.platform.ProjectTemplate in project intellij-community by JetBrains.
the class ProjectTypeStep method getTemplatesMap.
public static MultiMap<TemplatesGroup, ProjectTemplate> getTemplatesMap(WizardContext context) {
ProjectTemplatesFactory[] factories = ProjectTemplatesFactory.EP_NAME.getExtensions();
final MultiMap<TemplatesGroup, ProjectTemplate> groups = new MultiMap<>();
for (ProjectTemplatesFactory factory : factories) {
for (String group : factory.getGroups()) {
ProjectTemplate[] templates = factory.createTemplates(group, context);
List<ProjectTemplate> values = Arrays.asList(templates);
if (!values.isEmpty()) {
Icon icon = factory.getGroupIcon(group);
String parentGroup = factory.getParentGroup(group);
TemplatesGroup templatesGroup = new TemplatesGroup(group, null, icon, factory.getGroupWeight(group), parentGroup, group, null);
groups.putValues(templatesGroup, values);
}
}
}
return groups;
}
use of com.intellij.platform.ProjectTemplate in project intellij-community by JetBrains.
the class ProjectTypesList method buildItems.
private List<TemplateItem> buildItems(MultiMap<TemplatesGroup, ProjectTemplate> map) {
List<TemplateItem> items = new ArrayList<>();
List<TemplatesGroup> groups = new ArrayList<>(map.keySet());
Collections.sort(groups);
for (TemplatesGroup group : groups) {
for (ProjectTemplate template : map.get(group)) {
TemplateItem templateItem = new TemplateItem(template, group);
items.add(templateItem);
}
}
return items;
}
Aggregations