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.gnadenheimer.mg3.controller.admin.AdminConfigController.java

@FXML
private void cmdDataDirectory(ActionEvent event) {
    try {//  w  w w. j a va2s.  c om
        DirectoryChooser directoryChooser = new DirectoryChooser();
        File selectedDirectory = directoryChooser.showDialog(App.mainStage);
        if (selectedDirectory != null) {
            txtDataDir.setText(selectedDirectory.getAbsolutePath());
        }
    } catch (Exception ex) {
        App.showException(this.getClass().getName(), ex.getMessage(), ex);
    }
}

From source file:de.halirutan.spectralis.examples.sloexporter.Controller.java

private File showDirectorySelectDialog(String title) {
    Window window = root.getScene().getWindow();
    DirectoryChooser dirChooser = new DirectoryChooser();
    dirChooser.setTitle(title);//  w w w  .  ja va  2 s  . com
    return dirChooser.showDialog(window);
}

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

@FXML
protected void browseButtonAction() {
    DirectoryChooser dc = new DirectoryChooser();
    File selectedDC = dc.showDialog(null);
    if (selectedDC != null) {
        inputPath.setText(selectedDC.getPath());
    }/*from   w w w . j  a v a2  s  .co m*/
}

From source file:io.bitsquare.gui.main.account.content.backup.BackupView.java

@Override
protected void activate() {
    selectBackupDir.setOnAction(e -> {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        directoryChooser.setInitialDirectory(new File(preferences.getDefaultPath()));
        directoryChooser.setTitle("Select backup location");
        File dir = directoryChooser.showDialog(stage);
        if (dir != null) {
            String backupDirectory = dir.getAbsolutePath();
            preferences.setDefaultPath(backupDirectory);
            backUpLocationTextField.setText(backupDirectory);
            preferences.setBackupDirectory(backupDirectory);
            backupNow.setDisable(false);
            backupNow.setDefaultButton(true);
            selectBackupDir.setDefaultButton(false);
        }/*w w  w.ja v  a 2s .  c o  m*/
    });
    openDataDir.setOnAction(e -> {
        try {
            Utilities.openDirectory(dataDir);
        } catch (IOException e1) {
            log.error(e1.getMessage());
            new Popup().warning("Cannot open directory.\nError =" + e1.getMessage()).show();
        }
    });
    backupNow.setOnAction(e -> {
        String backupDirectory = preferences.getBackupDirectory();
        if (backupDirectory.length() > 0) {
            try {
                String dateString = new SimpleDateFormat("YYYY-MM-dd-HHmmss").format(new Date());
                String destination = Paths.get(backupDirectory, "bitsquare_backup_" + dateString).toString();
                FileUtils.copyDirectory(dataDir, new File(destination));
                new Popup().feedback("Backup successfully saved at:\n" + destination).show();
            } catch (IOException e1) {
                e1.printStackTrace();
                log.error(e1.getMessage());
                new Popup().error("Backup could not be saved.\nError message: " + e1.getMessage()).show();
            }
        }
    });
}

From source file:com.bekwam.resignator.SettingsController.java

@FXML
public void browseForJDK() {
    if (logger.isDebugEnabled()) {
        logger.debug("[BROWSE FOR JDK]");
    }/*from  ww  w.j  a v a 2  s .c  o m*/

    DirectoryChooser dirChooser = new DirectoryChooser();
    dirChooser.setTitle("Select a JDK");
    dirChooser.setInitialDirectory(new File(jdkDir));

    File d = dirChooser.showDialog(stage);
    if (d != null) {
        if (logger.isDebugEnabled()) {
            logger.debug("[BROWSE FOR JDK] selected dir={}", d.getAbsolutePath());
        }
        tfJDKHome.setText(d.getAbsolutePath());
        jdkDir = FilenameUtils.getFullPath(d.getAbsolutePath());
    }
}

From source file:analyzer.code.FXMLAnalyzerController.java

