Java Code Examples for javafx.stage.DirectoryChooser#showDialog()

The following examples show how to use javafx.stage.DirectoryChooser#showDialog() . 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: FilesController.java    From AudioBookConverter with GNU General Public License v2.0 6 votes vote down vote up
public void selectFolderDialog() {
    Window window = ConverterApplication.getEnv().getWindow();
    DirectoryChooser directoryChooser = new DirectoryChooser();
    String sourceFolder = AppProperties.getProperty("source.folder");
    directoryChooser.setInitialDirectory(Utils.getInitialDirecotory(sourceFolder));

    StringJoiner filetypes = new StringJoiner("/");

    Arrays.stream(FILE_EXTENSIONS).map(String::toUpperCase).forEach(filetypes::add);

    directoryChooser.setTitle("Select folder with " + filetypes.toString() + " files for conversion");
    File selectedDirectory = directoryChooser.showDialog(window);
    if (selectedDirectory != null) {
        processFiles(Collections.singleton(selectedDirectory));
        AppProperties.setProperty("source.folder", selectedDirectory.getAbsolutePath());
        if (!chaptersMode.get()) {
            filesChapters.getTabs().add(filesTab);
            filesChapters.getSelectionModel().select(filesTab);
        }
    }
}
 
Example 2
Source File: Components.java    From proxyee-down with Apache License 2.0 6 votes vote down vote up
/**
 * 弹出文件夹选择框
 */
public static File dirChooser() {
  Stage stage = buildBackgroundTopStage();
  DirectoryChooser chooser = new DirectoryChooser();
  chooser.setTitle("选择文件夹");
  File file = chooser.showDialog(stage);
  stage.close();
  return file;
}
 
Example 3
Source File: OptionStage.java    From dm3270 with Apache License 2.0 6 votes vote down vote up
private void editLocation ()
{
  DirectoryChooser chooser = new DirectoryChooser ();
  chooser.setTitle ("Choose Spy Folder");
  File currentLocation = spyFolder.isEmpty () ? null : new File (spyFolder);
  if (currentLocation != null && currentLocation.exists ())
    chooser.setInitialDirectory (currentLocation);

  File selectedDirectory = chooser.showDialog (this);
  if (selectedDirectory != null)
  {
    spyFolder = selectedDirectory.getAbsolutePath ();
    fileComboBox.getItems ().clear ();
    ObservableList<String> files = getSessionFiles (spyFolder);
    fileComboBox.setItems (files);
    if (files.size () > 0)
      fileComboBox.getSelectionModel ().select (0);
  }
}
 
