Search in sources :

Example 71 with FileChooserDescriptor

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

the class OsmorcFacetJAREditorTab method onAddAdditionalJarContent.

private void onAddAdditionalJarContent() {
    Project project = myEditorContext.getProject();
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createAllButJarContentsDescriptor().withTitle(OsmorcBundle.message("facet.editor.select.source.title"));
    VirtualFile rootFolder = null;
    VirtualFile[] contentRoots = ModuleRootManager.getInstance(myEditorContext.getModule()).getContentRoots();
    if (contentRoots.length > 0) {
        rootFolder = contentRoots[0];
    } else if (project.getBaseDir() != null) {
        rootFolder = project.getBaseDir();
    }
    VirtualFile[] files = FileChooser.chooseFiles(descriptor, project, rootFolder);
    for (VirtualFile file : files) {
        String destFile = determineMostLikelyLocationInJar(file);
        int row = myAdditionalJARContentsTableModel.addAdditionalJARContent(file.getPath(), destFile);
        myAdditionalJARContentsTable.editCellAt(row, 1);
        IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
            IdeFocusManager.getGlobalInstance().requestFocus(myAdditionalJARContentsTable.getEditorComponent(), true);
        });
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 72 with FileChooserDescriptor

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

the class ConfigFileRunSettingsSection method createComponent.

@NotNull
@Override
protected JComponent createComponent(@NotNull CreationContext creationContext) {
    JPanel panel = new JPanel(new GridBagLayout());
    {
        GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(UIUtil.DEFAULT_VGAP, 0, 0, UIUtil.DEFAULT_HGAP), 0, 0);
        myLabel.setDisplayedMnemonic('C');
        myLabel.setHorizontalAlignment(SwingConstants.RIGHT);
        myLabel.setLabelFor(myConfigFileTextFieldWithBrowseButton.getTextField());
        panel.add(myLabel, c);
    }
    {
        GridBagConstraints c = new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(UIUtil.DEFAULT_VGAP, 0, 0, 0), 0, 0);
        final Project project = creationContext.getProject();
        final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) {

            @Override
            public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
                boolean visible = super.isFileVisible(file, showHiddenFiles);
                if (visible && !file.isDirectory() && !showHiddenFiles) {
                    visible = JstdConfigFileUtils.isJstdConfigFile(file);
                }
                return visible;
            }
        };
        final JTextField configFileTextField = myConfigFileTextFieldWithBrowseButton.getTextField();
        FileChooserFactory.getInstance().installFileCompletion(configFileTextField, descriptor, false, null);
        myConfigFileTextFieldWithBrowseButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                PsiFile initialPsiFile = getConfigFile(project);
                TreeFileChooserDialog fileChooser = new TreeFileChooserDialog(project, "Select JsTestDriver configuration file", initialPsiFile, JstdConfigFileType.INSTANCE, new TreeFileChooser.PsiFileFilter() {

                    @Override
                    public boolean accept(PsiFile psiFile) {
                        return true;
                    }
                }, false, false);
                boolean jstdConfigFilesExists = JstdSettingsUtil.areJstdConfigFilesInProject(project);
                if (jstdConfigFilesExists) {
                    fileChooser.selectSearchByNameTab();
                }
                fileChooser.showDialog();
                PsiFile psiFile = fileChooser.getSelectedFile();
                if (psiFile != null) {
                    VirtualFile vFile = psiFile.getVirtualFile();
                    if (vFile != null) {
                        String path = FileUtil.toSystemDependentName(vFile.getPath());
                        configFileTextField.setText(path);
                    }
                }
            }
        });
        panel.add(myConfigFileTextFieldWithBrowseButton, c);
    }
    SwingUtils.addGreedyBottomRow(panel);
    return panel;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ActionEvent(java.awt.event.ActionEvent) Project(com.intellij.openapi.project.Project) TreeFileChooser(com.intellij.ide.util.TreeFileChooser) ActionListener(java.awt.event.ActionListener) PsiFile(com.intellij.psi.PsiFile) TreeFileChooserDialog(com.intellij.ide.util.TreeFileChooserDialog) NotNull(org.jetbrains.annotations.NotNull)

