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);
}
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);
}
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);
}
Aggregations