Ejemplo n.º 1
0
  @Override
  public void clearForm() {

    modTrans = null;

    amountField.setDecimal(BigDecimal.ZERO);

    reconciledButton.setDisable(false);
    reconciledButton.setSelected(false);
    reconciledButton.setIndeterminate(false);

    if (payeeTextField != null) { // transfer slips do not use the payee field
      payeeTextField.setEditable(true);
      payeeTextField.clear();
    }

    datePicker.setEditable(true);
    if (!Options.rememberLastDateProperty().get()) {
      datePicker.setValue(LocalDate.now());
    }

    memoTextField.clear();

    numberComboBox.setValue(null);
    numberComboBox.setDisable(false);

    attachmentPane.clear();
  }
Ejemplo n.º 2
0
  @FXML
  public void initialize() {

    // Needed to support tri-state capability
    reconciledButton.setAllowIndeterminate(true);

    // Number combo needs to know the account in order to determine the next transaction number
    numberComboBox.accountProperty().bind(accountProperty());

    AutoCompleteFactory.setMemoModel(memoTextField);

    accountProperty.addListener(
        (observable, oldValue, newValue) -> {
          // Set the number of fixed decimal places for entry
          amountField.scaleProperty().set(newValue.getCurrencyNode().getScale());

          // Enabled auto completion for the payee field
          if (payeeTextField != null) { // transfer slips do not use the payee field
            AutoCompleteFactory.setPayeeModel(payeeTextField, newValue);
          }
        });

    // If focus is lost, check and load the form with an existing transaction
    if (payeeTextField != null) { // transfer slips do not use the payee field
      payeeTextField
          .focusedProperty()
          .addListener(
              (observable, oldValue, newValue) -> {
                if (!newValue) {
                  handlePayeeFocusChange();
                }
              });
    }

    // Install an event handler when the parent has been set via injection
    parentProperty.addListener(
        (observable, oldValue, newValue) -> {
          newValue.addEventHandler(
              KeyEvent.KEY_PRESSED,
              event -> {
                if (JavaFXUtils.ESCAPE_KEY.match(
                    event)) { // clear the form if an escape key is detected
                  clearForm();
                } else if (JavaFXUtils.ENTER_KEY.match(event)) { // handle an enter key if detected
                  if (validateForm()) {
                    Platform.runLater(AbstractSlipController.this::handleEnterAction);
                  } else {
                    Platform.runLater(
                        () -> {
                          if (event.getSource() instanceof Node) {
                            JavaFXUtils.focusNext((Node) event.getSource());
                          }
                        });
                  }
                }
              });
        });
  }