Example usage for javafx.stage DirectoryChooser showDialog

List of usage examples for javafx.stage DirectoryChooser showDialog

Introduction

In this page you can find the example usage for javafx.stage DirectoryChooser showDialog.

Prototype

public File showDialog(final Window ownerWindow) 

Source Link

Document

Shows a new directory selection dialog.

Usage

From source file:com.respam.comniq.Controller.java

@FXML
protected void excludeButtonAction() {
    DirectoryChooser edc = new DirectoryChooser();
    edc.setInitialDirectory(new File(System.getProperty("user.home")));
    edc.setTitle("Exclude Directories");
    File excludeDC = edc.showDialog(null);
    if (null != excludeDC) {
        excludeArea.appendText(excludeDC.getName());
        excludeArea.appendText(";");
    }/* www.ja v a 2s  .  co m*/
}

From source file:de.thomasbolz.renamer.RenamerGUI.java

/**
 * Action handler for the source directory button.
 *
 * @param event/*from  www  .  j ava2  s.c  o  m*/
 */
@FXML
void changeSrc(ActionEvent event) {
    DirectoryChooser f = new DirectoryChooser();

    if (getSrcDirectory().isDirectory()) {
        f.setInitialDirectory(getSrcDirectory());
    }
    File file = f.showDialog(txtOut.getScene().getWindow());
    if (file != null && file.isDirectory()) {
        setSrcDirectory(file);
    }
}

From source file:deincraftlauncher.InstallController.java

@FXML
void onChangePath(ActionEvent event) {
    System.out.println("changing Path...");
    DirectoryChooser fileChooser = new DirectoryChooser();
    fileChooser.setInitialDirectory(defaultInstall);
    fileChooser.setTitle("Whle Installationsort");
    File chosen = fileChooser.showDialog(deincraftlauncher.DeincraftLauncherUI.window);
    if (chosen != null) {
        String choosed = chosen.toString();
        System.out.println("Chosen Path: " + choosed);

        targetPath = choosed + File.separator + "Minefactory" + File.separator;
        pathLabel.setText(targetPath);/*  w w w .  j ava2 s .  co  m*/
    } else {
        System.out.println("pathchange cancelled");
    }
    //fileChooser.showOpenDialog(deincraftlauncher.DeincraftLauncherUI.window);
}

From source file:dpfmanager.shell.interfaces.gui.component.dessign.DessignController.java

public void selectInputAction() {
    String txtFile = null;/* w w w.j  a v  a2s . com*/
    ComboBox c = getView().getComboChoice();
    String configDir = DPFManagerProperties.getDefaultDirFile();
    if (c.getValue().equals(getBundle().getString("comboFile"))) {
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle(getBundle().getString("openFile"));
        fileChooser.setInitialDirectory(new File(configDir));
        fileChooser.getExtensionFilters().addAll(generateExtensionsFilters());
        List<File> files = fileChooser.showOpenMultipleDialog(GuiWorkbench.getMyStage());
        if (files != null) {
            String sfiles = "";
            File last = null;
            for (File file : files) {
                if (sfiles.length() > 0)
                    sfiles += ";";
                sfiles += file.getPath();
                last = file;
            }
            txtFile = sfiles;
            if (last.exists() && last.getParent() != null && last.getParentFile().exists()
                    && last.getParentFile().isDirectory()) {
                String path = last.getParent();
                DPFManagerProperties.setDefaultDirFile(path);
            }
        }
    } else if (c.getValue().equals(getBundle().getString("comboFolder"))) {
        DirectoryChooser folderChooser = new DirectoryChooser();
        folderChooser.setTitle(getBundle().getString("openFolder"));
        folderChooser.setInitialDirectory(new File(configDir));
        File directory = folderChooser.showDialog(GuiWorkbench.getMyStage());
        if (directory != null) {
            txtFile = directory.getPath();
            DPFManagerProperties.setDefaultDirFile(directory.getPath());
        }
    }
    if (txtFile != null) {
        getView().getInputText().setText(txtFile);
    }
}

