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

The following examples show how to use javafx.stage.DirectoryChooser#setTitle() . 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: 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 2
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 3
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 4
Source File: OptionStage.java    From xframium-java with GNU General Public License v3.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 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: 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 7
Source File: FileShareController.java    From OEE-Designer with MIT License 6 votes vote down vote up
@FXML
private void onChooseFile() {
	try {
		// show file chooser
		DirectoryChooser directoryChooser = new DirectoryChooser();

		// Set title for DirectoryChooser
		directoryChooser.setTitle(DesignerLocalizer.instance().getLangString("select.dir"));

		// Set Initial Directory
		directoryChooser.setInitialDirectory(new File(System.getProperty("user.home")));

		File dir = directoryChooser.showDialog(null);

		if (dir == null) {
			return;
		}

		tfHost.setText(dir.getCanonicalPath());

	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 8
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 9
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 10
Source File: Preferences_Controller.java    From Path-of-Leveling with MIT License 5 votes vote down vote up
@FXML
private void locateLog(){

    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("Locate Path of Exile Installation Folder");
    File selectedDirectory = directoryChooser.showDialog(root.parent.getScene().getWindow());

    if (selectedDirectory != null) {
         directory = selectedDirectory.getAbsolutePath();
         System.out.println("Selected new log location : " + selectedDirectory.getAbsolutePath());
         System.out.println(directory + "\\logs\\Client.txt");
         //System.out.println(directoryA);
         poe_installation.setText(directory);
    }
}
 
Example 11
Source File: DestinationPaneController.java    From CMPDL with MIT License 5 votes vote down vote up
@FXML
void actionChooseDestination(ActionEvent event) {
    DirectoryChooser dc = new DirectoryChooser();
    dc.setTitle("Choose the destination folder :");
    String currentChosenDirectory = destinationField.getText();
    if (currentChosenDirectory != null && ! "".equals(currentChosenDirectory)) {
        dc.setInitialDirectory(new File(currentChosenDirectory));
    }
    File dst = dc.showDialog(CMPDL.stage);
    if (dst != null) {
        destinationField.setText(dst.getAbsolutePath());
    }
}
 
Example 12
Source File: ModpackPaneController.java    From CMPDL with MIT License 5 votes vote down vote up
@FXML
void actionChooseDestination(ActionEvent event) {
    DirectoryChooser dc = new DirectoryChooser();
    dc.setTitle("Choose the destination folder :");
    File dst = dc.showDialog(CMPDL.stage);
    if (dst != null) {
        destinationField.setText(dst.getAbsolutePath());
    }
}
 
Example 13
Source File: BatchImageProcessorController.java    From FakeImageDetection with GNU General Public License v3.0 5 votes vote down vote up
@FXML
private void loadSourceFolder(ActionEvent event) {
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle("Choose Source Folder");
    srcDir = chooser.showDialog(rootPane.getScene().getWindow());
    if (srcDir == null) {
        Calert.showAlert("Error", "Not a valid folder", Alert.AlertType.ERROR);
        return;
    }
    srcIndicator.setSelected(true);
}
 
Example 14
Source File: WelcomeWizard.java    From Lipi with MIT License 5 votes vote down vote up
@FXML
private void onOpenOldBlog() {
    DirectoryChooser blogDirChooser = new DirectoryChooser();
    blogDirChooser.setTitle("Select your blog folder");

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

    WelcomeWizard.openDirBlog(selectedDirectory, primaryStage);
}
 
Example 15
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 16
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 17
Source File: ConfigController.java    From logbook-kai with MIT License 4 votes vote down vote up
@FXML
void selectBouyomiDir(ActionEvent event) {
    DirectoryChooser dc = new DirectoryChooser();
    dc.setTitle("BouyomiChan.exeがあるフォルダを選択してください");

    String pathText = this.bouyomiPath.getText();
    if (pathText != null && !pathText.isEmpty() && Files.exists(Paths.get(pathText))) {
        dc.setInitialDirectory(Paths.get(pathText).toFile());
    }
    Path baseDir = Optional.ofNullable(dc.showDialog(this.getWindow()))
            .filter(File::exists)
            .map(File::toPath)
            .orElse(null);
    if (baseDir == null)
        return;

    Path bouyomichanPath = null;
    Path tryPath = baseDir.resolve("BouyomiChan.exe");
    if (Files.exists(tryPath)) {
        bouyomichanPath = tryPath;
    } else {
        // 1つ下のサブフォルダを見てみる
        try (DirectoryStream<Path> ds = Files.newDirectoryStream(baseDir, Files::isDirectory)) {
            for (Path path : ds) {
                tryPath = path.resolve("BouyomiChan.exe");
                if (Files.exists(tryPath)) {
                    bouyomichanPath = tryPath;
                    break;
                }
            }
        } catch (Exception e) {
        }
    }
    if (bouyomichanPath != null) {
        this.bouyomiPath.setText(bouyomichanPath.toString());
    } else {
        Tools.Conrtols.alert(AlertType.INFORMATION,
                "BouyomiChan.exeが見つかりません",
                "選択されたフォルダにBouyomiChan.exeが見つかりませんでした。",
                this.getWindow());
    }
}
 
Example 18
Source File: ExampleInstaller.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
/** Run the installer
 *  @throws Exception on error
 *  @return true when installed, false when aborted
 */
@Override
public Boolean call() throws Exception
{
    // Prompt for installation directory
    final Control pane = DockPane.getActiveDockPane();
    final Window window = pane.getScene().getWindow();
    final DirectoryChooser select = new DirectoryChooser();
    select.setTitle(directory_prompt);
    final File dir = select.showDialog(window);
    if (dir == null)
        return false;

    final File examples = new File(dir, examples_directory);

    // Prompt user: OK to overwrite?
    if (examples.exists())
    {
        final Alert confirm = new Alert(AlertType.CONFIRMATION);
        DialogHelper.positionDialog(confirm, pane, -300, -200);
        confirm.setTitle(Messages.InstallExamples);
        confirm.setHeaderText(MessageFormat.format(Messages.ReplaceExamplesWarningFMT, examples.toString()));
        if (confirm.showAndWait().orElse(ButtonType.CANCEL) != ButtonType.OK)
            return false;
    }

    logger.log(Level.INFO, "Install from " + examples_resource + " into " + examples);

    // In background:
    JobManager.schedule(Messages.InstallExamples, monitor ->
    {
        if (examples.exists())
        {   // Delete existing directory
            logger.log(Level.INFO, "Deleting existing " + examples);
            monitor.beginTask("Delete " + examples);
            FileHelper.delete(examples);
        }

        // Install examples, which may be in local file system or JAR
        monitor.beginTask("Install " + examples);
        if (examples_resource.getProtocol().equals("jar"))
        {   // Resource is inside a jar:  file:/C:/Users/.../app-display-model.jar!/examples
            String path = examples_resource.getPath();
            // Split into path to jar file and folder within the jar
            final int sep = path.indexOf("!");
            final String jar_folder = path.substring(sep+2);
            path = path.substring(0, sep);
            logger.log(Level.INFO, "Jar file: " + path);
            logger.log(Level.INFO, "Folder in jar: " + jar_folder);

            // Go via URI and file to handle "file:/C:.." on windows
            final Path jar = new File(URI.create(path)).toPath();
            logger.log(Level.INFO, "Install " + jar + " into " + examples);
            // Open file system for jar
            try
            (
                final FileSystem fs = FileSystems.newFileSystem(jar, (ClassLoader) null);
            )
            {
                copy(1, fs.getPath(jar_folder), examples, monitor);
            }
        }
        else
        {   // Copy from local filesystem
            final Path resource_path = Paths.get(examples_resource.toURI());
            logger.log(Level.INFO, "Install " + resource_path + " into " + examples);
            copy(resource_path.getNameCount(), resource_path, examples, monitor);
        }
        // Open runtime on UI thread
        Platform.runLater(() ->
        {
            final URI uri = new File(examples, example_to_open).toURI();
            ApplicationService.createInstance(example_application, uri);

            // Tell user what was done
            final Alert info = new Alert(AlertType.INFORMATION);
            DialogHelper.positionDialog(info, pane, -300, -200);
            info.setTitle(Messages.InstallExamples);
            info.setHeaderText(MessageFormat.format(completion_message_format, examples.toString()));
            info.showAndWait();
        });
    });

    return true;
}
 
Example 19
Source File: CaptureSaveController.java    From logbook-kai with MIT License 4 votes vote down vote up
@FXML
void save(ActionEvent event) {
    List<ImageData> selections = this.list.getCheckModel().getCheckedItems();

    if (!selections.isEmpty()) {
        DirectoryChooser dc = new DirectoryChooser();
        dc.setTitle("キャプチャの保存先");
        // 覚えた保存先をセット
        File initDir = Optional.ofNullable(AppConfig.get().getCaptureDir())
                .map(File::new)
                .filter(File::isDirectory)
                .orElse(null);
        if (initDir != null) {
            dc.setInitialDirectory(initDir);
        }
        File file = dc.showDialog(this.getWindow());
        if (file != null) {
            // 保存先を覚える
            AppConfig.get().setCaptureDir(file.getAbsolutePath());

            Path path = file.toPath();

            Task<Void> task = new Task<Void>() {
                @Override
                protected Void call() throws Exception {
                    CaptureSaveController.this.saveJpeg(selections, path);
                    return null;
                }

                @Override
                protected void succeeded() {
                    super.succeeded();

                    Tools.Conrtols.alert(AlertType.INFORMATION,
                            "キャプチャが保存されました",
                            "キャプチャが保存されました",
                            CaptureSaveController.this.getWindow());
                }

                @Override
                protected void failed() {
                    super.failed();
                    Throwable t = this.getException();

                    Tools.Conrtols.alert(AlertType.ERROR,
                            "キャプチャの保存先に失敗しました",
                            "キャプチャの保存先に失敗しました",
                            t,
                            CaptureSaveController.this.getWindow());
                }
            };
            ThreadManager.getExecutorService().execute(task);
        }
    }
}
 
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();
        }
    }


}