Example 73 with FileChooserDescriptor

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

the class JsFileRunSettingsSection method createComponent.

@NotNull
@Override
public JComponent createComponent(@NotNull CreationContext creationContext) {
    JPanel panel = new JPanel(new GridBagLayout());
    {
        GridBagConstraints c = new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
        JComponent configComponent = myConfigFileRunSettingsSection.getComponent(creationContext);
        panel.add(configComponent, c);
    }
    {
        myLabel.setHorizontalAlignment(SwingConstants.RIGHT);
        myLabel.setDisplayedMnemonic('J');
        myLabel.setLabelFor(myJsTestFileTextFieldWithBrowseButton.getTextField());
        GridBagConstraints c = new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(UIUtil.DEFAULT_VGAP, 0, 0, UIUtil.DEFAULT_HGAP), 0, 0);
        panel.add(myLabel, c);
    }
    {
        GridBagConstraints c = new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(UIUtil.DEFAULT_VGAP, 0, 0, 0), 0, 0);
        FileChooserDescriptor jsFileChooserDescriptor = new FileTypeDescriptor("Select JavaScript test file", ".js");
        myJsTestFileTextFieldWithBrowseButton.addBrowseFolderListener(null, null, creationContext.getProject(), jsFileChooserDescriptor);
        panel.add(myJsTestFileTextFieldWithBrowseButton, c);
        myLabel.setLabelFor(myJsTestFileTextFieldWithBrowseButton);
    }
    SwingUtils.addGreedyBottomRow(panel);
    return panel;
}
Also used : FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) FileTypeDescriptor(com.intellij.openapi.fileChooser.FileTypeDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Example 74 with FileChooserDescriptor

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

the class FlexLauncherDialog method initControls.

private void initControls(final LauncherParameters launcherParameters) {
    final LauncherParameters.LauncherType launcherType = launcherParameters.getLauncherType();
    myDefaultOSApplicationRadioButton.setSelected(launcherType == LauncherParameters.LauncherType.OSDefault);
    myBrowserRadioButton.setSelected(launcherType == LauncherParameters.LauncherType.Browser);
    myPlayerRadioButton.setSelected(launcherType == LauncherParameters.LauncherType.Player);
    myBrowserSelector.setSelected(launcherParameters.getBrowser());
    myPlayerTextWithBrowse.setText(FileUtil.toSystemDependentName(launcherParameters.getPlayerPath()));
    myPlayerTextWithBrowse.addBrowseFolderListener(null, null, myProject, new FileChooserDescriptor(true, true, false, false, false, false) {

        @Override
        public boolean isFileSelectable(final VirtualFile file) {
            return SystemInfo.isMac && file.isDirectory() && "app".equalsIgnoreCase(file.getExtension()) || !file.isDirectory();
        }
    });
    myNewPlayerInstanceCheckBox.setVisible(SystemInfo.isMac);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 75 with FileChooserDescriptor

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

the class ApkEditor method selectApkAndCompare.

@Override
public void selectApkAndCompare() {
    FileChooserDescriptor desc = new FileChooserDescriptor(true, false, false, false, false, false);
    desc.withFileFilter(file -> ApkFileSystem.EXTENSIONS.contains(file.getExtension()));
    VirtualFile file = FileChooser.chooseFile(desc, myProject, null);
    if (file == null) {
        // user canceled
        return;
    }
    VirtualFile newApk = ApkFileSystem.getInstance().getRootByLocal(file);
    assert newApk != null;
    DialogBuilder builder = new DialogBuilder(myProject);
    builder.setTitle(myRoot.getName() + " vs " + newApk.getName());
    ApkDiffParser parser = new ApkDiffParser(myRoot, newApk);
    ApkDiffPanel panel = new ApkDiffPanel(parser);
    builder.setCenterPanel(panel.getContainer());
    builder.setPreferredFocusComponent(panel.getPreferredFocusedComponent());
    builder.show();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ApkDiffPanel(com.android.tools.idea.apk.viewer.diff.ApkDiffPanel) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ApkDiffParser(com.android.tools.idea.apk.viewer.diff.ApkDiffParser) DialogBuilder(com.intellij.openapi.ui.DialogBuilder)

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