mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ProjectSummaryStep
This commit is contained in:
@@ -16,34 +16,20 @@
|
||||
package com.intellij.ide.projectWizard;
|
||||
|
||||
import com.intellij.ide.util.newProjectWizard.AbstractProjectWizard;
|
||||
import com.intellij.ide.util.newProjectWizard.ProjectNameStep;
|
||||
import com.intellij.ide.wizard.Step;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 04.09.13
|
||||
*/
|
||||
public class NewProjectWizard extends AbstractProjectWizard<Step> {
|
||||
|
||||
private final ProjectNameStep myProjectNameStep;
|
||||
|
||||
public NewProjectWizard(@Nullable Project project, String defaultPath) {
|
||||
super("New Project", null, defaultPath);
|
||||
addStep(new ProjectTypeStep(myWizardContext, getDisposable()));
|
||||
myProjectNameStep = new ProjectNameStep(myWizardContext, null) {
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
addStep(myProjectNameStep);
|
||||
Disposer.register(getDisposable(), myProjectNameStep);
|
||||
addStep(new ProjectSummaryStep(myWizardContext));
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -58,10 +44,4 @@ public class NewProjectWizard extends AbstractProjectWizard<Step> {
|
||||
protected String getDimensionServiceKey() {
|
||||
return "new project wizard";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
myProjectNameStep.updateDataModel();
|
||||
super.doOKAction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.projectWizard.ProjectSummaryStep">
|
||||
<grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="2" 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>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="15993" binding="myNameAndLocationPanel" layout-manager="BorderLayout" hgap="0" vgap="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"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<vspacer id="c6894">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.projectWizard;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.NamePathComponent;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.ide.wizard.CommitStepException;
|
||||
import com.intellij.ide.wizard.StepAdapter;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 20.09.13
|
||||
*/
|
||||
public class ProjectSummaryStep extends StepAdapter {
|
||||
|
||||
private final WizardContext myWizardContext;
|
||||
private JPanel myRootPanel;
|
||||
private JPanel myNameAndLocationPanel;
|
||||
private final NamePathComponent myNamePathComponent;
|
||||
|
||||
public ProjectSummaryStep(WizardContext context) {
|
||||
myWizardContext = context;
|
||||
myNamePathComponent = NamePathComponent.initNamePathComponent(myWizardContext);
|
||||
myNameAndLocationPanel.add(myNamePathComponent, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void _commit(boolean finishChosen) throws CommitStepException {
|
||||
myWizardContext.setProjectName(myNamePathComponent.getNameValue());
|
||||
myWizardContext.setProjectFileDirectory(myNamePathComponent.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return myRootPanel;
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class SelectTemplateStep extends ModuleWizardStep implements SettingsStep
|
||||
Messages.installHyperlinkSupport(myDescriptionPane);
|
||||
|
||||
myFormatPanel = new ProjectFormatPanel();
|
||||
myNamePathComponent = initNamePathComponent(context);
|
||||
myNamePathComponent = NamePathComponent.initNamePathComponent(context);
|
||||
if (context.isCreatingNewProject()) {
|
||||
mySettingsPanel.add(myNamePathComponent, BorderLayout.NORTH);
|
||||
addExpertPanel(myModulePanel);
|
||||
@@ -168,24 +168,6 @@ public class SelectTemplateStep extends ModuleWizardStep implements SettingsStep
|
||||
return helpId;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
restorePanel(myNamePathComponent, 4);
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.FieldPanel;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -118,6 +119,24 @@ public class NamePathComponent extends JPanel{
|
||||
insets, 0, 0));
|
||||
}
|
||||
|
||||
public 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 String getProjectFilePath(boolean isDefault) {
|
||||
if (isDefault) {
|
||||
return getPath() + "/" + getNameValue() + ProjectFileType.DOT_DEFAULT_EXTENSION;
|
||||
|
||||
Reference in New Issue
Block a user