Search in sources :

Example 6 with TextFieldWithBrowseButton

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

the class ImportOptionsDialog method createCenterPanel.

@Nullable
protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();
    gc.insets = JBUI.insets(2);
    gc.gridwidth = 1;
    gc.gridheight = 1;
    gc.gridx = 0;
    gc.gridy = 0;
    gc.anchor = GridBagConstraints.WEST;
    gc.fill = GridBagConstraints.NONE;
    gc.weightx = 0;
    gc.weighty = 0;
    panel.add(new JLabel("Import to:"), gc);
    gc.gridx += 1;
    gc.gridwidth = 2;
    gc.weightx = 1;
    gc.fill = GridBagConstraints.HORIZONTAL;
    JLabel urlLabel = new JLabel(myURL.toString());
    urlLabel.setFont(urlLabel.getFont().deriveFont(Font.BOLD));
    panel.add(urlLabel, gc);
    gc.gridy += 1;
    gc.gridwidth = 1;
    gc.gridx = 0;
    gc.weightx = 0;
    gc.fill = GridBagConstraints.NONE;
    panel.add(new JLabel("Import from:"), gc);
    gc.gridx += 1;
    gc.gridwidth = 2;
    gc.weightx = 1;
    gc.fill = GridBagConstraints.HORIZONTAL;
    myPathField = new TextFieldWithBrowseButton(this);
    myPathField.setText(myFile.getAbsolutePath());
    myPathField.setEditable(false);
    panel.add(myPathField, gc);
    // other options.
    gc.gridy += 1;
    gc.gridx = 0;
    gc.weightx = 0;
    gc.gridwidth = 3;
    gc.fill = GridBagConstraints.NONE;
    final JLabel depthLabel = new JLabel(SvnBundle.message("label.depth.text"));
    depthLabel.setToolTipText(SvnBundle.message("label.depth.description"));
    panel.add(depthLabel, gc);
    ++gc.gridx;
    myDepth = new DepthCombo(false);
    panel.add(myDepth, gc);
    depthLabel.setLabelFor(myDepth);
    gc.gridx = 0;
    gc.gridy += 1;
    myIncludeIgnoredCheckbox = new JCheckBox("Include ignored resources");
    myIncludeIgnoredCheckbox.setSelected(true);
    panel.add(myIncludeIgnoredCheckbox, gc);
    gc.gridy += 1;
    panel.add(new JLabel("Commit Message:"), gc);
    gc.gridy += 1;
    gc.gridwidth = 3;
    gc.gridx = 0;
    gc.weightx = 1;
    gc.weighty = 1;
    gc.anchor = GridBagConstraints.NORTH;
    gc.fill = GridBagConstraints.BOTH;
    myCommitMessage = new JTextArea(10, 0);
    myCommitMessage.setWrapStyleWord(true);
    myCommitMessage.setLineWrap(true);
    panel.add(ScrollPaneFactory.createScrollPane(myCommitMessage), gc);
    gc.gridy += 1;
    gc.gridwidth = 3;
    gc.gridx = 0;
    gc.weightx = 0;
    gc.weighty = 0;
    gc.anchor = GridBagConstraints.NORTH;
    gc.fill = GridBagConstraints.HORIZONTAL;
    panel.add(new JLabel("Recent Messages: "), gc);
    gc.gridy += 1;
    final ArrayList<String> messages = VcsConfiguration.getInstance(myProject).getRecentMessages();
    Collections.reverse(messages);
    final String[] model = ArrayUtil.toStringArray(messages);
    final JComboBox messagesBox = new JComboBox(model);
    messagesBox.setRenderer(new MessageBoxCellRenderer());
    panel.add(messagesBox, gc);
    String lastMessage = VcsConfiguration.getInstance(myProject).getLastNonEmptyCommitMessage();
    if (lastMessage != null) {
        myCommitMessage.setText(lastMessage);
        myCommitMessage.selectAll();
    }
    messagesBox.addActionListener(e -> {
        myCommitMessage.setText(messagesBox.getSelectedItem().toString());
        myCommitMessage.selectAll();
    });
    return panel;
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) DepthCombo(org.jetbrains.idea.svn.DepthCombo) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with TextFieldWithBrowseButton

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

