Search in sources :

Example 86 with Preferences

use of java.util.prefs.Preferences in project jgnash by ccavanaugh.

the class ReportActions method exportBalanceByMonthCSVReport.

public static void exportBalanceByMonthCSVReport() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    Objects.requireNonNull(engine);
    final Preferences preferences = Preferences.userNodeForPackage(ReportActions.class);
    final FXMLUtils.Pair<BalanceByMonthOptionsDialogController> pair = FXMLUtils.load(BalanceByMonthOptionsDialogController.class.getResource("BalanceByMonthOptionsDialog.fxml"), ResourceUtils.getString("Title.ReportOptions"));
    pair.getController().forceDefaultCurrencyProperty().set(preferences.getBoolean(FORCE_CURRENCY, false));
    pair.getStage().setResizable(false);
    pair.getStage().showAndWait();
    final boolean vertical = pair.getController().isVertical();
    final boolean forceCurrency = pair.getController().forceDefaultCurrencyProperty().get();
    final Optional<LocalDate[]> optional = pair.getController().getDates();
    optional.ifPresent(localDates -> {
        final String lastDir = preferences.get(LAST_DIR, null);
        preferences.putBoolean(FORCE_CURRENCY, forceCurrency);
        final FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle(ResourceUtils.getString("Title.SaveFile"));
        if (lastDir != null) {
            fileChooser.setInitialDirectory(new File(lastDir));
        }
        fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("CSV", "*.csv"));
        final File file = fileChooser.showSaveDialog(MainView.getPrimaryStage());
        if (file != null) {
            preferences.put(LAST_DIR, file.getParent());
            final BalanceByMonthCSVReport report;
            if (forceCurrency) {
                report = new BalanceByMonthCSVReport(file.getAbsolutePath(), localDates[0], localDates[1], engine.getDefaultCurrency(), vertical, AccountBalanceDisplayManager::convertToSelectedBalanceMode);
            } else {
                report = new BalanceByMonthCSVReport(file.getAbsolutePath(), localDates[0], localDates[1], null, vertical, AccountBalanceDisplayManager::convertToSelectedBalanceMode);
            }
            report.run();
        }
    });
}
Also used : FXMLUtils(jgnash.uifx.util.FXMLUtils) BalanceByMonthCSVReport(jgnash.report.BalanceByMonthCSVReport) FileChooser(javafx.stage.FileChooser) Preferences(java.util.prefs.Preferences) File(java.io.File) Engine(jgnash.engine.Engine)

Example 87 with Preferences

use of java.util.prefs.Preferences in project jgnash by ccavanaugh.

the class TableViewManager method saveColumnWidths.

private void saveColumnWidths() {
    JavaFXUtils.runLater(() -> {
        if (preferenceKeyFactory.get() != null) {
            final double[] columnWidths = tableView.getColumns().filtered(TableColumnBase::isVisible).stream().mapToDouble(value -> Math.floor(value.getWidth())).toArray();
            final Preferences preferences = Preferences.userRoot().node(preferencesUserRoot + PREF_NODE_REG_WIDTH);
            preferences.put(preferenceKeyFactory.get().get(), EncodeDecode.encodeDoubleArray(columnWidths));
        }
    });
}
Also used : Format(java.text.Format) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) OptionalDouble(java.util.OptionalDouble) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) TableColumn(javafx.scene.control.TableColumn) EncodeDecode(jgnash.util.EncodeDecode) HashSet(java.util.HashSet) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) ObjectProperty(javafx.beans.property.ObjectProperty) NotNull(jgnash.util.NotNull) Set(java.util.Set) Logger(java.util.logging.Logger) Preferences(java.util.prefs.Preferences) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) TableColumnBase(javafx.scene.control.TableColumnBase) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) Preferences(java.util.prefs.Preferences)

Example 88 with Preferences

use of java.util.prefs.Preferences in project jgnash by ccavanaugh.

the class TableViewManager method saveColumnVisibility.

private void saveColumnVisibility() {
    if (preferenceKeyFactory.get() != null) {
        final String uuid = preferenceKeyFactory.get().get();
        final Preferences preferences = Preferences.userRoot().node(preferencesUserRoot + PREF_NODE_REG_VIS);
        final boolean[] columnVisibility = new boolean[tableView.getColumns().size()];
        for (int i = 0; i < columnVisibility.length; i++) {
            columnVisibility[i] = tableView.getColumns().get(i).isVisible();
        }
        preferences.put(uuid, EncodeDecode.encodeBooleanArray(columnVisibility));
    }
}
Also used : Preferences(java.util.prefs.Preferences)

Example 89 with Preferences

use of java.util.prefs.Preferences in project jgnash by ccavanaugh.

the class AbstractSumByTypeReport method handleRefresh.

@FXML
private void handleRefresh() {
    final Preferences preferences = getPreferences();
    preferences.putBoolean(HIDE_ZERO_BALANCE, hideZeroBalanceAccounts.isSelected());
    preferences.putInt(MONTHS, DateUtils.getLastDayOfTheMonths(startDatePicker.getValue(), endDatePicker.getValue()).size());
    if (refreshCallBackProperty().get() != null) {
        refreshCallBackProperty().get().run();
    }
}
Also used : Preferences(java.util.prefs.Preferences) FXML(javafx.fxml.FXML)

Example 90 with Preferences

use of java.util.prefs.Preferences in project jgnash by ccavanaugh.

the class AbstractSumByTypeReport method initialize.

@FXML
private void initialize() {
    final Preferences preferences = getPreferences();
    hideZeroBalanceAccounts.setSelected(preferences.getBoolean(HIDE_ZERO_BALANCE, true));
    startDatePicker.setValue(LocalDate.now().minusMonths(preferences.getInt(MONTHS, 4)));
    startDatePicker.valueProperty().addListener((observable, oldValue, newValue) -> handleRefresh());
    endDatePicker.valueProperty().addListener((observable, oldValue, newValue) -> handleRefresh());
}
Also used : Preferences(java.util.prefs.Preferences) FXML(javafx.fxml.FXML)

Aggregations

Preferences (java.util.prefs.Preferences)291 BackingStoreException (java.util.prefs.BackingStoreException)49 File (java.io.File)45 ResourceBundle (java.util.ResourceBundle)24 FileChooser (javafx.stage.FileChooser)21 ArrayList (java.util.ArrayList)17 FXML (javafx.fxml.FXML)16 IOException (java.io.IOException)14 JFileChooser (javax.swing.JFileChooser)12 List (java.util.List)8 SwingWorker (javax.swing.SwingWorker)8 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)7 Engine (jgnash.engine.Engine)7 AutoCompletePreferences (org.jabref.logic.autocompleter.AutoCompletePreferences)6 FieldContentParserPreferences (org.jabref.logic.bibtex.FieldContentParserPreferences)6 LatexFieldFormatterPreferences (org.jabref.logic.bibtex.LatexFieldFormatterPreferences)6 BibtexKeyPatternPreferences (org.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences)6 CleanupPreferences (org.jabref.logic.cleanup.CleanupPreferences)6 ImportFormatPreferences (org.jabref.logic.importer.ImportFormatPreferences)6 JournalAbbreviationPreferences (org.jabref.logic.journals.JournalAbbreviationPreferences)6