use of com.jetbrains.python.packaging.ui.PyInstalledPackagesPanel in project intellij-community by JetBrains.
the class PyActiveSdkConfigurable method layoutPanel.
private void layoutPanel() {
final GridBagLayout layout = new GridBagLayout();
myMainPanel = new JPanel(layout);
final JLabel interpreterLabel = new JLabel(PyBundle.message("active.sdk.dialog.project.interpreter"));
final JLabel emptyLabel = new JLabel(" ");
mySdkCombo = new ComboBox() {
@Override
public void setSelectedItem(Object item) {
if (SHOW_ALL.equals(item)) {
ApplicationManager.getApplication().invokeLater(() -> {
PythonSdkDetailsDialog moreDialog = myModule == null ? new PythonSdkDetailsDialog(myProject, myAddSdkCallback, getSettingsModifiedCallback()) : new PythonSdkDetailsDialog(myModule, myAddSdkCallback, getSettingsModifiedCallback());
moreDialog.show();
});
return;
}
if (!PySdkListCellRenderer.SEPARATOR.equals(item))
super.setSelectedItem(item);
}
@Override
public void paint(Graphics g) {
try {
putClientProperty("JComboBox.isTableCellEditor", Boolean.FALSE);
super.paint(g);
} finally {
putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
}
}
};
mySdkCombo.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
final PackagesNotificationPanel notificationsArea = new PackagesNotificationPanel();
final JComponent notificationsComponent = notificationsArea.getComponent();
final Dimension preferredSize = mySdkCombo.getPreferredSize();
mySdkCombo.setPreferredSize(preferredSize);
notificationsArea.hide();
myDetailsButton = new FixedSizeButton();
myDetailsButton.setIcon(PythonIcons.Python.InterpreterGear);
//noinspection SuspiciousNameCombination
myDetailsButton.setPreferredSize(new Dimension(preferredSize.height, preferredSize.height));
myPackagesPanel = new PyInstalledPackagesPanel(myProject, notificationsArea);
final GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(2, 2, 2, 2);
c.gridx = 0;
c.gridy = 0;
myMainPanel.add(interpreterLabel, c);
c.gridx = 1;
c.gridy = 0;
c.weightx = 0.1;
myMainPanel.add(mySdkCombo, c);
c.insets = new Insets(2, 0, 2, 2);
c.gridx = 2;
c.gridy = 0;
c.weightx = 0.0;
myMainPanel.add(myDetailsButton, c);
final PyCustomSdkUiProvider customUiProvider = PyCustomSdkUiProvider.getInstance();
if (customUiProvider != null) {
myDisposable = Disposer.newDisposable();
customUiProvider.customizeActiveSdkPanel(myProject, mySdkCombo, myMainPanel, c, myDisposable);
}
c.insets = new Insets(2, 2, 0, 2);
c.gridx = 0;
c.gridy++;
c.gridwidth = 3;
c.weightx = 0.0;
myMainPanel.add(emptyLabel, c);
c.gridx = 0;
c.gridy++;
c.weighty = 1.;
c.gridwidth = 3;
c.gridheight = GridBagConstraints.RELATIVE;
c.fill = GridBagConstraints.BOTH;
myMainPanel.add(myPackagesPanel, c);
c.gridheight = GridBagConstraints.REMAINDER;
c.gridx = 0;
c.gridy++;
c.gridwidth = 3;
c.weighty = 0.;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.SOUTH;
myMainPanel.add(notificationsComponent, c);
}
Aggregations