javafx.stage.DirectoryChooser Java Examples

The following examples show how to use javafx.stage.DirectoryChooser. 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: LocalRepositoryDetailsPanel.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Populates the repository details step for the local repository
 */
private void populate() {
    this.pathField = new TextField();

    this.openBrowser = new Button(tr("Choose Directory..."));
    openBrowser.setOnAction(event -> {
        DirectoryChooser chooser = new DirectoryChooser();

        File directory = chooser.showDialog(null);

        pathField.setText(directory.toString());
    });

    HBox content = new HBox(pathField, openBrowser);
    content.setId("addLocalRepository");
    HBox.setHgrow(pathField, Priority.ALWAYS);

    this.setCenter(content);
}
 
Example #2
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 #3
Source File: Controller.java    From blobsaver with GNU General Public License v3.0 6 votes vote down vote up
public void filePickerHandler() {
    DirectoryChooser dirChooser = new DirectoryChooser();
    dirChooser.setTitle("Choose a folder to save Blobs in");
    File startIn = new File(pathField.getText());
    if (startIn.exists()) {
        dirChooser.setInitialDirectory(startIn);
    } else if (startIn.getParentFile().exists()) {
        dirChooser.setInitialDirectory(startIn.getParentFile());
    } else {
        dirChooser.setInitialDirectory(new File(System.getProperty("user.home")));
    }
    File result = dirChooser.showDialog(primaryStage);
    if (result != null) {
        pathField.setText(result.toString());
    }
}
 
Example #4
Source File: MainController.java    From gitPic with MIT License 6 votes vote down vote up
/**
 * 选择项目根目录
 */
@FXML
protected void chooseProjectPath() {
    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("选择项目目录");
    File file = directoryChooser.showDialog(stage);
    if (file == null || !file.isDirectory()) {
        return;
    }
    projectPathTextField.setText(file.getAbsolutePath());
    if (CastUtil.isEmpty(projectPathTextField.getText())) {
        return;
    }
    String projectPath = projectPathTextField.getText();
    Preference.getInstance().saveProjectPath(projectPath);
    initGit(projectPath);
}
 
Example #5
Source File: SegmentMeshExporterDialog.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private void createDialog()
{
	final VBox     vbox     = new VBox();
	final GridPane contents = new GridPane();

	int row = createCommonDialog(contents);

	final Button button = new Button("Browse");
	button.setOnAction(event -> {
		final DirectoryChooser directoryChooser = new DirectoryChooser();
		final File directory = directoryChooser.showDialog(contents.getScene().getWindow());
		if (directory != null)
		{
			filePath.setText(directory.getAbsolutePath());
			for (int i = 0; i < segmentIds.length; i++)
				filePaths[i] = Paths.get(directory.getAbsolutePath(), "neuron" + segmentIds[i]).toString();
			createMeshExporter(fileFormats.getSelectionModel().getSelectedItem());
		}
	});

	contents.add(button, 2, row);
	++row;

	vbox.getChildren().add(contents);
	this.getDialogPane().setContent(vbox);
}
 
Example #6
Source File: MeshExporterDialog.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private void createDialog()
{
	final VBox     vbox     = new VBox();
	final GridPane contents = new GridPane();

	int row = createCommonDialog(contents);

	final Button button = new Button("Browse");
	button.setOnAction(event -> {
		final DirectoryChooser directoryChooser = new DirectoryChooser();
		final File directory = directoryChooser.showDialog(contents.getScene().getWindow());
		if (directory != null)
		{
			dirPath.setText(directory.getAbsolutePath());
			filePath = Paths.get(directory.getAbsolutePath(), "synapses" + meshInfo.getKey().toString()).toString();
			createMeshExporter(fileFormats.getSelectionModel().getSelectedItem());
		}
	});

	contents.add(button, 2, row);
	++row;

	vbox.getChildren().add(contents);
	this.getDialogPane().setContent(vbox);
}
 
