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:org.noroomattheinn.visibletesla.TripController.java

@FXML
void exportItHandler(ActionEvent event) {
    String initialDir = prefs.storage().get(App.LastExportDirKey, System.getProperty("user.home"));
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export Trip as KMZ");
    fileChooser.setInitialDirectory(new File(initialDir));

    File file = fileChooser.showSaveDialog(app.stage);
    if (file != null) {
        String enclosingDirectory = file.getParent();
        if (enclosingDirectory != null)
            prefs.storage().put(App.LastExportDirKey, enclosingDirectory);
        if (vtData.exportTripsAsKML(getSelectedTrips(), file)) {
            Dialogs.showInformationDialog(app.stage, "Your data has been exported", "Data Export Process",
                    "Export Complete");
        } else {//from   ww w .j  ava  2  s. c  om
            Dialogs.showWarningDialog(app.stage, "There was a problem exporting your trip data to KMZ",
                    "Data Export Process", "Export Failed");
        }
    }
}

From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java

private void parseJSON() {
    //Show the File Chooser
    FileChooser fc = new FileChooser();
    fc.setTitle("Select Starbound AccessControl.config File");
    File starbound = fc.showOpenDialog(null);
    config = starbound;//w  w  w .  j  av a2s .c  o  m
    if (starbound != null) {
        try {
            FileInputStream fis = new FileInputStream(starbound);
            JSONTokener jst = new JSONTokener(fis);
            JSONObject jsob = new JSONObject(jst);

            JSONObject accounts = jsob.getJSONObject("accounts");
            JSONArray banned_accounts = jsob.getJSONArray("bannedAccountNames");
            JSONArray banned_addresses = jsob.getJSONArray("bannedAddresses");
            JSONArray banned_players = jsob.getJSONArray("bannedPlayerNames");

            Iterator account_keys = accounts.keys();
            while (account_keys.hasNext()) {
                String key = (String) account_keys.next();
                users.remove(key);
                users.add(key);
                userpasswords.put(key, accounts.getJSONObject(key).getString("password"));
            }

            for (int i = 0; i < banned_accounts.length(); i++) {
                banned_usernames.add(banned_accounts.getString(i));
            }
            for (int i = 0; i < banned_addresses.length(); i++) {
                banned_ips.add(banned_addresses.getString(i));
            }
            for (int i = 0; i < banned_players.length(); i++) {
                banned_playernames.add(banned_players.getString(i));
            }

        } catch (FileNotFoundException ex) {
            //In theory this shouldn't happen.
            System.exit(1);
        } catch (JSONException ex) {
            ex.printStackTrace();
            System.exit(1);
        }
    }

}

From source file:fr.amap.commons.javafx.chart.ChartViewer.java