@FXML
private void openProjectMenuItem() throws FileNotFoundException, IOException {
    source.clear();// w w  w .  j a va  2s  .c o  m
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle("C project");
    File selectedDirectory = chooser.showDialog(null);
    if (null != selectedDirectory) {
        File[] files = selectedDirectory.listFiles();
        for (File file : files) {
            if (FilenameUtils.getExtension(file.getAbsolutePath()).equals("java")) {
                analyzer = new AnalyzerC();
                curLang = C;
                countOperatorsEnable = true;
                levelNestEnable = true;
                middleLenIdentEnable = true;
                tableMetric.setVisible(true);
                tableDescript.setVisible(true);
                labelDesc.setVisible(true);
                labelMetrics.setVisible(true);
                button.setVisible(true);
                Scanner scanner = new Scanner(file);
                nameFile.add(FilenameUtils.getName(file.getAbsolutePath()));
                String tmpSource = new String();
                while (scanner.hasNext()) {
                    tmpSource += scanner.nextLine() + '\n';
                }
                source.add(tmpSource);
            }
        }
    }
}

From source file:caillou.company.clonemanager.gui.customComponent.location.LocationController.java

@FXML
private void handleFilechooserAction(ActionEvent event) {
    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle(SpringFxmlLoader.getResourceBundle().getString("title.selectDirectory"));
    File file = directoryChooser.showDialog(null);
    if (file != null) {
        path.setText(file.getAbsolutePath());
    }//from   ww  w.ja v  a  2s .  c  o m
}

From source file:ch.unibas.fittingwizard.presentation.MoleculeListPage.java

public void handleLoadExisting(ActionEvent event) {
    logger.info("Loading existing molecule.");

    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setInitialDirectory(moleculeDir.getDirectory());
    chooser.setTitle("Please select a molecule.");
    File selectedDir = chooser.showDialog(this.getScene().getWindow());
    if (selectedDir == null) {
        logger.info("User skipped.");
        return;/*  w w  w . j  a  va  2s .c  o  m*/
    }

    String moleculeName = selectedDir.getName();
    if (moleculeRepository.checkIfExists(new MoleculeId(moleculeName))) {
        logger.info("Molecule already loaded.");
        OverlayDialog.informUser("Molecule already loaded!",
                "The selected molecule was already loaded. Please select another molecule.");
        return;
    }

    File xyzFile = new File(selectedDir.getParentFile(), moleculeName + ".xyz");
    if (!xyzFile.isFile()) {
        logger.error("XYZ file not found. Skipping.");
        String format = String.format("No xyz file (%s) found for selected molecule %s.",
                xyzFile.getAbsolutePath(), moleculeName);
        OverlayDialog.showError("Could not load molecule", format);
        return;
    }

    xyzFile = copyFilesToMoleculesDir(selectedDir, xyzFile);

    XyzFile parse = null;
    try {
        parse = XyzFileParser.parse(xyzFile);
    } catch (Exception e) {
        OverlayDialog.showError("Could not load molecule",
                "Error while parsing the xyz file " + xyzFile.getAbsolutePath());
    }

    navigateTo(AtomTypeChargePage.class, new AtomChargesDto(parse));
}

From source file:vkmanager.controller.PhotosDetailedController.java

public void saveAlbumOnHard() throws MalformedURLException, IOException {
    int i = 0;/*from  w w  w.java2  s .  c  o m*/
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle("  ? ?? ");
    String userDir = System.getProperty("user.home");
    File defaultDirectory = new File(userDir + "/Desktop");
    chooser.setInitialDirectory(defaultDirectory);
    File selectedDirectory = chooser.showDialog(null);

    System.out.println(selectedDirectory);

    if (selectedDirectory != null) {
        for (VKPhoto photo : photos) {
            i++;
            URL photoUrl = new URL(photo.getLink_l());
            File file = new File(selectedDirectory.toString() + "\\" + photo.getId() + ".jpg");
            FileUtils.copyURLToFile(photoUrl, file);
        }
    }
}

From source file:org.beryx.viewreka.fxapp.ProjectBasicInfo.java

public void chooseProjectDir() {
    DirectoryChooser dirChooser = new DirectoryChooser();
    dirChooser.setTitle("New Project Directory");

    GuiSettings guiSettings = guiSettingsManager.getSettings();
    dirChooser.setInitialDirectory(guiSettings.getMostRecentProjectDir());

    File projectDir = dirChooser.showDialog(getScene().getWindow());
    if (projectDir != null && projectDir.isDirectory()) {
        txtNewProjectDir.setText(projectDir.getAbsolutePath());
        String prjName = toProjectName(projectDir.getName());
        if (isProjectNameValid(prjName)) {
            txtNewProjectName.setText(prjName);
        }/*from w w  w.  j  a  va2s.c o  m*/
    }
}