From source file:de.thomasbolz.renamer.RenamerGUI.java

/**
 * Action handler for the target directory button.
 *
 * @param event//from  w w  w .j  av a  2  s .  co m
 */
@FXML
void changeTarget(ActionEvent event) {
    DirectoryChooser chooser = new DirectoryChooser();

    if (getTargetDirectory().isDirectory()) {
        chooser.setInitialDirectory(getTargetDirectory());
    }
    File file = chooser.showDialog(txtOut.getScene().getWindow());
    if (file != null && file.isDirectory()) {
        setTargetDirectory(file);
    }
}

From source file:uk.co.everywheremusic.viewcontroller.SetupScene.java

private void startSetupWindow(Stage primaryStage) {
    try {/*from w  ww .  j  a  v a  2s.com*/
        installFolder = new File(".").getCanonicalPath() + Globals.INSTALL_EXT;
    } catch (IOException ex) {
        Logger.getLogger(SetupScene.class.getName()).log(Level.SEVERE, null, ex);
        installFolder = System.getProperty("user.dir") + Globals.INSTALL_EXT;
    }

    primaryStage.setTitle(Globals.APP_NAME);

    grid = new GridPane();
    grid.setAlignment(Pos.CENTER);
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    column1 = new ColumnConstraints(100, 100, Double.MAX_VALUE);
    column1.setHgrow(Priority.ALWAYS);
    column2 = new ColumnConstraints(100, 100, Double.MAX_VALUE);
    column2.setHgrow(Priority.ALWAYS);
    column3 = new ColumnConstraints(100, 100, Double.MAX_VALUE);
    column3.setHgrow(Priority.ALWAYS);
    column4 = new ColumnConstraints(100, 100, Double.MAX_VALUE);
    column4.setHgrow(Priority.ALWAYS);
    grid.getColumnConstraints().addAll(column1, column2, column3, column4);

    sceneTitle = new Label(Globals.SETUP_FRAME_TITLE);
    sceneTitle.setId(Globals.CSS_TITLE_ID);
    sceneTitle.setPrefWidth(Double.MAX_VALUE);
    sceneTitle.setAlignment(Pos.CENTER);

    ImageView imageView = null;
    try {

        imageView = new ImageView();
        String img = new File(Globals.IC_LOGO).toURI().toURL().toString();
        imgLogo = new Image(img);

        imageView.setImage(imgLogo);

    } catch (MalformedURLException ex) {
        Logger.getLogger(ServerScene.class.getName()).log(Level.SEVERE, null, ex);
    }

    GridPane titlePane = new GridPane();
    ColumnConstraints c1 = new ColumnConstraints(50);
    ColumnConstraints c2 = new ColumnConstraints(400);
    titlePane.getColumnConstraints().addAll(c1, c2);
    titlePane.add(imageView, 0, 0);
    titlePane.add(sceneTitle, 1, 0);
    titlePane.setAlignment(Pos.CENTER);
    grid.add(titlePane, 0, 0, 4, 1);

    lblFolder = new Label(Globals.SETUP_LBL_MUSIC_FOLDER);
    grid.add(lblFolder, 0, 2, 3, 1);

    txtFolder = new TextField();
    txtFolder.setText("/home/kyle/Music/Test music");
    grid.add(txtFolder, 0, 3, 3, 1);

    btnFolder = new Button(Globals.SETUP_BTN_MUSIC_FOLDER);
    btnFolder.setPrefWidth(Double.MAX_VALUE);
    grid.add(btnFolder, 3, 3);

    final DirectoryChooser dirChooser = new DirectoryChooser();

    btnFolder.setOnAction((ActionEvent event) -> {
        File dir = dirChooser.showDialog(primaryStage);
        if (dir != null) {
            txtFolder.setText(dir.getAbsolutePath());
        }
    });

    lblPassword = new Label("Choose a password:");
    grid.add(lblPassword, 0, 4, 2, 1);

    lblConfirmPassword = new Label("Confirm your password:");
    grid.add(lblConfirmPassword, 2, 4, 2, 1);

    txtPassword = new PasswordField();
    grid.add(txtPassword, 0, 5, 2, 1);

    txtConfirmPassword = new PasswordField();
    grid.add(txtConfirmPassword, 2, 5, 1, 1);

    textArea = new TextArea();
    textArea.setPrefHeight(Double.MAX_VALUE);
    textArea.setDisable(true);
    textArea.setWrapText(true);
    grid.add(textArea, 0, 7, 4, 2);

    StackPane progressPane = new StackPane();
    lblProgress = new Label(Globals.SETUP_LBL_PERCENT);
    lblProgress.setId(Globals.CSS_PROGBAR_LBL_ID);
    lblProgress.setVisible(false);
    progressBar = new ProgressBar(0);
    progressBar.setPrefWidth(Double.MAX_VALUE);
    progressBar.setVisible(false);
    progressPane.getChildren().addAll(progressBar, lblProgress);
    progressPane.setAlignment(Pos.CENTER_RIGHT);
    grid.add(progressPane, 0, 11, 3, 1);

    StackPane buttonPane = new StackPane();
    btnInstall = new Button(Globals.SETUP_BTN_INSTALL);
    btnInstall.setPrefWidth(Double.MAX_VALUE);
    btnDone = new Button(Globals.SETUP_BTN_DONE);
    btnDone.setPrefWidth(Double.MAX_VALUE);
    btnDone.setVisible(false);
    buttonPane.getChildren().addAll(btnInstall, btnDone);
    grid.add(buttonPane, 3, 11);

    btnInstall.setOnAction((ActionEvent event) -> {

        boolean valid = validateForm();
        if (valid) {

            lblFolder.setDisable(true);
            txtFolder.setDisable(true);
            btnFolder.setDisable(true);
            lblPassword.setDisable(true);
            txtPassword.setDisable(true);
            lblConfirmPassword.setDisable(true);
            txtConfirmPassword.setDisable(true);

            textArea.setDisable(false);
            lblProgress.setVisible(true);
            progressBar.setVisible(true);
            btnInstall.setDisable(true);

            musicFolder = txtFolder.getText();
            password = txtPassword.getText();

            setupWorker = createSetupWorker();
            progressBar.progressProperty().unbind();
            progressBar.progressProperty().bind(setupWorker.progressProperty());

            setupWorker.messageProperty().addListener(
                    (ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
                        String[] values = newValue.split("\\|");
                        lblProgress.setText(values[0] + "%");
                        textArea.appendText(values[1] + "\n");

                        if (values[1].equals(Globals.SETUP_MSG_DONE)) {
                            btnInstall.setVisible(false);
                            btnDone.setVisible(true);
                        }

                    });

            new Thread(setupWorker).start();

        }
    });

    btnDone.setOnAction((ActionEvent event) -> {
        primaryStage.hide();
        new ServerScene(installFolder, musicFolder).showWindow(new Stage());
    });

    try {
        String imgUrl = new File(Globals.IC_LOGO).toURI().toURL().toString();
        javafx.scene.image.Image i = new javafx.scene.image.Image(imgUrl);
        primaryStage.getIcons().add(i);
    } catch (MalformedURLException ex) {
        Logger.getLogger(ServerScene.class.getName()).log(Level.SEVERE, null, ex);
    }

    scene = new Scene(grid, 600, 400);
    primaryStage.setScene(scene);

    scene.getStylesheets().add(SetupScene.class.getResource(Globals.CSS_FILE).toExternalForm());
    //  grid.setGridLinesVisible(true);
    primaryStage.show();
}

