Java Code Examples for javafx.stage.DirectoryChooser

The following are top voted examples for showing how to use javafx.stage.DirectoryChooser. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: BetonQuest-Editor   File: MainMenuController.java   View source code 7 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 2
Project: FEFEditor   File: Selection.java   View source code 6 votes vote down vote up
private void openDialogue() {
    DirectoryChooser chooser = new DirectoryChooser();
    File file = chooser.showDialog(GuiData.getInstance().getStage());
    if (file != null) {
        try {
            FileData.getInstance().setWorkingFile(file);
            FXMLLoader loader = new FXMLLoader(FEFEditor.class.getResource("gui/fxml/fates/Dialogue.fxml"));
            content = loader.load();
            changeContent();
            Dialogue controller = loader.getController();
            controller.addAccelerators();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
Example 3
Project: FEFEditor   File: IndirectSound.java   View source code 6 votes vote down vote up
@FXML
private void addCharacter() {
    DirectoryChooser chooser = new DirectoryChooser();
    File file = chooser.showDialog(GuiData.getInstance().getStage());
    if (file != null) {
        TextInputDialog dialog = new TextInputDialog("placeholder");
        dialog.setTitle("Name Input");
        dialog.setHeaderText("Name Input");
        dialog.setContentText("Please enter the voice set name:");

        Optional<String> result = dialog.showAndWait();
        result.ifPresent(name -> bin.addEntries(name, file));

        entryList.getItems().clear();
        groupList.getItems().clear();
        selectedEntry = null;
        selectedGroup = null;
        for (VoiceGroup v : bin.getEntries()) {
            groupList.getItems().add(v.getMainLabel());
        }
    }
}
 
Example 4
Project: OpenDiabetes   File: MainGuiController.java   View source code 6 votes vote down vote up
private static DirectoryChooser configureDirectoryChooser(File initDir) {
    // fileChooser.setTitle("View Pictures");
    DirectoryChooser dirChooser = new DirectoryChooser();
    if (initDir != null && initDir.exists()) {
        if (initDir.isDirectory()) {
            dirChooser.setInitialDirectory(initDir);
        } else {
            dirChooser.setInitialDirectory(initDir.getParentFile());
        }
    } else {
        dirChooser.setInitialDirectory(
                new File(System.getProperty("user.home")));
    }

    return dirChooser;
}
 
Example 5
Project: marathonv5   File: SimpleWebServer.java   View source code 6 votes vote down vote up
@Override public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Simple Web Server");
    BorderPane root = new BorderPane();
    TextArea area = new TextArea();
    root.setCenter(area);
    ToolBar bar = new ToolBar();
    Button openInBrowser = FXUIUtils.createButton("open-in-browser", "Open in External Browser", true);
    openInBrowser.setOnAction((event) -> {
        try {
            Desktop.getDesktop().browse(URI.create(webRoot));
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    Button changeRoot = FXUIUtils.createButton("fldr_closed", "Change Web Root", true);
    changeRoot.setOnAction((event) -> {
        DirectoryChooser chooser = new DirectoryChooser();
        File showDialog = chooser.showDialog(primaryStage);
        if (showDialog != null)
            server.setRoot(showDialog);
    });
    bar.getItems().add(openInBrowser);
    bar.getItems().add(changeRoot);
    root.setTop(bar);
    System.setOut(new PrintStream(new Console(area)));
    System.setErr(new PrintStream(new Console(area)));
    area.setEditable(false);
    primaryStage.setScene(new Scene(root));
    primaryStage.setOnShown((e) -> startServer(getParameters().getRaw()));
    primaryStage.show();
}
 
Example 6
Project: marathonv5   File: DirectoryChooserSample.java   View source code 6 votes vote down vote up
@Override public void start(final Stage stage) {
    stage.setTitle("Directory Chooser Sample");

    final DirectoryChooser directoryChooser = new DirectoryChooser();
    final Button openButton = new Button("Select a folder...");

    openButton.setOnAction((final ActionEvent e) -> {
        File file = directoryChooser.showDialog(stage);
        if (file != null) {
            openFile(file);
        }
    });

    final GridPane inputGridPane = new GridPane();

    GridPane.setConstraints(openButton, 0, 1);
    inputGridPane.setHgap(6);
    inputGridPane.setVgap(6);
    inputGridPane.getChildren().addAll(openButton);

    final Pane rootGroup = new VBox(12);
    rootGroup.getChildren().addAll(inputGridPane);
    rootGroup.setPadding(new Insets(12, 12, 12, 12));

    stage.setScene(new Scene(rootGroup));
    stage.show();
}
 
Example 7
Project: ReqMan   File: EvaluatorHandler.java   View source code 6 votes vote down vote up
public void exportAllGroups() {
    LOGGER.traceEntry();
    if (!isCatalogueLoaded()) {
        LOGGER.debug(":exportAllGroups - No catalogue set. Returning");
        return;
    }
    DirectoryChooser dc = new DirectoryChooser();
    if (manager.hasLastExportLocation()) {
        dc.setInitialDirectory(manager.getLastExportLocation());
    }
    dc.setTitle("Choose an export folder");
    File dir = dc.showDialog(evaluator.getScene().getWindow());

    for (Group g : manager.groupList()) {
        assemble(g);
    }

    manager.exportAllGroups(dir);
}
 
Example 8
Project: Parallator   File: Helper.java   View source code 6 votes vote down vote up
public static File showDirectoryChooser(Scene scene) {
    String home = System.getProperty("user.home");
    File[] downloads = {
            new File(home + "/Downloads/"),
            new File(home + "/Загрузки/"),
            new File(home)
    };
    DirectoryChooser fileChooser = new DirectoryChooser();
    for (File download : downloads) {
        if (download.exists()) {
            fileChooser.setInitialDirectory(download);
            break;
        }
    }
    return fileChooser.showDialog(scene.getWindow());
}
 
Example 9
Project: OneClient   File: InstallLocation.java   View source code 6 votes vote down vote up
public static void getInstallDir(Predicate<File> predicate) throws IOException {
	ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
	URL fxmlUrl = classLoader.getResource("gui/install_location.fxml");
	if (fxmlUrl == null) {
		OneClientLogging.logger.error("An error has occurred loading the fxml!");
	}
	FXMLLoader fxmlLoader = new FXMLLoader();
	fxmlLoader.setLocation(fxmlUrl);
	fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
	Parent root = fxmlLoader.load(fxmlUrl.openStream());
	Stage stage = new Stage();
	stage.setTitle("Select Install Location");
	stage.getIcons().add(new Image("images/icon.png"));
	stage.setResizable(false);
	stage.initOwner(Main.stage);
	stage.initModality(Modality.WINDOW_MODAL);
	Scene scene = new Scene(root, 500, 150);
	scene.getStylesheets().add("gui/css/theme.css");
	stage.setScene(scene);
	stage.show();
	InstallLocation controller = fxmlLoader.getController();
	controller.okButton.setOnAction(event -> {
		predicate.test(new File(controller.locationField.getText()));
		stage.close();
	});
	controller.browseButton.setOnAction(event -> {
		DirectoryChooser directoryChooser = new DirectoryChooser();
		File dir = new File(controller.locationField.getText());
		if (dir.exists())
			directoryChooser.setInitialDirectory(dir);
		File selectedDirectory = directoryChooser.showDialog(stage);
		if (selectedDirectory != null) {
			controller.locationField.setText(selectedDirectory.getAbsolutePath());
		}
	});
	controller.locationField.setText(Constants.getDefaultDir().getAbsolutePath());
}
 
Example 10
Project: main_carauto_board   File: AudioController.java   View source code 6 votes vote down vote up
private void pickAndReadAudioFilesFromFolder(final Stage primaryStage, final VBox vboxPlaylist) {
    final DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("Find a folder with audio files");
    final File selectedDirectory = directoryChooser.showDialog(primaryStage);
    if (selectedDirectory != null) {
        final File[] listFiles = selectedDirectory.listFiles();
        if (listFiles != null) {
            LOGGER.info("Found " + listFiles.length + " files");
            Arrays.stream(listFiles)
                    .filter(file -> !file.isDirectory())
                    .filter(file -> {
                        final String extension = FilenameUtils.getExtension(file.getPath());
                        return extension.equals(MP3) || extension.equals(M4A);
                    })
                    .forEach(file -> {
                        LOGGER.info("Trying to load from the file: " + file.getPath());
                        try {
                            readFileAndSetInitialStateForAudioItem(file, vboxPlaylist);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    });
        }
    }
}
 
Example 11
Project: RNGames   File: MainWindowController.java   View source code 6 votes vote down vote up
/**
 * Open a DirectoryChooser window.
 */
@FXML
private void handleSelectFolder() {
	final DirectoryChooser chooser = new DirectoryChooser();

	chooser.setTitle(Locale.getString("directory.chooser.title")); //$NON-NLS-1$

	if (!this.textAreaSaveDirectory.getText().isEmpty()) {
		final File defaultDirectory = new File(this.textAreaSaveDirectory.getText());
		if (defaultDirectory.exists()) {
			chooser.setInitialDirectory(defaultDirectory);
		}
	}

	final File selectedDirectory = chooser.showDialog(this.app.getPrimaryStage());

	if (selectedDirectory != null) {
		this.textAreaSaveDirectory.setText(selectedDirectory.toString());
	}
}
 
Example 12
Project: project-cars-replay-enhancer-ui   File: PacketCaptureController.java   View source code 6 votes vote down vote up
@FXML
private void selectStorageDirectory() {
    Stage stage = (Stage) root.getScene().getWindow();
    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("Open Telemetry Storage Directory");
    directoryChooser.setInitialDirectory(
            new File(System.getProperty("user.home")));
    File directory = directoryChooser.showDialog(stage);
    if (directory != null && directory.isDirectory()) {
        try {
            String directoryName = directory.getCanonicalPath();
            txtStorageDirectory.setText(directoryName);
        } catch (IOException e) {
            e.printStackTrace();
        }
    } 
}
 
Example 13
Project: Gargoyle   File: DialogUtil.java   View source code 6 votes vote down vote up
public static File showDirSaveDialog(Window ownerWindow, File initDir, Consumer<DirectoryChooser> option) {
	DirectoryChooser chooser = new DirectoryChooser();
	chooser.setInitialDirectory(initDir);

	chooser.setTitle("Directory");
	if (option != null)
		option.accept(chooser);

	File selectedDir = chooser.showDialog(ownerWindow);
	if (selectedDir != null && selectedDir.exists()) {
		applyLastPath(selectedDir);
	}

	return selectedDir;

}
 
Example 14
Project: travelimg   File: ExportDialog.java   View source code 6 votes vote down vote up
private void handleBrowse(Event event) {
    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("Export Ort wählen");
    if (exportFolder != null) {
        directoryChooser.setInitialDirectory(new File(exportFolder));
    }
    File directory = directoryChooser.showDialog(null);

    if (directory == null || !directory.exists()) {
        getLogger().info("Invalid directory selected.");
        return;
    }

    directoryField.setText(directory.getPath());
    exportFolder = directory.getPath();
}
 
Example 15
Project: pattypan   File: ChooseDirectoryPane.java   View source code 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 16
Project: zest-writer   File: MenuController.java   View source code 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 17
Project: zest-writer   File: MenuController.java   View source code 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
Project: zest-writer   File: OpenContent.java   View source code 6 votes vote down vote up
@FXML public void handleOpenButtonAction() {
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle(Configuration.getBundle().getString("ui.menu.dialog.content.open.title"));
    File defaultDirectory;

    if(MainApp.getConfig().getWorkspaceFactory() == null){
        MainApp.getConfig().loadWorkspace();
    }
    defaultDirectory = new File(MainApp.getZdsutils().getOfflineContentPathDir());
    chooser.setInitialDirectory(defaultDirectory);
    File selectedDirectory = chooser.showDialog(MainApp.getPrimaryStage());

    if(selectedDirectory != null){
        File manifest = new File(selectedDirectory.getAbsolutePath() + File.separator + "manifest.json");
        ObjectMapper mapper = new ObjectMapper();
        Content content;
        try{
            content = mapper.readValue(manifest, Content.class);
            content.setRootContent(content, selectedDirectory.getAbsolutePath());
            mainApp.setContent(content);
            openContentWindow.close();
        }catch(IOException e){
            MainApp.getLogger().error(e.getMessage(), e);
        }
    }
}
 
Example 19
Project: xframium-java   File: OptionStage.java   View source code 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 20
Project: amperfi   File: Mp3ImportController.java   View source code 6 votes vote down vote up
@Override
public void handle(ActionEvent event) {
    DirectoryChooser dc = new DirectoryChooser();
    dc.setTitle("Choose directory to import from");
    File directory = dc.showDialog(Amperfi.ui.getWindow());

    if(directory == null) return;
    Amperfi.db.addFolder(directory.getAbsolutePath()); // TODO Check for duplicate/invalid folder
    Amperfi.ui.mp3Import.reloadFolders();

    TaskSyncFolders task = new TaskSyncFolders(directory);
    Amperfi.ui.mp3ImportProgress.btnCancel.setOnAction(action -> task.cancel());
    new Thread(task).start();

    Amperfi.ui.mp3ImportProgress.pbImporting.progressProperty().bind(task.progressProperty());
    Amperfi.ui.mp3ImportProgress.lblPath.textProperty().bind(task.messageProperty());
}
 
Example 21
Project: gitember   File: GitemberServiceImpl.java   View source code 6 votes vote down vote up
public void createRepo(final Consumer<String> onOk) {
    final DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setInitialDirectory(new File(GitemberApp.getSettingsService().getUserHomeFolder()));
    final File selectedDirectory =
            directoryChooser.showDialog(GitemberApp.getMainStage());
    if (selectedDirectory != null) {
        String absPath = selectedDirectory.getAbsolutePath();
        try {
            GitemberApp.getRepositoryService().createRepository(absPath);
            String repoPath = absPath + File.separator + Const.GIT_FOLDER;
            log.log(Level.INFO, "New repository was created - " + absPath);
            onOk.accept(repoPath);
        } catch (Exception e) {
            log.log(Level.SEVERE, "Cannot create repository", e);
            GitemberApp.showException("Cannot create repository", e);
        }

    }
}
 
Example 22
Project: gitember   File: FXMLController.java   View source code 6 votes vote down vote up
/**
 * Open repository.
 *
 * @param actionEvent event
 * @throws Exception
 */
public void openHandler(ActionEvent actionEvent) throws Exception {
    DirectoryChooser directoryChooser = new DirectoryChooser();
    if (GitemberApp.getSettingsService().getLastProject() != null) {
        directoryChooser.setInitialDirectory(new File(GitemberApp.getSettingsService().getLastProject()));
    }
    File selectedDirectory =
            directoryChooser.showDialog(GitemberApp.getMainStage());
    if (selectedDirectory != null) {
        String absPath = selectedDirectory.getAbsolutePath();
        if (!absPath.endsWith(Const.GIT_FOLDER)) {
            absPath += File.separator + Const.GIT_FOLDER;
        }
        openRepository(absPath);
    }
    createOpenRecentMenu();
}
 
Example 23
Project: xltsearch   File: App.java   View source code 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 24
Project: KorgPackage   File: MainController.java   View source code 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 25
Project: komplexni-validator   File: ImageUtilsCheckDialogController.java   View source code 6 votes vote down vote up
private void selectImageUtilPath(String property, File defaultDir, ImageUtil util, MyListener listener) {
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle(String.format("Vyberte adresář se spustitelnými soubory %s", util.getUserFriendlyName()));
    File currentDir = getConfigurationManager().getFileOrNull(property);
    if (currentDir != null && currentDir.exists()) {
        chooser.setInitialDirectory(currentDir);
    } else if (defaultDir != null && defaultDir.exists()) {
        chooser.setInitialDirectory(defaultDir);
    }
    File selectedDirectory = chooser.showDialog(stage);
    if (selectedDirectory != null) {
        getConfigurationManager().setFile(property, selectedDirectory);
        main.getValidationDataManager().getImageUtilManager().setPath(util, selectedDirectory);
        listener.onFinished();
    }
}
 
Example 26
Project: komplexni-validator   File: PspValidationConfigurationDialogController.java   View source code 6 votes vote down vote up
public void selectPspDir(ActionEvent actionEvent) {
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle("Vyberte kořenový adresář PSP balíku");
    File lastPspDir = getConfigurationManager().getFileOrNull(ConfigurationManager.PROP_LAST_PSP_DIR);
    if (lastPspDir != null && lastPspDir.exists()) {
        File parent = lastPspDir.getParentFile();
        if (parent != null && parent.exists()) {
            chooser.setInitialDirectory(parent);
        }
    }
    File selectedDir = chooser.showDialog(stage);
    if (selectedDir != null) {
        getConfigurationManager().setFile(ConfigurationManager.PROP_LAST_PSP_DIR, selectedDir);
        try {
            pspDirTextField.setText(selectedDir.getCanonicalPath());
        } catch (IOException e) {
            //should never happen
            throw new RuntimeException(e);
        }
    }
}
 
Example 27
Project: Krothium-Launcher   File: MainFX.java   View source code 6 votes vote down vote up
/**
 * Selects a game directory for the profile editor
 */
@FXML private void selectGameDirectory() {
    DirectoryChooser chooser = new DirectoryChooser();
    if (this.gameDir.getText().isEmpty()) {
        chooser.setInitialDirectory(Constants.APPLICATION_WORKING_DIR);
    } else {
        File gd = new File(this.gameDir.getText());
        if (gd.isDirectory()) {
            chooser.setInitialDirectory(gd);
        } else {
            chooser.setInitialDirectory(Constants.APPLICATION_WORKING_DIR);
        }
    }
    File selectedFolder = chooser.showDialog(null);
    if (selectedFolder != null) {
        this.gameDir.setText(selectedFolder.getAbsolutePath());
    }
}
 
Example 28
Project: certmgr   File: CertImportController.java   View source code 6 votes vote down vote up
@SuppressWarnings("unused")
@FXML
void onCmdChooseDirectorySource(ActionEvent evt) {
	DirectoryChooser chooser = new DirectoryChooser();

	chooser.setInitialDirectory(this.preferenceInitalDirectory.getValueAsFile());

	File directorySource = chooser.showDialog(getUI());

	if (directorySource != null) {
		this.ctlDirectorySourceInput.setText(directorySource.getAbsolutePath());
		this.preferenceInitalDirectory.putValueFromFile(directorySource);
		syncPreferences();
		validateAndReloadDirectorySource();
	}
}
 
Example 29
Project: beatoraja   File: PlayConfigurationView.java   View source code 6 votes vote down vote up
@FXML
public void addSongPath() {
	DirectoryChooser chooser = new DirectoryChooser();
	chooser.setTitle("楽曲のルートフォルダを選択してください");
	File f = chooser.showDialog(null);
	if (f != null) {
		boolean unique = true;
		for (String path : bmsroot.getItems()) {
			if (path.equals(f.getPath()) || f.getPath().startsWith(path + File.separatorChar)) {
				unique = false;
				break;
			}
		}
		if (unique) {
			bmsroot.getItems().add(f.getPath());
		}
	}
}
 
Example 30
Project: Maus   File: FileContextMenu.java   View source code 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 31
Project: SEGP_Group10   File: AllocatedPATsController.java   View source code 6 votes vote down vote up
@FXML
public void extractPDFOnClicked() {

    Stage primaryStage = new Stage();
    DirectoryChooser directoryChooser = new DirectoryChooser();
    File selectedDirectory
            = directoryChooser.showDialog(primaryStage);

    if (selectedDirectory == null) {

        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Warning");
        alert.setHeaderText("Look, an Information Dialog");
        alert.setContentText("You have not selected any directory!");
        alert.show();
    } else {

        getTables(selectedDirectory.getAbsolutePath());
    }
}
 
Example 32
Project: SEGP_Group10   File: Studentsinformation.java   View source code 6 votes vote down vote up
/**
 * When a user wants to extract the pdf file of the students information and
 * when he clicks the button call goes to under given method and it
 * generates the pdf file.
 */
@FXML
public void extractPDF() {

    Stage primaryStage = new Stage();
    DirectoryChooser directoryChooser = new DirectoryChooser();
    File selectedDirectory
            = directoryChooser.showDialog(primaryStage);

    if (selectedDirectory == null) {

        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Warning");
        alert.setHeaderText("Look, an Information Dialog");
        alert.setContentText("You have not selected any directory!");
        alert.show();
    } else {

        getTables(selectedDirectory.getAbsolutePath());
    }
}
 
Example 33
Project: Gamma-Music-Manager   File: PromptUI.java   View source code 6 votes vote down vote up
/**
 * Initial welcome prompt for first time startup. Browse button allows user
 * to browse directories and choose a folder
 *
 * @return set directory for master panel
 */
public static String initialWelcome() {
    Dialog dialog = makePlainDialog(WELCOME_TITLE, null, WELCOME_MESSAGE);
    setLogoDialog(dialog);

    ButtonType browse = new ButtonType("Browse");
    dialog.getDialogPane().getButtonTypes().addAll(browse);
    Optional<ButtonType> result = dialog.showAndWait();

    if (result.isPresent() && result.get() == browse) {
        DirectoryChooser directory = new DirectoryChooser();
        File selectedFile = directory.showDialog(null);
        if (selectedFile != null) {
            return selectedFile.getAbsolutePath();
        }
    }
    return null;
}
 
Example 34
Project: Gamma-Music-Manager   File: PromptUI.java   View source code 6 votes vote down vote up
/**
 * Prompt to export a selected playlist
 *
 * @param playlists list of playlists
 * @return selected playlist, null if prompt is canceled
 */
public static Pair<Playlist, File> exportPlaylist(List<Playlist> playlists) {
    if(playlists.isEmpty()) {
        customPromptError("Error", null, "Playlists not found");
        return null;
    }

    ChoiceDialog<Playlist> dialog = new ChoiceDialog<>(playlists.get(0), playlists);
    Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
    stage.getIcons().add(PROMPT_ICON);
    dialog.setTitle(EXPORT_PLAYLIST_TITLE);
    dialog.setHeaderText(EXPORT_PLAYLIST_HEADER);
    setDialogIcon(dialog, "export-playlist.png");
    dialog.setContentText(SELECT_PLAYLIST_LABEL);
    Optional<Playlist> result = dialog.showAndWait();

    if (result.isPresent()) {
        DirectoryChooser directory = new DirectoryChooser();
        File selectedFile = directory.showDialog(null);
        if (selectedFile != null) {
            return new Pair<>(result.get(), selectedFile);
        }
    }
    return null;
}
 
Example 35
Project: aptasuite   File: WizardStartController.java   View source code 6 votes vote down vote up
/**
 * Implements the logic for choosing the folder to server as the base path of the project
 */
@FXML
private void projectPathFileChooserActionButton() {
	
	// Get the configuration file path
	DirectoryChooser chooser = new DirectoryChooser();
	chooser.setTitle("Choose the project location");
	if (getDataModel().getProjectPath().isNotEmpty().get()) {
		chooser.setInitialDirectory(new File(getDataModel().getProjectPath().get()));
	}
	File selectedDirectory = chooser.showDialog(null);
	
	
	// Load configuration unless the user has chosen not to complete the dialog
	if (selectedDirectory != null) {
		
		projectPathTextField.setText(selectedDirectory.getAbsolutePath());
		getDataModel().setLastSelectedDirectory(selectedDirectory);
	}
	
}
 
Example 36
Project: triplea   File: JavaFxSelectionComponentFactory.java   View source code 6 votes vote down vote up
FolderSelector(final ClientSetting clientSetting) {
  this.clientSetting = clientSetting;
  final File initialValue = clientSetting.value().isEmpty() ? null : new File(clientSetting.value());
  final HBox wrapper = new HBox();
  textField = new TextField(clientSetting.value());
  textField.prefColumnCountProperty().bind(Bindings.add(1, Bindings.length(textField.textProperty())));
  textField.setMaxWidth(Double.MAX_VALUE);
  textField.setDisable(true);
  final Button chooseFileButton = new Button("...");
  selectedFile = initialValue;
  chooseFileButton.setOnAction(e -> {
    final DirectoryChooser fileChooser = new DirectoryChooser();
    if (selectedFile != null) {
      fileChooser.setInitialDirectory(selectedFile);
    }
    final File file = fileChooser.showDialog(chooseFileButton.getScene().getWindow());
    if (file != null) {
      selectedFile = file;
      textField.setText(file.toString());
    }
  });
  wrapper.getChildren().addAll(textField, chooseFileButton);
  getChildren().add(wrapper);
}
 
Example 37
Project: spyfs   File: GenericChooser.java   View source code 6 votes vote down vote up
public static GenericChooser newDirectoryC(){
    return new GenericChooser() {
        final DirectoryChooser ch = new DirectoryChooser();
        @Override
        public void setInitialDirectory(String initPath) {
            fixPath(initPath, (f) -> ch.setInitialDirectory(f));
        }
        
        @Override
        public void setTitle(String t) {
            ch.setTitle(t);
        }

        @Override
        public String show(final Window ownerWindow) {
            return ch.showDialog(ownerWindow).getAbsolutePath();
        }
    };
}
 
Example 38
Project: OS-Cache-Suite   File: CacheSuite.java   View source code 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    environments = new ArrayList<CacheEnvironment>();
    stage.setTitle("OSRS Cache Suite " + SuiteConstants.VERSION + "." + SuiteConstants.SUB_VERSION);
    stage.setResizable(false);
    Group rootGroup = new Group();
    Scene scene = new Scene(rootGroup, SuiteConstants.WIDTH, SuiteConstants.HEIGHT);

    cacheChooser = new DirectoryChooser();

    VBox vertical = new VBox();
    this.setupMenuBar(stage);
    vertical.getChildren().add(bar);
    setupTabPane(stage);
    vertical.getChildren().add(tabPane);
    rootGroup.getChildren().add(vertical);

    stage.setScene(scene);
    stage.show();
}
 
Example 39
Project: LifeTiles   File: MenuController.java   View source code 6 votes vote down vote up
/**
 * Perform functionality associated with opening a file.
 *
 * @throws IOException
 *             throws <code>IOException</code> if any of the files were not
 *             found
 */
private void loadDataFiles() throws IOException {
    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("Open folder containing data files");
    Window window = menuBar.getScene().getWindow();
    File directory = directoryChooser.showDialog(window);

    // user aborted
    if (directory == null) {
        return;
    }
    loadGraph(directory);
    loadTree(directory);
    loadKnownMutations(directory);
    loadAnnotations(directory);
    loadMetaData(directory);
}
 
Example 40
Project: dm3270   File: OptionStage.java   View source code 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);
  }
}