Example 4
Source File: SettingsController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
protected void setOCRPath(ActionEvent event) {
    try {
        DirectoryChooser chooser = new DirectoryChooser();
        String dataPath = AppVariables.getUserConfigValue("TessDataPath", null);
        if (dataPath != null) {
            chooser.setInitialDirectory(new File(dataPath));
        }
        File directory = chooser.showDialog(getMyStage());
        if (directory == null) {
            return;
        }
        recordFileWritten(directory);
        ocrDirInput.setText(directory.getPath());
    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
Example 5
Source File: ResourceConfigurationView.java    From beatoraja with GNU General Public License v3.0 6 votes vote down vote up
@FXML
public void addSongPath() {
	DirectoryChooser chooser = new DirectoryChooser();
	chooser.setTitle("楽曲のルートフォルダを選択してください");
	File f = chooser.showDialog(null);
	if (f != null) {
		final String defaultPath = new File(".").getAbsoluteFile().getParent() + File.separatorChar;;
		String targetPath = f.getAbsolutePath();
		if(targetPath.startsWith(defaultPath)) {
			targetPath = f.getAbsolutePath().substring(defaultPath.length());
		}
		boolean unique = true;
		for (String path : bmsroot.getItems()) {
			if (path.equals(targetPath) || targetPath.startsWith(path + File.separatorChar)) {
				unique = false;
				break;
			}
		}
		if (unique) {
			bmsroot.getItems().add(targetPath);
			main.loadBMSPath(targetPath);
		}
	}
}
 
Example 6
Source File: BatchTableController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public void addDirectory(int index) {
    try {
        DirectoryChooser dirChooser = new DirectoryChooser();
        File defaultPath = AppVariables.getUserConfigPath(sourcePathKey);
        if (defaultPath != null) {
            dirChooser.setInitialDirectory(defaultPath);
        }
        File directory = dirChooser.showDialog(getMyStage());
        if (directory == null) {
            return;
        }
        addDirectory(index, directory);
    } catch (Exception e) {
        logger.error(e.toString());
    }

}
 
Example 7
Source File: BaseController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
public void selectSourcePath() {
    try {
        DirectoryChooser chooser = new DirectoryChooser();
        File path = AppVariables.getUserConfigPath(sourcePathKey);
        if (path != null) {
            chooser.setInitialDirectory(path);
        }
        File directory = chooser.showDialog(getMyStage());
        if (directory == null) {
            return;
        }
        selectSourcePath(directory);
    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
Example 8
Source File: BaseController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
public void selectTargetPath() {
    if (targetPathInput == null) {
        return;
    }
    try {
        DirectoryChooser chooser = new DirectoryChooser();
        File path = AppVariables.getUserConfigPath(targetPathKey);
        if (path != null) {
            chooser.setInitialDirectory(path);
        }
        File directory = chooser.showDialog(getMyStage());
        if (directory == null) {
            return;
        }
        selectTargetPath(directory);
    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
Example 9
Source File: dashController.java    From gramophy with GNU General Public License v3.0 6 votes vote down vote up
@FXML
public void selectMusicLibraryFolderButtonClicked(ActionEvent event)
{
    Node e = (Node) event.getSource();
    Window ps = e.getScene().getWindow();
    DirectoryChooser directoryChooser = new DirectoryChooser();
    File newMusicFolder = directoryChooser.showDialog(ps);
    File presentFolder = new File(config.get("music_lib_path"));

    if(newMusicFolder == null) return;

    if(!newMusicFolder.getAbsolutePath().equals(presentFolder.getAbsolutePath()))
    {
        selectMusicLibraryField.setText(newMusicFolder.getAbsolutePath());
    }
}
 
Example 10
Source File: BatchImageProcessorController.java    From FakeImageDetection with GNU General Public License v3.0 5 votes vote down vote up
@FXML
private void loadDestinationFolder(ActionEvent event) {
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle("Choose Source Folder");
    destDir = chooser.showDialog(rootPane.getScene().getWindow());
    if (destDir == null) {
        Calert.showAlert("Error", "Not a valid folder", Alert.AlertType.ERROR);
        return;
    }
    destIndicator.setSelected(true);
}
 
Example 11
Source File: BatchImageTesterController.java    From FakeImageDetection with GNU General Public License v3.0 5 votes vote down vote up
@FXML
private void chooseRealImageSource(ActionEvent event) {
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle("Choose Real Image Folder");
    realDir = chooser.showDialog(rootPane.getScene().getWindow());
    if (realDir == null) {
        Calert.showAlert("Error", "Not a valid directory", Alert.AlertType.ERROR);
        return;
    }

    System.out.println("Loading Real Images from " + realDir.getAbsolutePath());
    realIndicator.setSelected(true);
}
 
Example 12
Source File: SettingsController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
protected void selectDataPath(ActionEvent event) {
    try {
        DirectoryChooser chooser = new DirectoryChooser();
        chooser.setInitialDirectory(new File(AppVariables.MyboxDataPath));
        File directory = chooser.showDialog(getMyStage());
        if (directory == null) {
            return;
        }
        recordFileWritten(directory);
        dataDirInput.setText(directory.getPath());
    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
Example 13
Source File: SettingsController.java    From Library-Assistant with Apache License 2.0 5 votes vote down vote up
@FXML
private void handleDatabaseExportAction(ActionEvent event) {
    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("Select Location to Create Backup");
    File selectedDirectory = directoryChooser.showDialog(getStage());
    if (selectedDirectory == null) {
        AlertMaker.showErrorMessage("Export cancelled", "No Valid Directory Found");
    } else {
        DatabaseExporter databaseExporter = new DatabaseExporter(selectedDirectory);
        progressSpinner.visibleProperty().bind(databaseExporter.runningProperty());
        new Thread(databaseExporter).start();
    }
}
 
Example 14
Source File: OptionsDialog.java    From zest-writer with GNU General Public License v3.0 5 votes vote down vote up
@FXML private void handleGeneralBrowseAction(){
    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle(Configuration.getBundle().getString("ui.options.workspace"));
    directoryChooser.setInitialDirectory(MainApp.getDefaultHome());

    File directory = directoryChooser.showDialog(null);

    if(directory != null && directory.exists()){
        workspacepath.setText(directory.getAbsolutePath());
    }
}
 
Example 15
Source File: CodeGeneratorApp.java    From Entitas-Java with MIT License 5 votes vote down vote up
@FXML
public void handleComponentsFolder(ActionEvent event) {
    final DirectoryChooser directoryChooser = new DirectoryChooser();
    final File selectedDirectory =
            directoryChooser.showDialog(stage);
    if (selectedDirectory != null) {
        fieldComponentFolder.setText(selectedDirectory.getAbsolutePath());
        if (props != null)
            props.setProperty("fieldComponentFolder", selectedDirectory.getAbsolutePath());
    }

}
 
Example 16
Source File: JFXDirectoryChooser.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void choose(UIDirectoryChooserHandler selectionHandler) {
	DirectoryChooser dialog = new DirectoryChooser();
	if( this.text != null ) {
		dialog.setTitle(this.text);
	}
	
	File initialDirectory = this.createInitialDirectory();
	if( initialDirectory != null ) {
		dialog.setInitialDirectory(initialDirectory);
	}
	
	File path = dialog.showDialog(this.window.getStage());
	
	selectionHandler.onSelectDirectory(path); 
}
 
Example 17
Source File: FileDirChooserFactory.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
/**
 * 文件夹选择器
 */
public static File createDirectoryScan(String title, String initDirectory) {
    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle(title);
    if (StringUtils.isNotEmpty(initDirectory)) {
        directoryChooser.setInitialDirectory(new File(initDirectory));
    }
    Stage fileStage = new Stage();
    return directoryChooser.showDialog(fileStage);
}
 
Example 18
Source File: NxdtController.java    From ns-usbloader with GNU General Public License v3.0 5 votes vote down vote up
@FXML
private void bntSelectSaveTo(){
    DirectoryChooser dc = new DirectoryChooser();
    dc.setTitle(rb.getString("tabSplMrg_Btn_SelectFolder"));
    dc.setInitialDirectory(new File(saveToLocationLbl.getText()));
    File saveToDir = dc.showDialog(saveToLocationLbl.getScene().getWindow());
    if (saveToDir != null)
        saveToLocationLbl.setText(saveToDir.getAbsolutePath());
}
 
Example 19
Source File: PlayConfigurationView.java    From beatoraja with GNU General Public License v3.0 4 votes vote down vote up
private String showDirectoryChooser(String title) {
DirectoryChooser chooser = new DirectoryChooser();
chooser.setTitle(title);
File f = chooser.showDialog(null);
return f != null ? f.getPath() : null;
  }
 
Example 20
Source File: BasicConfig.java    From Lipi with MIT License 2 votes vote down vote up
@FXML
private void onNextButton() {
    String confBlogNameText = confBlogTitleField.getText();
    String confBlogThemeText = confThemeChoice.getValue().getName();
    String confAuthorNameText = confBlogAuthorField.getText();

    DirectoryChooser blogDirChooser = new DirectoryChooser();
    blogDirChooser.setTitle("Select a folder to create your blog, Or maybe make a new one?");

    File selectedDirectory = blogDirChooser.showDialog(this.getScene().getWindow());

    if (selectedDirectory != null) {
        try {

            String selectedDirPath = selectedDirectory.getCanonicalPath();

            //history is saved
            WelcomeWizard.storeBlogHistory(selectedDirPath);


            //New site is created in program path!! FIX LATER
            String newSite = TabbedHMDPostEditor.toPrettyURL(confBlogNameText);
            new Hugo(selectedDirPath).hugoMakeSite(newSite);


            Path tempLoc = FileSystems.getDefault().getPath(newSite);

            System.out.println(tempLoc.toAbsolutePath());

            String newBlogsPath = selectedDirPath + File.separator + newSite;
            FileUtils.moveDirectory(new File(newSite), new File(newBlogsPath));

            //WRITE CONFIG
            TomlConfig tomlConfig = new TomlConfig(hugoDefaultConfigFilePath);

            Map<String, Object> mainTomlConfigMap = tomlConfig.getTomlMap();

            mainTomlConfigMap.put("title", confBlogNameText);
            mainTomlConfigMap.put("theme", confBlogThemeText);

            Map<String, Object> paramsMap = (Map<String, Object>) tomlConfig.getTomlMap().get("params");

            paramsMap.put("Author", confAuthorNameText);

            mainTomlConfigMap.put("params", paramsMap);

            tomlConfig.setTomlMap(mainTomlConfigMap);

            TomlConfig newToml = new TomlConfig(newBlogsPath + File.separator + "config.toml");
            newToml.setTomlMap(tomlConfig.getTomlMap());
            newToml.writeTomlMap();


            FileUtils.copyDirectory(new File(hugoBlogThemesDirPath), new File(newBlogsPath + File.separator + "themes"));
            FileUtils.copyDirectory(new File(hugoBlogExampleBlogDirPath), new File(newBlogsPath));

            WelcomeWizard.openDirBlog(new File(newBlogsPath), primaryStage);


        } catch (IOException e) {
            ExceptionAlerter.showException(e);
            e.getMessage();
        }
    }


}