Search in sources :

Example 1 with FixedSizeButton

use of com.intellij.openapi.ui.FixedSizeButton 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);
}
Also used : PackagesNotificationPanel(com.intellij.webcore.packaging.PackagesNotificationPanel) ComboBox(com.intellij.openapi.ui.ComboBox) PyInstalledPackagesPanel(com.jetbrains.python.packaging.ui.PyInstalledPackagesPanel) FixedSizeButton(com.intellij.openapi.ui.FixedSizeButton)

Example 2 with FixedSizeButton

use of com.intellij.openapi.ui.FixedSizeButton in project intellij-community by JetBrains.

the class CreateVirtualEnvDialog method layoutPanel.

protected void layoutPanel(final List<Sdk> allSdks) {
    final GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(2, 2, 2, 2);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0.0;
    myMainPanel.add(new JBLabel(PyBundle.message("sdk.create.venv.dialog.label.name")), c);
    c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 2;
    c.weightx = 1.0;
    myMainPanel.add(myName, c);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.weightx = 0.0;
    myMainPanel.add(new JBLabel(PyBundle.message("sdk.create.venv.dialog.label.location")), c);
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 2;
    c.weightx = 1.0;
    myMainPanel.add(myDestination, c);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.weightx = 0.0;
    myMainPanel.add(new JBLabel(PyBundle.message("sdk.create.venv.dialog.label.base.interpreter")), c);
    c.gridx = 1;
    c.gridy = 2;
    mySdkCombo = new ComboBox();
    c.insets = new Insets(2, 2, 2, 2);
    c.weightx = 1.0;
    myMainPanel.add(mySdkCombo, c);
    c.gridx = 2;
    c.gridy = 2;
    c.insets = new Insets(0, 0, 2, 2);
    c.weightx = 0.0;
    FixedSizeButton button = new FixedSizeButton();
    button.setPreferredSize(myDestination.getButton().getPreferredSize());
    myMainPanel.add(button, c);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 3;
    c.insets = new Insets(2, 2, 2, 2);
    mySitePackagesCheckBox = new JBCheckBox(PyBundle.message("sdk.create.venv.dialog.label.inherit.global.site.packages"));
    myMainPanel.add(mySitePackagesCheckBox, c);
    c.gridx = 0;
    c.gridy = 4;
    myMainPanel.add(myMakeAvailableToAllProjectsCheckbox, c);
    button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            final PythonSdkType sdkType = PythonSdkType.getInstance();
            final FileChooserDescriptor descriptor = sdkType.getHomeChooserDescriptor();
            String suggestedPath = sdkType.suggestHomePath();
            VirtualFile suggestedDir = suggestedPath == null ? null : LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(suggestedPath));
            final NullableConsumer<Sdk> consumer = sdk -> {
                if (sdk == null)
                    return;
                if (!allSdks.contains(sdk)) {
                    allSdks.add(sdk);
                }
                updateSdkList(allSdks, sdk);
            };
            FileChooser.chooseFiles(descriptor, myProject, suggestedDir, new FileChooser.FileChooserConsumer() {

                @Override
                public void consume(List<VirtualFile> selectedFiles) {
                    String path = selectedFiles.get(0).getPath();
                    if (sdkType.isValidSdkHome(path)) {
                        path = FileUtil.toSystemDependentName(path);
                        Sdk newSdk = null;
                        for (Sdk sdk : allSdks) {
                            if (path.equals(sdk.getHomePath())) {
                                newSdk = sdk;
                            }
                        }
                        if (newSdk == null) {
                            newSdk = new PyDetectedSdk(path);
                        }
                        consumer.consume(newSdk);
                    }
                }

                @Override
                public void cancelled() {
                }
            });
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ComboBox(com.intellij.openapi.ui.ComboBox) ActionEvent(java.awt.event.ActionEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) JBCheckBox(com.intellij.ui.components.JBCheckBox) ActionListener(java.awt.event.ActionListener) JBLabel(com.intellij.ui.components.JBLabel) ArrayList(java.util.ArrayList) List(java.util.List) Sdk(com.intellij.openapi.projectRoots.Sdk) NullableConsumer(com.intellij.util.NullableConsumer) FixedSizeButton(com.intellij.openapi.ui.FixedSizeButton)

Example 3 with FixedSizeButton

use of com.intellij.openapi.ui.FixedSizeButton in project intellij-community by JetBrains.

the class CheckoutOptionsDialog method createUIComponents.

private void createUIComponents() {
    mySelectTarget = new FixedSizeButton(20);
    myDepthCombo = new DepthCombo(false);
}
Also used : FixedSizeButton(com.intellij.openapi.ui.FixedSizeButton) DepthCombo(org.jetbrains.idea.svn.DepthCombo)

Example 4 with FixedSizeButton

