diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java
index 73d91d0f7ab4..d04f8d12f079 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameStep.java
@@ -28,7 +28,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.projectImport.ProjectFormatPanel;
-import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -39,7 +38,7 @@ import java.io.File;
* @author Eugene Zhuravlev
* Date: Jul 17, 2007
*/
-public class ProjectNameStep extends SettingsStep {
+public class ProjectNameStep extends ModuleWizardStep {
private final JPanel myPanel;
protected final JPanel myAdditionalContentPanel;
protected NamePathComponent myNamePathComponent;
@@ -64,6 +63,7 @@ public class ProjectNameStep extends SettingsStep {
myNamePathComponent.setPath(projectName == null ? (baseDir + File.separator + initialProjectName) : baseDir);
myNamePathComponent.setNameValue(initialProjectName);
myNamePathComponent.getNameComponent().select(0, initialProjectName.length());
+
myPanel = new JPanel(new GridBagLayout());
myPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
myPanel.add(myNamePathComponent, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 20, 0), 0, 0));
@@ -170,25 +170,4 @@ public class ProjectNameStep extends SettingsStep {
return shouldContinue;
}
-
- @NotNull
- @Override
- public JComponent getSettingsPanel() {
- return getComponent();
- }
-
- @Override
- public JComponent getExpertSettingsPanel() {
- return null;
- }
-
- @Override
- public SettingsStep addField(String label, JComponent field) {
- return this;
- }
-
- @Override
- public SettingsStep addExpertPanel(JComponent panel) {
- return this;
- }
}
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.form b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.form
deleted file mode 100644
index 2d88360d12eb..000000000000
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.form
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.java
deleted file mode 100644
index dbf9eeffc737..000000000000
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectSettingsStep.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.ide.util.newProjectWizard;
-
-import com.intellij.ide.IdeBundle;
-import com.intellij.ide.highlighter.ModuleFileType;
-import com.intellij.ide.util.BrowseFilesListener;
-import com.intellij.ide.util.newProjectWizard.modes.CreateFromTemplateMode;
-import com.intellij.ide.util.projectWizard.ModuleBuilder;
-import com.intellij.ide.util.projectWizard.ProjectWizardUtil;
-import com.intellij.ide.util.projectWizard.SettingsStep;
-import com.intellij.ide.util.projectWizard.WizardContext;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleManager;
-import com.intellij.openapi.options.ConfigurationException;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.project.ProjectBundle;
-import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.ui.TextFieldWithBrowseButton;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.ui.DocumentAdapter;
-import com.intellij.ui.components.JBLabel;
-import org.jetbrains.annotations.NotNull;
-
-import javax.swing.*;
-import javax.swing.event.DocumentEvent;
-import java.awt.*;
-import java.io.File;
-
-public class ProjectSettingsStep extends ProjectNameStep {
- private JPanel myModulePanel;
- private JTextField myModuleName;
- private TextFieldWithBrowseButton myModuleContentRoot;
- private TextFieldWithBrowseButton myModuleFileLocation;
- private JPanel myHeader;
- private JPanel myExpertPanel;
-
- private boolean myModuleNameChangedByUser = false;
- private boolean myModuleNameDocListenerEnabled = true;
-
- private boolean myContentRootChangedByUser = false;
- private boolean myContentRootDocListenerEnabled = true;
-
- private boolean myImlLocationChangedByUser = false;
- private boolean myImlLocationDocListenerEnabled = true;
-
-
- public ProjectSettingsStep(final WizardContext wizardContext) {
- super(wizardContext, null);
- myAdditionalContentPanel.add(myModulePanel,
- new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.NORTHWEST,
- GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
- myHeader.setVisible(myWizardContext.isCreatingNewProject() && !isCreateFromTemplateMode());
- myNamePathComponent.getNameComponent().getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (!myModuleNameChangedByUser) {
- setModuleName(myNamePathComponent.getNameValue());
- }
- }
- });
-
- myModuleContentRoot.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.content.root.chooser.title"), ProjectBundle.message("project.new.wizard.module.content.root.chooser.description"),
- myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
-
- myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (!myContentRootChangedByUser) {
- setModuleContentRoot(myNamePathComponent.getPath());
- }
- }
- });
- myModuleName.getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (myModuleNameDocListenerEnabled) {
- myModuleNameChangedByUser = true;
- }
- String path = getDefaultBaseDir(wizardContext);
- final String moduleName = getModuleName();
- if (path.length() > 0 && !Comparing.strEqual(moduleName, myNamePathComponent.getNameValue())) {
- path += "/" + moduleName;
- }
- if (!myContentRootChangedByUser) {
- final boolean f = myModuleNameChangedByUser;
- myModuleNameChangedByUser = true;
- setModuleContentRoot(path);
- myModuleNameChangedByUser = f;
- }
- if (!myImlLocationChangedByUser) {
- setImlFileLocation(path);
- }
- }
- });
- myModuleContentRoot.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (myContentRootDocListenerEnabled) {
- myContentRootChangedByUser = true;
- }
- if (!myImlLocationChangedByUser) {
- setImlFileLocation(getModuleContentRoot());
- }
- if (!myModuleNameChangedByUser) {
- final String path = FileUtil.toSystemIndependentName(getModuleContentRoot());
- final int idx = path.lastIndexOf("/");
-
- boolean f = myContentRootChangedByUser;
- myContentRootChangedByUser = true;
-
- boolean i = myImlLocationChangedByUser;
- myImlLocationChangedByUser = true;
-
- setModuleName(idx >= 0 ? path.substring(idx + 1) : "");
-
- myContentRootChangedByUser = f;
- myImlLocationChangedByUser = i;
- }
- }
- });
-
- myModuleFileLocation.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.file.chooser.title"), ProjectBundle.message("project.new.wizard.module.file.description"),
- myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
- myModuleFileLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (myImlLocationDocListenerEnabled) {
- myImlLocationChangedByUser = true;
- }
- }
- });
- myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (!myImlLocationChangedByUser) {
- setImlFileLocation(myNamePathComponent.getPath());
- }
- }
- });
- if (wizardContext.isCreatingNewProject()) {
- setModuleName(myNamePathComponent.getNameValue());
- setModuleContentRoot(myNamePathComponent.getPath());
- setImlFileLocation(myNamePathComponent.getPath());
- } else {
- final Project project = wizardContext.getProject();
- assert project != null;
- VirtualFile baseDir = project.getBaseDir();
- if (baseDir != null) { //e.g. was deleted
- final String baseDirPath = baseDir.getPath();
- String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, "untitled", "");
- String contentRoot = baseDirPath + "/" + moduleName;
- if (!Comparing.strEqual(project.getName(), wizardContext.getProjectName()) && !wizardContext.isCreatingNewProject() && wizardContext.getProjectName() != null) {
- moduleName = ProjectWizardUtil.findNonExistingFileName(wizardContext.getProjectFileDirectory(), wizardContext.getProjectName(), "");
- contentRoot = wizardContext.getProjectFileDirectory();
- }
- setModuleName(moduleName);
- setModuleContentRoot(contentRoot);
- setImlFileLocation(contentRoot);
- myModuleName.select(0, moduleName.length());
- }
- }
- }
-
- protected String getModuleContentRoot() {
- return myModuleContentRoot.getText();
- }
-
- private boolean isCreateFromTemplateMode() {
- return myMode instanceof CreateFromTemplateMode;
- }
-
- private String getDefaultBaseDir(WizardContext wizardContext) {
- if (wizardContext.isCreatingNewProject()) {
- return myNamePathComponent.getPath();
- } else {
- final Project project = wizardContext.getProject();
- assert project != null;
- final VirtualFile baseDir = project.getBaseDir();
- if (baseDir != null) {
- return baseDir.getPath();
- }
- return "";
- }
- }
-
- public JComponent getPreferredFocusedComponent() {
- return myWizardContext.isCreatingNewProject() ? super.getPreferredFocusedComponent() : myModuleName;
- }
-
- private void setImlFileLocation(final String path) {
- myImlLocationDocListenerEnabled = false;
- myModuleFileLocation.setText(FileUtil.toSystemDependentName(path));
- myImlLocationDocListenerEnabled = true;
- }
-
- private void setModuleContentRoot(final String path) {
- myContentRootDocListenerEnabled = false;
- myModuleContentRoot.setText(FileUtil.toSystemDependentName(path));
- myContentRootDocListenerEnabled = true;
- }
-
- private void setModuleName(String moduleName) {
- myModuleNameDocListenerEnabled = false;
- myModuleName.setText(moduleName);
- myModuleNameDocListenerEnabled = true;
- }
-
- public void updateDataModel() {
-
- super.updateDataModel();
-
- final ModuleBuilder builder = (ModuleBuilder)myWizardContext.getProjectBuilder();
- assert builder != null;
- final String moduleName = getModuleName();
- builder.setName(moduleName);
- builder.setModuleFilePath(
- FileUtil.toSystemIndependentName(myModuleFileLocation.getText()) + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
- builder.setContentEntryPath(FileUtil.toSystemIndependentName(getModuleContentRoot()));
- }
-
- public boolean validate() throws ConfigurationException {
- final String moduleName = getModuleName();
- if (!myWizardContext.isCreatingNewProject()) {
- final String moduleFileDirectory = myModuleFileLocation.getText();
- if (moduleFileDirectory.length() == 0) {
- throw new ConfigurationException("Enter module file location");
- }
- if (moduleName.length() == 0) {
- throw new ConfigurationException("Enter a module name");
- }
-
- if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.file"), moduleFileDirectory,
- myImlLocationChangedByUser)) {
- return false;
- }
- if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.content.root"), getModuleContentRoot(),
- myContentRootChangedByUser)) {
- return false;
- }
-
- File moduleFile = new File(moduleFileDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
- if (moduleFile.exists()) {
- int answer = Messages.showYesNoDialog(IdeBundle.message("prompt.overwrite.project.file", moduleFile.getAbsolutePath(), IdeBundle.message("project.new.wizard.module.identification")),
- IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon());
- if (answer != 0) {
- return false;
- }
- }
- }
- Project project = myWizardContext.getProject();
- if (project != null) {
- final Module module;
- final ProjectStructureConfigurable fromConfigurable = ProjectStructureConfigurable.getInstance(project);
- if (fromConfigurable != null) {
- module = fromConfigurable.getModulesConfig().getModule(moduleName);
- }
- else {
- module = ModuleManager.getInstance(project).findModuleByName(moduleName);
- }
- if (module != null) {
- throw new ConfigurationException("Module \'" + moduleName + "\' already exist in project. Please, specify another name.");
- }
- }
- return !myWizardContext.isCreatingNewProject() || super.validate();
- }
-
- protected String getModuleName() {
- return myModuleName.getText().trim();
- }
-
- @NotNull
- @Override
- public JComponent getSettingsPanel() {
- return myWizardContext.isCreatingNewProject() ? myNamePathComponent : myModulePanel;
- }
-
- @Override
- public JComponent getExpertSettingsPanel() {
- return myWizardContext.isCreatingNewProject() ? myModulePanel : myExpertPanel.getComponentCount() == 0 ? null : myExpertPanel;
- }
-
- @Override
- public SettingsStep addField(String label, JComponent field) {
- JComponent settingsPanel = getSettingsPanel();
-
- JLabel jLabel = new JBLabel(label);
- jLabel.setLabelFor(field);
- settingsPanel.add(jLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.WEST,
- GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
- settingsPanel.add(field, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST,
- GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
- return this;
- }
-
- @Override
- public SettingsStep addExpertPanel(JComponent panel) {
- JComponent settingsPanel = myExpertPanel;
- settingsPanel.add(panel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST,
- GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
- return this;
- }
-}
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.form b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.form
index d5d1b4f15b64..e1ee5c05740a 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.form
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.form
@@ -3,14 +3,16 @@
-
+
-
+
+
+
@@ -60,7 +62,15 @@
-
+
+
+
+
+
+
+
+
+
@@ -93,7 +103,70 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
index b3ac5e7b6719..99484f92e2b2 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
@@ -15,6 +15,9 @@
*/
package com.intellij.ide.util.newProjectWizard;
+import com.intellij.ide.IdeBundle;
+import com.intellij.ide.highlighter.ModuleFileType;
+import com.intellij.ide.util.BrowseFilesListener;
import com.intellij.ide.util.projectWizard.*;
import com.intellij.ide.util.treeView.AlphaComparator;
import com.intellij.ide.util.treeView.NodeDescriptor;
@@ -23,12 +26,17 @@ import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.ui.TextFieldWithBrowseButton;
+import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.platform.ProjectTemplate;
import com.intellij.platform.ProjectTemplatesFactory;
import com.intellij.platform.templates.ArchivedTemplatesFactory;
@@ -36,6 +44,7 @@ import com.intellij.platform.templates.EmptyModuleTemplatesFactory;
import com.intellij.psi.codeStyle.MinusculeMatcher;
import com.intellij.psi.codeStyle.NameUtil;
import com.intellij.ui.*;
+import com.intellij.ui.components.JBLabel;
import com.intellij.ui.speedSearch.ElementFilter;
import com.intellij.ui.treeStructure.*;
import com.intellij.ui.treeStructure.filtered.FilteringTreeBuilder;
@@ -55,6 +64,7 @@ import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
+import java.io.File;
import java.util.*;
import java.util.List;
@@ -62,7 +72,7 @@ import java.util.List;
* @author Dmitry Avdeev
* Date: 9/26/12
*/
-public class SelectTemplateStep extends ModuleWizardStep {
+public class SelectTemplateStep extends ModuleWizardStep implements SettingsStep {
private JPanel myPanel;
private SimpleTree myTemplatesTree;
@@ -70,24 +80,49 @@ public class SelectTemplateStep extends ModuleWizardStep {
private SearchTextField mySearchField;
private JTextPane myDescriptionPane;
private JPanel myDescriptionPanel;
- private JPanel myExpertPlaceholder;
- private HideableTitledPanel myExpertPanel = new HideableTitledPanel("E&xpert Settings", false);
- private final WizardContext myContext;
+ private JPanel myExpertPlaceholder;
+ private JPanel myExpertPanel;
+ private final HideableDecorator myExpertDecorator;
+
+ private final NamePathComponent myNamePathComponent;
+ private JTextField myModuleName;
+ private TextFieldWithBrowseButton myModuleContentRoot;
+ private TextFieldWithBrowseButton myModuleFileLocation;
+
+ private boolean myModuleNameChangedByUser = false;
+ private boolean myModuleNameDocListenerEnabled = true;
+
+ private boolean myContentRootChangedByUser = false;
+ private boolean myContentRootDocListenerEnabled = true;
+
+ private boolean myImlLocationChangedByUser = false;
+ private boolean myImlLocationDocListenerEnabled = true;
+
+ private final WizardContext myWizardContext;
private final StepSequence mySequence;
- private SettingsStep mySettingsStep;
+ @Nullable
+ private ModuleWizardStep mySettingsCallback;
private final ElementFilter.Active.Impl myFilter;
private final FilteringTreeBuilder myBuilder;
private MinusculeMatcher[] myMatchers;
+ @Nullable
private ModuleBuilder myModuleBuilder;
public SelectTemplateStep(WizardContext context, StepSequence sequence) {
- myContext = context;
+ myWizardContext = context;
mySequence = sequence;
Messages.installHyperlinkSupport(myDescriptionPane);
- myExpertPlaceholder.add(myExpertPanel, BorderLayout.CENTER);
+
+ myNamePathComponent = initNamePathComponent(context);
+ mySettingsPanel.add(myNamePathComponent, BorderLayout.NORTH);
+ bindTo();
+
+ myExpertDecorator = new HideableDecorator(myExpertPlaceholder, "Mor&e settings", false);
+ myExpertPanel.setBorder(IdeBorderFactory.createEmptyBorder(0, IdeBorderFactory.TITLED_BORDER_INDENT, 5, 0));
+ myExpertDecorator.setContentComponent(myExpertPanel);
ProjectTemplatesFactory[] factories = ProjectTemplatesFactory.EP_NAME.getExtensions();
final MultiMap groups = new MultiMap();
@@ -184,13 +219,9 @@ public class SelectTemplateStep extends ModuleWizardStep {
public void valueChanged(TreeSelectionEvent e) {
ProjectTemplate template = getSelectedTemplate();
myModuleBuilder = template == null ? null : template.createModuleBuilder();
- mySettingsStep = myModuleBuilder == null ? null : myModuleBuilder.createSettingsStep(myContext);
- if (mySettingsStep == null) {
- mySettingsStep = ProjectWizardStepFactory.getInstance().createSettingsStep(myContext);
- }
setupPanels(template);
mySequence.setType(myModuleBuilder == null ? null : myModuleBuilder.getBuilderId());
- myContext.requestWizardButtonsUpdate();
+ myWizardContext.requestWizardButtonsUpdate();
}
});
@@ -225,6 +256,7 @@ public class SelectTemplateStep extends ModuleWizardStep {
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN), mySearchField);
+ //noinspection SSBasedInspection
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@@ -239,22 +271,33 @@ public class SelectTemplateStep extends ModuleWizardStep {
});
}
+ private static NamePathComponent initNamePathComponent(WizardContext context) {
+ NamePathComponent component = new NamePathComponent(
+ IdeBundle.message("label.project.name"),
+ IdeBundle.message("label.project.files.location"),
+ IdeBundle.message("title.select.project.file.directory", IdeBundle.message("project.new.wizard.project.identification")),
+ IdeBundle.message("description.select.project.file.directory", StringUtil
+ .capitalize(IdeBundle.message("project.new.wizard.project.identification"))),
+ true, false
+ );
+ final String baseDir = context.getProjectFileDirectory();
+ final String projectName = context.getProjectName();
+ final String initialProjectName = projectName != null ? projectName : ProjectWizardUtil.findNonExistingFileName(baseDir, "untitled", "");
+ component.setPath(projectName == null ? (baseDir + File.separator + initialProjectName) : baseDir);
+ component.setNameValue(initialProjectName);
+ component.getNameComponent().select(0, initialProjectName.length());
+ return component;
+ }
+
private void setupPanels(@Nullable ProjectTemplate template) {
- if (mySettingsPanel.getComponentCount() > 0) {
- mySettingsPanel.remove(0);
- }
- myExpertPanel.setContentComponent(null);
- JComponent expertSettingsPanel = null;
+
+ restorePanel(myNamePathComponent, 4);
+ restorePanel(myExpertPanel, 6);
+
+ mySettingsCallback = myModuleBuilder == null ? null : myModuleBuilder.modifySettingsStep(this);
+
String description = null;
if (template != null) {
- if (mySettingsStep != null) {
- mySettingsPanel.add(mySettingsStep.getSettingsPanel(), BorderLayout.NORTH);
- expertSettingsPanel = mySettingsStep.getExpertSettingsPanel();
- if (expertSettingsPanel != null) {
- expertSettingsPanel.setBorder(IdeBorderFactory.createEmptyBorder(5, IdeBorderFactory.TITLED_BORDER_INDENT, 5, 0));
- myExpertPanel.setContentComponent(expertSettingsPanel);
- }
- }
description = template.getDescription();
if (StringUtil.isNotEmpty(description)) {
StringBuilder sb = new StringBuilder(" i) {
+ component.remove(component.getComponentCount() - 1);
+ }
+ }
+
@Override
public void updateStep() {
myBuilder.queueUpdate();
- myExpertPanel.setOn(SelectTemplateSettings.getInstance().EXPERT_MODE);
+ myExpertDecorator.setOn(SelectTemplateSettings.getInstance().EXPERT_MODE);
}
@Override
@@ -283,17 +333,17 @@ public class SelectTemplateStep extends ModuleWizardStep {
TreeState state = TreeState.createOn(myTemplatesTree, (DefaultMutableTreeNode)myTemplatesTree.getModel().getRoot());
SelectTemplateSettings settings = SelectTemplateSettings.getInstance();
settings.setTreeState(state);
- settings.EXPERT_MODE = myExpertPanel.isExpanded();
+ settings.EXPERT_MODE = myExpertDecorator.isExpanded();
}
@Override
public boolean validate() throws ConfigurationException {
ProjectTemplate template = getSelectedTemplate();
if (template == null) {
- throw new ConfigurationException(ProjectBundle.message("project.new.wizard.from.template.error", myContext.getPresentationName()));
+ throw new ConfigurationException(ProjectBundle.message("project.new.wizard.from.template.error", myWizardContext.getPresentationName()));
}
- if (mySettingsStep != null) {
- return mySettingsStep.validate();
+ if (mySettingsCallback != null) {
+ return mySettingsCallback.validate();
}
return true;
}
@@ -377,9 +427,21 @@ public class SelectTemplateStep extends ModuleWizardStep {
@Override
public void updateDataModel() {
- myContext.setProjectBuilder(myModuleBuilder);
- if (mySettingsStep != null) {
- mySettingsStep.updateDataModel();
+
+ myWizardContext.setProjectBuilder(myModuleBuilder);
+ myWizardContext.setProjectName(myNamePathComponent.getNameValue());
+ myWizardContext.setProjectFileDirectory(myNamePathComponent.getPath());
+
+ if (myModuleBuilder != null) {
+ final String moduleName = getModuleName();
+ myModuleBuilder.setName(moduleName);
+ myModuleBuilder.setModuleFilePath(
+ FileUtil.toSystemIndependentName(myModuleFileLocation.getText()) + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
+ myModuleBuilder.setContentEntryPath(FileUtil.toSystemIndependentName(getModuleContentRoot()));
+ }
+
+ if (mySettingsCallback != null) {
+ mySettingsCallback.updateDataModel();
}
}
@@ -397,6 +459,28 @@ public class SelectTemplateStep extends ModuleWizardStep {
mySearchField = new SearchTextField(false);
}
+ @Override
+ public WizardContext getContext() {
+ return myWizardContext;
+ }
+
+ @Override
+ public void addSettingsField(String label, JComponent field) {
+
+ JLabel jLabel = new JBLabel(label);
+ jLabel.setLabelFor(field);
+ myNamePathComponent.add(jLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.WEST,
+ GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
+ myNamePathComponent.add(field, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST,
+ GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
+ }
+
+ @Override
+ public void addExpertPanel(JComponent panel) {
+ myExpertPanel.add(panel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0, GridBagConstraints.NORTHWEST,
+ GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
+ }
+
private static class GroupNode extends SimpleNode {
private final String myGroup;
private final Collection myTemplates;
@@ -434,4 +518,151 @@ public class SelectTemplateStep extends ModuleWizardStep {
return myTemplate.getName();
}
}
+
+ public void bindTo() {
+
+ myNamePathComponent.getNameComponent().getDocument().addDocumentListener(new DocumentAdapter() {
+ protected void textChanged(final DocumentEvent e) {
+ if (!myModuleNameChangedByUser) {
+ setModuleName(myNamePathComponent.getNameValue());
+ }
+ }
+ });
+
+ myModuleContentRoot.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.content.root.chooser.title"), ProjectBundle.message("project.new.wizard.module.content.root.chooser.description"),
+ myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
+
+ myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() {
+ protected void textChanged(final DocumentEvent e) {
+ if (!myContentRootChangedByUser) {
+ setModuleContentRoot(myNamePathComponent.getPath());
+ }
+ }
+ });
+ myModuleName.getDocument().addDocumentListener(new DocumentAdapter() {
+ protected void textChanged(final DocumentEvent e) {
+ if (myModuleNameDocListenerEnabled) {
+ myModuleNameChangedByUser = true;
+ }
+ String path = getDefaultBaseDir(myWizardContext);
+ final String moduleName = getModuleName();
+ if (path.length() > 0 && !Comparing.strEqual(moduleName, myNamePathComponent.getNameValue())) {
+ path += "/" + moduleName;
+ }
+ if (!myContentRootChangedByUser) {
+ final boolean f = myModuleNameChangedByUser;
+ myModuleNameChangedByUser = true;
+ setModuleContentRoot(path);
+ myModuleNameChangedByUser = f;
+ }
+ if (!myImlLocationChangedByUser) {
+ setImlFileLocation(path);
+ }
+ }
+ });
+ myModuleContentRoot.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
+ protected void textChanged(final DocumentEvent e) {
+ if (myContentRootDocListenerEnabled) {
+ myContentRootChangedByUser = true;
+ }
+ if (!myImlLocationChangedByUser) {
+ setImlFileLocation(getModuleContentRoot());
+ }
+ if (!myModuleNameChangedByUser) {
+ final String path = FileUtil.toSystemIndependentName(getModuleContentRoot());
+ final int idx = path.lastIndexOf("/");
+
+ boolean f = myContentRootChangedByUser;
+ myContentRootChangedByUser = true;
+
+ boolean i = myImlLocationChangedByUser;
+ myImlLocationChangedByUser = true;
+
+ setModuleName(idx >= 0 ? path.substring(idx + 1) : "");
+
+ myContentRootChangedByUser = f;
+ myImlLocationChangedByUser = i;
+ }
+ }
+ });
+
+ myModuleFileLocation.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.file.chooser.title"), ProjectBundle.message("project.new.wizard.module.file.description"),
+ myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
+ myModuleFileLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
+ protected void textChanged(final DocumentEvent e) {
+ if (myImlLocationDocListenerEnabled) {
+ myImlLocationChangedByUser = true;
+ }
+ }
+ });
+ myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() {
+ protected void textChanged(final DocumentEvent e) {
+ if (!myImlLocationChangedByUser) {
+ setImlFileLocation(myNamePathComponent.getPath());
+ }
+ }
+ });
+ if (myWizardContext.isCreatingNewProject()) {
+ setModuleName(myNamePathComponent.getNameValue());
+ setModuleContentRoot(myNamePathComponent.getPath());
+ setImlFileLocation(myNamePathComponent.getPath());
+ } else {
+ final Project project = myWizardContext.getProject();
+ assert project != null;
+ VirtualFile baseDir = project.getBaseDir();
+ if (baseDir != null) { //e.g. was deleted
+ final String baseDirPath = baseDir.getPath();
+ String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, "untitled", "");
+ 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();
+ }
+ setModuleName(moduleName);
+ setModuleContentRoot(contentRoot);
+ setImlFileLocation(contentRoot);
+ myModuleName.select(0, moduleName.length());
+ }
+ }
+ }
+
+ protected String getModuleContentRoot() {
+ return myModuleContentRoot.getText();
+ }
+
+ private String getDefaultBaseDir(WizardContext wizardContext) {
+ if (wizardContext.isCreatingNewProject()) {
+ return myNamePathComponent.getPath();
+ } else {
+ final Project project = wizardContext.getProject();
+ assert project != null;
+ final VirtualFile baseDir = project.getBaseDir();
+ if (baseDir != null) {
+ return baseDir.getPath();
+ }
+ return "";
+ }
+ }
+
+ private void setImlFileLocation(final String path) {
+ myImlLocationDocListenerEnabled = false;
+ myModuleFileLocation.setText(FileUtil.toSystemDependentName(path));
+ myImlLocationDocListenerEnabled = true;
+ }
+
+ private void setModuleContentRoot(final String path) {
+ myContentRootDocListenerEnabled = false;
+ myModuleContentRoot.setText(FileUtil.toSystemDependentName(path));
+ myContentRootDocListenerEnabled = true;
+ }
+
+ private void setModuleName(String moduleName) {
+ myModuleNameDocListenerEnabled = false;
+ myModuleName.setText(moduleName);
+ myModuleNameDocListenerEnabled = true;
+ }
+
+ protected String getModuleName() {
+ return myModuleName.getText().trim();
+ }
}
diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.form b/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.form
index d2cc59b2b237..efd9ed6f918c 100644
--- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.form
+++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.form
@@ -1,7 +1,7 @@