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();
}
});
}
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));
}
});
}
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));
}
}
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();
}
}
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());
}
Aggregations