diff --git a/build/conf/mac/Contents/MacOS/idea b/build/conf/mac/Contents/MacOS/idea
index 228b1f89009f..fb9b268404fb 100755
Binary files a/build/conf/mac/Contents/MacOS/idea and b/build/conf/mac/Contents/MacOS/idea differ
diff --git a/build/conf/mac/Contents/MacOS/idea_appLauncher b/build/conf/mac/Contents/MacOS/idea_appLauncher
new file mode 100755
index 000000000000..228b1f89009f
Binary files /dev/null and b/build/conf/mac/Contents/MacOS/idea_appLauncher differ
diff --git a/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java
index 805cfba2b772..dc2e1afdc547 100644
--- a/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java
+++ b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugEnvironment.java
@@ -26,6 +26,7 @@ import com.intellij.execution.runners.ProgramRunner;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.psi.search.GlobalSearchScope;
+import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -60,6 +61,7 @@ public class DefaultDebugEnvironment implements DebugEnvironment {
mySearchScope = createSearchScope(project, runProfile);
}
+ @NotNull
public static GlobalSearchScope createSearchScope(Project project, RunProfile runProfile) {
Module[] modules = null;
if (runProfile instanceof ModuleRunProfile) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java
index 6996d7ebda82..f515f94e4f5b 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java
@@ -37,6 +37,7 @@ import com.intellij.util.text.StringTokenizer;
import com.intellij.util.ui.GeometryUtil;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -53,7 +54,6 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
private DebuggerTreeNodeImpl myCurrentTooltipNode;
private JComponent myCurrentTooltip;
- private Point myCurrentPosition;
protected final TipManager myTipManager;
@@ -62,14 +62,17 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
myProject = project;
myTipManager = new TipManager(this, new TipManager.TipFactory() {
+ @Override
public JComponent createToolTip(MouseEvent e) {
return DebuggerTreeBase.this.createToolTip(e);
}
+ @Override
public MouseEvent createTooltipEvent(MouseEvent candidateEvent) {
return DebuggerTreeBase.this.createTooltipEvent(candidateEvent);
}
+ @Override
public boolean isFocusOwner() {
return DebuggerTreeBase.this.isFocusOwner();
}
@@ -85,23 +88,6 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
TreeUtil.installActions(this);
}
- private static int getMaximumChars(final String s, final FontMetrics metrics, final int maxWidth) {
- int minChar = 0;
- int maxChar = s.length();
- int chars;
- while (minChar < maxChar) {
- chars = (minChar + maxChar + 1) / 2;
- final int width = metrics.stringWidth(s.substring(0, chars));
- if (width <= maxWidth) {
- minChar = chars;
- }
- else {
- maxChar = chars - 1;
- }
- }
- return minChar;
- }
-
private JComponent createTipContent(String tipText, DebuggerTreeNodeImpl node) {
final JToolTip tooltip = new JToolTip();
@@ -114,35 +100,30 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
rootSize.width -= (borderInsets.left + borderInsets.right) * 2;
rootSize.height -= (borderInsets.top + borderInsets.bottom) * 2;
- //noinspection HardCodedStringLiteral
- final StringBuilder tipBuilder = new StringBuilder();
- try {
- final String markupText = node.getMarkupTooltipText();
- if (markupText != null) {
- tipBuilder.append(markupText);
- }
+ @NonNls StringBuilder tipBuilder = new StringBuilder();
+ final String markupText = node.getMarkupTooltipText();
+ if (markupText != null) {
+ tipBuilder.append(markupText);
+ }
- if (tipText.length() > 0) {
- final StringTokenizer tokenizer = new StringTokenizer(tipText, "\n ", true);
+ if (!tipText.isEmpty()) {
+ final StringTokenizer tokenizer = new StringTokenizer(tipText, "\n ", true);
- while (tokenizer.hasMoreElements()) {
- final String each = tokenizer.nextElement();
- if ("\n".equals(each)) {
- tipBuilder.append("
");
- }
- else if (" ".equals(each)) {
- tipBuilder.append("  ");
- }
- else {
- tipBuilder.append(JDOMUtil.legalizeText(each));
- }
+ while (tokenizer.hasMoreElements()) {
+ final String each = tokenizer.nextElement();
+ if ("\n".equals(each)) {
+ tipBuilder.append("
");
+ }
+ else if (" ".equals(each)) {
+ tipBuilder.append("  ");
+ }
+ else {
+ tipBuilder.append(JDOMUtil.legalizeText(each));
}
}
+ }
- tooltip.setTipText(UIUtil.toHtml(tipBuilder.toString(), 0));
- }
- finally {
- }
+ tooltip.setTipText(UIUtil.toHtml(tipBuilder.toString(), 0));
}
tooltip.setBorder(null);
@@ -174,7 +155,7 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
final Rectangle bounds = getRowBounds(row);
return new MouseEvent(this, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, bounds.x,
- bounds.y + bounds.height - (bounds.height / 4), 0, false);
+ bounds.y + bounds.height - bounds.height / 4, 0, false);
}
@Nullable
@@ -198,8 +179,8 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
final JComponent tipContent = createTipContent(toolTipText, node);
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tipContent);
scrollPane.setBorder(null);
- scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+ scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
final Point point = e.getPoint();
SwingUtilities.convertPointToScreen(point, e.getComponent());
@@ -209,17 +190,7 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
final JToolTip toolTip = new JToolTip();
- tipContent.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseReleased(MouseEvent e) {
- if (UIUtil.isActionClick(e)) {
- final Window wnd = SwingUtilities.getWindowAncestor(toolTip);
- if (wnd instanceof JWindow) {
- wnd.setVisible(false);
- }
- }
- }
- });
+ tipContent.addMouseListener(new HideTooltip(toolTip));
final Border tooltipBorder = toolTip.getBorder();
if (tooltipBorder != null) {
@@ -228,16 +199,12 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
.setSize(tipRectangle.width + borderInsets.left + borderInsets.right, tipRectangle.height + borderInsets.top + borderInsets.bottom);
}
- boolean addScrollers = true;
-
toolTip.setLayout(new BorderLayout());
toolTip.add(scrollPane, BorderLayout.CENTER);
- if (addScrollers) {
- tipRectangle.height += scrollPane.getHorizontalScrollBar().getPreferredSize().height;
- tipRectangle.width += scrollPane.getVerticalScrollBar().getPreferredSize().width;
- }
+ tipRectangle.height += scrollPane.getHorizontalScrollBar().getPreferredSize().height;
+ tipRectangle.width += scrollPane.getVerticalScrollBar().getPreferredSize().width;
final int maxWidth = (int)(screen.width - screen.width * .25);
@@ -264,7 +231,6 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
toolTip.setPreferredSize(tipRectangle.getSize());
myCurrentTooltip = toolTip;
- myCurrentPosition = tipRectangle.getLocation();
return myCurrentTooltip;
}
@@ -287,7 +253,7 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
}
final String tipText = prepareToolTipText(text);
- if (tipText.length() > 0 &&
+ if (!tipText.isEmpty() &&
(tipText.indexOf('\n') >= 0 || !getVisibleRect().contains(getRowBounds(getRowForPath(new TreePath(node.getPath())))))) {
return tipText;
}
@@ -309,42 +275,6 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
return null;
}
- private Rectangle getTipBounds(final Point point, Dimension tipContentSize) {
- Rectangle nodeBounds = new Rectangle(point);
- TreePath pathForLocation = getPathForLocation(point.x, point.y);
- if (pathForLocation != null) {
- nodeBounds = getPathBounds(pathForLocation);
- }
-
- Rectangle contentRect = getVisibleRect();
- System.out.println("contentRect = " + contentRect);
-
- int vgap = nodeBounds.height;
- int width = Math.min(tipContentSize.width, contentRect.width);
- int height;
- int y;
- if (point.y > contentRect.y + contentRect.height / 2) {
- y = Math.max(contentRect.y, nodeBounds.y - tipContentSize.height - vgap);
- height = Math.min(tipContentSize.height, nodeBounds.y - contentRect.y - vgap);
- }
- else {
- y = nodeBounds.y + nodeBounds.height + vgap;
- height = Math.min(tipContentSize.height, contentRect.height - y);
- }
-
- final Dimension tipSize = new Dimension(width, height);
-
- int x = point.x - width / 2;
- if (x < contentRect.x) {
- x = contentRect.x;
- }
- if (x + width > contentRect.x + contentRect.width) {
- x = contentRect.x + contentRect.width - width;
- }
-
- return new Rectangle(new Point(x, y), tipSize);
- }
-
private String prepareToolTipText(String text) {
int tabSize = CodeStyleSettingsManager.getSettings(myProject).getTabSize(StdFileTypes.JAVA);
if (tabSize < 0) {
@@ -383,6 +313,7 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
return buf.toString();
}
+ @Override
public void dispose() {
final JComponent tooltip = myCurrentTooltip;
if (tooltip != null) {
@@ -391,4 +322,26 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable {
myCurrentTooltip = null;
myCurrentTooltipNode = null;
}
+
+ public Project getProject() {
+ return myProject;
+ }
+
+ private static class HideTooltip extends MouseAdapter {
+ private final JToolTip myToolTip;
+
+ public HideTooltip(JToolTip toolTip) {
+ myToolTip = toolTip;
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ if (UIUtil.isActionClick(e)) {
+ final Window wnd = SwingUtilities.getWindowAncestor(myToolTip);
+ if (wnd instanceof JWindow) {
+ wnd.setVisible(false);
+ }
+ }
+ }
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java
index 9f26238aefda..b655148002db 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java
@@ -71,7 +71,6 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
public static final DataKey DATA_KEY = DataKey.create("DebuggerTree");
- private final Project myProject;
protected final NodeManagerImpl myNodeManager;
private DebuggerContextImpl myDebuggerContext = DebuggerContextImpl.EMPTY_CONTEXT;
@@ -117,7 +116,6 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
setModel(model);
- myProject = project;
final TreeSpeedSearch search = new TreeSpeedSearch(this);
search.setComparator(new SpeedSearchComparator(false));
}
@@ -310,10 +308,6 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
}
}
- public Project getProject() {
- return myProject;
- }
-
protected abstract void build(DebuggerContextImpl context);
protected final void buildWhenPaused(DebuggerContextImpl context, RefreshDebuggerTreeCommand command) {
diff --git a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilterFactory.java b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilterFactory.java
index fd57dfe7cf89..5fb91ddee70d 100644
--- a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilterFactory.java
+++ b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilterFactory.java
@@ -17,6 +17,7 @@ package com.intellij.execution.filters;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.search.GlobalSearchScope;
+import org.jetbrains.annotations.NotNull;
/**
* Created by IntelliJ IDEA.
@@ -26,6 +27,7 @@ import com.intellij.psi.search.GlobalSearchScope;
*/
public interface ExceptionFilterFactory {
ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.exceptionFilter");
-
- Filter create(final GlobalSearchScope searchScope);
+
+ @NotNull
+ Filter create(@NotNull GlobalSearchScope searchScope);
}
diff --git a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java
index 2c79ed095130..1c3bd1ca4e13 100644
--- a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java
+++ b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilters.java
@@ -16,6 +16,7 @@
package com.intellij.execution.filters;
import com.intellij.psi.search.GlobalSearchScope;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -30,9 +31,10 @@ public class ExceptionFilters {
private ExceptionFilters() {
}
- public static List getFilters(final GlobalSearchScope searchScope) {
- List filters = new ArrayList();
+ @NotNull
+ public static List getFilters(@NotNull GlobalSearchScope searchScope) {
ExceptionFilterFactory[] extensions = ExceptionFilterFactory.EP_NAME.getExtensions();
+ List filters = new ArrayList(extensions.length);
for (ExceptionFilterFactory extension : extensions) {
filters.add(extension.create(searchScope));
}
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..770b946aabcc 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,18 @@ 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.ui.ValidationInfo;
+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 +45,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 +65,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 +73,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 +81,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);
+ bindModuleSettings();
+
+ 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 +220,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 +257,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 +272,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 +334,21 @@ 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()), "Error");
}
- if (mySettingsStep != null) {
- return mySettingsStep.validate();
+ ValidationInfo info = template.validateSettings();
+ if (info != null) {
+ throw new ConfigurationException(info.message, "Error");
+ }
+ if (mySettingsCallback != null) {
+ return mySettingsCallback.validate();
}
return true;
}
@@ -377,9 +432,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 +464,34 @@ 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 addSettingsComponent(JComponent component) {
+ myNamePathComponent.add(component, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0, GridBagConstraints.NORTHWEST,
+ GridBagConstraints.HORIZONTAL, 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 +529,151 @@ public class SelectTemplateStep extends ModuleWizardStep {
return myTemplate.getName();
}
}
+
+ public void bindModuleSettings() {
+
+ 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 @@