diff --git a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java index f2e2ba5be0a0..3e49048d6420 100644 --- a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java +++ b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java @@ -21,6 +21,7 @@ package com.intellij.ide.impl; import com.intellij.ide.GeneralSettings; import com.intellij.ide.util.newProjectWizard.AddModuleWizard; +import com.intellij.ide.util.newProjectWizard.AddModuleWizardPro; import com.intellij.ide.util.projectWizard.ProjectBuilder; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; @@ -44,6 +45,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.ThrowableComputable; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.wm.*; import com.intellij.openapi.wm.ex.WindowManagerEx; @@ -68,7 +70,9 @@ public class NewProjectUtil { } }, ProjectBundle.message("project.new.wizard.progress.title"), true, null); if (!proceed) return; - final AddModuleWizard dialog = new AddModuleWizard(null, ModulesProvider.EMPTY_MODULES_PROVIDER, defaultPath); + final AddModuleWizard dialog = Registry.is("new.project.wizard") + ? new AddModuleWizardPro(null, ModulesProvider.EMPTY_MODULES_PROVIDER, defaultPath) + : new AddModuleWizard(null, ModulesProvider.EMPTY_MODULES_PROVIDER, defaultPath); dialog.show(); if (!dialog.isOK()) { return; diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java index 04e2017cb64f..fcacd53f7607 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java @@ -56,7 +56,7 @@ public class AddModuleWizard extends AbstractWizard { private final Project myCurrentProject; private final ModulesProvider myModulesProvider; private WizardContext myWizardContext; - private ProjectCreateModeStep myRootStep; + protected ProjectCreateModeStep myRootStep; /** @@ -166,7 +166,7 @@ public class AddModuleWizard extends AbstractWizard { super.doOKAction(); } - private boolean commitStepData(final ModuleWizardStep step) { + protected boolean commitStepData(final ModuleWizardStep step) { try { if (!step.validate()) { return false; diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizardPro.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizardPro.java new file mode 100644 index 000000000000..91d54fb3ef73 --- /dev/null +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizardPro.java @@ -0,0 +1,197 @@ +package com.intellij.ide.util.newProjectWizard; + +import com.intellij.ide.util.projectWizard.ModuleWizardStep; +import com.intellij.ide.util.projectWizard.WizardContext; +import com.intellij.ide.wizard.CommitStepException; +import com.intellij.ide.wizard.Step; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CustomShortcutSet; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ui.configuration.ModulesProvider; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.ui.ValidationInfo; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Enumeration; + +/** + * @author Konstantin Bulenkov + */ +public class AddModuleWizardPro extends AddModuleWizard { + protected JPanel myStepsPanel; + + public AddModuleWizardPro(Project project, @NotNull ModulesProvider modulesProvider, @Nullable String defaultPath) { + super(project, modulesProvider, defaultPath); + getWizardContext().addContextListener(new WizardContext.Listener() { + @Override + public void buttonsUpdateRequested() { + updateStepsPanel(); + } + + @Override + public void nextStepRequested() { + updateStepsPanel(); + } + }); + } + + @Override + protected void updateButtons() { + super.updateButtons(); + if (isLastStep()) { + getNextButton().setText("Done"); + } + + getPreviousButton().setVisible(false); + getCancelButton().setVisible(false); + } + + public AddModuleWizardPro(Component parent, Project project, @NotNull ModulesProvider modulesProvider) { + super(parent, project, modulesProvider); + } + + @Override + protected void createDefaultActions() { + super.createDefaultActions(); + } + + @Override + protected JComponent createCenterPanel() { + myStepsPanel = new JPanel() { + @Override + public void addNotify() { + super.addNotify(); + getNextStepObject().updateDataModel(); + updateStepsPanel(); + new AnAction(){ + @Override + public void actionPerformed(AnActionEvent e) { + if (!isLastStep()) doNextAction(); + } + }.registerCustomShortcutSet(CustomShortcutSet.fromString("control TAB"), getContentPanel(), getDisposable()); + new AnAction(){ + @Override + public void actionPerformed(AnActionEvent e) { + doPreviousAction(); + } + }.registerCustomShortcutSet(CustomShortcutSet.fromString("control shift TAB"), getContentPanel(), getDisposable()); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + final Component c = getComponent(getComponentCount() - 1); + int y = c.getBounds().y + c.getBounds().height + 4; + g.translate(0, y); + myIcon.paintIcon(g); + g.translate(0, -y); + } + }; + myStepsPanel.setLayout(new BoxLayout(myStepsPanel, BoxLayout.Y_AXIS) { + @Override + public void layoutContainer(Container target) { + super.layoutContainer(target); + int maxWidth = -1; + for (Component c : target.getComponents()) { + maxWidth = Math.max(maxWidth, c.getWidth()); + } + for (Component c : target.getComponents()) { + final Rectangle b = c.getBounds(); + c.setBounds(b.x, b.y, maxWidth, b.height); + } + } + }); + myStepsPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 4)); + updateStepsPanel(); + + final JPanel panel = new JPanel(new BorderLayout()); + panel.add(myStepsPanel, BorderLayout.WEST); + panel.add(myContentPanel, BorderLayout.CENTER); + return panel; + + } + + @Override + public void doNextAction() { + super.doNextAction(); + updateStepsPanel(); + } + + @Override + protected void doPreviousAction() { + super.doPreviousAction(); + updateStepsPanel(); + } + + @Nullable + @Override + protected ValidationInfo doValidate() { + final ValidationInfo result = super.doValidate(); + updateStepsPanel(); + return result; + } + + private void updateStepsPanel() { + myStepsPanel.removeAll(); + int index = 0; + final ButtonGroup group = new ButtonGroup(); + while (index != -1) { + final int ind = index; + final ModuleWizardStep step = mySteps.get(index); + final JRadioButton rb = new JRadioButton(step.getName(), index == myCurrentStep); + rb.setUI(new WizardArrowUI(rb, index < myCurrentStep)); + myStepsPanel.add(rb); + group.add(rb); + rb.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final ModuleWizardStep step = getCurrentStepObject(); + if (ind > getCurrentStep() && !commitStepData(step)) { + updateStepsPanel(); + return; + } + step.onStepLeaving(); + + // Commit data of current step + final Step currentStep = mySteps.get(myCurrentStep); + try { + currentStep._commit(false); + } + catch (final CommitStepException exc) { + Messages.showErrorDialog( + myContentPanel, + exc.getMessage() + ); + return; + } + + myCurrentStep = ind; + updateStep(); + + } + }); + + final int next = getNextStep(index); + index = index == next ? -1 : next; + } + + final Enumeration buttons = group.getElements(); + while (buttons.hasMoreElements()) { + final JRadioButton b = (JRadioButton)buttons.nextElement(); + b.setUI(new WizardArrowUI(b, index < myCurrentStep)); + } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + myStepsPanel.revalidate(); + myStepsPanel.repaint(); + } + }); + } +} diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectCreateModeStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectCreateModeStep.java index aca930eb52ae..f6afd575f880 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectCreateModeStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectCreateModeStep.java @@ -30,7 +30,7 @@ import com.intellij.ide.util.projectWizard.WizardContext; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.util.Disposer; -import com.intellij.ui.DoubleClickListener; +import com.intellij.ui.ClickListener; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -93,11 +93,15 @@ public class ProjectCreateModeStep extends ModuleWizardStep { setMode(mode); } }); - new DoubleClickListener() { + new ClickListener() { @Override - protected boolean onDoubleClick(MouseEvent e) { - wizardContext.requestNextStep(); - return true; + public boolean onClick(MouseEvent event, int clickCount) { + if (mode.getAdditionalSettings(wizardContext) == null) { + wizardContext.requestNextStep(); + return true; + } else { + return false; + } } }.installOn(rb); @@ -139,6 +143,11 @@ public class ProjectCreateModeStep extends ModuleWizardStep { return myWizardContext.getStepIcon(); } + @Override + public String getName() { + return myMode.getShortName(); + } + public WizardMode getMode() { return myMode; } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.java index d353cb9319ce..8dc1fa6a6f1e 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.java @@ -467,4 +467,9 @@ public class ProjectNameWithTypeStep extends ProjectNameStep { myInternalPanel.add(component, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0)); } + + @Override + public String getName() { + return "Name and Type"; + } } 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 7af6ca11b872..bd879e4c11c3 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 @@ -359,6 +359,11 @@ public class SelectTemplateStep extends ModuleWizardStep { Disposer.dispose(myBuilder); } + @Override + public String getName() { + return "Template Type"; + } + private void createUIComponents() { mySearchField = new SearchTextField(false); } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SourcePathsStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SourcePathsStep.java index c24cee3db639..47eddbc247d5 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SourcePathsStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SourcePathsStep.java @@ -400,4 +400,9 @@ public class SourcePathsStep extends AbstractStepWithProgress { steps.add(wizardFactory.createProjectJdkStep(wizardContext, JavaSdk.getInstance(), moduleBuilder, new Computable() { @Override public Boolean compute() { - final Sdk projectJdk = wizardFactory.getNewProjectSdk(wizardContext); - return projectJdk == null || projectJdk.getSdkType() != JavaSdk.getInstance() ? Boolean.TRUE : Boolean.FALSE; + //final Sdk projectJdk = wizardFactory.getNewProjectSdk(wizardContext); + //return projectJdk == null || projectJdk.getSdkType() != JavaSdk.getInstance() ? Boolean.TRUE : Boolean.FALSE; + return Boolean.TRUE; } }, getWizardIcon(), "reference.dialogs.new.project.fromScratch.sdk")); final ModuleWizardStep supportForFrameworksStep = wizardFactory.createSupportForFrameworksStep(wizardContext, moduleBuilder, modulesProvider); diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java index 619f44f2180f..9ae42b311d16 100644 --- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java +++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java @@ -58,6 +58,10 @@ public abstract class ModuleWizardStep extends StepAdapter{ return true; } + public String getName() { + return getClass().getName(); + } + public void disposeUIResources() { } diff --git a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java index 8d5a4f367422..bb33c2184024 100644 --- a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java +++ b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java @@ -54,8 +54,8 @@ public abstract class AbstractWizard extends DialogWrapper { private JButton myNextButton; private JButton myCancelButton; private JButton myHelpButton; - private JPanel myContentPanel; - private TallImageComponent myIcon; + protected JPanel myContentPanel; + protected TallImageComponent myIcon; private Component myCurrentStepComponent; private final Alarm myFocusAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD); private final Map myComponentToIdMap = new HashMap(); @@ -227,7 +227,7 @@ public abstract class AbstractWizard extends DialogWrapper { } } - private static class TallImageComponent extends OpaquePanel { + public static class TallImageComponent extends OpaquePanel { private Icon myIcon; private TallImageComponent(Icon icon) { @@ -238,6 +238,10 @@ public abstract class AbstractWizard extends DialogWrapper { protected void paintChildren(Graphics g) { if (myIcon == null) return; + paintIcon(g); + } + + public void paintIcon(Graphics g) { final BufferedImage image = new BufferedImage(myIcon.getIconWidth(), myIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); final Graphics2D gg = image.createGraphics(); myIcon.paintIcon(this, gg, 0, 0); @@ -485,6 +489,10 @@ public abstract class AbstractWizard extends DialogWrapper { return myPreviousButton; } + public JButton getCancelButton() { + return myCancelButton; + } + @Deprecated protected JButton getFinishButton() { return new JButton(); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java index ec2d2b4ed526..bce1a315c911 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -1026,6 +1026,10 @@ public abstract class DialogWrapper { return myPeer.getWindow(); } + public JComponent getContentPanel() { + return (JComponent)myPeer.getContentPane(); + } + /** * @see javax.swing.JDialog#getRootPane * @return root pane diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index b8561e89fe45..6dab52896453 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -259,4 +259,5 @@ introduce.variable.prefer.statements=false show.method.base.class.in.java.file.structure=true vcs.log.empty.change.list.creation=false -debugger.enable.breakpoints.during.evaluation=false \ No newline at end of file +debugger.enable.breakpoints.during.evaluation=false +new.project.wizard=false \ No newline at end of file diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseWorkspaceRootStep.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseWorkspaceRootStep.java index 98d43419cb00..a1c20fbaa629 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseWorkspaceRootStep.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseWorkspaceRootStep.java @@ -86,6 +86,11 @@ public class EclipseWorkspaceRootStep extends ProjectImportWizardStep { return super.validate() && getContext().setRootDirectory(myWorkspaceRootComponent.getText()); } + @Override + public String getName() { + return "Eclipse Projects Root"; + } + public void updateDataModel() { final String projectFilesDir; if (myDirComponent.isEnabled()) { diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/SelectEclipseImportedProjectsStep.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/SelectEclipseImportedProjectsStep.java index e12a578744f1..e001e856ad88 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/SelectEclipseImportedProjectsStep.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/SelectEclipseImportedProjectsStep.java @@ -96,6 +96,11 @@ class SelectEclipseImportedProjectsStep extends SelectImportedProjectsStep