the class ConfigureProxiesOptionsPanel method setStringProperties.

public void setStringProperties(final Map<String, String> properties) {
    for (Map.Entry<String, String> entry : properties.entrySet()) {
        final JComponent component = myKey2Component.get(entry.getKey());
        if (component != null) {
            JTextComponent textComponent = null;
            if (component instanceof JTextComponent) {
                textComponent = (JTextComponent) component;
            } else if (component instanceof TextFieldWithBrowseButton) {
                textComponent = ((TextFieldWithBrowseButton) component).getTextField();
            }
            if (textComponent != null) {
                textComponent.setText(entry.getValue());
                textComponent.selectAll();
            }
            component.setToolTipText(entry.getKey());
        }
    }
    myTrustDefaultCAsCheckBox.setSelected(booleanPropertySelected(properties.get(myComponent2Key.get(myTrustDefaultCAsCheckBox))));
    repositoryUrlsRecalculation();
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) JTextComponent(javax.swing.text.JTextComponent) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with TextFieldWithBrowseButton

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

the class SshSettingsPanel method createUIComponents.

private void createUIComponents() {
    myExecutablePathTextField = new JBTextField();
    myExecutablePathField = new TextFieldWithBrowseButton(myExecutablePathTextField);
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) JBTextField(com.intellij.ui.components.JBTextField)

Example 9 with TextFieldWithBrowseButton

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

the class SparkSubmissionAdvancedConfigDialog method addRemoteDebugLineItem.