/**
* A handler for the export to SVG option in the context menu.
*//*from w ww .  j  ava  2 s  . co m*/
private void handleExportToSVG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to SVG");
    fileChooser.setSelectedExtensionFilter(
            new FileChooser.ExtensionFilter("Scalable Vector Graphics (SVG)", "svg"));
    File file = fileChooser.showSaveDialog(stage);
    if (file != null) {

        CanvasPositionsAndSize canvasPositionAndSize = getCanvasPositionAndSize();

        SVGGraphics2D sVGGraphics2D = new SVGGraphics2D((int) canvasPositionAndSize.totalWidth,
                (int) canvasPositionAndSize.totalHeight);

        Graphics2D graphics2D = (Graphics2D) sVGGraphics2D.create();

        int index = 0;
        for (ChartCanvas canvas : chartCanvasList) {

            ((Drawable) canvas.chart).draw(graphics2D, canvasPositionAndSize.positionsAndSizes.get(index));
            index++;
        }

        try {
            SVGUtils.writeToSVG(file, sVGGraphics2D.getSVGElement());
        } catch (IOException ex) {
            Logger.getLogger(ChartViewer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:fr.amap.commons.javafx.chart.ChartViewer.java

/**
 * A handler for the export to JPEG option in the context menu.
 *//*from  www  . j a v a  2  s .c  o  m*/
private void handleExportToJPEG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to JPEG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("JPEG", "jpg"));
    File file = fileChooser.showSaveDialog(stage);
    if (file != null) {
        try {
            CanvasPositionsAndSize canvasPositionAndSize = getCanvasPositionAndSize();

            BufferedImage image = new BufferedImage((int) canvasPositionAndSize.totalWidth,
                    (int) canvasPositionAndSize.totalHeight, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = image.createGraphics();

            int index = 0;
            for (ChartCanvas canvas : chartCanvasList) {

                Rectangle2D rectangle2D = canvasPositionAndSize.positionsAndSizes.get(index);

                ((Drawable) canvas.chart).draw(g2, new Rectangle((int) rectangle2D.getX(),
                        (int) rectangle2D.getY(), (int) rectangle2D.getWidth(), (int) rectangle2D.getHeight()));
                index++;
            }

            try (OutputStream out = new BufferedOutputStream(new FileOutputStream(file))) {
                ImageIO.write(image, "jpg", out);
            }

            /*ExportUtils.writeAsJPEG(chartCanvasList.get(0).chart, (int)chartCanvasList.get(0).getWidth(),
                (int)chartCanvasList.get(0).getHeight(), file);*/
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }
}

From source file:fr.amap.commons.javafx.chart.ChartViewer.java

/**
 * A handler for the export to PNG option in the context menu.
 *//* www. ja va2  s  .  c  o  m*/
private void handleExportToPNG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to PNG");
    fileChooser.setSelectedExtensionFilter(
            new FileChooser.ExtensionFilter("Portable Network Graphics (PNG)", "png"));
    File file = fileChooser.showSaveDialog(stage);

    if (file != null) {
        try {

            CanvasPositionsAndSize canvasPositionAndSize = getCanvasPositionAndSize();

            BufferedImage image = new BufferedImage((int) canvasPositionAndSize.totalWidth,
                    (int) canvasPositionAndSize.totalHeight, BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = image.createGraphics();

            int index = 0;
            for (ChartCanvas canvas : chartCanvasList) {

                Rectangle2D rectangle2D = canvasPositionAndSize.positionsAndSizes.get(index);

                ((Drawable) canvas.chart).draw(g2, new Rectangle((int) rectangle2D.getX(),
                        (int) rectangle2D.getY(), (int) rectangle2D.getWidth(), (int) rectangle2D.getHeight()));
                index++;
            }

            try (OutputStream out = new BufferedOutputStream(new FileOutputStream(file))) {
                ImageIO.write(image, "png", out);
            }

        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }
}

From source file:memoryaid.SetReminderController.java

@FXML
private void handleUploadImageAction(ActionEvent event) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Open Resource File");
    File selectedImage = fileChooser.showOpenDialog((Stage) ((Node) event.getSource()).getScene().getWindow());
    imagePathText.setText(selectedImage.getAbsolutePath());

}

From source file:mesclasses.view.RootLayoutController.java

@FXML
public void handleLoad() {
    FileChooser chooser = new FileChooser();
    chooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Fichiers de sauvegarde", "*.xml"));
    chooser.setTitle("Slectionnez un fichier de sauvegarde");
    chooser.setInitialDirectory(new File(FileConfigurationManager.getInstance().getBackupDir()));
    File file = chooser.showOpenDialog(primaryStage);
    if (file == null) {
        return;/*from www .j  a v a 2 s . c o  m*/
    }
    if (DataLoadUtil.isfileEmpty(file)) {
        ModalUtil.alert("Impossible de lire les donnes du fichier", "Ce fichier est vide");
        return;
    }
    ObservableData data;
    try {
        data = DataLoadUtil.initializeData(file);
    } catch (Exception e) {
        ModalUtil.alert("Impossible de lire les donnes du fichier",
                "Ce fichier n'est pas un fichier de sauvegarde " + Constants.APPLICATION_TITLE + " valide");
        return;
    }
    if (ModalUtil.confirm("Charger le fichier " + file.getName(), "Les donnes actuelles seront perdues")) {
        FileSaveUtil.restoreBackupFile(file);
        loadData(data);
    }
}

From source file:mesclasses.view.RootLayoutController.java

@FXML
public void onImport() {
    if (ModalUtil.confirm("Importer des donnes",
            "Cette opration crasera les donnes existantes.\nEtes-vous sr(e) ?")) {
        FileChooser chooser = new FileChooser();
        chooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Archive MesClasses", "*.zip"));
        chooser.setTitle("Slectionnez une archive");
        chooser.setInitialDirectory(new File(FileConfigurationManager.getInstance().getArchivesDir()));
        File file = chooser.showOpenDialog(primaryStage);
        if (file == null) {
            return;
        }/*from w  w w .j  av  a2 s . c om*/
        try {
            FileSaveUtil.restoreArchive(file);
        } catch (IOException e) {
            notif(e);
            return;
        }
        try {
            ObservableData data = DataLoadUtil.initializeData(FileSaveUtil.getSaveFile());
            loadData(data);
        } catch (Exception e) {
            notif(e);
        }
    }
}

From source file:org.craftercms.social.migration.controllers.MainController.java

@Override
public void initialize(final URL location, final ResourceBundle resources) {
    configTable();/*from  w w  w. ja va  2s. c om*/
    mnuQuit.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            stopTasks();
            Platform.exit();
        }
    });
    ctxClearLog.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            logTable.getItems().clear();
        }
    });
    ctxClearProfileSelection.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstProfileScripts.getSelectionModel().clearSelection();
        }
    });
    ctxClearSocialSelection.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstSocialScripts.getSelectionModel().clearSelection();
        }
    });

    lstProfileScripts.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    lstSocialScripts.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    lstProfileScripts.setCellFactory(new Callback<ListView, ListCell>() {
        @Override
        public ListCell call(final ListView listView) {
            return new FileListCell();
        }
    });
    lstSocialScripts.setCellFactory(new Callback<ListView, ListCell>() {
        @Override
        public ListCell call(final ListView listView) {
            return new FileListCell();
        }
    });
    ctxReloadProfileScrp.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstProfileScripts.getItems().clear();
            try {
                extractBuildInScripts("profile", lstProfileScripts);
            } catch (MigrationException e) {
                log.error("Unable to extract BuildIn scripts");
            }
            loadScripts(MigrationTool.systemProperties.getString("crafter.migration.profile.scripts"),
                    lstProfileScripts);
        }
    });
    ctxReloadSocialScrp.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent actionEvent) {
            lstSocialScripts.getItems().clear();
            try {
                extractBuildInScripts("profile", lstSocialScripts);
            } catch (MigrationException e) {
                log.error("Unable to extract BuildIn scripts");
            }
            loadScripts(MigrationTool.systemProperties.getString("crafter.migration.social.scripts"),
                    lstSocialScripts);
        }
    });
    final MigrationSelectionAction selectionEventHandler = new MigrationSelectionAction();
    rbtMigrateProfile.setOnAction(selectionEventHandler);
    rbtMigrateSocial.setOnAction(selectionEventHandler);
    loadScripts();
    loadDefaultValues();
    saveLog.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN));
    saveLog.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent event) {
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("Save Migration Log");
            fileChooser.setInitialFileName("Crafter-Migration-"
                    + new SimpleDateFormat("yyyy-MM-dd@HH_mm").format(new Date()) + ".html");
            final File savedFile = fileChooser.showSaveDialog(scene.getWindow());
            if (savedFile == null) {
                return;
            }
            try {
                getHtml(new FileWriter(savedFile));
                log.info("Saved Html log file");
            } catch (IOException | TransformerException ex) {
                log.error("Unable to save file", ex);
            }
        }
    });
    mnuStart.setAccelerator(new KeyCodeCombination(KeyCode.F5));
    mnuStart.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent event) {

            if (currentTask == null || !currentTask.isRunning()) {
                ObservableList scriptsToRun;
                if (rbtMigrateProfile.isSelected()) {
                    scriptsToRun = lstProfileScripts.getSelectionModel().getSelectedItems();
                } else {
                    scriptsToRun = lstSocialScripts.getSelectionModel().getSelectedItems();
                }
                currentTask = new MigrationPipeService(logTable, pgbTaskProgress, srcHost.getText(),
                        srcPort.getText(), srcDb.getText(), dstHost.getText(), dstPort.getText(),
                        dstDb.getText(), scriptsToRun);
            }
            if (!currentTask.isRunning()) {
                final Thread t = new Thread(currentTask, "Migration Task");
                t.start();
            }
        }
    });
}

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

private void saveProjectAs() {
    FileChooser chooser = new FileChooser();
    chooser.setTitle("Project Creator");
    File directoryFile = chooser.showSaveDialog(null);
    if (directoryFile != null) {
        GUIProject activeProject = getActive();
        if (activeProject != null) {
            GUIProject newProject = GUIProject.replace(appName, activeProject);

            try {
                newProject.createProject(directoryFile.toPath());
                newProject.saveProject();
            } catch (IOException ex) {
                ExceptionDialog dialog = new ExceptionDialog(ex);
                dialog.showAndWait();//from ww w . j  a  v a 2 s.  c om
            }
        }
    }

}