Search in sources :

Example 76 with FileChooser

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

the class ExecuteJavaScriptAction method configureFileChooser.

private static FileChooser configureFileChooser() {
    final Preferences pref = Preferences.userNodeForPackage(ExecuteJavaScriptAction.class);
    final FileChooser fileChooser = new FileChooser();
    final File initialDirectory = new File(pref.get(LAST_DIR, System.getProperty("user.home")));
    // Protect against an IllegalArgumentException
    if (initialDirectory.isDirectory()) {
        fileChooser.setInitialDirectory(initialDirectory);
    }
    fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("JavaScript Files", "*.js"));
    fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("All Files", "*.*"));
    return fileChooser;
}
Also used : FileChooser(javafx.stage.FileChooser) Preferences(java.util.prefs.Preferences) File(java.io.File)

Example 77 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 78 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();
    final File initialDirectory = new File(pref.get(LAST_DIR, System.getProperty("user.home")));
    // Protect against an IllegalArgumentException
    if (initialDirectory.isDirectory()) {
        fileChooser.setInitialDirectory(initialDirectory);
    }
    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 79 with FileChooser

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

the class ImportMt940FxAction method showAndWait.

static void showAndWait() {
    final ResourceBundle resources = ResourceUtils.getBundle();
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    if (engine == null || engine.getRootAccount().getChildCount() == 0) {
        StaticUIMethods.displayError(resources.getString("Message.Error.CreateBasicAccounts"));
        return;
    }
    final FileChooser fileChooser = configureFileChooser();
    fileChooser.setTitle(resources.getString("Title.SelFile"));
    final File file = fileChooser.showOpenDialog(MainView.getPrimaryStage());
    if (file != null) {
        Preferences pref = Preferences.userNodeForPackage(ImportMt940FxAction.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) Engine(jgnash.engine.Engine)

Example 80 with FileChooser

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

the class ImportMt940FxAction method configureFileChooser.

private static FileChooser configureFileChooser() {
    final Preferences pref = Preferences.userNodeForPackage(ImportMt940FxAction.class);
    final FileChooser fileChooser = new FileChooser();
    final File initialDirectory = new File(pref.get(LAST_DIR, System.getProperty("user.home")));
    // Protect against an IllegalArgumentException
    if (initialDirectory.isDirectory()) {
        fileChooser.setInitialDirectory(initialDirectory);
    }
    fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("All Files (*.*)", "*.*"));
    return fileChooser;
}
Also used : FileChooser(javafx.stage.FileChooser) Preferences(java.util.prefs.Preferences) File(java.io.File)

Aggregations

FileChooser (javafx.stage.FileChooser)208 File (java.io.File)189 IOException (java.io.IOException)55 FXML (javafx.fxml.FXML)49 Preferences (java.util.prefs.Preferences)24 Button (javafx.scene.control.Button)21 ArrayList (java.util.ArrayList)19 VBox (javafx.scene.layout.VBox)15 ResourceBundle (java.util.ResourceBundle)14 ExtensionFilter (javafx.stage.FileChooser.ExtensionFilter)14 Stage (javafx.stage.Stage)14 Label (javafx.scene.control.Label)13 Alert (javafx.scene.control.Alert)12 List (java.util.List)11 TextField (javafx.scene.control.TextField)11 ScriptException (javax.script.ScriptException)11 Scene (javafx.scene.Scene)10 Map (java.util.Map)9 ObservableList (javafx.collections.ObservableList)9 MenuItem (javafx.scene.control.MenuItem)9