Java Code Examples for org.openide.filesystems.FileChooserBuilder#showOpenDialog()

The following examples show how to use org.openide.filesystems.FileChooserBuilder#showOpenDialog() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExistingProjectVisual.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private File browseFile(String dirKey, String title, String currentDirectory) {
    File workDir = null;
    if (currentDirectory != null && !currentDirectory.isEmpty()) {
        File currDir = new File(currentDirectory);
        if (currDir.isDirectory()) {
            workDir = currDir;
        }
    }
    FileChooserBuilder builder = new FileChooserBuilder(ExistingProjectVisual.class.getName() + dirKey)
            .setTitle(title)
            .setDirectoriesOnly(true);
    if (workDir != null) {
        builder.setDefaultWorkingDirectory(workDir)
                .forceUseOfDefaultWorkingDirectory(true);
    }
    return builder.showOpenDialog();
}
 
Example 2
Source File: RequireJsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private File browseAction(String dirKey, String title, boolean filesOnly, File workDir) {
    FileChooserBuilder builder = new FileChooserBuilder(dirKey)
            .setTitle(title);
    if (workDir != null) {
        builder.setDefaultWorkingDirectory(workDir)
                .forceUseOfDefaultWorkingDirectory(true);
    }
    if (filesOnly) {
        builder.setFilesOnly(true);
    } 
    File selectedFile = builder.showOpenDialog();
    if (selectedFile != null) {
        return FileUtil.normalizeFile(selectedFile);
    }
    return null;
}
 
Example 3
Source File: ExistingClientSideProject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private File browseFile(String dirKey, String title, String currentDirectory) {
    File workDir = null;
    if (currentDirectory != null && !currentDirectory.isEmpty()) {
        File currDir = new File(currentDirectory);
        if (currDir.isDirectory()) {
            workDir = currDir;
        }
    }
    FileChooserBuilder builder = new FileChooserBuilder(ExistingClientSideProject.class.getName() + dirKey)
            .setTitle(title)
            .setDirectoriesOnly(true);
    if (workDir != null) {
        builder.setDefaultWorkingDirectory(workDir)
                .forceUseOfDefaultWorkingDirectory(true);
    }
    return builder.showOpenDialog();
}
 
Example 4
Source File: Utils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static File browseAction(String dirKey, String title, boolean filesOnly, File workDir) {
    FileChooserBuilder builder = new FileChooserBuilder(dirKey)
            .setTitle(title);
    if (workDir != null) {
        builder.setDefaultWorkingDirectory(workDir)
                .forceUseOfDefaultWorkingDirectory(true);
    }
    if (filesOnly) {
        builder.setFilesOnly(true);
    } else {
        builder.setDirectoriesOnly(true);
    }
    File selectedFile = builder.showOpenDialog();
    if (selectedFile != null) {
        return FileUtil.normalizeFile(selectedFile);
    }
    return null;
}
 
Example 5
Source File: PHPSamplesPanelVisual.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages("PhpSamplePanelVisual.fileChooser.title=Select Project Location")
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder(PHPSamplesPanelVisual.class)
            .setTitle(Bundle.PhpSamplePanelVisual_fileChooser_title())
            .setDirectoriesOnly(true)
            .forceUseOfDefaultWorkingDirectory(true);
    String path = projectLocationTextField.getText();
    if (path.length() > 0) {
        File f = new File(path);
        if (f.exists()) {
            builder.setDefaultWorkingDirectory(f);
        }
    }
    File selectedFile = builder.showOpenDialog();
    if (selectedFile != null) {
        projectLocationTextField.setText(FileUtil.normalizeFile(selectedFile).getAbsolutePath());
    }
    panel.fireChangeEvent();

}
 
Example 6
Source File: AvdHwProfile.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private void skinButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skinButtonActionPerformed
    // TODO add your handling code here:
    FileChooserBuilder builder = new FileChooserBuilder("ANDROID_SKIN");
    builder.setDirectoriesOnly(true);
    builder.setTitle("Select skin directory...");
    File skinFolder = builder.showOpenDialog();
    if (skinFolder != null && skinFolder.exists()) {
        File layout = new File(skinFolder.getAbsolutePath() + File.separator + "layout");
        if (layout.exists()) {
            skin.setModel(new SkinsComboboxModel(new File(skinFolder.getParent())));
            skin.setSelectedItem(skinFolder);
        } else {
            NotifyDescriptor nd = new NotifyDescriptor.Message("The selected directory does not contain a skin!", NotifyDescriptor.WARNING_MESSAGE);
            DialogDisplayer.getDefault().notifyLater(nd);
        }
    }
}
 
