Search in sources :

Example 6 with MutableProjectConfig

use of org.eclipse.che.ide.api.project.MutableProjectConfig in project che by eclipse.

the class ImportProjectWizardPresenter method onImporterSelected.

@Override
public void onImporterSelected(ProjectImporterDescriptor importer) {
    final MutableProjectConfig prevData = wizard.getDataObject();
    wizard = getWizardForImporter(importer);
    final MutableProjectConfig dataObject = wizard.getDataObject();
    dataObject.getSource().setType(importer.getId());
    // some values should be shared between wizards for different project types
    dataObject.setName(prevData.getName());
    dataObject.setDescription(prevData.getDescription());
    WizardPage<MutableProjectConfig> firstPage = wizard.navigateToFirst();
    if (firstPage != null) {
        firstPage.init(dataObject);
    }
    WizardPage<MutableProjectConfig> importerPage = wizard.navigateToNext();
    importerPage.go(mainPage.getImporterPanel());
}
Also used : MutableProjectConfig(org.eclipse.che.ide.api.project.MutableProjectConfig)

Example 7 with MutableProjectConfig

use of org.eclipse.che.ide.api.project.MutableProjectConfig in project che by eclipse.

the class ImportProjectWizardPresenter method getWizardForImporter.

/** Creates or returns import wizard for the specified importer. */
private ImportWizard getWizardForImporter(@NotNull ProjectImporterDescriptor importer) {
    if (wizardsCache.containsKey(importer)) {
        return wizardsCache.get(importer);
    }
    final ImportWizardRegistrar wizardRegistrar = wizardRegistry.getWizardRegistrar(importer.getId());
    if (wizardRegistrar == null) {
        // should never occur
        throw new IllegalStateException("WizardRegistrar for the importer " + importer.getId() + " isn't registered.");
    }
    List<Provider<? extends WizardPage<MutableProjectConfig>>> pageProviders = wizardRegistrar.getWizardPages();
    final ImportWizard importWizard = createDefaultWizard();
    for (Provider<? extends WizardPage<MutableProjectConfig>> provider : pageProviders) {
        importWizard.addPage(provider.get(), 1, false);
    }
    wizardsCache.put(importer, importWizard);
    return importWizard;
}
Also used : ImportWizardRegistrar(org.eclipse.che.ide.api.project.wizard.ImportWizardRegistrar) MutableProjectConfig(org.eclipse.che.ide.api.project.MutableProjectConfig) ImportWizard(org.eclipse.che.ide.projectimport.wizard.ImportWizard) WizardPage(org.eclipse.che.ide.api.wizard.WizardPage) Provider(com.google.inject.Provider)

Example 8 with MutableProjectConfig

use of org.eclipse.che.ide.api.project.MutableProjectConfig in project che by eclipse.

the class ImportProjectWizardPresenter method createDefaultWizard.

/** Creates and returns 'default' project wizard with pre-defined pages only. */
private ImportWizard createDefaultWizard() {
    final MutableProjectConfig dataObject = new MutableProjectConfig();
    final ImportWizard importWizard = importWizardFactory.newWizard(dataObject);
    importWizard.setUpdateDelegate(this);
    // add pre-defined first page
    importWizard.addPage(mainPage);
    return importWizard;
}
Also used : MutableProjectConfig(org.eclipse.che.ide.api.project.MutableProjectConfig) ImportWizard(org.eclipse.che.ide.projectimport.wizard.ImportWizard)

Example 9 with MutableProjectConfig

use of org.eclipse.che.ide.api.project.MutableProjectConfig in project che by eclipse.

the class ConvertFolderToProjectActionTest method configurationWizardShouldBeShowed.

@Test
public void configurationWizardShouldBeShowed() throws Exception {
    when(resource.getName()).thenReturn(TEXT);
    action.actionPerformed(event);
    verify(resource).getName();
    verify(projectConfigWizard).show(projectConfigCapture.capture());
    MutableProjectConfig projectConfig = projectConfigCapture.getValue();
    assertEquals(TEXT, projectConfig.getName());
    assertEquals(TEXT, projectConfig.getPath());
}
Also used : MutableProjectConfig(org.eclipse.che.ide.api.project.MutableProjectConfig) Test(org.junit.Test)

Example 10 with MutableProjectConfig

use of org.eclipse.che.ide.api.project.MutableProjectConfig 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

MutableProjectConfig (org.eclipse.che.ide.api.project.MutableProjectConfig)13 List (java.util.List)3 Function (org.eclipse.che.api.promises.client.Function)3 FunctionException (org.eclipse.che.api.promises.client.FunctionException)3 Promise (org.eclipse.che.api.promises.client.Promise)3 Project (org.eclipse.che.ide.api.resources.Project)3 Resource (org.eclipse.che.ide.api.resources.Resource)3 Provider (com.google.inject.Provider)2 PromiseError (org.eclipse.che.api.promises.client.PromiseError)2 WizardPage (org.eclipse.che.ide.api.wizard.WizardPage)2 ImportWizard (org.eclipse.che.ide.projectimport.wizard.ImportWizard)2 Path (org.eclipse.che.ide.resource.Path)2 Optional (com.google.common.base.Optional)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 NewProjectConfig (org.eclipse.che.api.core.model.project.NewProjectConfig)1 SourceStorage (org.eclipse.che.api.core.model.project.SourceStorage)1 AttributeDto (org.eclipse.che.api.project.shared.dto.AttributeDto)1