Search in sources :

Example 11 with TextFieldWithBrowseButton

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

the class CustomizableActionsPanel method createBrowseField.

private static TextFieldWithBrowseButton createBrowseField() {
    TextFieldWithBrowseButton textField = new TextFieldWithBrowseButton();
    textField.setPreferredSize(new Dimension(200, textField.getPreferredSize().height));
    textField.setMinimumSize(new Dimension(200, textField.getPreferredSize().height));
    final FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            //noinspection HardCodedStringLiteral
            return file.getName().endsWith(".png");
        }
    };
    textField.addBrowseFolderListener(IdeBundle.message("title.browse.icon"), IdeBundle.message("prompt.browse.icon.for.selected.action"), null, fileChooserDescriptor);
    InsertPathAction.addTo(textField.getTextField(), fileChooserDescriptor);
    return textField;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 12 with TextFieldWithBrowseButton

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

the class CreatePatchConfigurationPanel method initMainPanel.

private void initMainPanel() {
    myFileNameField = new TextFieldWithBrowseButton();
    myBasePathField = new TextFieldWithBrowseButton();
    myReversePatchCheckbox = new JCheckBox(VcsBundle.message("create.patch.reverse.checkbox"));
    myEncoding = new ComboBox<>();
    myWarningLabel = new JLabel();
    myMainPanel = FormBuilder.createFormBuilder().addLabeledComponent(VcsBundle.message("create.patch.file.path"), myFileNameField).addLabeledComponent("&Base path:", myBasePathField).addComponent(myReversePatchCheckbox).addLabeledComponent(VcsBundle.message("create.patch.encoding"), myEncoding).addComponent(myWarningLabel).getPanel();
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton)

Example 13 with TextFieldWithBrowseButton

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

the class JarApplicationConfigurable method createUIComponents.

private void createUIComponents() {
    myJarPathComponent = new LabeledComponent<>();
    TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton();
    textFieldWithBrowseButton.addBrowseFolderListener("Choose JAR File", null, myProject, new FileChooserDescriptor(false, false, true, true, false, false));
    myJarPathComponent.setComponent(textFieldWithBrowseButton);
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 14 with TextFieldWithBrowseButton

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

the class ChooseGradleHomeDialogFixture method requireValidationError.

@NotNull
public ChooseGradleHomeDialogFixture requireValidationError(@NotNull final String errorText) {
    Wait.seconds(1).expecting(String.format("error message '%1$s' to appear", errorText)).until(() -> {
        ComponentFinder finder = robot().finder();
        Collection<JPanel> errorTextPanels = finder.findAll(target(), new GenericTypeMatcher<JPanel>(JPanel.class) {

            @Override
            protected boolean isMatching(@NotNull JPanel panel) {
                // ErrorText is a private inner class
                return panel.isShowing() && panel.getClass().getSimpleName().endsWith("ErrorText");
            }
        });
        if (errorTextPanels.size() != 1) {
            return false;
        }
        JPanel errorTextPanel = getFirstItem(errorTextPanels);
        Collection<JLabel> labels = finder.findAll(errorTextPanel, JLabelMatcher.withText(Pattern.compile(".*" + errorText + ".*")));
        return labels.size() == 1;
    });
    // The label with the error message above also has HTML formatting, which makes the check for error not 100% reliable.
    // To ensure that the shown error message is what we expect, we store the message as a client property in the dialog's
    // TextFieldWithBrowseButton component.
    TextFieldWithBrowseButton field = robot().finder().findByType(target(), TextFieldWithBrowseButton.class);
    Object actual = field.getClientProperty(VALIDATION_MESSAGE_CLIENT_PROPERTY);
    assertEquals("Error message", errorText, actual);
    return this;
}
Also used : ComponentFinder(org.fest.swing.core.ComponentFinder) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with TextFieldWithBrowseButton

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

the class AddAdapterSupportDialog method createSelectDirectoryPanel.

@NotNull
private JPanel createSelectDirectoryPanel(@NotNull Project project, @NotNull JTextField directoryTextField) {
    FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    String adapterName = getAssertFrameworkAdapterName();
    String title = "Select a directory for " + adapterName + " files";
    String description = adapterName + " source files will be copied to the selected directory";
    TextFieldWithBrowseButton directoryTextFieldWithBrowseButton = new TextFieldWithBrowseButton(directoryTextField);
    directoryTextFieldWithBrowseButton.addBrowseFolderListener(title, description, project, fileChooserDescriptor);
    Dimension oldDimension = directoryTextFieldWithBrowseButton.getPreferredSize();
    directoryTextFieldWithBrowseButton.setMaximumSize(oldDimension);
    JPanel panel = new JPanel(new BorderLayout(0, 2));
    panel.add(new JLabel("Copy these files to directory:"), BorderLayout.NORTH);
    panel.add(directoryTextFieldWithBrowseButton, BorderLayout.CENTER);
    return SwingHelper.wrapWithHorizontalStretch(panel);
}
Also used : TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) NotNull(org.jetbrains.annotations.NotNull)

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