Example usage for javafx.stage FileChooser setTitle

List of usage examples for javafx.stage FileChooser setTitle

Introduction

In this page you can find the example usage for javafx.stage FileChooser setTitle.

Prototype

public final void setTitle(final String value) 

Source Link

Usage

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private FileChooser getLabFileChooser(String operation) {
    File labdir = getLabDir();//from www . jav  a2s.  co m
    FileChooser chooser = new FileChooser();

    chooser.setInitialDirectory(labdir);
    chooser.setTitle(operation + " ESP Lab Settings");
    chooser.getExtensionFilters().add(new ExtensionFilter("ESP Lab Files", "*.lab"));
    return chooser;
}

From source file:net.rptools.tokentool.controller.TokenTool_Controller.java

private void saveToken() {
    FileChooser fileChooser = new FileChooser();

    try {//from www. j  a  va  2  s .c  o  m
        File tokenFile = fileSaveUtil.getFileName(false, useFileNumberingCheckbox.isSelected(),
                fileNameTextField.getText(), fileNameSuffixTextField);
        fileChooser.setInitialFileName(tokenFile.getName());
        if (tokenFile.getParentFile() != null)
            if (tokenFile.getParentFile().isDirectory())
                fileChooser.setInitialDirectory(tokenFile.getParentFile());
    } catch (IOException e1) {
        log.error("Error writing token!", e1);
    }

    fileChooser.getExtensionFilters().addAll(AppConstants.IMAGE_EXTENSION_FILTER);
    fileChooser.setTitle(I18N.getString("TokenTool.save.filechooser.title"));
    fileChooser.setSelectedExtensionFilter(AppConstants.IMAGE_EXTENSION_FILTER);

    File tokenSaved = fileChooser.showSaveDialog(saveOptionsPane.getScene().getWindow());

    if (tokenSaved == null)
        return;

    writeTokenImage(tokenSaved);

    updateFileNameTextField(FilenameUtils.getBaseName(tokenSaved.getName()));
    FileSaveUtil.setLastFile(tokenSaved);
    updateOverlayTreeViewRecentFolder(true);
}

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

@FXML
public void browseSource() {
    if (logger.isDebugEnabled()) {
        logger.debug("[BROWSE SOURCE]");
    }//from   w  ww  .j a va 2s .c  o  m

    clearValidationErrors();

    switch (activeProfile.getArgsType()) {
    case JAR:
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("Select Source JAR");
        fileChooser.setInitialDirectory(new File(jarDir));
        fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("JAR", "*.jar"));

        File f = fileChooser.showOpenDialog(stage);
        if (f != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("[BROWSE SOURCE] selected file={}", f.getAbsolutePath());
            }
            tfSourceFile.setText(f.getAbsolutePath());

            jarDir = FilenameUtils.getFullPath(f.getAbsolutePath());
        }
        break;
    case FOLDER:
        DirectoryChooser dirChooser = new DirectoryChooser();
        dirChooser.setTitle("Select Source Folder");
        dirChooser.setInitialDirectory(new File(jarDir));

        File d = dirChooser.showDialog(stage);
        if (d != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("[BROWSE SOURCE] selected dir={}", d.getAbsolutePath());
            }
            tfSourceFile.setText(d.getAbsolutePath());

            jarDir = FilenameUtils.getFullPath(d.getAbsolutePath());
        }
        break;
    }
}

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

@FXML
public void browseTarget() {
    if (logger.isDebugEnabled()) {
        logger.debug("[BROWSE TARGET]");
    }//  w w w .ja  v  a  2  s .  c  o  m

    clearValidationErrors();

    switch (activeProfile.getArgsType()) {
    case JAR:
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("Select Target JAR");
        fileChooser.setInitialDirectory(new File(jarDir));
        fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("JAR", "*.jar"));

        File f = fileChooser.showOpenDialog(stage);
        if (f != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("[BROWSE TARGET] selected file={}", f.getAbsolutePath());
            }
            tfTargetFile.setText(f.getAbsolutePath());

            jarDir = FilenameUtils.getFullPath(f.getAbsolutePath());
        }
        break;
    case FOLDER:
        DirectoryChooser dirChooser = new DirectoryChooser();
        dirChooser.setTitle("Select Target Folder");
        dirChooser.setInitialDirectory(new File(jarDir));

        File d = dirChooser.showDialog(stage);
        if (d != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("[BROWSE TARGET] selected dir={}", d.getAbsolutePath());
            }
            tfTargetFile.setText(d.getAbsolutePath());

            jarDir = FilenameUtils.getFullPath(d.getAbsolutePath());
        }
        break;
    }
}

From source file:UI.MainStageController.java

/**
 * <h1>Lets the user choose a file / files to load.</h1>
 * Distinguishes which filetype is about to be loaded by the user
 * and calls the associated methods.// w ww  .  j a v  a 2s  .c om
 *
 * @param fileType Enum to differentiate which type of file is loaded by the user.
 */
