IDEA-123691 Minor project wizard edits: moving settings to the first page

This commit is contained in:
Dmitry Avdeev
2014-04-11 18:28:18 +04:00
parent c67ada4d70
commit 86e8dd82fd
15 changed files with 146 additions and 49 deletions

View File

@@ -224,11 +224,11 @@ public class ProjectSettingsStep extends ModuleWizardStep implements SettingsSte
addField(label, field, panel);
}
private static void addField(String label, JComponent field, JPanel panel) {
static void addField(String label, JComponent field, JPanel panel) {
JLabel jLabel = new JBLabel(label);
jLabel.setLabelFor(field);
panel.add(jLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0));
GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 4, 0));
panel.add(field, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST,
GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
}

View File

@@ -38,36 +38,51 @@
</scrollpane>
</children>
</grid>
<grid id="ad16" binding="myOptionsPanel" layout-manager="CardLayout" hgap="0" vgap="0">
<grid id="22e59" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
</clientProperties>
<border type="none"/>
<children>
<grid id="27a92" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<card name="templates card"/>
</constraints>
<grid id="9b063" binding="myHeaderPanel" layout-manager="GridBagLayout">
<constraints border-constraint="North"/>
<properties/>
<border type="empty">
<size top="5" left="5" bottom="5" right="5"/>
</border>
<children/>
</grid>
<grid id="ad16" binding="myOptionsPanel" layout-manager="CardLayout" hgap="0" vgap="0">
<constraints border-constraint="Center"/>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
</clientProperties>
<border type="none"/>
<children>
<nested-form id="b063c" form-file="com/intellij/ide/projectWizard/ProjectTemplateList.form" binding="myTemplatesList">
<constraints border-constraint="Center"/>
</nested-form>
<grid id="27a92" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<card name="templates card"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<nested-form id="b063c" form-file="com/intellij/ide/projectWizard/ProjectTemplateList.form" binding="myTemplatesList">
<constraints border-constraint="Center"/>
</nested-form>
</children>
</grid>
<grid id="b50ee" binding="myFrameworksPanelPlaceholder" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<card name="frameworks card"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
<grid id="b50ee" binding="myFrameworksPanelPlaceholder" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<card name="frameworks card"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</children>

View File

