Search in sources :

Example 1 with ComboBox

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

the class SparkSubmissionContentPanel method addSelectedArtifactLineItem.

private void addSelectedArtifactLineItem() {
    final String tipInfo = "The Artifact you want to use.";
    JLabel artifactSelectLabel = new JLabel("Select an Artifact to submit");
    artifactSelectLabel.setToolTipText(tipInfo);
    selectedArtifactComboBox = new ComboBox();
    selectedArtifactComboBox.setToolTipText(tipInfo);
    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()] = new JLabel("Artifact should not be null!");
    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()].setVisible(false);
    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()] = new JLabel("Could not find the local jar package for Artifact");
    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()].setForeground(DarkThemeManager.getInstance().getErrorMessageColor());
    errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()].setVisible(false);
    selectedArtifactTextField = new TextFieldWithBrowseButton();
    selectedArtifactTextField.setToolTipText("Artifact from local jar package.");
    selectedArtifactTextField.setEditable(true);
    selectedArtifactTextField.setEnabled(false);
    selectedArtifactTextField.getTextField().getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2, !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2, !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            setVisibleForFixedErrorMessageLabel(2, !SparkSubmitHelper.isLocalArtifactPath(selectedArtifactTextField.getText()));
        }
    });
    selectedArtifactTextField.getButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, false, true, false, true, false);
            chooserDescriptor.setTitle("Select Local Artifact File");
            VirtualFile chooseFile = FileChooser.chooseFile(chooserDescriptor, null, null);
            if (chooseFile != null) {
                String path = chooseFile.getPath();
                if (path.endsWith("!/")) {
                    path = path.substring(0, path.length() - 2);
                }
                selectedArtifactTextField.setText(path);
            }
        }
    });
    intelliJArtifactRadioButton = new JRadioButton("Artifact from IntelliJ project:", true);
    localArtifactRadioButton = new JRadioButton("Artifact from local disk:", false);
    intelliJArtifactRadioButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectedArtifactComboBox.setEnabled(true);
                selectedArtifactTextField.setEnabled(false);
                mainClassTextField.setButtonEnabled(true);
                setVisibleForFixedErrorMessageLabel(2, false);
                if (selectedArtifactComboBox.getItemCount() == 0) {
                    setVisibleForFixedErrorMessageLabel(2, true);
                }
            }
        }
    });
    localArtifactRadioButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectedArtifactComboBox.setEnabled(false);
                selectedArtifactTextField.setEnabled(true);
                mainClassTextField.setButtonEnabled(false);
                setVisibleForFixedErrorMessageLabel(1, false);
                if (StringHelper.isNullOrWhiteSpace(selectedArtifactTextField.getText())) {
                    setVisibleForFixedErrorMessageLabel(2, true);
                }
            }
        }
    });
    ButtonGroup group = new ButtonGroup();
    group.add(intelliJArtifactRadioButton);
    group.add(localArtifactRadioButton);
    intelliJArtifactRadioButton.setSelected(true);
    add(artifactSelectLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));
    add(intelliJArtifactRadioButton, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));
    add(selectedArtifactComboBox, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
    add(errorMessageLabels[ErrorMessageLabelTag.SystemArtifact.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
    add(localArtifactRadioButton, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));
    add(selectedArtifactTextField, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
    add(errorMessageLabels[ErrorMessageLabelTag.LocalArtifact.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DocumentListener(javax.swing.event.DocumentListener) ItemEvent(java.awt.event.ItemEvent) ComboBox(com.intellij.openapi.ui.ComboBox) ActionEvent(java.awt.event.ActionEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentEvent(javax.swing.event.DocumentEvent) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener)

Example 2 with ComboBox

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

the class TrelloRepositoryEditor method createCustomPanel.

@Nullable
@Override
protected JComponent createCustomPanel() {
    myBoardComboBox = new ComboBox(300);
    myBoardLabel = new JBLabel("Board:", SwingConstants.RIGHT);
    myBoardLabel.setLabelFor(myBoardComboBox);
    myListComboBox = new ComboBox(300);
    myListLabel = new JBLabel("List:", SwingConstants.RIGHT);
    myListLabel.setLabelFor(myListComboBox);
    myAllCardsCheckBox = new JBCheckBox("Include cards not assigned to me");
    return FormBuilder.createFormBuilder().addLabeledComponent(myBoardLabel, myBoardComboBox).addLabeledComponent(myListLabel, myListComboBox).addComponentToRightColumn(myAllCardsCheckBox).getPanel();
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) ComboBox(com.intellij.openapi.ui.ComboBox) JBCheckBox(com.intellij.ui.components.JBCheckBox) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with ComboBox

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

the class CreateCondaEnvDialog 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.conda.dialog.label.python.version")), 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 = 0;
    c.gridy = 3;
    c.gridwidth = 3;
    myMainPanel.add(myMakeAvailableToAllProjectsCheckbox, c);
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) ComboBox(com.intellij.openapi.ui.ComboBox)

Example 4 with ComboBox

use of com.intellij.openapi.ui.ComboBox 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 5 with ComboBox

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

the class MvcRunTargetDialog method createUIComponents.

private void createUIComponents() {
    myTargetField = new ComboBox(MvcRunTargetHistoryService.getInstance().getHistory());
    myTargetField.setLightWeightPopupEnabled(false);
    EditorComboBoxEditor editor = new StringComboboxEditor(myModule.getProject(), PlainTextFileType.INSTANCE, myTargetField);
    myTargetField.setRenderer(new EditorComboBoxRenderer(editor));
    myTargetField.setEditable(true);
    myTargetField.setEditor(editor);
    EditorTextField editorTextField = editor.getEditorComponent();
    myFakePanel = new JPanel(new BorderLayout());
    myFakePanel.add(myTargetField, BorderLayout.CENTER);
    TextFieldCompletionProvider vmOptionCompletionProvider = new TextFieldCompletionProviderDumbAware() {

        @NotNull
        @Override
        protected String getPrefix(@NotNull String currentTextPrefix) {
            return MvcRunTargetDialog.getPrefix(currentTextPrefix);
        }

        @Override
        protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
            if (prefix.endsWith("-D")) {
                result.addAllElements(MvcTargetDialogCompletionUtils.getSystemPropertiesVariants());
            }
        }
    };
    myVmOptionsField = vmOptionCompletionProvider.createEditor(myModule.getProject());
    new TextFieldCompletionProviderDumbAware() {

        @NotNull
        @Override
        protected String getPrefix(@NotNull String currentTextPrefix) {
            return MvcRunTargetDialog.getPrefix(currentTextPrefix);
        }

        @Override
        protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
            for (LookupElement variant : MvcTargetDialogCompletionUtils.collectVariants(myModule, text, offset, prefix)) {
                result.addElement(variant);
            }
        }
    }.apply(editorTextField);
    editorTextField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        public void documentChanged(DocumentEvent e) {
            setOKActionEnabled(!StringUtil.isEmptyOrSpaces(e.getDocument().getText()));
        }
    });
    setOKActionEnabled(false);
}
Also used : EditorComboBoxEditor(com.intellij.ui.EditorComboBoxEditor) StringComboboxEditor(com.intellij.ui.StringComboboxEditor) ComboBox(com.intellij.openapi.ui.ComboBox) ModulesComboBox(com.intellij.application.options.ModulesComboBox) CompletionResultSet(com.intellij.codeInsight.completion.CompletionResultSet) DocumentAdapter(com.intellij.openapi.editor.event.DocumentAdapter) LookupElement(com.intellij.codeInsight.lookup.LookupElement) DocumentEvent(com.intellij.openapi.editor.event.DocumentEvent) NotNull(org.jetbrains.annotations.NotNull) TextFieldCompletionProviderDumbAware(com.intellij.util.TextFieldCompletionProviderDumbAware) EditorTextField(com.intellij.ui.EditorTextField) TextFieldCompletionProvider(com.intellij.util.TextFieldCompletionProvider) EditorComboBoxRenderer(com.intellij.ui.EditorComboBoxRenderer)

Aggregations

ComboBox (com.intellij.openapi.ui.ComboBox)46 Nullable (org.jetbrains.annotations.Nullable)12 ActionListener (java.awt.event.ActionListener)11 ActionEvent (java.awt.event.ActionEvent)10 JBLabel (com.intellij.ui.components.JBLabel)7 NotNull (org.jetbrains.annotations.NotNull)7 JBTextField (com.intellij.ui.components.JBTextField)6 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)5 AndroidTargetHash.getAddonHashString (com.android.sdklib.AndroidTargetHash.getAddonHashString)4 BuildFileKey (com.android.tools.idea.gradle.parser.BuildFileKey)4 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)4 Project (com.intellij.openapi.project.Project)4 javax.swing (javax.swing)4 Module (com.intellij.openapi.module.Module)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 JBCheckBox (com.intellij.ui.components.JBCheckBox)3 java.awt (java.awt)3 ItemEvent (java.awt.event.ItemEvent)3 ItemListener (java.awt.event.ItemListener)3 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)2