Example #7
Source File: FileContextMenu.java    From Maus with GNU General Public License v3.0 6 votes vote down vote up
public static void getFileContextMenu(HBox fileIcon, String fileName, MouseEvent e, ClientObject client) {
    ContextMenu cm = new ContextMenu();
    MenuItem sb1 = new MenuItem("Delete File");
    MenuItem sb2 = new MenuItem("Download File");
    sb2.setOnAction(event -> {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        directoryChooser.setTitle("Select download location");
        File selectedDirectory =
                directoryChooser.showDialog(Maus.getPrimaryStage());
        FileContextMenu.selectedDirectory = selectedDirectory.getAbsolutePath();
        try {
            client.clientCommunicate("DOWNLOAD");
            client.clientCommunicate(fileName);
        } catch (IOException e1) {
            Logger.log(Level.ERROR, e1.toString());
        }
    });
    cm.getItems().addAll(sb1, sb2);
    cm.show(fileIcon, e.getScreenX(), e.getScreenY());
}
 
Example #8
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 #9
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 #10
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 #11
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 #12
Source File: MainController.java    From KorgPackage with GNU General Public License v3.0 6 votes vote down vote up
public void exportChunkAction() {
        Chunk chunk = (Chunk) chunksListView.getSelectionModel().getSelectedItem();
        if (chunk != null) {
//            FileChooser fileChooser = new FileChooser();
//            fileChooser.setTitle("Save File");
            DirectoryChooser directoryChooser = new DirectoryChooser();
            directoryChooser.setInitialDirectory(lastFileChooserPath);
            directoryChooser.setTitle("Choose directory");
            File dir = directoryChooser.showDialog(stage);
            if (dir != null) {
                try {
                    lastFileChooserPath = dir;
                    ObservableList<Chunk> chunks = chunksListView.getSelectionModel().getSelectedItems();
                    for (Chunk c : chunks) {
                        c.export(dir.getPath());
                    }
                } catch (IOException e) {
                    System.err.println(e.getMessage());
                }
            }
        }
    }
 
Example #13
Source File: App.java    From xltsearch with Apache License 2.0 6 votes vote down vote up
@FXML
private void openFolder() {
    if (catalog.get().isIndexing()) {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle("Confirmation");
        alert.setHeaderText("Indexing in progress");
        alert.setContentText("Opening a new folder will cancel indexing. Continue?");
        Optional<ButtonType> result = alert.showAndWait();
        // escape on cancel/close
        if (!result.isPresent() || result.get() != ButtonType.OK) {
            return;
        }
    }
    DirectoryChooser directoryChooser = new DirectoryChooser();
    File dir = directoryChooser.showDialog(stage);
    if (dir != null) {
        if (catalog.get() != null) {
            catalog.get().close();
        }
        catalog.set(new Catalog(dir));
    }  // do nothing on cancel
}
 
