Search in sources :

Example 1 with FileChooserDescriptor

use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project buck by facebook.

the class BuckSettingsUI method init.

private void init() {
    setLayout(new BorderLayout());
    JPanel container = this;
    buckPathField = new TextFieldWithBrowseButton();
    FileChooserDescriptor buckFileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
    buckPathField.addBrowseFolderListener("", "Buck Executable Path", null, buckFileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT, false);
    adbPathField = new TextFieldWithBrowseButton();
    FileChooserDescriptor adbFileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
    adbPathField.addBrowseFolderListener("", "Adb Executable Path", null, adbFileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT, false);
    customizedInstallSettingField = new JBTextField();
    customizedInstallSettingField.getEmptyText().setText(CUSTOMIZED_INSTALL_FLAGS_HINT);
    customizedInstallSettingField.setEnabled(false);
    showDebug = new JCheckBox("Show debug in tool window");
    enableAutoDeps = new JCheckBox("Enable auto dependencies");
    runAfterInstall = new JCheckBox("Run after install (-r)");
    multiInstallMode = new JCheckBox("Multi-install mode (-x)");
    uninstallBeforeInstall = new JCheckBox("Uninstall before installing (-u)");
    customizedInstallSetting = new JCheckBox("Use customized install setting:  ");
    initCustomizedInstallCommandListener();
    JPanel buckSettings = new JPanel(new GridBagLayout());
    buckSettings.setBorder(IdeBorderFactory.createTitledBorder("Buck Settings", true));
    container.add(container = new JPanel(new BorderLayout()), BorderLayout.NORTH);
    container.add(buckSettings, BorderLayout.NORTH);
    final GridBagConstraints constraints = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
    buckSettings.add(new JLabel("Buck Executable Path:"), constraints);
    constraints.gridx = 1;
    constraints.weightx = 1;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    buckSettings.add(buckPathField, constraints);
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.weightx = 1;
    buckSettings.add(new JLabel("Adb Executable Path:"), constraints);
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.weightx = 1;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    buckSettings.add(adbPathField, constraints);
    constraints.gridx = 0;
    constraints.gridy = 2;
    buckSettings.add(showDebug, constraints);
    constraints.gridx = 0;
    constraints.gridy = 3;
    buckSettings.add(enableAutoDeps, constraints);
    JPanel installSettings = new JPanel(new BorderLayout());
    installSettings.setBorder(IdeBorderFactory.createTitledBorder("Buck Install Settings", true));
    container.add(container = new JPanel(new BorderLayout()), BorderLayout.SOUTH);
    container.add(installSettings, BorderLayout.NORTH);
    installSettings.add(runAfterInstall, BorderLayout.NORTH);
    installSettings.add(installSettings = new JPanel(new BorderLayout()), BorderLayout.SOUTH);
    installSettings.add(multiInstallMode, BorderLayout.NORTH);
    installSettings.add(installSettings = new JPanel(new BorderLayout()), BorderLayout.SOUTH);
    installSettings.add(uninstallBeforeInstall, BorderLayout.NORTH);
    installSettings.add(installSettings = new JPanel(new BorderLayout()), BorderLayout.SOUTH);
    final GridBagConstraints customConstraints = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
    JPanel customizedInstallSetting = new JPanel(new GridBagLayout());
    customizedInstallSetting.add(this.customizedInstallSetting, customConstraints);
    customConstraints.gridx = 1;
    customConstraints.weightx = 1;
    customConstraints.fill = GridBagConstraints.HORIZONTAL;
    customizedInstallSetting.add(customizedInstallSettingField, customConstraints);
    installSettings.add(customizedInstallSetting, BorderLayout.NORTH);
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) Insets(java.awt.Insets) BorderLayout(java.awt.BorderLayout) GridBagLayout(java.awt.GridBagLayout) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) JLabel(javax.swing.JLabel) JBTextField(com.intellij.ui.components.JBTextField)

Example 2 with FileChooserDescriptor

use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.

the class SuiteBrowser method showDialog.

@Override
public String showDialog() {
    FileChooserDescriptor descriptor = 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() || "xml".equals(virtualFile.getExtension());
        }
    };
    descriptor.setDescription("Please select the testng.xml suite file");
    descriptor.setTitle("Select Suite");
    VirtualFile file = FileChooser.chooseFile(descriptor, getProject(), null);
    return file != null ? file.getPath() : null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 3 with FileChooserDescriptor

use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project kotlin by JetBrains.

the class K2JSRunConfigurationEditor method setUpChooseHtmlToShow.

private void setUpChooseHtmlToShow() {
    FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFileDescriptor(StdFileTypes.HTML);
    fileChooserDescriptor.setRoots(ProjectRootManager.getInstance(project).getContentRoots());
    htmlChooseFile.addBrowseFolderListener("Choose file to show after translation is finished", null, project, fileChooserDescriptor);
}
Also used : FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 4 with FileChooserDescriptor

use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.

the class AddAssociationAction method addAssociation.

protected void addAssociation(final PsiFile psiFile) {
    final VirtualFile virtualFile = psiFile.getVirtualFile();
    assert virtualFile != null;
    final FileChooserDescriptor descriptor = new AnyXMLDescriptor(true) {

        public boolean isFileSelectable(VirtualFile file) {
            return super.isFileSelectable(file) && !file.equals(virtualFile);
        }
    };
    final VirtualFile[] virtualFiles = FileChooser.chooseFiles(descriptor, psiFile.getProject(), psiFile.getVirtualFile());
    // cancel
    if (virtualFiles.length == 0)
        return;
    for (VirtualFile file : virtualFiles) {
        assert !virtualFile.equals(file);
        myManager.addAssociation(psiFile, file);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 5 with FileChooserDescriptor

use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.

the class AddManagedFilesAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final MavenProjectsManager manager = MavenActionUtil.getProjectsManager(e.getDataContext());
    if (manager == null)
        return;
    FileChooserDescriptor singlePomSelection = new FileChooserDescriptor(true, false, false, false, false, true) {

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            return super.isFileSelectable(file) && !manager.isManagedFile(file);
        }

        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            if (!file.isDirectory() && !MavenActionUtil.isMavenProjectFile(file))
                return false;
            return super.isFileVisible(file, showHiddenFiles);
        }
    };
    Project project = MavenActionUtil.getProject(e.getDataContext());
    VirtualFile fileToSelect = e.getData(CommonDataKeys.VIRTUAL_FILE);
    VirtualFile[] files = FileChooser.chooseFiles(singlePomSelection, project, fileToSelect);
    if (files.length == 0)
        return;
    manager.addManagedFilesOrUnignore(Arrays.asList(files));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Aggregations

FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)166 VirtualFile (com.intellij.openapi.vfs.VirtualFile)110 NotNull (org.jetbrains.annotations.NotNull)35 File (java.io.File)24 Project (com.intellij.openapi.project.Project)22 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)21 Nullable (org.jetbrains.annotations.Nullable)19 ActionEvent (java.awt.event.ActionEvent)17 ActionListener (java.awt.event.ActionListener)16 DocumentEvent (javax.swing.event.DocumentEvent)14 DocumentAdapter (com.intellij.ui.DocumentAdapter)11 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 FileChooser (com.intellij.openapi.fileChooser.FileChooser)9 List (java.util.List)9 FileChooserDialog (com.intellij.openapi.fileChooser.FileChooserDialog)7 JBLabel (com.intellij.ui.components.JBLabel)7 javax.swing (javax.swing)7 MacroComboBoxWithBrowseButton (com.intellij.execution.ui.MacroComboBoxWithBrowseButton)5 Module (com.intellij.openapi.module.Module)5