Beispiel #1
0
  @Override
  public void addFormForAddAccount() {
    gridRowFrom = gridRow + 1;

    InputTextField holderNameInputTextField =
        addLabelInputTextField(gridPane, ++gridRow, "Account holder name:").second;
    holderNameInputTextField.setValidator(inputValidator);
    holderNameInputTextField
        .textProperty()
        .addListener(
            (ov, oldValue, newValue) -> {
              perfectMoneyAccount.setHolderName(newValue);
              updateFromInputs();
            });

    accountNrInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Account nr.:").second;
    accountNrInputTextField.setValidator(perfectMoneyValidator);
    accountNrInputTextField
        .textProperty()
        .addListener(
            (ov, oldValue, newValue) -> {
              perfectMoneyAccount.setAccountNr(newValue);
              updateFromInputs();
            });

    addLabelTextField(
        gridPane,
        ++gridRow,
        "Currency:",
        perfectMoneyAccount.getSingleTradeCurrency().getCodeAndName());
    addAllowedPeriod();
    addAccountNameTextFieldWithAutoFillCheckBox();
  }
  private void addContent() {
    addMultilineLabel(
        gridPane,
        ++rowIndex,
        "Please use that only in emergency case if you cannot access your fund from the UI.\n"
            + "Before you use this tool, you should backup your data directory. After you have successfully transferred your wallet balance, remove"
            + " the db directory inside the data directory to start with a newly created and consistent data structure.\n"
            + "Please make a bug report on Github so that we can investigate what was causing the problem.",
        10);

    Coin totalBalance = walletService.getAvailableBalance();
    boolean isBalanceSufficient = totalBalance.compareTo(FeePolicy.TX_FEE) >= 0;
    addressTextField =
        addLabelTextField(
                gridPane,
                ++rowIndex,
                "Your available wallet balance:",
                formatter.formatCoinWithCode(totalBalance),
                10)
            .second;
    Tuple2<Label, InputTextField> tuple =
        addLabelInputTextField(gridPane, ++rowIndex, "Your destination address:");
    addressInputTextField = tuple.second;

    emptyWalletButton = new Button("Empty wallet");
    emptyWalletButton.setDefaultButton(isBalanceSufficient);
    emptyWalletButton.setDisable(
        !isBalanceSufficient && addressInputTextField.getText().length() > 0);
    emptyWalletButton.setOnAction(
        e -> {
          if (addressInputTextField.getText().length() > 0 && isBalanceSufficient) {
            if (walletService.getWallet().isEncrypted()) {
              walletPasswordPopup
                  .onClose(() -> blurAgain())
                  .onAesKey(aesKey -> doEmptyWallet(aesKey))
                  .show();
            } else {
              doEmptyWallet(null);
            }
          }
        });

    closeButton = new Button("Cancel");
    closeButton.setOnAction(
        e -> {
          hide();
          closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run());
        });

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    GridPane.setRowIndex(hBox, ++rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    hBox.getChildren().addAll(emptyWalletButton, closeButton);
    gridPane.getChildren().add(hBox);
    GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
  }
Beispiel #3
0
  public static Tuple3<HBox, InputTextField, Label> getValueCurrencyBox(String promptText) {
    InputTextField input = new InputTextField();
    input.setPrefWidth(170);
    input.setAlignment(Pos.CENTER_RIGHT);
    input.setId("text-input-with-currency-text-field");
    input.setPromptText(promptText);

    Label currency = new Label();
    currency.setId("currency-info-label");

    HBox box = new HBox();
    box.getChildren().addAll(input, currency);
    return new Tuple3<>(box, input, currency);
  }
 private void doEmptyWallet(KeyParameter aesKey) {
   emptyWalletButton.setDisable(true);
   try {
     walletService.emptyWallet(
         addressInputTextField.getText(),
         aesKey,
         () -> {
           closeButton.setText("Close");
           addressTextField.setText(
               formatter.formatCoinWithCode(walletService.getAvailableBalance()));
           emptyWalletButton.setDisable(true);
           log.debug("wallet empty successful");
           FxTimer.runLater(
               Duration.ofMillis(Transitions.DEFAULT_DURATION),
               () ->
                   new Popup()
                       .information("The balance of your wallet was successfully transferred.")
                       .onClose(() -> blurAgain())
                       .show());
         },
         (errorMessage) -> {
           emptyWalletButton.setDisable(false);
           log.debug("wallet empty failed " + errorMessage);
         });
   } catch (InsufficientMoneyException | AddressFormatException e1) {
     e1.printStackTrace();
     log.error(e1.getMessage());
     emptyWalletButton.setDisable(false);
   }
 }
Beispiel #5
0
 @Override
 protected void autoFillNameTextField() {
   if (autoFillCheckBox != null && autoFillCheckBox.isSelected()) {
     String accountNr = accountNrInputTextField.getText();
     accountNr = accountNr.substring(0, Math.min(5, accountNr.length())) + "...";
     String method = BSResources.get(paymentAccount.getPaymentMethod().getId());
     accountNameTextField.setText(method.concat(", ").concat(accountNr));
   }
 }