private void openFiles(FileType fileType) {
    FileChooser fileChooser = new FileChooser();
    String fileChooserTitle = "Load from ";

    if ((Boolean) UserSettings.userSettings.get("isDefaultFileChooserLocation")) {
        setDefaultOpenDirectory(fileChooser);
    } else {
        fileChooser.setInitialDirectory(
                new File((String) UserSettings.userSettings.get("defaultFileChooserLocation")));
    }

    switch (fileType) {
    case taxonId2Count:
        fileChooser.setTitle(fileChooserTitle + "taxonId2Count file");
        break;
    case readName2TaxonId:
        fileChooser.setTitle(fileChooserTitle + "readName2TaxonId file");
        break;
    case biomV1:
        fileChooser.setTitle(fileChooserTitle + "biomV1 file");
        break;
    case biomV2:
        fileChooser.setTitle(fileChooserTitle + "biomV2 file");
        break;
    case qiime:
        fileChooser.setTitle(fileChooserTitle + "qiime file");
        break;
    }

    //Choose the file / files

    List<File> selectedFiles = fileChooser.showOpenMultipleDialog(getPrimaryStage());

    if (selectedFiles != null) {
        //Keeps every file that has been loaded before in a list to show only one alert
        //for multiple files
        ArrayList<String> namesOfAlreadyLoadedFiles = new ArrayList<>();
        for (File file : selectedFiles) {
            String foundFilePath = file.getAbsolutePath();
            if (LoadedData.getOpenFiles() != null && LoadedData.getOpenFiles().contains(foundFilePath)) {
                namesOfAlreadyLoadedFiles.add(file.getName());
            } else {
                switch (fileType) {
                case taxonId2Count:
                    addId2CountFileToTreeView(file);
                    break;
                case readName2TaxonId:
                    addReadName2TaxonIdFileToTreeView(file);
                    break;
                case biomV1:
                    addBiomV1FileToTreeView(file);
                    break;
                case biomV2:
                    addBiomV2FileToTreeView(file);
                    break;
                case qiime:
                    //TODO HANDLE METADATA PROVIDED BY QIIME
                    break;
                }
            }
        }
        //Shows an alert if the user chose to load one or multiple files
        //that have already been loaded before.
        if (namesOfAlreadyLoadedFiles.size() != 0) {
            showFileAlreadyLoadedAlert(namesOfAlreadyLoadedFiles);
        }
    }

}

From source file:ui.main.MainViewController.java

private void sendImage() {
    if (!contactsManager.getAvailabilityforSharing(currentChat.getParticipant())) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Attention!");
        alert.setHeaderText("The user is not available!");
        alert.setContentText("The file receiving user should be available online to receive the file.");
        alert.showAndWait();//from  ww  w.j av a2 s.c  o m
        return;
    }
    ItemType type = contactsManager.getUserType(currentChat.getParticipant());
    if (type.equals(ItemType.none)) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Attention!");
        alert.setHeaderText("The is not available for you!");
        alert.setContentText(
                "The user has not accepted the Friend Request." + " The user is not available for you.");
        alert.showAndWait();
        return;
    } else if (type.equals(ItemType.from)) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Attention!");
        alert.setHeaderText("The user has not accepted!");
        alert.setContentText("The user has not accepted the Friend Request."
                + " You can not send any messages until the user accepts the friend request.");
        alert.showAndWait();
        return;
    } else if (type.equals(ItemType.to)) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Attention!");
        alert.setHeaderText("The user has not accepted!");
        alert.setContentText("The user has not accepted the Friend Request."
                + " You can not send any messages until the user accepts the friend request.");
        alert.showAndWait();
        return;
    }
    try {
        FileChooser fc = new FileChooser();
        fc.setTitle("Choose an image to send");
        fc.getExtensionFilters().addAll(
                new FileChooser.ExtensionFilter("All Images", "*.jpg*", "*.png", "*.bmp"),
                new FileChooser.ExtensionFilter("JPG", "*.jpg"),
                new FileChooser.ExtensionFilter("PNG", "*.png"),
                new FileChooser.ExtensionFilter("BMP", "*.bmp"));

        File file = fc.showOpenDialog(presence.getScene().getWindow());
        if (file == null) {
            return;
        }
        BufferedImage image = ImageIO.read(file);
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    fileManager.sendFile(file, currentChat.getParticipant());
                    if (history.isSelected()) {
                        Timestamp time = new Timestamp(System.currentTimeMillis());
                        DBSingleChat.savePictureMessage(currentChat.getParticipant(), false, file.getPath(),
                                time);
                    }

                    paintSentPhoto(currentChat, file, dtfT.print(DateTime.now()));

                    Task tt = new Task() {
                        @Override
                        protected Object call() throws Exception {
                            Thread.sleep(500);
                            return new Object();
                        }
                    };

                    tt.setOnSucceeded(value -> scrollPane.setVvalue(scrollPane.getHmax()));

                    Thread thread1 = new Thread(tt);
                    thread1.start();
                } catch (FileNotFoundException ex) {
                    Alert alert = new Alert(Alert.AlertType.ERROR);
                    alert.setTitle("IMP");
                    alert.setHeaderText("File is not Found!");
                    alert.setContentText("File you selected does not exist.");
                    alert.showAndWait();
                    return;
                }
            }
        });
        t.start();
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:de.bayern.gdi.gui.Controller.java

