mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new module wizard: don't change path to module content root if I create a module from a directory selected in Project View and then change module name
This commit is contained in:
@@ -59,6 +59,8 @@ public class ModuleNameLocationComponent {
|
||||
private boolean myImlLocationChangedByUser = false;
|
||||
private boolean myImlLocationDocListenerEnabled = true;
|
||||
|
||||
private boolean myUpdatePathsWhenNameIsChanged;
|
||||
|
||||
public ModuleNameLocationComponent(@NotNull WizardContext wizardContext) {
|
||||
myWizardContext = wizardContext;
|
||||
}
|
||||
@@ -97,6 +99,10 @@ public class ModuleNameLocationComponent {
|
||||
});
|
||||
myModuleName.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
if (!myUpdatePathsWhenNameIsChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (myModuleNameDocListenerEnabled) {
|
||||
myModuleNameChangedByUser = true;
|
||||
}
|
||||
@@ -159,6 +165,7 @@ public class ModuleNameLocationComponent {
|
||||
}
|
||||
}
|
||||
});
|
||||
myUpdatePathsWhenNameIsChanged = true;
|
||||
if (myWizardContext.isCreatingNewProject()) {
|
||||
setModuleName(namePathComponent.getNameValue());
|
||||
setModuleContentRoot(namePathComponent.getPath());
|
||||
@@ -178,6 +185,7 @@ public class ModuleNameLocationComponent {
|
||||
moduleName =
|
||||
ProjectWizardUtil.findNonExistingFileName(myWizardContext.getProjectFileDirectory(), myWizardContext.getProjectName(), "");
|
||||
contentRoot = myWizardContext.getProjectFileDirectory();
|
||||
myUpdatePathsWhenNameIsChanged = !myWizardContext.isProjectFileDirectorySetExplicitly();
|
||||
}
|
||||
setModuleName(moduleName);
|
||||
setModuleContentRoot(contentRoot);
|
||||
@@ -234,7 +242,7 @@ public class ModuleNameLocationComponent {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String getModuleContentRoot() {
|
||||
private String getModuleContentRoot() {
|
||||
return myModuleContentRoot.getText();
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS
|
||||
private static WizardContext initContext(@Nullable Project project, @Nullable String defaultPath, Disposable parentDisposable) {
|
||||
WizardContext context = new WizardContext(project, parentDisposable);
|
||||
if (defaultPath != null) {
|
||||
context.setProjectFileDirectory(defaultPath);
|
||||
context.setProjectFileDirectory(defaultPath, true);
|
||||
context.setProjectName(defaultPath.substring(FileUtil.toSystemIndependentName(defaultPath).lastIndexOf("/") + 1));
|
||||
}
|
||||
return context;
|
||||
|
||||
@@ -52,6 +52,7 @@ public class WizardContext extends UserDataHolderBase {
|
||||
private StorageScheme myProjectStorageFormat = StorageScheme.DIRECTORY_BASED;
|
||||
private boolean myNewWizard;
|
||||
private ModulesProvider myModulesProvider;
|
||||
private boolean myProjectFileDirectorySetExplicitly;
|
||||
|
||||
public void setProjectStorageFormat(StorageScheme format) {
|
||||
myProjectStorageFormat = format;
|
||||
@@ -122,7 +123,16 @@ public class WizardContext extends UserDataHolderBase {
|
||||
return myProjectFileDirectory != null;
|
||||
}
|
||||
|
||||
public boolean isProjectFileDirectorySetExplicitly() {
|
||||
return myProjectFileDirectorySetExplicitly;
|
||||
}
|
||||
|
||||
public void setProjectFileDirectory(String projectFileDirectory) {
|
||||
setProjectFileDirectory(projectFileDirectory, false);
|
||||
}
|
||||
|
||||
public void setProjectFileDirectory(String projectFileDirectory, boolean explicitly) {
|
||||
myProjectFileDirectorySetExplicitly = explicitly;
|
||||
myProjectFileDirectory = projectFileDirectory;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user