From source file:ca.wumbo.doommanager.client.controller.file.DXMLProjectCreatorController.java

/**
 * Does directory browsing for the user to supply a directory.
 *//*w ww  .j  av  a 2  s  . c o  m*/
public void browseFolders() {
    if (stage == null) {
        log.error("Attempting to browse folders with a null parent stage.");
        return;
    }

    // Lock on to the main stage and wait until we get a directory.
    DirectoryChooser directoryChooser = new DirectoryChooser();
    File selectedDirectory = directoryChooser.showDialog(stage);
    if (selectedDirectory != null) {
        projectFolderTextfield.setText(selectedDirectory.getAbsolutePath());
        projectFolderTextfield.requestFocus();
        projectFolderTextfield.end(); // Move the caret to the end so the user can see the important part.
        projectInfoTextUpdated();
    }
}

From source file:org.nmrfx.processor.gui.MainApp.java

private void loadProject() {
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle("Project Chooser");
    File directoryFile = chooser.showDialog(null);
    if (directoryFile != null) {
        loadProject(directoryFile.toPath());
    }/* w  w  w  . j  av a2 s  . c om*/
}

From source file:org.martus.client.swingui.PureFxMainWindow.java

public File showChooseDirectoryDialog(String windowTitle) {
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle(windowTitle);//from www.j  a v a  2 s .  co m

    return chooser.showDialog(getActiveStage());
}

