Example usage for com.intellij.openapi.ui TextFieldWithBrowseButton addBrowseFolderListener

List of usage examples for com.intellij.openapi.ui TextFieldWithBrowseButton addBrowseFolderListener

Introduction

In this page you can find the example usage for com.intellij.openapi.ui TextFieldWithBrowseButton addBrowseFolderListener.

Prototype

public void addBrowseFolderListener(@Nullable @Nls(capitalization = Nls.Capitalization.Title) String title,
            @Nullable @Nls(capitalization = Nls.Capitalization.Sentence) String description,
            @Nullable Project project, FileChooserDescriptor fileChooserDescriptor) 

Source Link

Usage

From source file:com.googlecode.idea.red5.SelectRed5LocationDialog.java

License:Open Source License

private static void initChooser(TextFieldWithBrowseButton field, String title, String description) {
    field.setText(getDefaultLocation());
    field.getTextField().setEditable(true);
    field.addBrowseFolderListener(title, description, null,
            new FileChooserDescriptor(false, true, false, false, false, false));
}

From source file:com.intellij.codeEditor.printing.ExportToHTMLDialog.java

License:Apache License

public static LabeledComponent<TextFieldWithBrowseButton> assignLabel(
        TextFieldWithBrowseButton targetDirectoryField, Project project) {
    LabeledComponent<TextFieldWithBrowseButton> labeledComponent = new LabeledComponent<TextFieldWithBrowseButton>();
    labeledComponent.setText(CodeEditorBundle.message("export.to.html.output.directory.label"));
    targetDirectoryField.addBrowseFolderListener(
            CodeEditorBundle.message("export.to.html.select.output.directory.title"),
            CodeEditorBundle.message("export.to.html.select.output.directory.description"), project,
            FileChooserDescriptorFactory.createSingleFolderDescriptor());
    labeledComponent.setComponent(targetDirectoryField);
    return labeledComponent;
}

From source file:com.intellij.execution.jar.JarApplicationConfigurable.java

License:Apache License

private void createUIComponents() {
    myJarPathComponent = new LabeledComponent<TextFieldWithBrowseButton>();
    TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton();
    textFieldWithBrowseButton.addBrowseFolderListener("Choose JAR File", null, myProject,
            new FileChooserDescriptor(false, false, true, true, false, false));
    myJarPathComponent.setComponent(textFieldWithBrowseButton);
}

From source file:com.intellij.ide.ui.customization.CustomizableActionsPanel.java

License:Apache License

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) {//from ww  w  .j  a v  a  2  s. c o  m
        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;
}

From source file:com.theoryinpractice.testng.configuration.TestNGConfigurationEditor.java

License:Apache License

