public FileChooserBuilder setDefaultWorkingDirectory(FileObject fileobject){ return super.setDefaultWorkingDirectory(org.openide.filesystems.FileUtil.toFile(fileobject)); } }
private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed // TODO add your handling code here: String dlgTitle = NbBundle.getMessage(DefaultProjectCopyPanel.class, "TITLE_BrowseProjectLocation"); String okText = NbBundle.getMessage(DefaultProjectCopyPanel.class, "LBL_BrowseProjectLocation_OK_Button"); File dir = new FileChooserBuilder(DefaultProjectCopyPanel.class).setDefaultWorkingDirectory( new File(projectLocation.getText())).setDirectoriesOnly( true).setTitle(dlgTitle).setApproveText(okText).showOpenDialog(); if (dir != null) { projectLocation.setText(dir.getAbsolutePath()); } }//GEN-LAST:event_browseActionPerformed
private void chooseDocButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseDocButtonActionPerformed File file = new FileChooserBuilder(SupportPanel.class) .setDirectoriesOnly(true) .setDefaultWorkingDirectory(null) .setTitle(NbBundle.getMessage(SupportPanel.class, "LBL_Select_Directory")) .setApproveText(NbBundle.getMessage(SupportPanel.class, "LBL_Select_Directory")) .showOpenDialog(); if (file != null) { if (!new File(new File(file, "groovy-jdk"), "index.html").isFile()) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(SupportPanel.class, "LBL_Not_groovy_doc"), NotifyDescriptor.Message.WARNING_MESSAGE)); return; } groovyDocTextField.setText(file.getAbsolutePath()); } }//GEN-LAST:event_chooseDocButtonActionPerformed
private void chooseDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseDirActionPerformed File file = new FileChooserBuilder(GrailsRuntimePanel.class) .setDirectoriesOnly(true) .setDefaultWorkingDirectory(new File(System.getProperty("user.home"))) .setApproveText(NbBundle.getMessage(GrailsRuntimePanel.class, "LBL_Select_Directory")) .setTitle(NbBundle.getMessage(GrailsRuntimePanel.class, "LBL_Select_Directory")) .showOpenDialog(); if (file != null && RuntimeHelper.isValidRuntime(file)) { grailsHomeLocation.setText(file.getAbsolutePath()); } else if (file != null) { displayGrailsHomeWarning(); } }//GEN-LAST:event_chooseDirActionPerformed
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(NewClientSideProject.class.getName() + dirKey) .setTitle(title) .setDirectoriesOnly(true); if (workDir != null) { builder.setDefaultWorkingDirectory(workDir) .forceUseOfDefaultWorkingDirectory(true); } return builder.showOpenDialog(); }
private String browseFolder(final String title) { File defPath = platform.getHomePath() == null ? null : new File(platform.getHomePath()); File f; if ((f = new FileChooserBuilder (getClass().getName() + ".fld"). setFileFilter(new FolderFilter()).setTitle(title). setDefaultWorkingDirectory(defPath).showOpenDialog()) != null) { return f.getAbsolutePath(); } return null; }
public void setSelectedItem(Object item) { String oldSelectedItem = selectedItem; selectedItem = (String) item; if (names.indexOf(item) != -1) { if (types.get(names.indexOf(selectedItem)).equals( SuiteInstallerProjectProperties.LICENSE_TYPE_CUSTOM)) { File home = FileUtil.toFile(suiteProject.getProjectDirectory()); File licenseFile = new FileChooserBuilder("installer-license-dir").setTitle(NbBundle.getMessage(LicenseComboBoxModel.class, "InstallerPanel_License.FileChooser.Title")). setDefaultWorkingDirectory(home).setFilesOnly(true).showOpenDialog(); if (licenseFile != null) { names.add(licenseFile.getAbsolutePath()); types.add(SuiteInstallerProjectProperties.LICENSE_TYPE_FILE); selectedItem = names.get(names.size() - 1); } else { selectedItem = oldSelectedItem; } } selectedItemFromList = true; } else { selectedItemFromList = false; } fireContentsChanged(-1); }
fcb.setDefaultWorkingDirectory(userHome); fcb.addFileFilter(ff); fcb.setApproveText(NbBundle.getMessage(this.getClass(), "chooser.shape.approve.text"));
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed File selectedFile = new FileChooserBuilder(RunFilePanel.class) .setTitle(NbBundle.getMessage(RunFilePanel.class, "LBL_SelectWorkingDirectory")) .setDirectoriesOnly(true) .forceUseOfDefaultWorkingDirectory(true) .setDefaultWorkingDirectory(new File(createRunConfig().getWorkDir())) .showOpenDialog(); if (selectedFile != null) { File workDir = FileUtil.normalizeFile(selectedFile); workDirField.setText(workDir.getAbsolutePath()); } }//GEN-LAST:event_browseButtonActionPerformed
/** * Shows the actual filepicker and return the selected file or dir * @return The selected file */ private File showPicker() { String name = AreaFieldPreference.LAST_SHAPE_DIR.getValue(); File userHome = (name.equals("")) ? new File(System.getProperty(USER_HOME)) : new File(name); List<String> supportedExtensions = new ArrayList<String>(); supportedExtensions.add(".shp"); FileFilter ff = FilePickerUtil.createSwingFileFilter(supportedExtensions, "Shape file (*.shp)"); FileChooserBuilder fcb = new FileChooserBuilder(FILECHOOSER_DIR); fcb.setTitle(FILECHOOSER_TITLE); fcb.setDefaultWorkingDirectory(userHome); fcb.addFileFilter(ff); fcb.setApproveText(FILECHOOSER_APPROVE_TEXT); File file = fcb.showOpenDialog(); // file will be null if cancel is pressed if (file != null) { // save the file path for next time window is opened AreaFieldPreference.LAST_SHAPE_DIR.saveValue(file.getPath()); } return file; }
@NbBundle.Messages("ClientSideProject.dialog.location.title=Select Project Location") private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed File workDir = null; String projectLocation = getProjectLocation(); if (projectLocation != null && !projectLocation.isEmpty()) { File projDir = new File(projectLocation); if (projDir.isDirectory()) { workDir = projDir; } } if (workDir == null) { workDir = ProjectChooser.getProjectsFolder(); } File projectDir = new FileChooserBuilder(NewClientSideProject.class) .setTitle(Bundle.ClientSideProject_dialog_location_title()) .setDirectoriesOnly(true) .setDefaultWorkingDirectory(workDir) .forceUseOfDefaultWorkingDirectory(true) .showOpenDialog(); if (projectDir != null) { projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath()); } }//GEN-LAST:event_browseButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed if (searchTask != null && !searchTask.isFinished()) return; String aDescription = NbBundle.getMessage(FindPanel.class, "AD_LocationChooser"); //NOI18N String title = NbBundle.getMessage(FindPanel.class, "Title_FindPanel_Choose_To_Search"); //NOI18N Badger badger = new Badger(); File dir; if ((dir = new FileChooserBuilder(getClass().getName()).setDirectoriesOnly(true). setTitle(title). setAccessibleDescription(aDescription). setBadgeProvider(badger). setDefaultWorkingDirectory(File.listRoots().length > 0 ? File.listRoots()[0] : null). setFileFilter(badger).showOpenDialog()) != null) { searchRunnable = new SearchRunnable(this, dir, -1); jButton1.setEnabled(false); showError(NbBundle.getMessage(FindPanel.class, "WARN_SearchInProgress"));//NOI18N searchTask = RequestProcessor.getDefault().post(searchRunnable); } }//GEN-LAST:event_jButton1ActionPerformed
public static File browseTestSources(JTextField textField, PhpProject phpProject) { File selectedFile = new FileChooserBuilder(LastUsedFolders.TEST_DIR) .setTitle(NbBundle.getMessage(Utils.class, "LBL_SelectUnitTestFolder", ProjectUtils.getInformation(phpProject).getDisplayName())) .setDirectoriesOnly(true) .setDefaultWorkingDirectory(FileUtil.toFile(phpProject.getProjectDirectory())) .forceUseOfDefaultWorkingDirectory(true) .showOpenDialog(); if (selectedFile != null) { selectedFile = FileUtil.normalizeFile(selectedFile); if (textField != null) { textField.setText(selectedFile.getAbsolutePath()); } } return selectedFile; }
"LoadProjectAction"); fileChooserBuilder.setTitle("Load project"); fileChooserBuilder.setDefaultWorkingDirectory(initialDirectory); fileChooserBuilder.setApproveText("Load"); fileChooserBuilder.setDirectoriesOnly(true);
private void workDirBrowseButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_workDirBrowseButtonActionPerformed File curDir; String workDir = createRunConfig().getWorkDir(); if (StringUtils.hasText(workDir)) { curDir = new File(workDir); } else { curDir = FileUtil.toFile(ProjectPropertiesSupport.getSourcesDirectory(project)); } File selectedFile = new FileChooserBuilder(RunAsScript.class) .forceUseOfDefaultWorkingDirectory(true) .setTitle(NbBundle.getMessage(RunAsScript.class, "LBL_SelectWorkingDirectory")) .setDirectoriesOnly(true) .setDefaultWorkingDirectory(curDir) .showOpenDialog(); if (selectedFile != null) { workDirTextField.setText(FileUtil.normalizeFile(selectedFile).getAbsolutePath()); } }//GEN-LAST:event_workDirBrowseButtonActionPerformed
/** * Get the save location for the file. * pops up a save dialog * @return a file from the save dialog */ public File getSaveLocation() { if (fcb == null) { fcb = new FileChooserBuilder("Export-directory"); fcb.setTitle(FILECHOOSER_TITLE); fcb.setApproveText(FILECHOOSER_OK); fcb.addFileFilter(new FileFilter() { @Override public boolean accept(File pathname) { if (pathname.isDirectory() && pathname.getName().startsWith(".")) { return false; } return true; } @Override public String getDescription() { return FILECHOOSER_FILE_DESC; } }); } File workingDirectory = new File(SensorPreference.LAST_EXPORT_DIR.getValue()); fcb.setDefaultWorkingDirectory(workingDirectory); return fcb.showSaveDialog(); }
private String browseFolder(String title, File currentPath) { File workDir = null; if (currentPath != null) { workDir = currentPath.getParentFile(); } if (workDir == null || !workDir.exists()) { workDir = FileUtil.toFile(project.getProjectDirectory()); } File folder = new FileChooserBuilder(SourcesPanel.class) .setTitle(title) .setDirectoriesOnly(true) .setDefaultWorkingDirectory(workDir) .forceUseOfDefaultWorkingDirectory(true) .setFileHiding(true) .showOpenDialog(); if (folder == null) { return null; } String filePath = PropertyUtils.relativizeFile(FileUtil.toFile(project.getProjectDirectory()), folder); if (filePath == null) { // path cannot be relativized filePath = folder.getAbsolutePath(); } else if (".".equals(filePath)) { // NOI18N // project directory return null; } return beautifyPath(filePath); }
private void addFolders() { FileChooserBuilder builder = new FileChooserBuilder(directoryHandler.getDirKey()) .setDirectoriesOnly(true) .setTitle(NbBundle.getMessage(PathUiSupport.class, "LBL_AddFolders_DialogTitle")); File currentDirectory = directoryHandler.getCurrentDirectory(); if (currentDirectory != null) { builder.forceUseOfDefaultWorkingDirectory(true) .setDefaultWorkingDirectory(currentDirectory); } File[] selectedFiles = builder.showMultiOpenDialog(); if (selectedFiles != null && selectedFiles.length > 0) { String[] paths = new String[selectedFiles.length]; for (int i = 0; i < selectedFiles.length; i++) { paths[i] = selectedFiles[i].getAbsolutePath(); } int[] newSelection = PathUiSupport.addFolders(listModel, list.getSelectedIndices(), paths); list.setSelectedIndices(newSelection); } }
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; }
@NbBundle.Messages("DirectoryProblemResolver.dialog.choose=Choose") @Override public Future<ProjectProblemsProvider.Result> resolve() { File projectDir = FileUtil.toFile(project.getProjectDirectory()); File selectedDir = new FileChooserBuilder(ProjectPropertiesProblemProvider.class) .setTitle(dialogTitle) .setDefaultWorkingDirectory(projectDir) .forceUseOfDefaultWorkingDirectory(true) .setDirectoriesOnly(true) .setFileHiding(true) .setApproveText(Bundle.DirectoryProblemResolver_dialog_choose()) .showOpenDialog(); if (selectedDir == null) { // no file selected return new Done(ProjectProblemsProvider.Result.create(ProjectProblemsProvider.Status.UNRESOLVED)); } // save metadata String relPath = ProjectPropertiesSupport.relativizeFile(projectDir, selectedDir); PhpProjectProperties.save(project, Collections.singletonMap(propertyName, relPath), Collections.<String, String>emptyMap()); // return unresolved state; it will change automatically once the metadata are really saved (property change will be fired) return new Done(ProjectProblemsProvider.Result.create(ProjectProblemsProvider.Status.UNRESOLVED)); }