Example 7
Source File: CreateAvdVisualPanel3.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private void skinSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skinSelectActionPerformed
    // TODO add your handling code here:
    FileChooserBuilder builder = new FileChooserBuilder("ANDROID_SKIN");
    builder.setDirectoriesOnly(true);
    builder.setTitle("Select skin directory...");
    File skinFolder = builder.showOpenDialog();
    if (skinFolder != null && skinFolder.exists()) {
        File layout = new File(skinFolder.getAbsolutePath() + File.separator + "layout");
        if (layout.exists()) {
            skinCombo.setModel(new SkinsComboboxModel(new File(skinFolder.getParent())));
            skinCombo.setSelectedItem(skinFolder);
        } else {
            NotifyDescriptor nd = new NotifyDescriptor.Message("The selected directory does not contain a skin!", NotifyDescriptor.WARNING_MESSAGE);
            DialogDisplayer.getDefault().notifyLater(nd);
        }
    }
}
 
Example 8
Source File: CreateProjectVisualPanel1.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
//        File path = new File(jTextField1.getText());
//        if (path.isDirectory()) {

        FileChooserBuilder builder = new FileChooserBuilder(this.getClass());
        builder.setDirectoriesOnly(true);
        builder.setTitle("Select Project Folder");
        File file = builder.showOpenDialog();
        if (file != null) {
            try {
                jTextField1.setText(file.getAbsolutePath() + File.separator + jTextField2.getText());
            } catch (Exception e) {
            }
        }
//        }
    }
 
Example 9
Source File: DialogProviderManager.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public File msgOpenFileDialog(final Component parentComponent, final String id, final String title, final File defaultFolder, final boolean fileOnly, final FileFilter[] fileFilters, final String approveButtonText) {
  final FileChooserBuilder builder = new FileChooserBuilder(id)
          .setTitle(title)
          .setDefaultWorkingDirectory(defaultFolder)
          .setFilesOnly(fileOnly)
          .setApproveText(approveButtonText);

  for (final FileFilter filter : fileFilters) {
    builder.addFileFilter(filter);
  }

  if (fileFilters.length != 0) {
    builder.setFileFilter(fileFilters[0]);
  }

  return builder.showOpenDialog();
}
 
Example 10
Source File: MobilePanel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder(AndroidSdkTool.class);
    builder.setTitle("Please select Android SDK Folder");
    builder.setDirectoriesOnly(true);
    File file = builder.showOpenDialog();
    if (file != null) {
        FileObject folder = FileUtil.toFileObject(file);
        if (folder.getFileObject("tools") == null) {
            Message msg = new NotifyDescriptor.Message(
                    "Not a valid SDK folder!",
                    NotifyDescriptor.ERROR_MESSAGE);
            DialogDisplayer.getDefault().notifyLater(msg);

        } else {
            String name = file.getPath();
            jTextField1.setText(name);
        }
    }
}
 
Example 11
Source File: CodelessProjectWizardVisualPanel1.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder(System.getProperty("user.home"));
    builder.setDirectoriesOnly(true);
    builder.setTitle("Select Project Folder");
    File file = builder.showOpenDialog();
    if (file != null) {
        jTextField1.setText(file.getPath());
    }
}
 
Example 12
Source File: ConnectionPanel.java    From constellation with Apache License 2.0 5 votes vote down vote up
private void findJarButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_findJarButtonActionPerformed
{//GEN-HEADEREND:event_findJarButtonActionPerformed
    final FileChooserBuilder fChooser = new FileChooserBuilder("ExportJDbc")
            .setTitle("JDBC JAR file")
            .setFileFilter(new FileFilter() {
                @Override
                public boolean accept(final File pathName) {
                    final String name = pathName.getName().toLowerCase();
                    if (pathName.isFile() && name.toLowerCase().endsWith(EXT)) {
                        return true;
                    }

                    return pathName.isDirectory();
                }

                @Override
                public String getDescription() {
                    return "JAR file";
                }
            });

    final File file = fChooser.showOpenDialog();
    if (file != null) {
        getDrivers(file.getPath());
        final String fnam = file.getAbsolutePath();
        jarText.setText(fnam);

    }
}
 
Example 13
Source File: InstallBlenderExporterPanel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder("");
    builder.setDirectoriesOnly(true);
    builder.setTitle("Select Blender Scripts Directory");
    File file = builder.showOpenDialog();
    if (file != null) {
        jTextField1.setText(file.getPath());
    }
}
 