@@ -25,10 +25,7 @@ import com.intellij.ide.util.newProjectWizard.FrameworkSupportNode;
import com.intellij.ide.util.newProjectWizard.TemplatesGroup;
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
import com.intellij.ide.util.newProjectWizard.modes.CreateFromTemplateMode;
import com.intellij.ide.util.projectWizard.EmptyModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.ide.util.projectWizard.*;
import com.intellij.ide.wizard.CommitStepException;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.module.Module;
@@ -63,6 +60,7 @@ import com.intellij.ui.popup.list.GroupedItemsListRenderer;
import com.intellij.util.Function;
import com.intellij.util.PlatformUtils;
import com.intellij.util.containers.*;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
@@ -82,7 +80,7 @@ import java.util.List;
* Date: 04.09.13
*/
@SuppressWarnings("unchecked")
public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, Disposable {
private static final String TEMPLATES_CARD = "templates card";
private static final String FRAMEWORKS_CARD = "frameworks card";
@@ -107,12 +105,16 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
private JBList myProjectTypeList;
private ProjectTemplateList myTemplatesList;
private JPanel myFrameworksPanelPlaceholder;
private JPanel myHeaderPanel;
private final WizardContext myContext;
private final NewProjectWizard myWizard;
private final ModulesProvider myModulesProvider;
private final AddSupportForFrameworksPanel myFrameworksPanel;
private final ModuleBuilder.ModuleConfigurationUpdater myConfigurationUpdater;
@Nullable
private ModuleWizardStep mySettingsStep;
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
private final FactoryMap<ProjectTemplate, ModuleBuilder> myBuilders = new FactoryMap<ProjectTemplate, ModuleBuilder>() {
@@ -202,7 +204,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
return StringUtil.notNullize(builder.getContentEntryPath());
}
};
myFrameworksPanel = new AddSupportForFrameworksPanel(Collections.<FrameworkSupportInModuleProvider>emptyList(), model, true);
myFrameworksPanel = new AddSupportForFrameworksPanel(Collections.<FrameworkSupportInModuleProvider>emptyList(), model, true, myHeaderPanel);
Disposer.register(this, myFrameworksPanel);
myFrameworksPanelPlaceholder.add(myFrameworksPanel.getMainPanel());
@@ -364,6 +366,13 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
if (group == null) return;
PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_GROUP, group.getId() );
ModuleBuilder groupModuleBuilder = group.getModuleBuilder();
mySettingsStep = null;
myHeaderPanel.removeAll();
if (groupModuleBuilder != null && groupModuleBuilder.getModuleType() != null) {
mySettingsStep = groupModuleBuilder.modifyProjectTypeStep(this);
}
if (groupModuleBuilder == null || groupModuleBuilder.isTemplateBased()) {
showTemplates(group);
}
@@ -398,6 +407,21 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
showCard(FRAMEWORKS_CARD);
}
myHeaderPanel.setVisible(myHeaderPanel.getComponentCount() > 0);
// align header labels
List<JLabel> labels = UIUtil.findComponentsOfType(myHeaderPanel, JLabel.class);
int width = 0;
for (JLabel label : labels) {
int width1 = label.getPreferredSize().width;
width = Math.max(width, width1);
}
for (JLabel label : labels) {
label.setPreferredSize(new Dimension(width, label.getPreferredSize().height));
}
myHeaderPanel.revalidate();
myHeaderPanel.repaint();
updateSelection();
}
@@ -519,10 +543,16 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
if (step != null) {
step.updateDataModel();
}
if (mySettingsStep != null) {
mySettingsStep.updateDataModel();
}
}
@Override
public boolean validate() throws ConfigurationException {
if (mySettingsStep != null) {
if (!mySettingsStep.validate()) return false;
}
ModuleWizardStep step = getCustomStep();
return step != null ? step.validate() : super.validate();
}
@@ -630,4 +660,33 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
public AddSupportForFrameworksPanel getFrameworksPanel() {
return myFrameworksPanel;
}
@Override
public WizardContext getContext() {
return myContext;
}
@Override
public void addSettingsField(@NotNull String label, @NotNull JComponent field) {
ProjectSettingsStep.addField(label, field, myHeaderPanel);
}
@Override
public void addSettingsComponent(@NotNull JComponent component) {
}
@Override
public void addExpertPanel(@NotNull JComponent panel) {
}
@Override
public void addExpertField(@NotNull String label, @NotNull JComponent field) {
}
@Override
public JTextField getModuleNameField() {
return null;
}
}

View File

