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 @@
- + diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java index 434c2e9bc5ba..ab24038cc150 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/JavaSettingsStep.java @@ -17,7 +17,6 @@ package com.intellij.ide.util.projectWizard; import com.intellij.ide.IdeBundle; import com.intellij.ide.util.BrowseFilesListener; -import com.intellij.ide.util.newProjectWizard.ProjectSettingsStep; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.SdkType; @@ -44,20 +43,21 @@ import java.util.Collections; * @author Dmitry Avdeev * Date: 10/23/12 */ -public class JavaSettingsStep extends ProjectSettingsStep { +public class JavaSettingsStep extends ModuleWizardStep { private final ModuleBuilder myModuleBuilder; private JBCheckBox myCreateSourceRoot; private TextFieldWithBrowseButton mySourcePath; private JPanel myPanel; private final JdkComboBox myJdkComboBox; + private final WizardContext myWizardContext; - public JavaSettingsStep(WizardContext wizardContext, ModuleBuilder moduleBuilder, Condition sdkFilter) { - super(wizardContext); + public JavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition sdkFilter) { myModuleBuilder = moduleBuilder; + myWizardContext = settingsStep.getContext(); ProjectSdksModel model = new ProjectSdksModel(); - Project project = wizardContext.getProject(); + Project project = myWizardContext.getProject(); model.reset(project, sdkFilter); myJdkComboBox = new JdkComboBox(model, sdkFilter); JButton button = new JButton("\u001BNew..."); @@ -68,7 +68,7 @@ public class JavaSettingsStep extends ProjectSettingsStep { JPanel jdkPanel = new JPanel(new BorderLayout(SystemInfo.isMac? 0 : 2, 0)); jdkPanel.add(myJdkComboBox); jdkPanel.add(button, BorderLayout.EAST); - addField("Project \u001BSDK:", jdkPanel); + settingsStep.addSettingsField("Project \u001BSDK:", jdkPanel); if (moduleBuilder instanceof JavaModuleBuilder) { ComponentWithBrowseButton.BrowseFolderActionListener listener = @@ -96,16 +96,21 @@ public class JavaSettingsStep extends ProjectSettingsStep { mySourcePath.setEnabled(myCreateSourceRoot.isSelected()); } }); - addExpertPanel(myPanel); + settingsStep.addExpertPanel(myPanel); } } + @Override + public JComponent getComponent() { + return myPanel; + } + @Override public void updateDataModel() { - super.updateDataModel(); Sdk jdk = myJdkComboBox.getSelectedJdk(); myWizardContext.setProjectJdk(jdk); + if (myModuleBuilder instanceof JavaModuleBuilder && myCreateSourceRoot.isSelected()) { String contentEntryPath = myModuleBuilder.getContentEntryPath(); if (contentEntryPath != null) { diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java index 57641db4cb8b..b7da81b9ad80 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java @@ -139,12 +139,7 @@ public class ProjectWizardStepFactoryImpl extends ProjectWizardStepFactory { } @Override - public SettingsStep createSettingsStep(WizardContext context) { - return new ProjectSettingsStep(context); - } - - @Override - public SettingsStep createJavaSettingsStep(final WizardContext context, final ModuleBuilder moduleBuilder, Condition sdkFilter) { - return new JavaSettingsStep(context, moduleBuilder, sdkFilter); + public ModuleWizardStep createJavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition sdkFilter) { + return new JavaSettingsStep(settingsStep, moduleBuilder, sdkFilter); } } diff --git a/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java b/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java index 2c4149946054..96416c2d3f5d 100644 --- a/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java +++ b/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java @@ -103,8 +103,8 @@ public class JavaModuleType extends ModuleType { @Nullable @Override - public SettingsStep createSettingsStep(WizardContext context, ModuleBuilder moduleBuilder) { - return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(context, moduleBuilder, new Condition() { + public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder) { + return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, moduleBuilder, new Condition() { @Override public boolean value(SdkType sdk) { return sdk instanceof JavaSdkType; diff --git a/java/openapi/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactory.java b/java/openapi/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactory.java index 923b1e15e494..4a904f4e566a 100644 --- a/java/openapi/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactory.java +++ b/java/openapi/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactory.java @@ -72,7 +72,5 @@ public abstract class ProjectWizardStepFactory { @Nullable public abstract ModuleWizardStep createSupportForFrameworksStep(WizardContext context, ModuleBuilder builder, ModulesProvider modulesProvider); - public abstract SettingsStep createSettingsStep(WizardContext context); - - public abstract SettingsStep createJavaSettingsStep(WizardContext context, ModuleBuilder moduleBuilder, Condition sdkFilter); + public abstract ModuleWizardStep createJavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition sdkFilter); } diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java index 8dbb852aa1a7..50209c025b3b 100644 --- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java +++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java @@ -91,9 +91,9 @@ public abstract class ModuleBuilder extends ProjectBuilder{ } @Nullable - public SettingsStep createSettingsStep(WizardContext wizardContext) { + public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep) { ModuleType type = getModuleType(); - return type == null ? null : type.createSettingsStep(wizardContext, this); + return type == null ? null : type.modifySettingsStep(settingsStep, this); } public void setName(String name) { diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java index 3a1cefe23e5e..ca1bab66669d 100644 --- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java +++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java @@ -15,24 +15,17 @@ */ package com.intellij.ide.util.projectWizard; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import javax.swing.*; /** * @author Dmitry Avdeev * Date: 10/23/12 */ -public abstract class SettingsStep extends ModuleWizardStep { +public interface SettingsStep { - @NotNull - public abstract JComponent getSettingsPanel(); + WizardContext getContext(); - @Nullable - public abstract JComponent getExpertSettingsPanel(); + void addSettingsField(String label, JComponent field); - public abstract SettingsStep addField(String label, JComponent field); - - public abstract SettingsStep addExpertPanel(JComponent panel); + void addExpertPanel(JComponent panel); } diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java index c99f0fdfdff8..8486e306f989 100644 --- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java +++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java @@ -171,7 +171,7 @@ public class WizardContext { return myProjectBuilder; } - public void setProjectBuilder(final ProjectBuilder projectBuilder) { + public void setProjectBuilder(@Nullable final ProjectBuilder projectBuilder) { myProjectBuilder = projectBuilder; } diff --git a/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java b/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java index b378069698da..05bb5b25181a 100644 --- a/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java +++ b/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java @@ -50,7 +50,7 @@ public abstract class ModuleType { } @Nullable - public SettingsStep createSettingsStep(WizardContext context, ModuleBuilder moduleBuilder) { + public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder) { return null; } diff --git a/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java b/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java index 6c0bc76a69ba..f8ae101733d7 100644 --- a/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java +++ b/platform/platform-api/src/com/intellij/util/EditSourceOnDoubleClickHandler.java @@ -106,16 +106,16 @@ public class EditSourceOnDoubleClickHandler { @Override public boolean onDoubleClick(MouseEvent e) { - final TreePath path = myTree.getUI() instanceof WideSelectionTreeUI ? myTree.getClosestPathForLocation(e.getX(), e.getY()) - : myTree.getPathForLocation(e.getX(), e.getY()); - if (path == null) return false; + final TreePath clickPath = myTree.getUI() instanceof WideSelectionTreeUI ? myTree.getClosestPathForLocation(e.getX(), e.getY()) + : myTree.getPathForLocation(e.getX(), e.getY()); + if (clickPath == null) return false; final DataContext dataContext = DataManager.getInstance().getDataContext(myTree); final Project project = PlatformDataKeys.PROJECT.getData(dataContext); if (project == null) return false; final TreePath selectionPath = myTree.getSelectionPath(); - if (selectionPath == null) return false; + if (selectionPath == null || !clickPath.equals(selectionPath)) return false; final Object lastPathComponent = selectionPath.getLastPathComponent(); if (((TreeNode)lastPathComponent).isLeaf() || !expandOnDoubleClick(((TreeNode)lastPathComponent))) { //Node expansion for non-leafs has a higher priority diff --git a/platform/platform-impl/src/org/jetbrains/io/WebServer.java b/platform/platform-impl/src/org/jetbrains/io/WebServer.java index c9cd0e547393..8d5184d44815 100644 --- a/platform/platform-impl/src/org/jetbrains/io/WebServer.java +++ b/platform/platform-impl/src/org/jetbrains/io/WebServer.java @@ -13,6 +13,7 @@ import org.jboss.netty.channel.group.ChannelGroup; import org.jboss.netty.channel.group.DefaultChannelGroup; import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; import org.jboss.netty.handler.codec.http.*; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import java.net.InetAddress; @@ -32,6 +33,9 @@ public class WebServer { private static final Logger LOG = Logger.getInstance(WebServer.class); + @NonNls + private static final String PROPERTY_ONLY_ANY_HOST = "rpc.onlyAnyHost"; + public WebServer() { final Application application = ApplicationManager.getApplication(); final Executor pooledThreadExecutor = new Executor() { @@ -74,11 +78,13 @@ public class WebServer { // but if we bind only to any local port (0.0.0.0), instance of idea <121 can bind to our ports and any request to us will be intercepted // so, we bind to 127.0.0.1 and 0.0.0.0 private int bind(int firstPort, int portsCount, boolean tryAnyPort, ServerBootstrap bootstrap) { + String property = System.getProperty(PROPERTY_ONLY_ANY_HOST); + boolean onlyAnyHost = property == null ? SystemInfo.isLinux : (property.isEmpty() || Boolean.valueOf(property)); for (int i = 0; i < portsCount; i++) { int port = firstPort + i; try { openChannels.add(bootstrap.bind(new InetSocketAddress(port))); - if (!SystemInfo.isLinux) { + if (!onlyAnyHost) { openChannels.add(bootstrap.bind(new InetSocketAddress(InetAddress.getByName("127.0.0.1"), port))); } return port; diff --git a/plugins/android/src/org/jetbrains/android/newProject/AndroidModuleBuilder.java b/plugins/android/src/org/jetbrains/android/newProject/AndroidModuleBuilder.java index 38831a424218..e498b0fefde5 100644 --- a/plugins/android/src/org/jetbrains/android/newProject/AndroidModuleBuilder.java +++ b/plugins/android/src/org/jetbrains/android/newProject/AndroidModuleBuilder.java @@ -746,8 +746,8 @@ public class AndroidModuleBuilder extends JavaModuleBuilder { @Nullable @Override - public SettingsStep createSettingsStep(WizardContext wizardContext) { - return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(wizardContext, this, Conditions.is(AndroidSdkType.getInstance())); + public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep) { + return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, this, Conditions.is(AndroidSdkType.getInstance())); } private static boolean hasAppropriateJdk() { diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResource.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResource.java index d0ff33a96e7a..4b828c37c091 100644 --- a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResource.java +++ b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResource.java @@ -109,7 +109,7 @@ public class TemplateResource implements Serializable { // skip the starting and ending { } final String trimmed = s.trim(); - return trimmed.substring(1, s.length() - 1); + return trimmed.substring(1, trimmed.length() - 1); } /**