Search in sources :

Example 76 with FileChooserDescriptor

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

the class AnalyzeApkAction method promptUserForApk.

@Nullable
private static VirtualFile promptUserForApk(Project project) {
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor().withDescription("Select APK to analyze").withFileFilter(file -> ApkFileSystem.EXTENSIONS.contains(file.getExtension()));
    VirtualFile apk = FileChooser.chooseFile(descriptor, project, getLastSelectedApk(project));
    if (apk != null) {
        saveLastSelectedApk(project, apk);
    }
    return apk;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) Nullable(org.jetbrains.annotations.Nullable)

Example 77 with FileChooserDescriptor

use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-leiningen-plugin by derkork.

the class LeiningenSettings method createComponent.

public JComponent createComponent() {
    JPanel outerPanel = new JPanel(new BorderLayout());
    JPanel leinPanel = new JPanel(new FormLayout("80dlu, fill:80dlu:grow, 20dlu, 80dlu", "p,p,p"));
    CellConstraints c = new CellConstraints();
    int row = 1;
    leinPanel.add(new JBLabel("Leiningen executable:"), c.xy(1, row));
    this.leinBinSelectorField = new TextFieldWithBrowseButton();
    leinBinSelectorField.addBrowseFolderListener("Select the Leiningen executable", "'lein' on Linux/MacOS, 'lein.bat' on Windows. ", null, new FileChooserDescriptor(true, false, false, false, false, false));
    leinPanel.add(leinBinSelectorField, c.xy(2, row));
    row++;
    leinPanel.add(new JBLabel("Leiningen Home:"), c.xy(1, row));
    this.leinHomeSelectorField = new TextFieldWithBrowseButton();
    leinHomeSelectorField.addBrowseFolderListener("Select the Leiningen home directory", "usually at $USER_HOME/.lein", null, new FileChooserDescriptor(false, true, false, false, false, false));
    leinPanel.add(leinHomeSelectorField, c.xy(2, row));
    this.overrideLeinHome = new JBCheckBox();
    leinPanel.add(overrideLeinHome, c.xy(3, row));
    leinPanel.add(new JBLabel("Override"), c.xy(4, row));
    row++;
    leinPanel.add(new JBLabel("Leiningen Jar:"), c.xy(1, row));
    this.leinJarSelectorField = new TextFieldWithBrowseButton();
    leinJarSelectorField.addBrowseFolderListener("Select the Leiningen Jar", "usually at $USER_HOME/.lein/self-installs/leinigen-VERSION-standalone.jar", null, new FileChooserDescriptor(true, false, true, true, false, false));
    leinPanel.add(leinJarSelectorField, c.xy(2, row));
    this.overrideLeinJar = new JBCheckBox();
    leinPanel.add(overrideLeinJar, c.xy(3, row));
    leinPanel.add(new JBLabel("Override"), c.xy(4, row));
    outerPanel.add(leinPanel, BorderLayout.NORTH);
    myWatcher = new UserActivityWatcher();
    myWatcher.register(outerPanel);
    myWatcher.addUserActivityListener(new UserActivityListener() {

        public void stateChanged() {
            changed = true;
            leinJarSelectorField.setEnabled(overrideLeinJar.isSelected());
            leinHomeSelectorField.setEnabled(overrideLeinHome.isSelected());
        }
    });
    return outerPanel;
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) JBLabel(com.intellij.ui.components.JBLabel) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) UserActivityWatcher(com.intellij.ui.UserActivityWatcher) UserActivityListener(com.intellij.ui.UserActivityListener) CellConstraints(com.jgoodies.forms.layout.CellConstraints) JBCheckBox(com.intellij.ui.components.JBCheckBox)

Example 78 with FileChooserDescriptor

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

the class ElementWithManifestPropertiesPanel method chooseManifest.

private void chooseManifest() {
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) {

        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || file.getName().equalsIgnoreCase(ManifestFileUtil.MANIFEST_FILE_NAME));
        }
    };
    descriptor.setTitle("Specify Path to MANIFEST.MF File");
    final VirtualFile file = FileChooser.chooseFile(descriptor, myContext.getProject(), null);
    if (file == null)
        return;
    ManifestFileUtil.addManifestFileToLayout(file.getPath(), myContext, myElement);
    updateManifest();
    myContext.getThisArtifactEditor().updateLayoutTree();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 79 with FileChooserDescriptor

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

the class ConfigureAvdOptionsStep method bindComponents.