@@ -51,7 +51,7 @@ public class AddFrameworkSupportDialog extends DialogWrapper {
myModule = module;
final LibrariesContainer container = LibrariesContainerFactory.createContainer(module.getProject());
final FrameworkSupportModelBase model = new FrameworkSupportModelImpl(module.getProject(), contentRootPath, container);
myAddSupportPanel = new AddSupportForFrameworksPanel(providers, model, false) {
myAddSupportPanel = new AddSupportForFrameworksPanel(providers, model, false, null) {
@Override
protected void onFrameworkStateChanged() {
setOKActionEnabled(isOKActionEnabled());

View File

@@ -37,9 +37,9 @@ import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.util.Comparing;
import com.intellij.ui.CheckedTreeNode;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
@@ -78,16 +78,18 @@ public class AddSupportForFrameworksPanel implements Disposable {
private FrameworkSupportNodeBase myLastSelectedNode;
private Collection<FrameworkSupportNodeBase> myAssociatedFrameworks;
private final JPanel myAssociatedFrameworksPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
@Nullable
private final JPanel myAssociatedFrameworksPanel;
public AddSupportForFrameworksPanel(final List<FrameworkSupportInModuleProvider> providers,
final FrameworkSupportModelBase model, boolean vertical) {
final FrameworkSupportModelBase model, boolean vertical, @Nullable JPanel associatedFrameworksPanel) {
myModel = model;
myAssociatedFrameworksPanel = associatedFrameworksPanel;
myLibrariesContainer = model.getLibrariesContainer();
myLabel.setVisible(!vertical);
Splitter splitter = vertical ? new Splitter(true, 0.6f) : new Splitter(false, 0.3f, 0.3f, 0.7f);
splitter.setHonorComponentsMinimumSize(true);
Splitter splitter = vertical ? new Splitter(true, 0.6f, 0.2f, 0.8f) : new Splitter(false, 0.3f, 0.3f, 0.7f);
splitter.setHonorComponentsMinimumSize(false);
myFrameworksTree = new FrameworksTree(model) {
@Override
protected void onNodeStateChanged(CheckedTreeNode node) {
@@ -118,7 +120,6 @@ public class AddSupportForFrameworksPanel implements Disposable {
JPanel treePanel = new JPanel(new BorderLayout());
treePanel.add(ScrollPaneFactory.createScrollPane(myFrameworksTree), BorderLayout.CENTER);
treePanel.add(myAssociatedFrameworksPanel, BorderLayout.NORTH);
treePanel.setMinimumSize(new Dimension(200, 300));
splitter.setFirstComponent(treePanel);
@@ -154,21 +155,25 @@ public class AddSupportForFrameworksPanel implements Disposable {
public void setAssociatedFrameworks() {
myAssociatedFrameworksPanel.setVisible(!myAssociatedFrameworks.isEmpty());
myAssociatedFrameworksPanel.removeAll();
if (myAssociatedFrameworksPanel == null) return;
for (FrameworkSupportNodeBase nodeBase : myAssociatedFrameworks) {
if (nodeBase instanceof FrameworkSupportNode) {
((FrameworkSupportNode)nodeBase).getConfigurable().onFrameworkSelectionChanged(true);
FrameworkSupportOptionsComponent component = initializeOptionsPanel((FrameworkSupportNode)nodeBase, false);
myAssociatedFrameworksPanel.add(component.getMainPanel());
addAssociatedFrameworkComponent(component.getMainPanel(), myAssociatedFrameworksPanel);
}
else {
JPanel panel = initializeGroupPanel((FrameworkGroup<?>)nodeBase.getUserObject(), false);
myAssociatedFrameworksPanel.add(panel);
addAssociatedFrameworkComponent(panel, myAssociatedFrameworksPanel);
}
}
}
private static void addAssociatedFrameworkComponent(JPanel component, JPanel panel) {
panel.add(component, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0, GridBagConstraints.NORTHWEST,
GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
}
protected void onFrameworkStateChanged() {}
private void onSelectionChanged() {
@@ -261,7 +266,10 @@ public class AddSupportForFrameworksPanel implements Disposable {
}
private static JScrollPane wrapInScrollPane(JPanel panel) {
return ScrollPaneFactory.createScrollPane(panel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
JPanel wrapper = new JPanel(new BorderLayout());
wrapper.add(panel);
wrapper.setBorder(IdeBorderFactory.createEmptyBorder(5));
return ScrollPaneFactory.createScrollPane(wrapper, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
}

View File

@@ -60,7 +60,7 @@ public class FrameworkSupportOptionsComponent {
final FrameworkSupportInModuleConfigurable configurable) {
myModel = model;
myConfigurable = configurable;
VerticalFlowLayout layout = new VerticalFlowLayout();
VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 3, true, false);
layout.setVerticalFill(true);
myMainPanel = new JPanel(layout);
myModel.registerOptionsComponent(provider, this);

View File

@@ -28,7 +28,7 @@ public class FrameworkVersionComponent {
final List<? extends FrameworkVersion> versions_, String labelText) {
myModel = model;
myAllVersions = versions_;
myMainPanel = new JPanel(new VerticalFlowLayout());
myMainPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 3, true, false));
myFrameworkOrGroupId = frameworkOrGroupId;
myVersionsBox = new ComboBox();
myVersionsBox.setRenderer(new ListCellRendererWrapper<FrameworkVersion>() {
@@ -47,7 +47,7 @@ public class FrameworkVersionComponent {
}
});
myVersionsPanel = FormBuilder.createFormBuilder().addLabeledComponent(labelText, myVersionsBox).getPanel();
myVersionsPanel = FormBuilder.createFormBuilder().setHorizontalGap(5).addLabeledComponent(labelText, myVersionsBox).getPanel();
myMainPanel.add(myVersionsPanel);
updateVersionsList();
}

View File

@@ -1,4 +1,3 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
@@ -55,7 +54,7 @@ public class SupportForFrameworksStep extends ModuleWizardStep {
myBuilder = builder;
List<FrameworkSupportInModuleProvider> providers = FrameworkSupportUtil.getProviders(builder);
myFrameworkSupportModel = new FrameworkSupportModelInWizard(librariesContainer, builder);
mySupportForFrameworksPanel = new AddSupportForFrameworksPanel(providers, myFrameworkSupportModel, false);
mySupportForFrameworksPanel = new AddSupportForFrameworksPanel(providers, myFrameworkSupportModel, false, null);
myConfigurationUpdater = new ModuleBuilder.ModuleConfigurationUpdater() {
public void update(@NotNull final Module module, @NotNull final ModifiableRootModel rootModel) {
mySupportForFrameworksPanel.addSupport(module, rootModel);

View File

@@ -81,7 +81,7 @@ public class JavaModuleType extends ModuleType<JavaModuleBuilder> {
@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep, @NotNull final ModuleBuilder moduleBuilder) {
public ModuleWizardStep modifyProjectTypeStep(@NotNull SettingsStep settingsStep, @NotNull final ModuleBuilder moduleBuilder) {
return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, moduleBuilder, new Condition<SdkTypeId>() {
@Override
public boolean value(SdkTypeId sdkType) {

View File

@@ -39,6 +39,9 @@ public abstract class AbstractModuleBuilder extends ProjectBuilder {
return null;
}
@Nullable
public ModuleWizardStep modifyProjectTypeStep(@NotNull SettingsStep step) { return null; }
/**
* Custom UI to be shown on the first wizard page
*/

View File

@@ -106,6 +106,10 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
@Override
@Nullable
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
return modifyStep(settingsStep);
}
public ModuleWizardStep modifyStep(SettingsStep settingsStep) {
ModuleType type = getModuleType();
if (type == null) {
return null;
@@ -142,6 +146,11 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
}
}
public ModuleWizardStep modifyProjectTypeStep(@NotNull SettingsStep settingsStep) {
ModuleType type = getModuleType();
return type == null ? null : type.modifyProjectTypeStep(settingsStep, this);
}
protected List<WizardInputField> getAdditionalFields() {
return Collections.emptyList();
}

View File

@@ -34,6 +34,5 @@ public interface SettingsStep {
void addExpertPanel(@NotNull JComponent panel);
void addExpertField(@NotNull String label, @NotNull JComponent field);
@NotNull
JTextField getModuleNameField();
}

View File

@@ -67,6 +67,11 @@ public abstract class ModuleType<T extends ModuleBuilder> {
return null;
}
@Nullable
public ModuleWizardStep modifyProjectTypeStep(@NotNull SettingsStep settingsStep, @NotNull ModuleBuilder moduleBuilder) {
return null;
}
@NotNull
public final String getId() {
return myId;

View File

@@ -51,7 +51,7 @@ public class GroovyAwareModuleBuilder extends JavaModuleBuilder {
@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
public ModuleWizardStep modifyProjectTypeStep(@NotNull SettingsStep settingsStep) {
return new GroovySdkForNewModuleWizardStep(this, settingsStep.getContext(), getFramework(), settingsStep);
}

View File

@@ -38,7 +38,7 @@ public class GroovySdkForNewModuleWizardStep extends GroovySdkWizardStepBase {
super(framework, wizardContext, moduleBuilder.getContentEntryPath());
moduleBuilder.addModuleConfigurationUpdater(createModuleConfigurationUpdater());
if (settingsStep != null) {
myJavaStep = JavaModuleType.getModuleType().modifySettingsStep(settingsStep, moduleBuilder);
myJavaStep = JavaModuleType.getModuleType().modifyProjectTypeStep(settingsStep, moduleBuilder);
settingsStep.addSettingsField("\u001B" + (framework == null ? "Groovy" : framework.getDisplayName()) + " library:", getPanel().getSimplePanel());
}
}