/**
 * Opens up a file dialog to choose a config file to load.
 *
 * @return The chosen file/*w  w w  . ja va  2  s .  co m*/
 */
protected File openConfigFileOpenDialog() {
    FileChooser fileChooser = new FileChooser();
    File initialDir = new File(
            Config.getInstance().getServices().getBaseDirectory().isEmpty() ? System.getProperty(USER_DIR)
                    : Config.getInstance().getServices().getBaseDirectory());
    fileChooser.setInitialDirectory(initialDir);
    fileChooser.setTitle(I18n.getMsg("menu.load_config"));
    fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("XML Files", "*.xml"),
            new FileChooser.ExtensionFilter("All Files", "*.*"));
    return fileChooser.showOpenDialog(primaryStage);
}

From source file:de.bayern.gdi.gui.Controller.java

/**
 * Handle config saving./*from w w  w  .  ja  va 2 s  .c o m*/
 *
 * @param event The event.
 */
@FXML
protected void handleSaveConfig(ActionEvent event) {
    extractStoredQuery();
    extractBoundingBox();
    extractCql();
    if (validateInput() && validateCqlInput()) {
        FileChooser fileChooser = new FileChooser();
        DirectoryChooser dirChooser = new DirectoryChooser();
        File downloadDir;
        File initDir;

        dirChooser.setTitle(I18n.getMsg("gui.save-dir"));

        if (downloadConfig == null) {
            downloadDir = dirChooser.showDialog(getPrimaryStage());
            String basedir = Config.getInstance().getServices().getBaseDirectory();
            initDir = new File(basedir.isEmpty() ? System.getProperty(USER_DIR) : basedir);
            File uniqueName = Misc.uniqueFile(downloadDir, "config", "xml", null);
            fileChooser.setInitialFileName(uniqueName.getName());
        } else {
            File downloadInitDir = new File(downloadConfig.getDownloadPath());
            if (!downloadInitDir.exists()) {
                downloadInitDir = new File(System.getProperty(USER_DIR));
            }
            dirChooser.setInitialDirectory(downloadInitDir);
            downloadDir = dirChooser.showDialog(getPrimaryStage());

            String path = downloadConfig.getFile().getAbsolutePath();
            path = path.substring(0, path.lastIndexOf(File.separator));
            initDir = new File(path);
            fileChooser.setInitialFileName(downloadConfig.getFile().getName());
        }
        fileChooser.setInitialDirectory(initDir);
        FileChooser.ExtensionFilter xmlFilter = new FileChooser.ExtensionFilter("xml files (*.xml)", "*.xml");
        fileChooser.getExtensionFilters().add(xmlFilter);
        fileChooser.setSelectedExtensionFilter(xmlFilter);
        fileChooser.setTitle(I18n.getMsg("gui.save-conf"));
        File configFile = fileChooser.showSaveDialog(getPrimaryStage());
        if (configFile == null) {
            return;
        }

        if (!configFile.toString().endsWith(".xml")) {
            configFile = new File(configFile.toString() + ".xml");
        }

        this.dataBean.setProcessingSteps(extractProcessingSteps());

        String savePath = downloadDir.getPath();
        DownloadStep ds = dataBean.convertToDownloadStep(savePath);
        try {
            ds.write(configFile);
        } catch (IOException ex) {
            log.warn(ex.getMessage(), ex);
        }
    }
}

From source file:snpviewer.SnpViewer.java

public boolean saveProject() {
    if (projectFile != null) {
        return saveProject(projectFile);
    } else {/*from  w ww. j a  v a2 s  . c  o  m*/
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("Save Snp Viewer Project (.svproj) As...");
        FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("SNP Viewer Projects",
                "*.svproj");
        fileChooser.getExtensionFilters().add(extFilter);
        projectFile = fileChooser.showSaveDialog(mainWindow);
        if (projectFile != null) {
            if (!projectFile.getName().endsWith(".svproj")) {
                projectFile = new File(projectFile.getAbsolutePath() + ".svproj");
            }
            return saveProject(projectFile);

        } else {
            return false;
        }
    }
}

From source file:snpviewer.SnpViewer.java

public void saveColours(ActionEvent e) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save Colour Scheme (.svcols) As...");
    FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("SNP Viewer Colour Scheme",
            "*.svcols");
    fileChooser.getExtensionFilters().add(extFilter);
    File colorFile = fileChooser.showSaveDialog(mainWindow);
    if (colorFile != null) {
        if (!colorFile.getName().endsWith(".svcols")) {
            colorFile = new File(colorFile.getAbsolutePath() + ".svcols");
        }/* w ww  .  java 2s  .co m*/

        try {
            FileOutputStream fos = new FileOutputStream(colorFile);
            try (ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(fos))) {
                for (Color c : colorComp) {
                    out.writeObject(c.toString());
                }
                out.close();
                projectLabel.setText("Project: " + projectFile.getName());
            }
        } catch (IOException ex) {
            Dialogs.showErrorDialog(null, "Could not save colour scheme - IO error", "Save Failed",
                    "SNP Viewer", ex);
        }
    }
}