Search in sources :

Example 1 with FXMLUtils

use of jgnash.uifx.util.FXMLUtils in project jgnash by ccavanaugh.

the class ReconcileSettingsDialogController method handleOkayAction.

@FXML
private void handleOkayAction() {
    final LocalDate statementDate = datePicker.getValue();
    final BigDecimal openingBalance = openingBalanceTextField.getDecimal();
    final BigDecimal closingBalance = closingBalanceTextField.getDecimal();
    final FXMLUtils.Pair<ReconcileDialogController> pair = FXMLUtils.load(ReconcileDialogController.class.getResource("ReconcileDialog.fxml"), ResourceUtils.getString("Button.Reconcile") + " - " + account.get().getPathName());
    pair.getController().initialize(account.get(), statementDate, openingBalance, closingBalance);
    // Override the defaults set by FXMLUtils
    pair.getStage().initModality(Modality.NONE);
    pair.getStage().initOwner(null);
    JavaFXUtils.runLater(() -> {
        pair.getStage().show();
        pair.getStage().setMinWidth(pair.getStage().getWidth());
        pair.getStage().setMinHeight(pair.getStage().getHeight());
    });
    // push account updates outside the UI thread to improve performance
    new Thread(() -> {
        ReconcileManager.setAccountDateAttribute(accountProperty().get(), Account.RECONCILE_LAST_ATTEMPT_DATE, LocalDate.now());
        ReconcileManager.setAccountDateAttribute(accountProperty().get(), Account.RECONCILE_LAST_STATEMENT_DATE, statementDate);
        ReconcileManager.setAccountBigDecimalAttribute(accountProperty().get(), Account.RECONCILE_LAST_OPENING_BALANCE, openingBalance);
        ReconcileManager.setAccountBigDecimalAttribute(accountProperty().get(), Account.RECONCILE_LAST_CLOSING_BALANCE, closingBalance);
    }).start();
    // close the dialog
    handleCloseAction();
}
Also used : FXMLUtils(jgnash.uifx.util.FXMLUtils) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Aggregations

BigDecimal (java.math.BigDecimal)1 LocalDate (java.time.LocalDate)1 FXML (javafx.fxml.FXML)1 FXMLUtils (jgnash.uifx.util.FXMLUtils)1 InjectFXML (jgnash.uifx.util.InjectFXML)1