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