From b235f0c27ff09d350b4eaa6ffc0908696bb3be0d Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Thu, 5 Oct 2017 17:36:47 +0300 Subject: [PATCH] PY-22324 Removed the hide interpreter UI that is no longer used in Edu --- .../PyStudyDirectoryProjectGenerator.java | 5 -- .../steps/ProjectSpecificSettingsStep.java | 51 +++---------------- .../newProject/PythonProjectGenerator.java | 6 +++ 3 files changed, 14 insertions(+), 48 deletions(-) diff --git a/python/educational-python/Edu-Python/src/com/jetbrains/edu/learning/PyStudyDirectoryProjectGenerator.java b/python/educational-python/Edu-Python/src/com/jetbrains/edu/learning/PyStudyDirectoryProjectGenerator.java index 61f3ce506f56..e2e84390f4a0 100644 --- a/python/educational-python/Edu-Python/src/com/jetbrains/edu/learning/PyStudyDirectoryProjectGenerator.java +++ b/python/educational-python/Edu-Python/src/com/jetbrains/edu/learning/PyStudyDirectoryProjectGenerator.java @@ -312,11 +312,6 @@ public class PyStudyDirectoryProjectGenerator extends PythonProjectGenerator beforeProjectGenerated(@Nullable Sdk sdk) { diff --git a/python/python-community-configure/src/com/jetbrains/python/newProject/steps/ProjectSpecificSettingsStep.java b/python/python-community-configure/src/com/jetbrains/python/newProject/steps/ProjectSpecificSettingsStep.java index d2666b11ccbe..4a5dd2374711 100644 --- a/python/python-community-configure/src/com/jetbrains/python/newProject/steps/ProjectSpecificSettingsStep.java +++ b/python/python-community-configure/src/com/jetbrains/python/newProject/steps/ProjectSpecificSettingsStep.java @@ -52,7 +52,10 @@ import com.jetbrains.python.packaging.PyPackageManager; import com.jetbrains.python.packaging.PyPackageUtil; import com.jetbrains.python.remote.PyProjectSynchronizer; import com.jetbrains.python.remote.PythonRemoteInterpreterManager; -import com.jetbrains.python.sdk.*; +import com.jetbrains.python.sdk.PreferredSdkComparator; +import com.jetbrains.python.sdk.PyLazySdk; +import com.jetbrains.python.sdk.PySdkUtil; +import com.jetbrains.python.sdk.PythonSdkType; import com.jetbrains.python.sdk.add.PyAddNewVirtualEnvPanel; import icons.PythonIcons; import org.jetbrains.annotations.NotNull; @@ -61,8 +64,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.DocumentEvent; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.io.File; import java.util.*; @@ -137,7 +138,6 @@ public class ProjectSpecificSettingsStep extends ProjectSettingsStepBase i public Sdk getSdk() { if (!(myProjectGenerator instanceof PythonProjectGenerator)) return null; if (mySdk != null) return mySdk; - if (((PythonProjectGenerator)myProjectGenerator).hideInterpreter()) return null; if (mySelectedInterpretersPanel != null && mySelectedInterpretersPanel == myNewVirtualEnvPanel) { return new PyLazySdk("Uninitialized virtual environment at " + myNewVirtualEnvPanel.getPath(), () -> myNewVirtualEnvPanel != null ? myNewVirtualEnvPanel.getOrCreateSdk() : null); @@ -156,7 +156,7 @@ public class ProjectSpecificSettingsStep extends ProjectSettingsStepBase i @Override protected void registerValidators() { super.registerValidators(); - if (myProjectGenerator instanceof PythonProjectGenerator && !((PythonProjectGenerator)myProjectGenerator).hideInterpreter()) { + if (myProjectGenerator instanceof PythonProjectGenerator) { myLocationField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { @@ -237,11 +237,8 @@ public class ProjectSpecificSettingsStep extends ProjectSettingsStepBase i if (myProjectGenerator instanceof PythonProjectGenerator) { final Sdk sdk = getSdk(); if (sdk == null) { - if (!((PythonProjectGenerator)myProjectGenerator).hideInterpreter()) { - setErrorText("No Python interpreter selected"); - return false; - } - return true; + setErrorText("No Python interpreter selected"); + return false; } if (!(sdk instanceof PyLazySdk) && PythonSdkType.isInvalid(sdk)) { setErrorText("Choose valid python interpreter"); @@ -322,12 +319,7 @@ public class ProjectSpecificSettingsStep extends ProjectSettingsStepBase i locationPanel.add(location, BorderLayout.CENTER); panel.add(locationPanel); - if (((PythonProjectGenerator)myProjectGenerator).hideInterpreter()) { - addInterpreterButton(locationPanel, location); - } - else { - panel.add(createInterpretersPanel()); - } + panel.add(createInterpretersPanel()); final PythonRemoteInterpreterManager remoteInterpreterManager = PythonRemoteInterpreterManager.getInstance(); @@ -470,33 +462,6 @@ public class ProjectSpecificSettingsStep extends ProjectSettingsStepBase i return manager.getSynchronizer(sdk); } - private void addInterpreterButton(final JPanel locationPanel, final LabeledComponent location) { - final JButton interpreterButton = new FixedSizeButton(location); - if (SystemInfo.isMac && !UIUtil.isUnderDarcula()) { - interpreterButton.putClientProperty("JButton.buttonType", null); - } - interpreterButton.setIcon(PythonIcons.Python.Python); - interpreterButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final DialogBuilder builder = new DialogBuilder(); - final JPanel panel = new JPanel(); - final LabeledComponent interpreterCombo = LabeledComponent.create(createInterpreterCombo(), - "Interpreter", BorderLayout.WEST); - if (mySdk != null) { - mySdkCombo.getComboBox().setSelectedItem(mySdk); - } - panel.add(interpreterCombo); - builder.setCenterPanel(panel); - builder.setTitle("Select Python Interpreter"); - if (builder.showAndGet()) { - mySdk = (Sdk)mySdkCombo.getComboBox().getSelectedItem(); - } - } - }); - locationPanel.add(interpreterButton, BorderLayout.EAST); - } - @NotNull private PythonSdkChooserCombo createInterpreterCombo() { final Project project = ProjectManager.getInstance().getDefaultProject(); diff --git a/python/src/com/jetbrains/python/newProject/PythonProjectGenerator.java b/python/src/com/jetbrains/python/newProject/PythonProjectGenerator.java index 596344a27f25..0c271105b26c 100644 --- a/python/src/com/jetbrains/python/newProject/PythonProjectGenerator.java +++ b/python/src/com/jetbrains/python/newProject/PythonProjectGenerator.java @@ -30,6 +30,7 @@ import com.intellij.util.containers.ContainerUtil; import com.jetbrains.python.remote.*; import com.jetbrains.python.sdk.PyLazySdk; import com.jetbrains.python.sdk.PySdkUtil; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -256,6 +257,11 @@ public abstract class PythonProjectGenerator ext return null; } + /** + * @deprecated This method no longer has any effect. The standard interpreter chooser UI is always shown. + */ + @Deprecated + @Contract(" -> false") public boolean hideInterpreter() { return false; }