@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); } }
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(); } } }
@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()); } } }
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; }
@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(); }
@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(); }
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); }
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()); }
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()); }
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(); } }); } } }
/** * 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()); } }
@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(); } } }
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; }
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(); }
/** * 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); } }
@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(); } }
@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(); } }
@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); } } }
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); } }
@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()); }
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); } } }
/** * 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(); }
@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 }
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()); } } } }
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(); } }
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); } } }
/** * 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()); } }
@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(); } }
@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()); } } }
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()); }
@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()); } }
/** * 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()); } }
/** * 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; }
/** * 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; }
/** * 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); } }
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); }
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(); } }; }
@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(); }
/** * 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); }