From source file:ipat_fx.FXMLDocumentController.java

@FXML
private void loadOption(ActionEvent event) {

    DirectoryChooser dc = new DirectoryChooser();
    File file = new File(contextPath + "Saves/");
    dc.setInitialDirectory(file);//  w w  w .  j  a v  a 2 s.c o m
    File dest = new File(dataPath);
    File seeds = new File(dataPath + "/seeds/");
    seeds.delete();
    seeds.mkdirs();
    dest.delete();
    dest.mkdirs();
    File src = dc.showDialog(null);

    try {

        FileUtils.copyDirectory(src, dest);
        File profiles = new File(outputFolder.getAbsolutePath() + "/generations");
        File[] listFiles = profiles.listFiles();

        int lastGeneration = 0;
        for (File listFile : listFiles) {
            if (!listFile.isDirectory()) {
                String profileName = listFile.getName();
                System.out.println("profileName : " + profileName);
                int generation = Integer.parseInt(
                        profileName.substring((profileName.indexOf('_') + 1), profileName.indexOf('-')));
                System.out.println("generation : " + generation);
                if (generation > lastGeneration) {
                    lastGeneration = generation;
                }
            }
        }

        for (File listFile : listFiles) {
            String profileName = listFile.getName();
            if (Integer.parseInt(profileName.substring((profileName.indexOf('_') + 1),
                    profileName.indexOf('-'))) == lastGeneration) {
                FileUtils.copyFile(listFile, new File(seeds + "/" + listFile.getName()));
            }
        }

        controller = new Controller(inputFolder, outputFolder, seeds, hintsXML, problemDataFolderName);

        HashMap<String, Object> display = controller.initialisation();
        WebView previewView = (WebView) display.get("previewView");
        previewPane.getChildren().add(previewView);
        @SuppressWarnings("unchecked")
        HashMap<String, ArrayList<GridPane>> map = (HashMap<String, ArrayList<GridPane>>) display
                .get("results");

        if (tabFlag.equalsIgnoreCase("byImage")) {
            byImageTab = getByImage(map);
            byImagePane.setCenter(byImageTab);
        } else if (tabFlag.equalsIgnoreCase("byProfile")) {
            byProfileTab = getByProfile(map, controller.noOfProfiles);
            byProfilePane.setCenter(byProfileTab);
        }

        tabPane.getSelectionModel().selectedIndexProperty()
                .addListener((ObservableValue<? extends Number> ov, Number oldValue, Number newValue) -> {
                    if (newValue == Number.class.cast(1)) {
                        byImageTab = getByImage(map);
                        byImagePane.setCenter(byImageTab);
                    } else if (newValue == Number.class.cast(0)) {
                        byProfileTab = getByProfile(map, controller.noOfProfiles);
                        byProfilePane.setCenter(byProfileTab);
                    } else {
                        System.out.println("Error this tab has not been created.");
                    }
                });
    } catch (IOException ex) {
        Logger.getLogger(IPAT_FX.class.getName()).log(Level.SEVERE, null, ex);
    }

}