Search in sources :

Example 1 with ProjectTemplateDescriptor

use of org.eclipse.che.api.project.templates.shared.dto.ProjectTemplateDescriptor in project che by eclipse.

the class CategoriesPagePresenter method loadProjectTypesAndTemplates.

private void loadProjectTypesAndTemplates() {
    List<ProjectTypeDto> projectTypes = projectTypeRegistry.getProjectTypes();
    Map<String, Set<ProjectTypeDto>> typesByCategory = new HashMap<>();
    Map<String, Set<ProjectTemplateDescriptor>> templatesByCategory = new HashMap<>();
    for (ProjectTypeDto type : projectTypes) {
        if (wizardRegistry.getWizardRegistrar(type.getId()) != null) {
            final String category = wizardRegistry.getWizardCategory(type.getId());
            if (!typesByCategory.containsKey(category)) {
                typesByCategory.put(category, new HashSet<ProjectTypeDto>());
            }
            typesByCategory.get(category).add(type);
        }
        List<ProjectTemplateDescriptor> templateDescriptors = projectTemplateRegistry.getTemplateDescriptors(type.getId());
        for (ProjectTemplateDescriptor template : templateDescriptors) {
            final String category = template.getCategory() == null ? DEFAULT_TEMPLATE_CATEGORY : template.getCategory();
            if (!templatesByCategory.containsKey(category)) {
                templatesByCategory.put(category, new HashSet<ProjectTemplateDescriptor>());
            }
            templatesByCategory.get(category).add(template);
        }
    }
    view.setProjectTypes(projectTypes);
    view.setCategories(typesByCategory, templatesByCategory);
}
Also used : ProjectTemplateDescriptor(org.eclipse.che.api.project.templates.shared.dto.ProjectTemplateDescriptor) HashSet(java.util.HashSet) Set(java.util.Set) ProjectTypeDto(org.eclipse.che.api.project.shared.dto.ProjectTypeDto) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ProjectTypeDto (org.eclipse.che.api.project.shared.dto.ProjectTypeDto)1 ProjectTemplateDescriptor (org.eclipse.che.api.project.templates.shared.dto.ProjectTemplateDescriptor)1