new project wizard: properly update project name/location

When a new project is created we need to update the both module and the project names and locations.
This commit is contained in:
nik
2018-01-18 18:24:21 +03:00
parent b516529522
commit 05beabd649
2 changed files with 43 additions and 1 deletions
@@ -0,0 +1,41 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide.projectWizard;
import com.intellij.ide.util.projectWizard.ModuleNameLocationSettings;
import com.intellij.ide.util.projectWizard.NamePathComponent;
import org.jetbrains.annotations.NotNull;
public class NewProjectNameLocationSettings implements ModuleNameLocationSettings {
private final NamePathComponent myProjectNamePathComponent;
private final ModuleNameLocationComponent myModuleNameLocationComponent;
public NewProjectNameLocationSettings(NamePathComponent projectNamePathComponent,
ModuleNameLocationComponent moduleNameLocationComponent) {
myProjectNamePathComponent = projectNamePathComponent;
myModuleNameLocationComponent = moduleNameLocationComponent;
}
@NotNull
@Override
public String getModuleName() {
return myModuleNameLocationComponent.getModuleName();
}
@Override
public void setModuleName(@NotNull String moduleName) {
myProjectNamePathComponent.getNameComponent().setText(moduleName);
myModuleNameLocationComponent.setModuleName(moduleName);
}
@NotNull
@Override
public String getModuleContentRoot() {
return myModuleNameLocationComponent.getModuleContentRoot();
}
@Override
public void setModuleContentRoot(@NotNull String path) {
myProjectNamePathComponent.setPath(path);
myModuleNameLocationComponent.setModuleContentRoot(path);
}
}
@@ -224,7 +224,8 @@ public class ProjectSettingsStep extends ModuleWizardStep implements SettingsSte
@Nullable
@Override
public ModuleNameLocationSettings getModuleNameLocationSettings() {
return myModuleNameLocationComponent;
return myWizardContext.isCreatingNewProject() ? new NewProjectNameLocationSettings(myNamePathComponent, myModuleNameLocationComponent)
: myModuleNameLocationComponent;
}
@TestOnly