private void bindComponents() {
    myBindings.bindTwoWay(new TextProperty(myAvdDisplayName), getModel().avdDisplayName());
    myBindings.bind(new TextProperty(myAvdId), new StringExpression(getModel().avdDisplayName()) {

        @NotNull
        @Override
        public String get() {
            String displayName = getModel().avdDisplayName().get();
            getModel().avdId().set(StringUtil.isNotEmpty(displayName) ? AvdWizardUtils.cleanAvdName(connection, displayName, !displayName.equals(myOriginalName)) : "");
            return getModel().avdId().get();
        }
    });
    myBindings.bindTwoWay(new TextProperty(mySystemImageName), getModel().systemImageName());
    myBindings.bindTwoWay(new TextProperty(mySystemImageDetails), getModel().systemImageDetails());
    myBindings.bindTwoWay(new SelectedProperty(myQemu2CheckBox), getModel().useQemu2());
    myBindings.bindTwoWay(new SelectedItemProperty<Integer>(myCoreCount), getModel().cpuCoreCount());
    myBindings.bindTwoWay(myRamStorage.storage(), getModel().getAvdDeviceData().ramStorage());
    myBindings.bindTwoWay(myVmHeapStorage.storage(), getModel().vmHeapStorage());
    myBindings.bindTwoWay(myInternalStorage.storage(), getModel().internalStorage());
    myBindings.bindTwoWay(myBuiltInSdCardStorage.storage(), new OptionalToValuePropertyAdapter<Storage>(getModel().sdCardStorage()));
    myBindings.bindTwoWay(new SelectedItemProperty<GpuMode>(myHostGraphics), getModel().hostGpuMode());
    myBindings.bindTwoWay(new SelectedProperty(myDeviceFrameCheckbox), getModel().hasDeviceFrame());
    myBindings.bindTwoWay(new SelectedItemProperty<File>(mySkinComboBox.getComboBox()), getModel().getAvdDeviceData().customSkinFile());
    myOrientationToggle.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            ScreenOrientation orientation = myOrientationToggle.getSelectedElement();
            if (orientation == null) {
                getModel().selectedAvdOrientation().set(ScreenOrientation.PORTRAIT);
            } else {
                getModel().selectedAvdOrientation().set(orientation);
            }
        }
    });
    FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {

        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, true);
        }
    };
    fileChooserDescriptor.setHideIgnored(false);
    myExternalSdCard.addBrowseFolderListener("Select SD Card", "Select an existing SD card image", myProject, fileChooserDescriptor);
    myBindings.bindTwoWay(new TextProperty(myExternalSdCard.getTextField()), getModel().externalSdCardLocation());
    myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdCamera>(new SelectedItemProperty<AvdCamera>(myFrontCameraCombo)), getModel().selectedFrontCamera());
    myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdCamera>(new SelectedItemProperty<AvdCamera>(myBackCameraCombo)), getModel().selectedBackCamera());
    myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdNetworkSpeed>(new SelectedItemProperty<AvdNetworkSpeed>(mySpeedCombo)), getModel().selectedNetworkSpeed());
    myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdNetworkLatency>(new SelectedItemProperty<AvdNetworkLatency>(myLatencyCombo)), getModel().selectedNetworkLatency());
    myBindings.bindTwoWay(new SelectedProperty(myEnableComputerKeyboard), getModel().enableHardwareKeyboard());
    myBindings.bindTwoWay(new SelectedProperty(myExternalRadioButton), getModel().useExternalSdCard());
    myBindings.bindTwoWay(new SelectedProperty(myBuiltInRadioButton), getModel().useBuiltInSdCard());
    myCheckSdForChanges = true;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GpuMode(com.android.sdklib.internal.avd.GpuMode) ListSelectionEvent(javax.swing.event.ListSelectionEvent) NotNull(org.jetbrains.annotations.NotNull) TextProperty(com.android.tools.idea.ui.properties.swing.TextProperty) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ListSelectionListener(javax.swing.event.ListSelectionListener) ScreenOrientation(com.android.resources.ScreenOrientation) SelectedItemProperty(com.android.tools.idea.ui.properties.swing.SelectedItemProperty) StringExpression(com.android.tools.idea.ui.properties.expressions.string.StringExpression) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) SelectedProperty(com.android.tools.idea.ui.properties.swing.SelectedProperty)

Example 80 with FileChooserDescriptor

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

the class ModuleDependenciesPanel method addFileDependency.

private void addFileDependency() {
    FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, true, false, false);
    VirtualFile buildFile = myGradleBuildFile.getFile();
    VirtualFile parent = buildFile.getParent();
    descriptor.setRoots(parent);
    VirtualFile virtualFile = FileChooser.chooseFile(descriptor, myProject, null);
    if (virtualFile != null) {
        String path = VfsUtilCore.getRelativePath(virtualFile, parent, '/');
        if (path == null) {
            path = virtualFile.getPath();
        }
        myModel.addItem(new ModuleDependenciesTableItem(new Dependency(Dependency.Scope.COMPILE, Dependency.Type.FILES, path)));
    }
    myModel.fireTableDataChanged();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

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