Search in sources :

Example 1 with AttributeDto

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

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());
}
Also used : AttributeDto(org.eclipse.che.api.project.shared.dto.AttributeDto) MutableProjectConfig(org.eclipse.che.ide.api.project.MutableProjectConfig) HashMap(java.util.HashMap) List(java.util.List)

Aggregations

AttributeDto (org.eclipse.che.api.project.shared.dto.AttributeDto)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Attribute (org.eclipse.che.api.core.model.project.type.Attribute)1 ProjectTypeDto (org.eclipse.che.api.project.shared.dto.ProjectTypeDto)1 ValueDto (org.eclipse.che.api.project.shared.dto.ValueDto)1 MutableProjectConfig (org.eclipse.che.ide.api.project.MutableProjectConfig)1