void (final NamePathComponent namePathComponent) { namePathComponent.getNameComponent().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull final DocumentEvent e) { if (!myModuleNameChangedByUser) { setModuleName(namePathComponent.getNameValue()); } } }); myModuleContentRoot.addBrowseFolderListener(JavaUiBundle.message("project.new.wizard.module.content.root.chooser.title"), JavaUiBundle.message("project.new.wizard.module.content.root.chooser.description"), myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR); namePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull final DocumentEvent e) { if (!myContentRootChangedByUser) { setModuleContentRoot(namePathComponent.getPath(), true); } } }); myModuleName.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull final DocumentEvent e) { if (!myUpdatePathsWhenNameIsChanged) { return; } if (myModuleNameDocListenerEnabled) { myModuleNameChangedByUser = true; } String path = getDefaultBaseDir(myWizardContext, namePathComponent); final String moduleName = getModuleName(); if (path.length() > 0 && !Comparing.strEqual(moduleName, namePathComponent.getNameValue())) { path += "/" + moduleName; } if (!myContentRootChangedByUser) { setModuleContentRoot(path); } if (!myImlLocationChangedByUser) { setImlFileLocation(path); } } }); myModuleContentRoot.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull final DocumentEvent e) { if (myContentRootDocListenerEnabled) { myContentRootChangedByUser = true; } if (!myImlLocationChangedByUser) { setImlFileLocation(getModuleContentRoot()); } if (!myModuleNameChangedByUser && myUpdateNameWhenPathIsChanged) { final String path = FileUtil.toSystemIndependentName(getModuleContentRoot()); final int idx = path.lastIndexOf("/"); boolean oldValue = myUpdatePathsWhenNameIsChanged; myUpdatePathsWhenNameIsChanged = false; setModuleName(idx >= 0 ? path.substring(idx + 1) : ""); myUpdatePathsWhenNameIsChanged = oldValue; } } }); myModuleFileLocation.addBrowseFolderListener(JavaUiBundle.message("project.new.wizard.module.file.chooser.title"), JavaUiBundle.message("project.new.wizard.module.file.description"), myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR); myModuleFileLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull final DocumentEvent e) { if (myImlLocationDocListenerEnabled) { myImlLocationChangedByUser = true; } } }); namePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull final DocumentEvent e) { if (!myImlLocationChangedByUser) { setImlFileLocation(namePathComponent.getPath()); } } }); myUpdatePathsWhenNameIsChanged = true; if (myWizardContext.isCreatingNewProject()) { setModuleName(namePathComponent.getNameValue()); setModuleContentRoot(namePathComponent.getPath()); setImlFileLocation(namePathComponent.getPath()); } else { Project project = myWizardContext.getProject(); assert project != null; String baseDirPath = project.getBasePath(); //e.g. was deleted if (baseDirPath != null) { String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, myWizardContext.getDefaultModuleName(), ""); String contentRoot = baseDirPath + "/" + moduleName; if (!Comparing.strEqual(project.getName(), myWizardContext.getProjectName()) && !myWizardContext.isCreatingNewProject() && myWizardContext.getProjectName() != null) { moduleName = ProjectWizardUtil.findNonExistingFileName(myWizardContext.getProjectFileDirectory(), myWizardContext.getProjectName(), ""); contentRoot = myWizardContext.getProjectFileDirectory(); myUpdatePathsWhenNameIsChanged = !myWizardContext.isProjectFileDirectorySetExplicitly(); } setModuleName(moduleName); setModuleContentRoot(contentRoot); setImlFileLocation(contentRoot); myModuleName.select(0, moduleName.length()); } } }