Search in sources :

Example 6 with FileChooserDescriptor

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

the class GroovyCompilerConfigurable method createExcludedConfigurable.

private ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
    final ExcludesConfiguration configuration = myConfig.getExcludeFromStubGeneration();
    final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {

        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, showHiddenFiles) && !index.isExcluded(file);
        }
    };
    descriptor.setRoots(ContainerUtil.concat(ContainerUtil.map(ModuleManager.getInstance(project).getModules(), new Function<Module, List<VirtualFile>>() {

        @Override
        public List<VirtualFile> fun(final Module module) {
            return ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
        }
    })));
    return new ExcludedEntriesConfigurable(project, descriptor, configuration);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExcludedEntriesConfigurable(com.intellij.openapi.compiler.options.ExcludedEntriesConfigurable) ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) List(java.util.List) Module(com.intellij.openapi.module.Module)

Example 7 with FileChooserDescriptor

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

the class SdkHomeConfigurable method createComponent.

@Override
public JComponent createComponent() {
    myPanel = new JPanel(new BorderLayout(10, 5));
    final JPanel contentPanel = new JPanel(new BorderLayout(4, 0));
    myPanel.add(contentPanel, BorderLayout.NORTH);
    contentPanel.add(new JLabel(myFrameworkName + " home:"), BorderLayout.WEST);
    myPathField = new TextFieldWithBrowseButton();
    contentPanel.add(myPathField);
    myPathField.addBrowseFolderListener("Select " + myFrameworkName + " home", "", myProject, new FileChooserDescriptor(false, true, false, false, false, false) {

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            return isSdkHome(file);
        }
    });
    return myPanel;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 8 with FileChooserDescriptor

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

the class SvnConfigurable method selectConfigurationDirectory.

public static void selectConfigurationDirectory(@NotNull String path, @NotNull final Consumer<String> dirConsumer, final Project project, @Nullable final Component component) {
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor().withTitle(SvnBundle.message("dialog.title.select.configuration.directory")).withDescription(SvnBundle.message("dialog.description.select.configuration.directory")).withShowFileSystemRoots(true).withHideIgnored(false).withShowHiddenFiles(true);
    path = "file://" + path.replace(File.separatorChar, '/');
    VirtualFile root = VirtualFileManager.getInstance().findFileByUrl(path);
    VirtualFile file = FileChooser.chooseFile(descriptor, component, project, root);
    if (file == null) {
        return;
    }
    final String resultPath = file.getPath().replace('/', File.separatorChar);
    dirConsumer.consume(resultPath);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 9 with FileChooserDescriptor

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

the class TestNGConfigurationEditor method createView.

private void createView() {
    commonParametersPanel.add(commonJavaParameters, BorderLayout.CENTER);
    classField.setComponent(new EditorTextFieldWithBrowseButton(project, true, new JavaCodeFragment.VisibilityChecker() {

        @Override
        public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
            if (declaration instanceof PsiClass && place.getParent() instanceof PsiJavaCodeReferenceElement) {
                return Visibility.VISIBLE;
            }
            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());
    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 ModulesComboBox());
    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(propertiesTableModel);
    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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) MessageInfoException(com.theoryinpractice.testng.MessageInfoException) ModulesComboBox(com.intellij.application.options.ModulesComboBox) TestClassBrowser(com.theoryinpractice.testng.configuration.browser.TestClassBrowser) JBList(com.intellij.ui.components.JBList) TableView(com.intellij.ui.table.TableView)

Example 10 with FileChooserDescriptor

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

the class TerminalSettingsPanel method createPanel.

public JComponent createPanel(@NotNull TerminalOptionsProvider provider, @NotNull TerminalProjectOptionsProvider projectOptionsProvider) {
    myOptionsProvider = provider;
    myProjectOptionsProvider = projectOptionsProvider;
    myProjectSettingsPanel.setBorder(IdeBorderFactory.createTitledBorder("Project settings"));
    myGlobalSettingsPanel.setBorder(IdeBorderFactory.createTitledBorder("Application settings"));
    FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
    myShellPathField.addBrowseFolderListener("", "Shell executable path", null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
    fileChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false);
    myStartDirectoryField.addBrowseFolderListener("", "Starting directory", null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
    myShellPathField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            myShellPathField.getTextField().setForeground(StringUtil.equals(myShellPathField.getText(), myProjectOptionsProvider.getDefaultShellPath()) ? getDefaultValueColor() : getChangedValueColor());
        }
    });
    myStartDirectoryField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            myStartDirectoryField.getTextField().setForeground(StringUtil.equals(myStartDirectoryField.getText(), myProjectOptionsProvider.getDefaultStartingDirectory()) ? getDefaultValueColor() : getChangedValueColor());
        }
    });
    for (LocalTerminalCustomizer c : LocalTerminalCustomizer.EP_NAME.getExtensions()) {
        UnnamedConfigurable configurable = c.getConfigurable(projectOptionsProvider.getProject());
        if (configurable != null) {
            myConfigurables.add(configurable);
            JComponent component = configurable.createComponent();
            if (component != null) {
                myConfigurablesPanel.add(component, BorderLayout.CENTER);
            }
        }
    }
    return myWholePanel;
}
Also used : FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentAdapter(com.intellij.ui.DocumentAdapter) UnnamedConfigurable(com.intellij.openapi.options.UnnamedConfigurable) DocumentEvent(javax.swing.event.DocumentEvent)

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