Example 14
Source File: PublishAssetPackVisualPanel2.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder(this.getClass());
    builder.setDirectoriesOnly(true);
    builder.setTitle("Select Export Folder");
    File file = builder.showOpenDialog();
    if (file != null) {
        try {
            jTextField1.setText(file.getAbsolutePath());
        } catch (Exception e) {
        }
    }
}
 
Example 15
Source File: CodelessProjectWizardVisualPanel1.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    File path=new File(jTextField1.getText());
    if(path.isDirectory()){
        FileChooserBuilder builder = new FileChooserBuilder(path.getAbsolutePath());
        builder.setDirectoriesOnly(true);
        builder.setTitle("Select Assets Folder");
        File file = builder.showOpenDialog();
        if (file != null) {
            try {
                jTextField2.setText(file.getAbsolutePath().substring(path.getAbsolutePath().length(), file.getAbsolutePath().length()));
            } catch (Exception e) {
            }
        }
    }
}
 
Example 16
Source File: AndroidSdkTool.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns a String with the path to the SDK or null if none is specified.
 * @return 
 */
public static String getSdkPath() {
    String path = NbPreferences.forModule(AndroidSdkTool.class).get("sdk_path", null);
    if (path == null) {
        FileChooserBuilder builder = new FileChooserBuilder(AndroidSdkTool.class);
        builder.setTitle("Please select Android SDK Folder");
        builder.setDirectoriesOnly(true);
        File file = builder.showOpenDialog();
        if (file != null) {
            FileObject folder = FileUtil.toFileObject(file);
            if (folder.getFileObject("tools") == null) {
                Message msg = new NotifyDescriptor.Message(
                        "Not a valid SDK folder!",
                        NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notifyLater(msg);

            } else {
                String name = file.getPath();
                NbPreferences.forModule(AndroidSdkTool.class).put("sdk_path", name);
                return name;
            }
        }
    } else {
        return path;
    }
    return null;
}
 
Example 17
Source File: SDKVisualPanelInstall.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed
    // TODO add your handling code here:
    FileChooserBuilder chooserBuilder = new FileChooserBuilder(SDKVisualPanelInstall.class);
    chooserBuilder.setDirectoriesOnly(true);
    chooserBuilder.setTitle("Choose the folder in which to install Android SDK Tools.");
    chooserBuilder.setApproveText("OK");
    File tmp = chooserBuilder.showOpenDialog();
    if (tmp != null) {
        path.setText(tmp.getAbsolutePath());
    }
}
 
Example 18
Source File: SDKVisualPanelSelect.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed
    // TODO add your handling code here:
    FileChooserBuilder chooserBuilder = new FileChooserBuilder(SDKVisualPanelSelect.class);
    chooserBuilder.setDirectoriesOnly(true);
    chooserBuilder.setTitle("Choose the folder where is the Android SDK installed.");
    chooserBuilder.setApproveText("OK");
    File tmp = chooserBuilder.showOpenDialog();
    if (tmp != null) {
        path.setText(tmp.getAbsolutePath());
    }
}
 
Example 19
Source File: CreateAvdVisualPanel3.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void sdcardSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sdcardSelectActionPerformed
    // TODO add your handling code here:
    FileChooserBuilder builder = new FileChooserBuilder(CreateAvdVisualPanel3.class);
    builder.setFilesOnly(true);
    File sdcardImage = builder.showOpenDialog();
    if (sdcardImage != null && sdcardImage.exists()) {
        try (FileImageInputStream fi = new FileImageInputStream(sdcardImage)) {
            byte[] boot = new byte[3];
            fi.read(boot);
            if (boot[0] == ((byte) 0xeb) && boot[1] == ((byte) 0x5a) && boot[2] == ((byte) 0x90)) {
                sdcardPath.setText(sdcardImage.getAbsolutePath());
            } else {
                NotifyDescriptor nd = new NotifyDescriptor.Confirmation("<html>"
                        + "Signature of selected file does not match Android SD Card image.<br/>"
                        + "Are you sure you want to use the selected file?", "SD Card image problem...",
                        NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.WARNING_MESSAGE);
                Object notify = DialogDisplayer.getDefault().notify(nd);
                if (NotifyDescriptor.YES_OPTION.equals(notify)) {
                    sdcardPath.setText(sdcardImage.getAbsolutePath());
                }
            }

        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }

    }
}
 
Example 20
Source File: AttachCustomizer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void localSourcesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_localSourcesButtonActionPerformed
    FileChooserBuilder fchb = new FileChooserBuilder(AttachCustomizer.class);
    fchb.setDirectoriesOnly(true);
    File dir = fchb.showOpenDialog();
    if (dir != null) {
        localSourcesTextField.setText(dir.getAbsolutePath());
    }
}