private void addRemoteDebugLineItem() {
    enableRemoteDebugCheckBox = new JCheckBox("Enable Spark remote debug", true);
    enableRemoteDebugCheckBox.setToolTipText("Enable Spark remote debug, use with caution since this might override data previously generated");
    add(enableRemoteDebugCheckBox, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(margin / 6, 0, 0, 0), 0, 0));
    String sshUserNameToolTipText = "Secure shell (SSH) user name used in Spark remote debugging, by default using sshuser";
    JLabel sshUserNameLabel = new JLabel("Secure Shell (SSH) User Name:");
    sshUserNameLabel.setToolTipText(sshUserNameToolTipText);
    add(sshUserNameLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, 0), 0, 0));
    sshUserNameTextField = new JTextField("sshuser");
    sshUserNameTextField.setToolTipText(sshUserNameToolTipText);
    add(sshUserNameTextField, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, margin), 0, 0));
    JLabel sshAuthTypeLabel = new JLabel("Secure Shell (SSH) Auth Type");
    sshAuthTypeLabel.setToolTipText("Secure shell (SSH) authentication type used in Spark remote debugging, by default using the password");
    sshPasswordUsePasswordRadioButton = new JRadioButton("Use secure shell (SSH) password:", false);
    String sshPasswordUsePasswordToolTip = "For secure shell (SSH) password, use the password specified here";
    sshPasswordUsePasswordRadioButton.setToolTipText(sshPasswordUsePasswordToolTip);
    sshPasswordUsePasswordField = new JPasswordField();
    sshPasswordUsePasswordField.setToolTipText(sshPasswordUsePasswordToolTip);
    sshPasswordUseKeyFileRadioButton = new JRadioButton("Use private key file:", false);
    String sshPasswordUseKeyFileToolTip = "For secure shell (SSH) password, use the key file specified here";
    sshPasswordUseKeyFileRadioButton.setToolTipText(sshPasswordUseKeyFileToolTip);
    sshPasswordUseKeyFileTextField = new TextFieldWithBrowseButton();
    sshPasswordUseKeyFileTextField.setToolTipText(sshPasswordUseKeyFileToolTip);
    sshPasswordUseKeyFileTextField.getButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
            fileChooserDescriptor.setTitle("Select SSH key file");
            VirtualFile chooseFile = FileChooser.chooseFile(fileChooserDescriptor, null, null);
            if (chooseFile != null) {
                String path = chooseFile.getPath();
                sshPasswordUseKeyFileTextField.setText(path);
            }
        }
    });
    sshPasswordButtonGroup = new ButtonGroup();
    sshPasswordButtonGroup.add(sshPasswordUsePasswordRadioButton);
    sshPasswordButtonGroup.add(sshPasswordUseKeyFileRadioButton);
    sshPasswordUsePasswordRadioButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                sshPasswordUsePasswordField.setEnabled(true);
                sshPasswordUseKeyFileTextField.setEnabled(false);
            }
        }
    });
    sshPasswordUseKeyFileRadioButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                sshPasswordUsePasswordField.setEnabled(false);
                sshPasswordUseKeyFileTextField.setEnabled(true);
            }
        }
    });
    enableRemoteDebugCheckBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (enableRemoteDebugCheckBox.isSelected()) {
                sshUserNameTextField.setEnabled(true);
                sshUserNameLabel.setEnabled(true);
                sshAuthTypeLabel.setEnabled(true);
                sshPasswordUsePasswordRadioButton.setEnabled(true);
                sshPasswordUseKeyFileRadioButton.setEnabled(true);
                sshPasswordUsePasswordField.setEnabled(true);
                sshPasswordUseKeyFileTextField.setEnabled(true);
                ButtonModel currentSelection = sshPasswordButtonGroup.getSelection();
                sshPasswordUsePasswordRadioButton.setSelected(true);
                sshPasswordUseKeyFileRadioButton.setSelected(true);
                currentSelection.setSelected(true);
            } else {
                sshUserNameTextField.setEnabled(false);
                sshUserNameLabel.setEnabled(false);
                sshAuthTypeLabel.setEnabled(false);
                sshPasswordUsePasswordRadioButton.setEnabled(false);
                sshPasswordUseKeyFileRadioButton.setEnabled(false);
                sshPasswordUsePasswordField.setEnabled(false);
                sshPasswordUseKeyFileTextField.setEnabled(false);
            }
        }
    });
    add(sshAuthTypeLabel, new GridBagConstraints(0, ++displayLayoutCurrentRow, 0, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));
    add(sshPasswordUsePasswordRadioButton, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));
    add(sshPasswordUsePasswordField, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
    add(sshPasswordUseKeyFileRadioButton, new GridBagConstraints(0, ++displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin / 3, margin * 3, 0, margin), 0, 0));
    add(sshPasswordUseKeyFileTextField, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin / 3, margin, 0, margin), 0, 0));
    sshPasswordUsePasswordRadioButton.setSelected(true);
    enableRemoteDebugCheckBox.setSelected(false);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ItemEvent(java.awt.event.ItemEvent) ActionEvent(java.awt.event.ActionEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener)

Example 10 with TextFieldWithBrowseButton

use of com.intellij.openapi.ui.TextFieldWithBrowseButton 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)

Aggregations

TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)59 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)22 NotNull (org.jetbrains.annotations.NotNull)12 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 ActionEvent (java.awt.event.ActionEvent)9 ActionListener (java.awt.event.ActionListener)8 JBLabel (com.intellij.ui.components.JBLabel)6 JBTextField (com.intellij.ui.components.JBTextField)6 DocumentEvent (javax.swing.event.DocumentEvent)6 File (java.io.File)5 Nullable (org.jetbrains.annotations.Nullable)5 FileTextField (com.intellij.openapi.fileChooser.FileTextField)4 ComboBox (com.intellij.openapi.ui.ComboBox)4 TextBrowseFolderListener (com.intellij.openapi.ui.TextBrowseFolderListener)4 DocumentListener (javax.swing.event.DocumentListener)4 AndroidTargetHash.getAddonHashString (com.android.sdklib.AndroidTargetHash.getAddonHashString)3 BuildFileKey (com.android.tools.idea.gradle.parser.BuildFileKey)3 ComponentWithBrowseButton (com.intellij.openapi.ui.ComponentWithBrowseButton)3 RawCommandLineEditor (com.intellij.ui.RawCommandLineEditor)3 JBCheckBox (com.intellij.ui.components.JBCheckBox)3