Example #14
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 #15
Source File: MainMenuController.java    From BetonQuest-Editor with GNU General Public License v3.0 6 votes vote down vote up
@FXML private void saveDirectory() {
	try {
		BetonQuestEditor instance = BetonQuestEditor.getInstance();
		DirectoryChooser dc = new DirectoryChooser();
		dc.setTitle(instance.getLanguage().getString("select-directory"));
		File desktop = new File(System.getProperty("user.home") + File.separator + "Desktop");
		if (desktop != null) dc.setInitialDirectory(desktop);
		File selectedFile = dc.showDialog(instance.getPrimaryStage());
		if (selectedFile != null) {
			PackageSet set = BetonQuestEditor.getInstance().getDisplayedPackage().getSet();
			set.saveToDirectory(selectedFile);
			set.setSaveType(SaveType.DIR);
			set.setFile(selectedFile);
			MainMenuController.setSaveEnabled(true);
		}
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}
 
Example #16
Source File: FileSelectionFactory.java    From BowlerStudio with GNU General Public License v3.0 6 votes vote down vote up
public static File GetDirectory(File start) {
	if(start==null)
		throw new NullPointerException();

	final fileHolder file=new fileHolder();
	Platform.runLater(() -> {
		DirectoryChooser fileChooser = new DirectoryChooser();
		
		fileChooser.setInitialDirectory(start.isDirectory()?start:start.getParentFile());
		fileChooser.setTitle("Bowler File Chooser");
		file.setFile(fileChooser.showDialog(BowlerStudioModularFrame.getPrimaryStage()));
		file.setDone(true);
		
	});
	while(!file.isDone()){
		ThreadUtil.wait(16);
	}
		
	return file.getFile();
}
 
Example #17
Source File: MenuController.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
@FXML private void handleExportMarkdownButtonAction(ActionEvent event){
    Content content = mainApp.getContent();
    DirectoryChooser fileChooser = new DirectoryChooser();
    fileChooser.setInitialDirectory(MainApp.getDefaultHome());
    fileChooser.setTitle(Configuration.getBundle().getString("ui.dialog.export.dir.title"));
    File selectedDirectory = fileChooser.showDialog(MainApp.getPrimaryStage());
    File selectedFile = new File(selectedDirectory, ZdsHttp.toSlug(content.getTitle()) + ".md");
    log.debug("Tentative d'export vers le fichier " + selectedFile.getAbsolutePath());

    if(selectedDirectory != null){

        content.saveToMarkdown(selectedFile);
        log.debug("Export réussi vers " + selectedFile.getAbsolutePath());

        Alert alert = new CustomAlert(AlertType.INFORMATION);
        alert.setTitle(Configuration.getBundle().getString("ui.dialog.export.success.title"));
        alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.export.success.header"));
        alert.setContentText(Configuration.getBundle().getString("ui.dialog.export.success.text")+" \"" + selectedFile.getAbsolutePath() + "\"");
        alert.setResizable(true);

        alert.showAndWait();
    }
}
 
Example #18
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 #19
Source File: MenuController.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
@FXML private void handleSwitchWorkspaceAction(ActionEvent event) throws IOException{
    DirectoryChooser fileChooser = new DirectoryChooser();
    fileChooser.setInitialDirectory(MainApp.getDefaultHome());
    fileChooser.setTitle(Configuration.getBundle().getString("ui.dialog.switchworkspace"));
    File selectedDirectory = fileChooser.showDialog(MainApp.getPrimaryStage());
    if(selectedDirectory!=null) {
        MainApp.getConfig().setWorkspacePath(selectedDirectory.getAbsolutePath());
        MainApp.getConfig().loadWorkspace();

        Alert alert = new CustomAlert(AlertType.INFORMATION);
        alert.setTitle(Configuration.getBundle().getString("ui.options.workspace"));
        alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.workspace.header"));
        alert.setContentText(Configuration.getBundle().getString("ui.dialog.workspace.text") + " " + MainApp.getConfig().getWorkspacePath());
        alert.setResizable(true);

        alert.showAndWait();
    }
}
 
Example #20
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 #21
Source File: ChooseDirectoryPane.java    From pattypan with MIT License 6 votes vote down vote up
/**
 * Opens directory chooser
 */
private void chooseAndSetDirectory() {
  DirectoryChooser fileChooser = new DirectoryChooser();
  fileChooser.setTitle(Util.text("choose-directory-window-name"));

  Session.DIRECTORY = !Settings.getSetting("path").isEmpty()
          ? new File(Settings.getSetting("path"))
          : null;
  fileChooser.setInitialDirectory(Session.DIRECTORY);

  File file;
  try {
    file = fileChooser.showDialog(stage);
  } catch (IllegalArgumentException ex) {
    fileChooser.setInitialDirectory(null);
    file = fileChooser.showDialog(stage);
  }

  if (file != null) {
    Session.DIRECTORY = file;
    browsePath.setText(file.getAbsolutePath());
    Settings.setSetting("path", Session.DIRECTORY.getAbsolutePath());
    getFileListByDirectory(file);
  }
}
 
Example #22
Source File: FrontController.java    From ns-usbloader with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Functionality for selecting Split NSP button.
 * */
private void selectSplitBtnAction(){
    File splitFile;
    DirectoryChooser dirChooser = new DirectoryChooser();
    dirChooser.setTitle(resourceBundle.getString("btn_OpenFile"));

    File validator = new File(previouslyOpenedPath);
    if (validator.exists() && validator.isDirectory())
        dirChooser.setInitialDirectory(validator);
    else
        dirChooser.setInitialDirectory(new File(System.getProperty("user.home")));

    splitFile = dirChooser.showDialog(usbNetPane.getScene().getWindow());

    if (splitFile != null && splitFile.getName().toLowerCase().endsWith(".nsp")) {
        tableFilesListController.setFile(splitFile);
        uploadStopBtn.setDisable(false);    // Is it useful?
        previouslyOpenedPath = splitFile.getParent();
    }
}
 
Example #23
Source File: OpenLabelerController.java    From OpenLabeler with Apache License 2.0 5 votes vote down vote up
@FXML
private void onFileOpenDir(ActionEvent actionEvent) {
    DirectoryChooser dirChooser = new DirectoryChooser();
    dirChooser.setTitle(bundle.getString("menu.openMediaDir").replaceAll("_", ""));
    File dir = dirChooser.showDialog(tagBoard.getScene().getWindow());
    openFileOrDir(dir);
}
 
Example #24
Source File: MenuActions.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@ActionProxy(
        text="Open Repository",
        graphic="font>FontAwesome|FOLDER_OPEN",
        accelerator="ctrl+O")
private void openRepo() {
    View currentView = viewManager.getCurrentView();

    if (currentView instanceof RepoManagerView) {
        RepoManagerView view = (RepoManagerView) currentView;
        DirectoryChooser dirChooser = new DirectoryChooser();
        dirChooser.setTitle("Open Git Repository");
        Optional.ofNullable(dirChooser.showDialog(app.getPrimaryStage())).ifPresent(view::openRepo);
    }
}
 
Example #25
Source File: LocationPanel.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Ask for a path, and return it (possibly return the currentPath.)
 * @param currentPath when entering the method
 * @param dialogTitle to show
 * @param textField to update with the path information
 */
private static void askForPath(final File currentPath, final String dialogTitle, final TextField textField)
{
	GuiAssertions.assertIsJavaFXThread();
	DirectoryChooser directoryChooser = new DirectoryChooser();
	directoryChooser.setInitialDirectory(currentPath);
	directoryChooser.setTitle(dialogTitle);
	File returnFile = directoryChooser.showDialog(null);
	if (returnFile == null)
	{
		returnFile = currentPath;
	}

	textField.setText(returnFile.toString());
}
 
Example #26
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 #27
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 #28
Source File: CodeGeneratorJFX.java    From Entitas-Java with MIT License 5 votes vote down vote up
@FXML
public void handleGeneratedFolder(ActionEvent event) {
    final DirectoryChooser directoryChooser = new DirectoryChooser();
    final File selectedDirectory =
            directoryChooser.showDialog(stage);
    if (selectedDirectory != null) {
        fieldGeneratedFolder.setText(selectedDirectory.getAbsolutePath());
        if (props != null)
            props.setProperty("fieldGeneratedFolder", selectedDirectory.getAbsolutePath());
    }
}
 
Example #29
Source File: OptionsPathDialogController.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@FXML
private void doChooser(final ActionEvent actionEvent)
{
	DirectoryChooser directoryChooser = new DirectoryChooser();
	String modelDirectory = model.directoryProperty().getValue();
	if (!modelDirectory.isBlank())
	{
		directoryChooser.setInitialDirectory(new File(model.directoryProperty().getValue()));
	}

	File dir = directoryChooser.showDialog(optionsPathDialogScene.getWindow());

	if (dir != null)
	{
		if (dir.listFiles().length > 0)
		{
			Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
			alert.setTitle("Directory Not Empty");
			alert.setContentText("The folder " + dir.getAbsolutePath() + " is not empty.\n"
					+ "All ini files in this directory may be overwritten. " + "Are you sure?");
			Optional<ButtonType> buttonType = alert.showAndWait();
			buttonType.ifPresent(option -> {
				if (option != ButtonType.YES)
				{
					return;
				}
			});
		}
		model.directoryProperty().setValue(dir.getAbsolutePath());
	}
}
 
Example #30
Source File: CodeGeneratorJFX.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());
    }

}