use of org.eclipse.che.api.project.shared.dto.AttributeDto 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.AttributeDto in project che by eclipse.
the class ProjectWizardPresenter method onProjectTypeSelected.
@Override
public void onProjectTypeSelected(ProjectTypeDto projectType) {
final MutableProjectConfig prevData = wizard.getDataObject();
wizard = getWizardForProjectType(projectType, prevData);
wizard.navigateToFirst();
final MutableProjectConfig newProject = wizard.getDataObject();
// some values should be shared between wizards for different project types
newProject.setPath(prevData.getPath());
newProject.setName(prevData.getName());
newProject.setDescription(prevData.getDescription());
newProject.setMixins(prevData.getMixins());
if (wizardMode == UPDATE) {
newProject.setAttributes(prevData.getAttributes());
} else {
final MutableProjectConfig.MutableSourceStorage sourceStorage = prevData.getSource();
if (sourceStorage != null) {
// some values should be cleared when user switch between categories
sourceStorage.setLocation("");
sourceStorage.setType("");
sourceStorage.getParameters().clear();
}
prevData.getProjects().clear();
final List<AttributeDto> attributes = projectType.getAttributes();
Map<String, List<String>> prevDataAttributes = prevData.getAttributes();
Map<String, List<String>> newAttributes = new HashMap<>();
for (AttributeDto attribute : attributes) {
if (prevDataAttributes.containsKey(attribute.getName())) {
newAttributes.put(attribute.getName(), prevDataAttributes.get(attribute.getName()));
}
}
newProject.setAttributes(newAttributes);
}
// set dataObject's values from projectType
newProject.setType(projectType.getId());
}
Aggregations