Search in sources :

Example 31 with FileChooserDescriptor

use of com.intellij.openapi.fileChooser.FileChooserDescriptor 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 32 with FileChooserDescriptor

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

the class ConfigureTestDiscoveryAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final FileChooserDescriptor folderDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    folderDescriptor.setTitle("Choose External Discovery Index Directory");
    folderDescriptor.setDescription("Local directory with indices retrieved from CI \n" + "to be replaced within TeamCity IDEA plugin");
    final VirtualFile virtualFile = FileChooser.chooseFile(folderDescriptor, e.getProject(), null);
    if (virtualFile != null) {
        TestDiscoveryIndex.getInstance(e.getProject()).setRemoteTestRunDataPath(virtualFile.getPath());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 33 with FileChooserDescriptor

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

the class JavadocEditor method createComponentImpl.

@Override
public JComponent createComponentImpl() {
    final DefaultTableModel tableModel = createModel();
    myTable = new JBTable(tableModel);
    myTable.setIntercellSpacing(new Dimension(0, 0));
    myTable.setDefaultRenderer(TableItem.class, new MyRenderer());
    myTable.setShowGrid(false);
    myTable.setDragEnabled(false);
    myTable.setShowHorizontalLines(false);
    myTable.setShowVerticalLines(false);
    myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    JPanel tablePanel = ToolbarDecorator.createDecorator(myTable).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            FileChooserDescriptor myDescriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor();
            myDescriptor.setTitle(ProjectBundle.message("module.javadoc.add.path.title"));
            myDescriptor.setDescription(ProjectBundle.message("module.javadoc.add.path.prompt"));
            VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myTable, myProject, null);
            final MyTableModel tableModel = (MyTableModel) myTable.getModel();
            boolean changes = false;
            for (final VirtualFile file : files) {
                if (file != null) {
                    tableModel.addTableItem(new TableItem(file));
                    changes = true;
                }
            }
            if (changes) {
                saveData();
                TableUtil.selectRows(myTable, new int[] { tableModel.getRowCount() - 1 });
            }
        }
    }).addExtraAction(new DumbAwareActionButton(ProjectBundle.message("module.javadoc.add.url.button"), IconUtil.getAddLinkIcon()) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            VirtualFile[] files = new VirtualFile[] { Util.showSpecifyJavadocUrlDialog(myTable) };
            final MyTableModel tableModel = (MyTableModel) myTable.getModel();
            boolean changes = false;
            for (final VirtualFile file : files) {
                if (file != null) {
                    tableModel.addTableItem(new TableItem(file));
                    changes = true;
                }
            }
            if (changes) {
                saveData();
                TableUtil.selectRows(myTable, new int[] { tableModel.getRowCount() - 1 });
            }
        }
    }).setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            final List removedItems = TableUtil.removeSelectedItems(myTable);
            if (removedItems.size() > 0) {
                saveData();
            }
        }
    }).setButtonComparator("Add", ProjectBundle.message("module.javadoc.add.url.button"), "Remove").createPanel();
    final JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(tablePanel, BorderLayout.CENTER);
    mainPanel.add(new JBLabel(ProjectBundle.message("project.roots.javadoc.tab.description"), UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER), BorderLayout.NORTH);
    return mainPanel;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DefaultTableModel(javax.swing.table.DefaultTableModel) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) JBLabel(com.intellij.ui.components.JBLabel) List(java.util.List)

Example 34 with FileChooserDescriptor

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

the class AnnotationsEditor method createComponentImpl.

@Override
public JComponent createComponentImpl() {
    final DefaultTableModel tableModel = createModel();
    myTable = new JBTable(tableModel);
    myTable.setIntercellSpacing(new Dimension(0, 0));
    myTable.setDefaultRenderer(TableItem.class, new MyRenderer());
    myTable.setShowGrid(false);
    myTable.setDragEnabled(false);
    myTable.setShowHorizontalLines(false);
    myTable.setShowVerticalLines(false);
    myTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    JPanel tablePanel = ToolbarDecorator.createDecorator(myTable).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            FileChooserDescriptor myDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
            myDescriptor.setTitle(ProjectBundle.message("add.external.annotations.path.title"));
            myDescriptor.setDescription(ProjectBundle.message("add.external.annotations.path.description"));
            VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myTable, myProject, null);
            final MyTableModel tableModel = (MyTableModel) myTable.getModel();
            boolean changes = false;
            for (final VirtualFile file : files) {
                if (file != null) {
                    tableModel.addTableItem(new TableItem(file));
                    changes = true;
                }
            }
            if (changes) {
                saveData();
                TableUtil.selectRows(myTable, new int[] { tableModel.getRowCount() - 1 });
            }
        }
    }).setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            final List removedItems = TableUtil.removeSelectedItems(myTable);
            if (removedItems.size() > 0) {
                saveData();
            }
        }
    }).createPanel();
    final JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(tablePanel, BorderLayout.CENTER);
    mainPanel.add(new JBLabel(ProjectBundle.message("project.roots.external.annotations.description"), UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER), BorderLayout.NORTH);
    return mainPanel;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DefaultTableModel(javax.swing.table.DefaultTableModel) JBTable(com.intellij.ui.table.JBTable) JBLabel(com.intellij.ui.components.JBLabel) List(java.util.List)

Example 35 with FileChooserDescriptor

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

the class ProjectConfigurable method createUIComponents.

private void createUIComponents() {
    myLanguageLevelCombo = new LanguageLevelCombo(JavaCoreBundle.message("default.language.level.description")) {

        @Override
        protected LanguageLevel getDefaultLevel() {
            Sdk sdk = myProjectJdkConfigurable.getSelectedProjectJdk();
            if (sdk == null)
                return null;
            JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
            return version == null ? null : version.getMaxLanguageLevel();
        }
    };
    final JTextField textField = new JTextField();
    final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
    outputPathsChooserDescriptor.setHideIgnored(false);
    BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor);
    myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance());
    FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null);
}
Also used : JavaSdkVersion(com.intellij.openapi.projectRoots.JavaSdkVersion) BrowseFilesListener(com.intellij.ide.util.BrowseFilesListener) LanguageLevel(com.intellij.pom.java.LanguageLevel) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) Sdk(com.intellij.openapi.projectRoots.Sdk) FieldPanel(com.intellij.ui.FieldPanel)

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