private void createView() {
    commonParametersPanel.add(commonJavaParameters, BorderLayout.CENTER);

    packageTest.setSelected(false);/*from w  ww  . ja v a2s. c  o m*/
    suiteTest.setSelected(false);
    suiteTest.setEnabled(true);
    groupTest.setSelected(false);
    groupTest.setEnabled(true);
    classTest.setSelected(false);
    classTest.setEnabled(true);
    patternTest.setSelected(false);
    patternTest.setEnabled(true);

    classField.setComponent(
            new EditorTextFieldWithBrowseButton(project, true, new JavaCodeFragment.VisibilityChecker() {
                @Override
                public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
                    try {
                        if (declaration instanceof PsiClass
                                && new TestClassBrowser(project, TestNGConfigurationEditor.this).getFilter()
                                        .isAccepted((PsiClass) declaration)) {
                            return Visibility.VISIBLE;
                        }
                    } catch (MessageInfoException e) {
                        return Visibility.NOT_VISIBLE;
                    }
                    return Visibility.NOT_VISIBLE;
                }
            }));

    final EditorTextFieldWithBrowseButton methodEditorTextField = new EditorTextFieldWithBrowseButton(project,
            true, JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE,
            PlainTextLanguage.INSTANCE.getAssociatedFileType());
    new TextFieldCompletionProvider() {
        @Override
        protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix,
                @NotNull CompletionResultSet result) {
            final String className = getClassName();
            if (className.trim().length() == 0) {
                return;
            }
            final PsiClass testClass = getModuleSelector().findClass(className);
            if (testClass == null)
                return;
            for (PsiMethod psiMethod : testClass.getAllMethods()) {
                if (TestNGUtil.hasTest(psiMethod)) {
                    result.addElement(LookupElementBuilder.create(psiMethod.getName()));
                }
            }
        }
    }.apply(methodEditorTextField.getChildComponent());
    methodField.setComponent(methodEditorTextField);

    groupField.setComponent(new TextFieldWithBrowseButton.NoPathCompletion());
    suiteField.setComponent(new TextFieldWithBrowseButton());
    packageField.setVisible(true);
    packageField.setEnabled(true);
    packageField.setComponent(new EditorTextFieldWithBrowseButton(project, false));

    TextFieldWithBrowseButton outputDirectoryButton = new TextFieldWithBrowseButton();
    outputDirectory.setComponent(outputDirectoryButton);
    outputDirectoryButton.addBrowseFolderListener("TestNG", "Select test output directory", project,
            FileChooserDescriptorFactory.createSingleFolderDescriptor());
    moduleClasspath.setEnabled(true);
    moduleClasspath.setComponent(new JComboBox());

    propertiesTableModel = new TestNGParametersTableModel();
    listenerModel = new TestNGListenersTableModel();

    TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton();
    propertiesFile.setComponent(textFieldWithBrowseButton);

    FileChooserDescriptor propertiesFileDescriptor = new FileChooserDescriptor(true, false, false, false, false,
            false) {
        @Override
        public boolean isFileVisible(VirtualFile virtualFile, boolean showHidden) {
            if (!showHidden && virtualFile.getName().charAt(0) == '.')
                return false;
            return virtualFile.isDirectory() || "properties".equals(virtualFile.getExtension());
        }
    };

    textFieldWithBrowseButton.addBrowseFolderListener("TestNG", "Select .properties file for test properties",
            project, propertiesFileDescriptor);

    propertiesTableView = new TableView();
    propertiesTableView.setModelAndUpdateColumns(propertiesTableModel);
    propertiesTableView.setShowGrid(true);

    myPropertiesPanel.add(
            ToolbarDecorator.createDecorator(propertiesTableView).setAddAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton button) {
                    propertiesTableModel.addParameter();
                    int index = propertiesTableModel.getRowCount() - 1;
                    propertiesTableView.setRowSelectionInterval(index, index);
                }
            }).setRemoveAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton button) {
                    int idx = propertiesTableView.getSelectedRow() - 1;
                    for (int row : propertiesTableView.getSelectedRows()) {
                        propertiesTableModel.removeProperty(row);
                    }
                    if (idx > -1)
                        propertiesTableView.setRowSelectionInterval(idx, idx);
                }
            }).disableUpDownActions().createPanel(), BorderLayout.CENTER);

    myListenersList = new JBList(listenerModel);
    myListenersPanel.add(ToolbarDecorator.createDecorator(myListenersList)
            .setAddAction(new AddActionButtonRunnable()).setRemoveAction(new AnActionButtonRunnable() {
                @Override
                public void run(AnActionButton button) {
                    int idx = myListenersList.getSelectedIndex() - 1;
                    for (int row : myListenersList.getSelectedIndices()) {
                        listenerModel.removeListener(row);
                    }
                    if (idx > -1)
                        myListenersList.setSelectedIndex(idx);
                }
            }).setAddActionUpdater(new AnActionButtonUpdater() {
                @Override
                public boolean isEnabled(AnActionEvent e) {
                    return !project.isDefault();
                }
            }).disableUpDownActions().createPanel(), BorderLayout.CENTER);
}

From source file:de.mprengemann.intellij.plugin.androidicons.util.AndroidResourcesHelper.java

License:Apache License

