Search in sources :

Example 1 with ProjectTypeDto

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

the class DtoConverter method asDto.

/** Converts {@link ProjectTypeDef} to {@link ProjectTypeDto}. */
public static ProjectTypeDto asDto(ProjectTypeDef projectType) {
    final List<AttributeDto> typeAttributes = new ArrayList<>();
    for (Attribute attr : projectType.getAttributes()) {
        ValueDto valueDto = newDto(ValueDto.class);
        if (attr.getValue() != null) {
            valueDto.withList(attr.getValue().getList());
        }
        typeAttributes.add(newDto(AttributeDto.class).withName(attr.getName()).withDescription(attr.getDescription()).withRequired(attr.isRequired()).withVariable(attr.isVariable()).withValue(valueDto));
    }
    return newDto(ProjectTypeDto.class).withId(projectType.getId()).withDisplayName(projectType.getDisplayName()).withPrimaryable(projectType.isPrimaryable()).withMixable(projectType.isMixable()).withParents(projectType.getParents()).withAncestors(projectType.getAncestors()).withAttributes(typeAttributes);
}
Also used : AttributeDto(org.eclipse.che.api.project.shared.dto.AttributeDto) ValueDto(org.eclipse.che.api.project.shared.dto.ValueDto) ProjectTypeDto(org.eclipse.che.api.project.shared.dto.ProjectTypeDto) Attribute(org.eclipse.che.api.core.model.project.type.Attribute) ArrayList(java.util.ArrayList)

Example 2 with ProjectTypeDto

use of org.eclipse.che.api.project.shared.dto.ProjectTypeDto 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)

Example 3 with ProjectTypeDto

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

the class CategoriesPageViewImpl method selectProjectType.

@Override
public void selectProjectType(final String projectTypeId) {
    ProjectTypeDto typeDescriptor = null;
    for (Map.Entry<String, Set<ProjectTypeDto>> entry : typesByCategory.entrySet()) {
        for (ProjectTypeDto typeDefinition : entry.getValue()) {
            if (typeDefinition.getId().equals(projectTypeId)) {
                typeDescriptor = typeDefinition;
                break;
            }
        }
        if (typeDescriptor != null) {
            break;
        }
    }
    if (typeDescriptor != null) {
        for (ProjectTypeDto existingProjectTypeDescriptor : availableProjectTypes) {
            if (existingProjectTypeDescriptor.getId().equals(typeDescriptor.getId())) {
                categoriesList.selectElement(typeDescriptor);
                selectNextWizardType(typeDescriptor);
            }
        }
    }
    projectName.setFocus(true);
}
Also used : Set(java.util.Set) ProjectTypeDto(org.eclipse.che.api.project.shared.dto.ProjectTypeDto) Map(java.util.Map)

Aggregations

ProjectTypeDto (org.eclipse.che.api.project.shared.dto.ProjectTypeDto)3 Set (java.util.Set)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Attribute (org.eclipse.che.api.core.model.project.type.Attribute)1 AttributeDto (org.eclipse.che.api.project.shared.dto.AttributeDto)1 ValueDto (org.eclipse.che.api.project.shared.dto.ValueDto)1 ProjectTemplateDescriptor (org.eclipse.che.api.project.templates.shared.dto.ProjectTemplateDescriptor)1