diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java index 5ccc56b00e63..2ed47fd7cb13 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java @@ -202,6 +202,11 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D ModuleBuilder builder = getSelectedBuilder(); return StringUtil.notNullize(builder.getContentEntryPath()); } + + @Override + public ModuleBuilder getModuleBuilder() { + return getSelectedBuilder(); + } }; myFrameworksPanel = new AddSupportForFrameworksPanel(Collections.emptyList(), model, true, myHeaderPanel); Disposer.register(this, myFrameworksPanel); diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java index 9acbbd5b9fad..b497b144540c 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java @@ -81,6 +81,7 @@ public class SdkSettingsStep extends ModuleWizardStep { if (jdk != null) { component.setValue(selectedJdkProperty, jdk.getName()); } + OnSdkSelected(jdk); } }); @@ -118,6 +119,8 @@ public class SdkSettingsStep extends ModuleWizardStep { myJdkPanel.add(myJdkComboBox.getSetUpButton(), BorderLayout.EAST); } + protected void OnSdkSelected(Sdk sdk) {} + public boolean isEmpty() { return myJdkPanel.getComponentCount() == 0; } diff --git a/python/pluginSrc/com/jetbrains/python/module/PythonModuleBuilder.java b/python/pluginSrc/com/jetbrains/python/module/PythonModuleBuilder.java index c86f89d034d2..a14edc51357e 100644 --- a/python/pluginSrc/com/jetbrains/python/module/PythonModuleBuilder.java +++ b/python/pluginSrc/com/jetbrains/python/module/PythonModuleBuilder.java @@ -16,10 +16,14 @@ package com.jetbrains.python.module; import com.intellij.ide.util.projectWizard.ModuleWizardStep; +import com.intellij.ide.util.projectWizard.SdkSettingsStep; +import com.intellij.ide.util.projectWizard.SettingsStep; import com.intellij.ide.util.projectWizard.SourcePathsBuilder; -import com.intellij.ide.util.projectWizard.WizardContext; -import com.intellij.openapi.roots.ui.configuration.ModulesProvider; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.SdkTypeId; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Pair; +import com.jetbrains.python.sdk.PythonSdkType; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -47,8 +51,17 @@ public class PythonModuleBuilder extends PythonModuleBuilderBase implements Sour } @Override - public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, - @NotNull ModulesProvider modulesProvider) { - return getModuleType().createWizardSteps(wizardContext, this, modulesProvider); + public ModuleWizardStep modifyProjectTypeStep(@NotNull SettingsStep settingsStep) { + return new SdkSettingsStep(settingsStep, this, new Condition() { + @Override + public boolean value(SdkTypeId id) { + return PythonSdkType.getInstance() == id; + } + }) { + @Override + protected void OnSdkSelected(Sdk sdk) { + setSdk(sdk); + } + }; } } diff --git a/python/pluginSrc/com/jetbrains/python/module/PythonModuleType.java b/python/pluginSrc/com/jetbrains/python/module/PythonModuleType.java index 22de18026fbf..a8ff4ad22b41 100644 --- a/python/pluginSrc/com/jetbrains/python/module/PythonModuleType.java +++ b/python/pluginSrc/com/jetbrains/python/module/PythonModuleType.java @@ -15,50 +15,13 @@ */ package com.jetbrains.python.module; -import com.intellij.facet.impl.DefaultFacetsProvider; -import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider; -import com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil; -import com.intellij.ide.util.newProjectWizard.SupportForFrameworksStep; -import com.intellij.ide.util.projectWizard.ModuleWizardStep; -import com.intellij.ide.util.projectWizard.WizardContext; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; -import com.intellij.openapi.roots.ui.configuration.ModulesProvider; -import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory; import com.jetbrains.python.PythonModuleTypeBase; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.List; - /** * @author yole */ public class PythonModuleType extends PythonModuleTypeBase { - @NotNull - @Override - public ModuleWizardStep[] createWizardSteps(@NotNull final WizardContext wizardContext, - @NotNull final PythonModuleBuilderBase moduleBuilder, - @NotNull final ModulesProvider modulesProvider) { - ArrayList steps = new ArrayList(); - final Project project = getProject(wizardContext); - steps.add(new PythonSdkSelectStep(moduleBuilder, "reference.project.structure.sdk.python", project)); - if (!wizardContext.isNewWizard()) { - final List providers = FrameworkSupportUtil.getProviders(getInstance(), DefaultFacetsProvider.INSTANCE); - if (!providers.isEmpty()) { - steps.add(new SupportForFrameworksStep(wizardContext, moduleBuilder, LibrariesContainerFactory.createContainer(project))); - } - } - return steps.toArray(new ModuleWizardStep[steps.size()]); - } - - private static Project getProject(final WizardContext context) { - Project project = context.getProject(); - if (project == null) { - project = ProjectManager.getInstance().getDefaultProject(); - } - return project; - } @NotNull public PythonModuleBuilder createModuleBuilder() { diff --git a/python/pluginSrc/com/jetbrains/python/module/PythonSdkChooserPanel.java b/python/pluginSrc/com/jetbrains/python/module/PythonSdkChooserPanel.java deleted file mode 100644 index 757ba052de7d..000000000000 --- a/python/pluginSrc/com/jetbrains/python/module/PythonSdkChooserPanel.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.jetbrains.python.module; - -import com.intellij.ide.util.projectWizard.JdkChooserPanel; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.SdkType; -import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.openapi.ui.MultiLineLabelUI; -import com.intellij.util.ui.UIUtil; -import com.jetbrains.python.sdk.PythonSdkType; -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; - -/** - * @author oleg, Roman.Chernyatchik - */ -public class PythonSdkChooserPanel extends JComponent { - private final JdkChooserPanel myJdkChooser; - - /** - * PythonSdkChooserPanel - the panel to choose Python SDK - * - * @param project Current project - */ - public PythonSdkChooserPanel(@NotNull final Project project) { - myJdkChooser = new JdkChooserPanel(project); - - setLayout(new GridBagLayout()); - setBorder(BorderFactory.createEtchedBorder()); - - final JLabel label = new JLabel("Specify the Python interpreter"); - label.setUI(new MultiLineLabelUI()); - add(label, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.HORIZONTAL, new Insets(8, 10, 8, 10), 0, 0)); - - final JLabel jdkLabel = new JLabel("Python Interpreter:"); - jdkLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD)); - add(jdkLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(8, 10, 0, 10), 0, 0)); - - add(myJdkChooser, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.BOTH, new Insets(2, 10, 10, 5), 0, 0)); - JButton configureButton = new JButton("Configure..."); - add(configureButton, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(2, 0, 10, 5), 0, 0)); - - - configureButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - myJdkChooser.editJdkTable(); - } - }); - - myJdkChooser.setAllowedJdkTypes(new SdkType[]{PythonSdkType.getInstance()}); - - final Sdk selectedJdk = project == null ? null : ProjectRootManager.getInstance(project).getProjectSdk(); - myJdkChooser.updateList(selectedJdk, null, null); - } - - @Nullable - public Sdk getChosenJdk() { - return myJdkChooser.getChosenJdk(); - } - - public JComponent getPreferredFocusedComponent() { - return myJdkChooser; - } - - public void selectSdk(@Nullable final Sdk sdk) { - myJdkChooser.selectJdk(sdk); - } -} diff --git a/python/pluginSrc/com/jetbrains/python/module/PythonSdkSelectStep.java b/python/pluginSrc/com/jetbrains/python/module/PythonSdkSelectStep.java deleted file mode 100644 index 92fa82ccc536..000000000000 --- a/python/pluginSrc/com/jetbrains/python/module/PythonSdkSelectStep.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2000-2014 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.jetbrains.python.module; - -import com.intellij.ide.util.projectWizard.ModuleWizardStep; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.projectRoots.Sdk; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; - -/** - * @author oleg - */ -public class PythonSdkSelectStep extends ModuleWizardStep { - protected final PythonSdkChooserPanel myPanel; - protected final PythonModuleBuilderBase mySettingsHolder; - - private final String myHelp; - - public PythonSdkSelectStep(@NotNull final PythonModuleBuilderBase settingsHolder, - @Nullable final String helpId, - @Nullable final Project project) { - super(); - mySettingsHolder = settingsHolder; - myPanel = new PythonSdkChooserPanel(project); - myHelp = helpId; - } - - public String getHelpId() { - return myHelp; - } - - public JComponent getPreferredFocusedComponent() { - return myPanel.getPreferredFocusedComponent(); - } - - public JComponent getComponent() { - return myPanel; - } - - - public void updateDataModel() { - final Sdk sdk = getSdk(); - mySettingsHolder.setSdk(sdk); - } - - @Nullable - private Sdk getSdk() { - return myPanel.getChosenJdk(); - } - - public boolean validate() { - return true; - } -}