use of com.intellij.openapi.ui.FixedSizeButton in project azure-tools-for-java by Microsoft.

the class SparkSubmissionContentPanel method addConfigurationLineItem.

private void addConfigurationLineItem() {
    JLabel jobConfigurationLabel = new JLabel("Job configurations");
    add(jobConfigurationLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, 0), 0, 0));
    String[] columns = { "Key", "Value", "" };
    jobConfigurationTable = new JBTable();
    Dimension jobConfigurationTableSize = new Dimension(320, 100);
    jobConfigurationTable.setPreferredScrollableViewportSize(jobConfigurationTableSize);
    jobConfigurationTable.setSurrendersFocusOnKeystroke(true);
    jobConfigurationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jobConfigurationTable.setColumnSelectionAllowed(true);
    JBScrollPane scrollPane = new JBScrollPane(jobConfigurationTable);
    jobConfigurationTable.setFillsViewportHeight(true);
    scrollPane.setMinimumSize(jobConfigurationTableSize);
    jobConfigurationTable.addPropertyChangeListener((evt) -> {
        if ((evt.getPropertyName().equals("tableCellEditor") || evt.getPropertyName().equals("model")) && jobConfigurationTable.getModel() instanceof SubmissionTableModel) {
            SubmissionTableModel model = (SubmissionTableModel) jobConfigurationTable.getModel();
            setVisibleForFixedErrorMessageLabel(ErrorMessageLabelTag.JobConfiguration.ordinal(), false);
            SparkSubmissionJobConfigCheckResult result = model.getFirstCheckResults();
            if (result != null) {
                setStatusForMessageLabel(ErrorMessageLabelTag.JobConfiguration.ordinal(), true, result.getMessaqge(), result.getStatus() == SparkSubmissionJobConfigCheckStatus.Warning);
            }
        }
    });
    add(scrollPane, new GridBagConstraints(1, displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, 0), 0, 0));
    JButton loadJobConfigurationButton = new JButton("...");
    loadJobConfigurationButton.setPreferredSize(selectedArtifactTextField.getButton().getPreferredSize());
    FixedSizeButton loadJobConfigurationFixedSizeButton = new FixedSizeButton(loadJobConfigurationButton);
    add(loadJobConfigurationFixedSizeButton, new GridBagConstraints(2, displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(margin, margin / 2, 0, margin), 0, 0));
    loadJobConfigurationFixedSizeButton.setToolTipText("Load Spark config from property file");
    loadJobConfigurationFixedSizeButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
            fileChooserDescriptor.setTitle("Select Spark property file");
            VirtualFile chooseFile = FileChooser.chooseFile(fileChooserDescriptor, null, null);
            if (chooseFile != null) {
                submitModel.loadJobConfigMapFromPropertyFile(chooseFile.getCanonicalPath());
            }
        }
    });
    errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()] = new JLabel();
    errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()].setVisible(false);
    add(errorMessageLabels[ErrorMessageLabelTag.JobConfiguration.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, margin, 0, margin), 0, 0));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ActionEvent(java.awt.event.ActionEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) JBTable(com.intellij.ui.table.JBTable) ActionListener(java.awt.event.ActionListener) FixedSizeButton(com.intellij.openapi.ui.FixedSizeButton) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 5 with FixedSizeButton

use of com.intellij.openapi.ui.FixedSizeButton in project intellij-community by JetBrains.

the class SelectTemplateDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    loadCombo();
    JButton editTemplatesButton = new FixedSizeButton(myCbxTemplates);
    JPanel centerPanel = new JPanel(new GridBagLayout());
    JLabel selectTemplateLabel = new JLabel(IdeBundle.message("label.name"));
    centerPanel.add(selectTemplateLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, JBUI.insets(2), 0, 0));
    centerPanel.add(myCbxTemplates, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, JBUI.insets(2), 50, 0));
    centerPanel.add(editTemplatesButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, JBUI.insets(2), 0, 0));
    editTemplatesButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            onEditTemplates();
        }
    });
    return centerPanel;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) FixedSizeButton(com.intellij.openapi.ui.FixedSizeButton)

Aggregations

FixedSizeButton (com.intellij.openapi.ui.FixedSizeButton)19 ActionEvent (java.awt.event.ActionEvent)6 ActionListener (java.awt.event.ActionListener)6 ComboBox (com.intellij.openapi.ui.ComboBox)3 EditorTextField (com.intellij.ui.EditorTextField)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 JBLabel (com.intellij.ui.components.JBLabel)2 JBScrollPane (com.intellij.ui.components.JBScrollPane)2 List (java.util.List)2 NotNull (org.jetbrains.annotations.NotNull)2 FileChooserDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.FileChooserDialogFixture)1 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1 ExternalProjectPojo (com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)1 ExternalSystemNode (com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemNode)1 ExternalSystemTasksTree (com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemTasksTree)1