Search in sources :

Example 66 with FileChooserDescriptor

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

the class PerFileConfigurableBase method doAddAction.

private void doAddAction(@NotNull AnActionButton button) {
    TableCellEditor editor = myTable.getCellEditor();
    if (editor != null)
        editor.cancelCellEditing();
    int row = myTable.getSelectedRow();
    Object selectedTarget = row >= 0 ? myModel.data.get(myTable.convertRowIndexToModel(row)).first : null;
    VirtualFile toSelect = myFileToSelect != null ? myFileToSelect : ObjectUtils.tryCast(selectedTarget, VirtualFile.class);
    FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, true, true, true);
    FileChooser.chooseFiles(descriptor, myProject, myTable, toSelect, this::doAddFiles);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) AbstractTableCellEditor(com.intellij.util.ui.AbstractTableCellEditor)

Example 67 with FileChooserDescriptor

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

the class FileDownloaderImpl method chooseDirectoryForFiles.

@Nullable
private static VirtualFile chooseDirectoryForFiles(Project project, JComponent parentComponent) {
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor().withTitle(IdeBundle.message("dialog.directory.for.downloaded.files.title")).withDescription(IdeBundle.message("dialog.directory.for.downloaded.files.description"));
    VirtualFile baseDir = project != null ? project.getBaseDir() : null;
    return FileChooser.chooseFile(descriptor, parentComponent, project, baseDir);
}
Also used : FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) Nullable(org.jetbrains.annotations.Nullable)

Example 68 with FileChooserDescriptor

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

the class CustomLibraryDescriptionBase method createNewLibrary.

@Override
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, VirtualFile contextDirectory) {
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, false, false, true);
    descriptor.setTitle(IdeBundle.message("new.library.file.chooser.title"));
    descriptor.setDescription(IdeBundle.message("new.library.file.chooser.description"));
    final VirtualFile[] files = FileChooser.chooseFiles(descriptor, parentComponent, null, contextDirectory);
    if (files.length == 0) {
        return null;
    }
    return new NewLibraryConfiguration(myDefaultLibraryName, getDownloadableLibraryType(), new LibraryVersionProperties()) {

        @Override
        public void addRoots(@NotNull LibraryEditor editor) {
            for (VirtualFile file : files) {
                editor.addRoot(file, OrderRootType.CLASSES);
            }
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) NotNull(org.jetbrains.annotations.NotNull) NewLibraryConfiguration(com.intellij.openapi.roots.libraries.NewLibraryConfiguration) LibraryVersionProperties(com.intellij.framework.library.LibraryVersionProperties)

Example 69 with FileChooserDescriptor

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

the class UnscrambleDialog method createLogFileChooser.

private void createLogFileChooser() {
    myLogFile = new TextFieldWithHistory();
    JPanel panel = GuiUtils.constructFieldWithBrowseButton(myLogFile, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
            FileChooser.chooseFiles(descriptor, myProject, null, files -> myLogFile.setText(FileUtil.toSystemDependentName(files.get(files.size() - 1).getPath())));
        }
    });
    myLogFileChooserPanel.setLayout(new BorderLayout());
    myLogFileChooserPanel.add(panel, BorderLayout.CENTER);
}
Also used : FileChooserDescriptorFactory(com.intellij.openapi.fileChooser.FileChooserDescriptorFactory) AllIcons(com.intellij.icons.AllIcons) ArrayUtil(com.intellij.util.ArrayUtil) ActionListener(java.awt.event.ActionListener) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) NonNls(org.jetbrains.annotations.NonNls) ContainerUtil(com.intellij.util.containers.ContainerUtil) ArrayList(java.util.ArrayList) TextFieldWithHistory(com.intellij.ui.TextFieldWithHistory) Comparing(com.intellij.openapi.util.Comparing) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Project(com.intellij.openapi.project.Project) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) FileUtil(com.intellij.openapi.util.io.FileUtil) VcsContentAnnotationConfigurable(com.intellij.openapi.vcs.configurable.VcsContentAnnotationConfigurable) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) DumbService(com.intellij.openapi.project.DumbService) ContainerUtil.ar(com.intellij.util.containers.ContainerUtil.ar) StringUtil(com.intellij.openapi.util.text.StringUtil) IOException(java.io.IOException) ListCellRendererWrapper(com.intellij.ui.ListCellRendererWrapper) GuiUtils(com.intellij.ui.GuiUtils) ActionEvent(java.awt.event.ActionEvent) java.awt(java.awt) IdeBundle(com.intellij.ide.IdeBundle) HelpManager(com.intellij.openapi.help.HelpManager) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) StringReader(java.io.StringReader) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) Registry(com.intellij.openapi.util.registry.Registry) BufferedReader(java.io.BufferedReader) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) FileChooser(com.intellij.openapi.fileChooser.FileChooser) CharArrayUtil(com.intellij.util.text.CharArrayUtil) Condition(com.intellij.openapi.util.Condition) javax.swing(javax.swing) ActionListener(java.awt.event.ActionListener) TextFieldWithHistory(com.intellij.ui.TextFieldWithHistory) ActionEvent(java.awt.event.ActionEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 70 with FileChooserDescriptor

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

the class CloneDvcsDialog method initListeners.

/**
   * Init components
   */
private void initListeners() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle(DvcsBundle.getString("clone.destination.directory.title"));
    fcd.setDescription(DvcsBundle.getString("clone.destination.directory.description"));
    fcd.setHideIgnored(false);
    myParentDirectory.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(fcd.getTitle(), fcd.getDescription(), myParentDirectory, myProject, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {

        @Override
        protected VirtualFile getInitialFile() {
            // suggest project base directory only if nothing is typed in the component.
            String text = getComponentText();
            if (text.length() == 0) {
                VirtualFile file = myProject.getBaseDir();
                if (file != null) {
                    return file;
                }
            }
            return super.getInitialFile();
        }
    });
    final DocumentListener updateOkButtonListener = new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            updateButtons();
        }
    };
    myParentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
    String parentDir = getRememberedInputs().getCloneParentDir();
    if (StringUtil.isEmptyOrSpaces(parentDir)) {
        parentDir = ProjectUtil.getBaseDir();
    }
    myParentDirectory.setText(parentDir);
    myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener);
    myTestButton.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            test();
        }
    });
    setOKActionEnabled(false);
    myTestButton.setEnabled(false);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DocumentListener(javax.swing.event.DocumentListener) ActionListener(java.awt.event.ActionListener) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Aggregations

FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)143 VirtualFile (com.intellij.openapi.vfs.VirtualFile)97 NotNull (org.jetbrains.annotations.NotNull)35 Project (com.intellij.openapi.project.Project)21 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)19 Nullable (org.jetbrains.annotations.Nullable)18 ActionEvent (java.awt.event.ActionEvent)17 File (java.io.File)17 ActionListener (java.awt.event.ActionListener)16 DocumentEvent (javax.swing.event.DocumentEvent)13 DocumentAdapter (com.intellij.ui.DocumentAdapter)10 ArrayList (java.util.ArrayList)10 FileChooser (com.intellij.openapi.fileChooser.FileChooser)9 List (java.util.List)9 IOException (java.io.IOException)8 JBLabel (com.intellij.ui.components.JBLabel)7 javax.swing (javax.swing)7 Module (com.intellij.openapi.module.Module)5 StringUtil (com.intellij.openapi.util.text.StringUtil)5 JBTable (com.intellij.ui.table.JBTable)5