mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
initial python project interpreters page
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.jetbrains.python.configuration.PyActiveSdkConfigurable">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" 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>
|
||||
<component id="70598" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Project Interpreter:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="3aae9">
|
||||
<constraints>
|
||||
<grid row="2" 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>
|
||||
<component id="7421c" class="javax.swing.JComboBox" binding="mySdkCombo">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="19f49" binding="myConfigureInterpretersPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -32,52 +32,133 @@ import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.CollectionComboBoxModel;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.webcore.packaging.PackagesNotificationPanel;
|
||||
import com.jetbrains.python.packaging.ui.PyInstalledPackagesPanel;
|
||||
import com.jetbrains.python.packaging.ui.PyPackageManagementService;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.sdk.PySdkListCellRenderer;
|
||||
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
|
||||
import icons.PythonIcons;
|
||||
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.List;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PyActiveSdkConfigurable implements UnnamedConfigurable {
|
||||
private JPanel myPanel;
|
||||
private final Project myProject;
|
||||
@Nullable private final Module myModule;
|
||||
private JComboBox mySdkCombo;
|
||||
private JPanel myConfigureInterpretersPanel;
|
||||
private PyConfigurableInterpreterList myInterpreterList;
|
||||
private ProjectSdksModel myProjectSdksModel;
|
||||
private MyListener myListener;
|
||||
|
||||
public PyActiveSdkConfigurable(Project project) {
|
||||
private PyConfigurableInterpreterList myInterpreterList;
|
||||
private ProjectSdksModel myProjectSdksModel;
|
||||
private ComboBox mySdkCombo;
|
||||
private PyInstalledPackagesPanel myPackagesPanel;
|
||||
|
||||
public PyActiveSdkConfigurable(@NotNull Project project) {
|
||||
myModule = null;
|
||||
myProject = project;
|
||||
init();
|
||||
layoutPanel();
|
||||
initContent();
|
||||
}
|
||||
|
||||
public PyActiveSdkConfigurable(@NotNull Module module) {
|
||||
myModule = module;
|
||||
myProject = module.getProject();
|
||||
init();
|
||||
layoutPanel();
|
||||
initContent();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mySdkCombo.setRenderer(new SdkListCellRenderer("<None>"));
|
||||
|
||||
private void initContent() {
|
||||
myInterpreterList = PyConfigurableInterpreterList.getInstance(myProject);
|
||||
myInterpreterList.setSdkCombo(mySdkCombo);
|
||||
|
||||
myProjectSdksModel = myInterpreterList.getModel();
|
||||
myListener = new MyListener(this);
|
||||
myProjectSdksModel.addListener(myListener);
|
||||
myConfigureInterpretersPanel.add(new PyConfigureInterpretersLinkPanel(myPanel), BorderLayout.CENTER);
|
||||
myInterpreterList.setSdkCombo(mySdkCombo);
|
||||
|
||||
mySdkCombo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final Sdk selectedSdk = (Sdk)mySdkCombo.getSelectedItem();
|
||||
myPackagesPanel.updatePackages(selectedSdk == null ? null : new PyPackageManagementService(myProject, selectedSdk));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void layoutPanel() {
|
||||
final GridBagLayout layout = new GridBagLayout();
|
||||
myPanel = new JPanel(layout);
|
||||
final JLabel label = new JLabel("Project Interpreter:");
|
||||
final JLabel label1 = new JLabel(" ");
|
||||
mySdkCombo = new ComboBox();
|
||||
mySdkCombo.setRenderer(new SdkListCellRenderer("<None>"));
|
||||
|
||||
PackagesNotificationPanel notificationsArea = new PackagesNotificationPanel(myProject);
|
||||
final JComponent notificationsComponent = notificationsArea.getComponent();
|
||||
notificationsComponent.setPreferredSize(new Dimension(500, 29));
|
||||
|
||||
JButton detailsButton = new JButton();
|
||||
detailsButton.setIcon(PythonIcons.Python.InterpreterGear);
|
||||
detailsButton.setIconTextGap(0);
|
||||
detailsButton.setPreferredSize(new Dimension(29, 29));
|
||||
if (((UIUtil.isUnderAquaLookAndFeel())) || UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula()) {
|
||||
detailsButton.putClientProperty("JButton.buttonType", "square");
|
||||
}
|
||||
|
||||
myPackagesPanel = new PyInstalledPackagesPanel(myProject, notificationsArea);
|
||||
mySdkCombo.setPreferredSize(new Dimension(250, 29));
|
||||
final GridBagConstraints c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
c.insets = new Insets(2,2,2,2);
|
||||
|
||||
c.gridx = 0;
|
||||
c.gridy = 0;
|
||||
myPanel.add(label, c);
|
||||
|
||||
c.gridx = 1;
|
||||
c.gridy = 0;
|
||||
c.weightx = 0.1;
|
||||
myPanel.add(mySdkCombo, c);
|
||||
|
||||
c.insets = new Insets(0,5,0,2);
|
||||
c.gridx = 2;
|
||||
c.gridy = 0;
|
||||
c.weightx = 0.0;
|
||||
myPanel.add(detailsButton, c);
|
||||
|
||||
c.insets = new Insets(2,2,2,2);
|
||||
c.gridx = 0;
|
||||
c.gridy = 1;
|
||||
c.gridwidth = 3;
|
||||
myPanel.add(label1, c);
|
||||
|
||||
c.gridx = 0;
|
||||
c.gridy = 2;
|
||||
c.weighty = 0.5;
|
||||
c.gridwidth = 3;
|
||||
c.gridheight = GridBagConstraints.RELATIVE;
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
myPanel.add(myPackagesPanel, c);
|
||||
|
||||
c.gridheight = GridBagConstraints.REMAINDER;
|
||||
c.gridx = 0;
|
||||
c.gridy = 3;
|
||||
c.gridwidth = 3;
|
||||
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
c.anchor = GridBagConstraints.SOUTH;
|
||||
|
||||
myPanel.add(notificationsComponent, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-12
@@ -18,7 +18,6 @@ package com.jetbrains.python.configuration;
|
||||
import com.intellij.application.options.ModuleAwareProjectConfigurable;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -28,17 +27,12 @@ import com.jetbrains.python.sdk.PythonSdkUpdater;
|
||||
import com.jetbrains.python.testing.VFSTestFrameworkListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PyActiveSdkModuleConfigurable extends ModuleAwareProjectConfigurable implements Configurable.Composite {
|
||||
public class PyActiveSdkModuleConfigurable extends ModuleAwareProjectConfigurable {
|
||||
private final Project myProject;
|
||||
private final Configurable mySdkConfigurable;
|
||||
|
||||
public PyActiveSdkModuleConfigurable(Project project) {
|
||||
super(project, "Project Interpreter", "reference.settings.project.interpreter");
|
||||
myProject = project;
|
||||
mySdkConfigurable = new PythonSdkConfigurable(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -67,9 +61,4 @@ public class PyActiveSdkModuleConfigurable extends ModuleAwareProjectConfigurabl
|
||||
}
|
||||
PythonSdkUpdater.getInstance().updateActiveSdks(myProject, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configurable[] getConfigurables() {
|
||||
return new Configurable[] { mySdkConfigurable };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user