Search in sources :

Example 21 with FileChooser

use of javafx.stage.FileChooser in project jgnash by ccavanaugh.

the class ExportAccountsAction method showAndWait.

public static void showAndWait() {
    final ResourceBundle resources = ResourceUtils.getBundle();
    final FileChooser fileChooser = configureFileChooser();
    fileChooser.setTitle(resources.getString("Title.SelFile"));
    final File file = fileChooser.showSaveDialog(MainView.getPrimaryStage());
    if (file != null) {
        Preferences pref = Preferences.userNodeForPackage(ExportAccountsAction.class);
        pref.put(LAST_DIR, file.getParentFile().getAbsolutePath());
        final ExportTask exportTask = new ExportTask(Paths.get(FileUtils.stripFileExtension(file.getAbsolutePath()) + ".xml"));
        new Thread(exportTask).start();
        MainView.getInstance().setBusy(exportTask);
    }
}
Also used : FileChooser(javafx.stage.FileChooser) ResourceBundle(java.util.ResourceBundle) Preferences(java.util.prefs.Preferences) File(java.io.File)

Example 22 with FileChooser

use of javafx.stage.FileChooser in project jgnash by ccavanaugh.

the class ImportAccountsAction method showAndWait.

public static void showAndWait() {
    final ResourceBundle resources = ResourceUtils.getBundle();
    final FileChooser fileChooser = configureFileChooser();
    fileChooser.setTitle(resources.getString("Title.SelFile"));
    final File file = fileChooser.showOpenDialog(MainView.getPrimaryStage());
    if (file != null) {
        Preferences pref = Preferences.userNodeForPackage(ImportAccountsAction.class);
        pref.put(LAST_DIR, file.getParentFile().getAbsolutePath());
        final ImportTask importTask = new ImportTask(Paths.get(FileUtils.stripFileExtension(file.getAbsolutePath()) + ".xml"));
        new Thread(importTask).start();
        MainView.getInstance().setBusy(importTask);
    }
}
Also used : FileChooser(javafx.stage.FileChooser) ResourceBundle(java.util.ResourceBundle) Preferences(java.util.prefs.Preferences) File(java.io.File)

Example 23 with FileChooser

use of javafx.stage.FileChooser in project jgnash by ccavanaugh.

the class ImportOfxAction method showAndWait.

public static void showAndWait() {
    final ResourceBundle resources = ResourceUtils.getBundle();
    final FileChooser fileChooser = configureFileChooser();
    fileChooser.setTitle(resources.getString("Title.SelFile"));
    final File file = fileChooser.showOpenDialog(MainView.getPrimaryStage());
    if (file != null) {
        Preferences pref = Preferences.userNodeForPackage(ImportOfxAction.class);
        pref.put(LAST_DIR, file.getParentFile().getAbsolutePath());
        new Thread(new ImportTask(file)).start();
    }
}
Also used : FileChooser(javafx.stage.FileChooser) ResourceBundle(java.util.ResourceBundle) Preferences(java.util.prefs.Preferences) File(java.io.File)

Example 24 with FileChooser

use of javafx.stage.FileChooser in project jgnash by ccavanaugh.

the class ImportQifAction method configureFileChooser.

private static FileChooser configureFileChooser() {
    final Preferences pref = Preferences.userNodeForPackage(ImportQifAction.class);
    final FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(new File(pref.get(LAST_DIR, System.getProperty("user.home"))));
    fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Qif Files (*.qif)", "*.qif"));
    return fileChooser;
}
Also used : FileChooser(javafx.stage.FileChooser) Preferences(java.util.prefs.Preferences) File(java.io.File)

Example 25 with FileChooser

use of javafx.stage.FileChooser in project jgnash by ccavanaugh.

the class ChartUtilities method saveChart.

static void saveChart(final Pane pane) {
    final FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle(ResourceUtils.getString("Title.SaveFile"));
    fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("PNG", "*.png"));
    final File file = fileChooser.showSaveDialog(MainView.getPrimaryStage());
    if (file != null) {
        final WritableImage image = takeSnapshot(pane);
        try {
            final String type = FileUtils.getFileExtension(file.toString().toLowerCase(Locale.ROOT));
            ImageIO.write(SwingFXUtils.fromFXImage(image, null), type, file);
        } catch (final IOException e) {
            StaticUIMethods.displayException(e);
        }
    }
}
Also used : WritableImage(javafx.scene.image.WritableImage) FileChooser(javafx.stage.FileChooser) IOException(java.io.IOException) File(java.io.File)

Aggregations

FileChooser (javafx.stage.FileChooser)64 File (java.io.File)59 Preferences (java.util.prefs.Preferences)21 IOException (java.io.IOException)17 ResourceBundle (java.util.ResourceBundle)11 FXML (javafx.fxml.FXML)11 FileOutputStream (java.io.FileOutputStream)5 ArrayList (java.util.ArrayList)5 Alert (javafx.scene.control.Alert)5 Button (javafx.scene.control.Button)4 Popup (io.bitsquare.gui.main.overlays.popups.Popup)3 List (java.util.List)3 GargoyleFileAlreadyExistException (com.kyj.fx.voeditor.visual.exceptions.GargoyleFileAlreadyExistException)2 Palette (fractal.Palette)2 Path (java.nio.file.Path)2 ObservableList (javafx.collections.ObservableList)2 FilteredList (javafx.collections.transformation.FilteredList)2 SortedList (javafx.collections.transformation.SortedList)2 Task (javafx.concurrent.Task)2 Insets (javafx.geometry.Insets)2