Search in sources :

Example 1 with ProjectTemplate

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()]);
}
Also used : IOException(java.io.IOException) URL(java.net.URL) ProjectTemplate(com.intellij.platform.ProjectTemplate) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ProjectTemplate

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);
        }
    }
}
Also used : ProjectTemplate(com.intellij.platform.ProjectTemplate) ArchivedProjectTemplate(com.intellij.platform.templates.ArchivedProjectTemplate)

Example 3 with ProjectTemplate

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;
}
Also used : ProjectTemplateEP(com.intellij.platform.ProjectTemplateEP) URL(java.net.URL) CommitStepException(com.intellij.ide.wizard.CommitStepException) ConfigurationException(com.intellij.openapi.options.ConfigurationException) ProjectTemplate(com.intellij.platform.ProjectTemplate)

Example 4 with ProjectTemplate

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;
}
Also used : ProjectTemplatesFactory(com.intellij.platform.ProjectTemplatesFactory) ProjectTemplate(com.intellij.platform.ProjectTemplate)

Example 5 with ProjectTemplate

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;
}
Also used : ArrayList(java.util.ArrayList) ProjectTemplate(com.intellij.platform.ProjectTemplate)

Aggregations

ProjectTemplate (com.intellij.platform.ProjectTemplate)9 ArchivedProjectTemplate (com.intellij.platform.templates.ArchivedProjectTemplate)2 URL (java.net.URL)2 NotNull (org.jetbrains.annotations.NotNull)2 CommitStepException (com.intellij.ide.wizard.CommitStepException)1 ModuleType (com.intellij.openapi.module.ModuleType)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 ProjectTemplateEP (com.intellij.platform.ProjectTemplateEP)1 ProjectTemplatesFactory (com.intellij.platform.ProjectTemplatesFactory)1 CollectionListModel (com.intellij.ui.CollectionListModel)1 CustomHDInsightTemplateItem (com.microsoft.azure.hdinsight.projects.template.CustomHDInsightTemplateItem)1 CustomProjectTemplate (com.microsoft.azure.hdinsight.projects.template.CustomProjectTemplate)1 THashMap (gnu.trove.THashMap)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1