Search in sources :

Example 16 with FileChooserDescriptor

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

the class SetBackgroundImageDialog method setupComponents.

private void setupComponents() {
    myAdjusting = true;
    myPreviewPanel.setLayout(new CardLayout());
    myPreviewPanel.add(myEditorPreview.getPanel(), "editor");
    myPreviewPanel.add(myIdePreview, "ide");
    ((CardLayout) myPreviewPanel.getLayout()).show(myPreviewPanel, "editor");
    myPathField.getComboBox().setEditable(true);
    FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, true, false).withFileFilter(file -> ImageFileTypeManager.getInstance().isImage(file));
    myPathField.addBrowseFolderListener(null, null, null, descriptor, TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
    JTextComponent textComponent = getComboEditor();
    textComponent.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            if (myAdjusting)
                return;
            imagePathChanged();
        }
    });
    for (Enumeration<AbstractButton> e = getTargetRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::targetChanged);
    }
    for (Enumeration<AbstractButton> e = getFillRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::fillOrPlaceChanged);
    }
    for (Enumeration<AbstractButton> e = getPlaceRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::fillOrPlaceChanged);
    }
    ChangeListener opacitySync = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (myAdjusting)
                return;
            myAdjusting = true;
            boolean b = e.getSource() == myOpacitySpinner;
            if (b) {
                int value = (Integer) myOpacitySpinner.getValue();
                myOpacitySpinner.setValue(Math.min(Math.max(0, value), 100));
                myOpacitySlider.setValue(value);
            } else {
                myOpacitySpinner.setValue(myOpacitySlider.getValue());
            }
            myAdjusting = false;
            opacityChanged();
        }
    };
    myOpacitySpinner.addChangeListener(opacitySync);
    myOpacitySlider.addChangeListener(opacitySync);
    myOpacitySlider.setValue(15);
    myOpacitySpinner.setValue(15);
    myScaleRb.setSelected(true);
    myCenterRb.setSelected(true);
    myEditorRb.setSelected(true);
    boolean perProject = !Comparing.equal(getBackgroundSpec(myProject, getSystemProp(true)), getBackgroundSpec(null, getSystemProp(true)));
    myThisProjectOnlyCb.setSelected(perProject);
    myAdjusting = false;
}
Also used : FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentAdapter(com.intellij.ui.DocumentAdapter) JTextComponent(javax.swing.text.JTextComponent) DocumentEvent(javax.swing.event.DocumentEvent) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 17 with FileChooserDescriptor

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

the class ValidationConfigurable method createExcludedConfigurable.

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

        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, showHiddenFiles) && (project.isDefault() || !index.isExcluded(file));
        }
    };
    List<VirtualFile> allContentRoots = new ArrayList<>();
    for (final Module module : ModuleManager.getInstance(project).getModules()) {
        final VirtualFile[] moduleContentRoots = ModuleRootManager.getInstance(module).getContentRoots();
        Collections.addAll(allContentRoots, moduleContentRoots);
    }
    descriptor.setRoots(allContentRoots);
    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) Module(com.intellij.openapi.module.Module)

Example 18 with FileChooserDescriptor

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

the class ExtractedDirectoryElementType method chooseAndCreate.

@NotNull
public List<? extends PackagingElement<?>> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement<?> parent) {
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, true, false, true, true) {

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            if (file.isInLocalFileSystem() && file.isDirectory())
                return false;
            return super.isFileSelectable(file);
        }
    };
    final VirtualFile[] files = FileChooser.chooseFiles(descriptor, context.getProject(), null);
    final List<PackagingElement<?>> list = new ArrayList<>();
    final PackagingElementFactory factory = PackagingElementFactory.getInstance();
    for (VirtualFile file : files) {
        list.add(factory.createExtractedDirectory(file));
    }
    return list;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ArrayList(java.util.ArrayList) PackagingElement(com.intellij.packaging.elements.PackagingElement) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement) PackagingElementFactory(com.intellij.packaging.elements.PackagingElementFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with FileChooserDescriptor

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

the class ManifestFileUtil method showDialogAndCreateManifest.

@Nullable
public static VirtualFile showDialogAndCreateManifest(final ArtifactEditorContext context, final CompositePackagingElement<?> element) {
    FileChooserDescriptor descriptor = createDescriptorForManifestDirectory();
    final VirtualFile directory = suggestManifestFileDirectory(element, context, context.getArtifactType());
    final VirtualFile file = FileChooser.chooseFile(descriptor, context.getProject(), directory);
    if (file == null) {
        return null;
    }
    return createManifestFile(file, context.getProject());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) Nullable(org.jetbrains.annotations.Nullable)

Example 20 with FileChooserDescriptor

use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project azure-tools-for-java by Microsoft.

the class SparkLibraryDescription method getSparkSDKConfigurationFromLocalFile.

private NewLibraryConfiguration getSparkSDKConfigurationFromLocalFile() {
    FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, false, true, false, true, false);
    chooserDescriptor.setTitle("Select Spark SDK");
    String pluginPath = PluginUtil.getPluginRootDirectory();
    VirtualFile pluginVfs = LocalFileSystem.getInstance().findFileByPath(pluginPath);
    VirtualFile chooseFile = FileChooser.chooseFile(chooserDescriptor, null, pluginVfs);
    if (chooseFile == null) {
        return null;
    }
    this.localPath = chooseFile.getPath();
    final List<OrderRoot> roots = RootDetectionUtil.detectRoots(Arrays.asList(chooseFile), null, null, new DefaultLibraryRootsComponentDescriptor());
    if (roots.isEmpty()) {
        return null;
    }
    return new NewLibraryConfiguration(LibraryTypeServiceImpl.suggestLibraryName(roots), SparkLibraryType.getInstance(), new SparkLibraryProperties()) {

        @Override
        public void addRoots(@NotNull LibraryEditor libraryEditor) {
            libraryEditor.addRoots(roots);
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DefaultLibraryRootsComponentDescriptor(com.intellij.openapi.roots.ui.configuration.libraryEditor.DefaultLibraryRootsComponentDescriptor) LibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) OrderRoot(com.intellij.openapi.roots.libraries.ui.OrderRoot) NotNull(org.jetbrains.annotations.NotNull) NewLibraryConfiguration(com.intellij.openapi.roots.libraries.NewLibraryConfiguration)

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