public static void initResourceBrowser(final Project project, Module module, final String title,
        @Nullable final TextFieldWithBrowseButton browser) {
    final VirtualFile resRoot = SettingsHelper.getResRootForProject(project);

    if (resRoot == null) {
        getResRootFile(project, module, new ResourcesDialog.ResourceSelectionListener() {
            @Override//from   w w w .j  ava  2 s .  com
            public void onResourceSelected(VirtualFile resDir) {
                if (browser != null) {
                    browser.setText(resDir.getCanonicalPath());
                }
                SettingsHelper.saveResRootForProject(project, resDir.getUrl());
            }
        });
    } else {
        if (browser != null) {
            browser.setText(resRoot.getCanonicalPath());
        }
    }

    if (browser != null) {
        FileChooserDescriptor workingDirectoryChooserDescriptor = FileChooserDescriptorFactory
                .createSingleFolderDescriptor();
        workingDirectoryChooserDescriptor.setTitle(title);
        browser.addBrowseFolderListener(title, null, project, workingDirectoryChooserDescriptor);
        browser.addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor) {
            @Override
            @SuppressWarnings("deprecation") // Otherwise not compatible to AndroidStudio
            protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
                super.onFileChoosen(chosenFile);
                SettingsHelper.saveResRootForProject(project, chosenFile.getUrl());
            }
        });
    }
}

From source file:org.codehaus.cargo.intellijidea.CargoConfigurationEditor.java

License:Apache License

/**
 * Init the chooser./*from  w w w .  ja  va2 s.  c  o m*/
 *
 * @param field       textField
 * @param title       title
 * @param description description
 */
private void initChooser(TextFieldWithBrowseButton field, String title, String description) {
    field.getTextField().setEditable(true);
    field.addBrowseFolderListener(title, description, null,
            new FileChooserDescriptor(false, true, false, false, false, false));
}

From source file:org.intellij.erlang.console.ErlangConsoleRunConfigurationForm.java

License:Apache License

@NotNull
private static FileChooserDescriptor addFileChooser(@NotNull final String title,
        @NotNull final TextFieldWithBrowseButton textField, @NotNull final Project project) {
    final FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(false, true, false, false,
            false, false) {/*from   w w  w. jav  a2  s. c o  m*/
        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, showHiddenFiles) && file.isDirectory();
        }
    };
    fileChooserDescriptor.setTitle(title);
    textField.addBrowseFolderListener(title, null, project, fileChooserDescriptor);
    return fileChooserDescriptor;
}

From source file:org.intellij.erlang.utils.ErlangUiUtil.java

License:Apache License

public static void installWorkingDirectoryChooser(@NotNull TextFieldWithBrowseButton on,
        @Nullable Project project) {// www  .  j  a  v  a2 s  . c o m
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    on.addBrowseFolderListener("Choose Working Directory", null, project, descriptor);
}

From source file:org.jboss.forge.plugin.idea.components.FileChooserComponentBuilder.java

License:Open Source License

@Override
public JComponent build(final InputComponent<?, Object> input, Container container) {
    // Added Label
    container.add(new JLabel(input.getLabel() == null ? input.getName() : input.getLabel()));

    final TextFieldWithBrowseButton fileField = new TextFieldWithBrowseButton(new ActionListener() {

        @Override/* w  ww . j a va2 s .  c  o m*/
        public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub

        }
    });
    // Set Default Value
    final ConverterFactory converterFactory = ForgeService.INSTANCE.getConverterFactory();
    Converter<Object, String> converter = converterFactory.getConverter(input.getValueType(), String.class);
    String value = converter.convert(InputComponents.getValueFor(input));
    fileField.setText(value == null ? "" : value);

    final JTextField textField = fileField.getTextField();
    textField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            InputComponents.setValueFor(converterFactory, input, textField.getText());
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            InputComponents.setValueFor(converterFactory, input, textField.getText());
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            InputComponents.setValueFor(converterFactory, input, textField.getText());
        }
    });

    fileField.addBrowseFolderListener("Select a directory", null, null,
            FileChooserDescriptorFactory.createSingleFolderDescriptor());
    container.add(fileField);
    return null;
}