mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.util.newProjectWizard.ProjectSettingsStep">
|
||||
<grid id="807b" binding="myModulePanel" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="893" height="453"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="8a2b7" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="1.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e6ad1" class="javax.swing.JTextField" binding="myModuleName">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="1f996" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="e6ad1"/>
|
||||
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.name.title"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4af6e" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleContentRoot">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="c4851" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="4af6e"/>
|
||||
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.root.title"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="83a50" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleFileLocation">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<preferredSize width="280" height="20"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a4319" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="83a50"/>
|
||||
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.file.title"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="fa640" binding="myHeader" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<visible value="true"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="8ada9" binding="myExpertPanel" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,16 @@
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="503" height="400"/>
|
||||
<xy x="20" y="20" width="608" height="393"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="ac540" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="155" height="44"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -60,7 +62,15 @@
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title="Settings"/>
|
||||
<children/>
|
||||
<children>
|
||||
<grid id="14333" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="North"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="5732c" binding="myDescriptionPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
@@ -93,7 +103,70 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
<children>
|
||||
<grid id="a59bf" binding="myExpertPanel" layout-manager="GridBagLayout">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="edb8a" class="javax.swing.JTextField" binding="myModuleName">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
<gridbag top="2" left="0" bottom="2" right="0" weightx="1.0" weighty="1.0"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="40abf" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="1.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="e6ad1"/>
|
||||
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.name.title"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d2d6b" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleContentRoot">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag top="2" left="0" bottom="2" right="0" weightx="1.0" weighty="1.0"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="7afef" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="1.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="4af6e"/>
|
||||
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.root.title"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9e1b8" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleFileLocation">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag top="2" left="0" bottom="2" right="0" weightx="1.0" weighty="1.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<preferredSize width="280" height="20"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2ac4e" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="1.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="83a50"/>
|
||||
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.file.title"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
|
||||
@@ -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<SimpleNode> 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<String, ProjectTemplate> groups = new MultiMap<String, ProjectTemplate>();
|
||||
@@ -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("<html><body><font face=\"Verdana\" ");
|
||||
@@ -265,17 +308,24 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
}
|
||||
}
|
||||
|
||||
mySettingsPanel.setVisible(mySettingsStep != null);
|
||||
myExpertPanel.setVisible(expertSettingsPanel != null);
|
||||
mySettingsPanel.setVisible(template != null);
|
||||
myExpertPlaceholder.setVisible(myModuleBuilder != null);
|
||||
myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description));
|
||||
|
||||
mySettingsPanel.revalidate();
|
||||
mySettingsPanel.repaint();
|
||||
}
|
||||
|
||||
private static void restorePanel(JPanel component, int i) {
|
||||
while (component.getComponentCount() > 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<ProjectTemplate> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.util.projectWizard.JavaSettingsStep">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="5" left="0" bottom="0" right="0"/>
|
||||
<margin top="2" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="31"/>
|
||||
</constraints>
|
||||
|
||||
@@ -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<SdkType> sdkFilter) {
|
||||
super(wizardContext);
|
||||
public JavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition<SdkType> 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<JTextField> 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) {
|
||||
|
||||
+2
-7
@@ -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<SdkType> sdkFilter) {
|
||||
return new JavaSettingsStep(context, moduleBuilder, sdkFilter);
|
||||
public ModuleWizardStep createJavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition<SdkType> sdkFilter) {
|
||||
return new JavaSettingsStep(settingsStep, moduleBuilder, sdkFilter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ public class JavaModuleType extends ModuleType<JavaModuleBuilder> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public SettingsStep createSettingsStep(WizardContext context, ModuleBuilder moduleBuilder) {
|
||||
return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(context, moduleBuilder, new Condition<SdkType>() {
|
||||
public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder) {
|
||||
return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, moduleBuilder, new Condition<SdkType>() {
|
||||
@Override
|
||||
public boolean value(SdkType sdk) {
|
||||
return sdk instanceof JavaSdkType;
|
||||
|
||||
@@ -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<SdkType> sdkFilter);
|
||||
public abstract ModuleWizardStep createJavaSettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder, Condition<SdkType> sdkFilter);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ public class WizardContext {
|
||||
return myProjectBuilder;
|
||||
}
|
||||
|
||||
public void setProjectBuilder(final ProjectBuilder projectBuilder) {
|
||||
public void setProjectBuilder(@Nullable final ProjectBuilder projectBuilder) {
|
||||
myProjectBuilder = projectBuilder;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class ModuleType<T extends ModuleBuilder> {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SettingsStep createSettingsStep(WizardContext context, ModuleBuilder moduleBuilder) {
|
||||
public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep, ModuleBuilder moduleBuilder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -746,8 +746,8 @@ public class AndroidModuleBuilder extends JavaModuleBuilder {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public SettingsStep createSettingsStep(WizardContext wizardContext) {
|
||||
return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(wizardContext, this, Conditions.<SdkType>is(AndroidSdkType.getInstance()));
|
||||
public ModuleWizardStep modifySettingsStep(SettingsStep settingsStep) {
|
||||
return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, this, Conditions.<SdkType>is(AndroidSdkType.getInstance()));
|
||||
}
|
||||
|
||||
private static boolean hasAppropriateJdk() {
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user