bisq.common.util.Tuple2 Java Examples

The following examples show how to use bisq.common.util.Tuple2. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MutableOfferView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private VBox getBuyerSecurityDepositBox() {
    Tuple3<HBox, InfoInputTextField, Label> tuple = getEditableValueBoxWithInfo(
            Res.get("createOffer.securityDeposit.prompt"));
    buyerSecurityDepositInfoInputTextField = tuple.second;
    buyerSecurityDepositInputTextField = buyerSecurityDepositInfoInputTextField.getInputTextField();
    buyerSecurityDepositPercentageLabel = tuple.third;
    // getEditableValueBox delivers BTC, so we overwrite it with %
    buyerSecurityDepositPercentageLabel.setText("%");

    Tuple2<Label, VBox> tradeInputBoxTuple = getTradeInputBox(tuple.first, model.getSecurityDepositLabel());
    VBox depositBox = tradeInputBoxTuple.second;
    buyerSecurityDepositLabel = tradeInputBoxTuple.first;
    depositBox.setMaxWidth(310);

    editOfferElements.add(buyerSecurityDepositInputTextField);
    editOfferElements.add(buyerSecurityDepositPercentageLabel);

    return depositBox;
}
 
Example #2
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Label, TextFieldWithCopyIcon> addTopLabelTextFieldWithCopyIcon(GridPane gridPane,
                                                                                    int rowIndex,
                                                                                    int colIndex,
                                                                                    String title,
                                                                                    String value,
                                                                                    double top) {

    TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon();
    textFieldWithCopyIcon.setText(value);

    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, textFieldWithCopyIcon, top);
    topLabelWithVBox.second.setAlignment(Pos.TOP_LEFT);
    GridPane.setColumnIndex(topLabelWithVBox.second, colIndex);

    return new Tuple2<>(topLabelWithVBox.first, textFieldWithCopyIcon);
}
 
Example #3
Source File: DisputeAgentSelection.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@VisibleForTesting
static String getLeastUsedDisputeAgent(List<String> lastAddressesUsedInTrades, Set<String> disputeAgents) {
    checkArgument(!disputeAgents.isEmpty(), "disputeAgents must not be empty");
    List<Tuple2<String, AtomicInteger>> disputeAgentTuples = disputeAgents.stream()
            .map(e -> new Tuple2<>(e, new AtomicInteger(0)))
            .collect(Collectors.toList());
    disputeAgentTuples.forEach(tuple -> {
        int count = (int) lastAddressesUsedInTrades.stream()
                .filter(tuple.first::startsWith) // we use only first 4 chars for comparing
                .mapToInt(e -> 1)
                .count();
        tuple.second.set(count);
    });

    disputeAgentTuples.sort(Comparator.comparing(e -> e.first));
    disputeAgentTuples.sort(Comparator.comparingInt(e -> e.second.get()));
    return disputeAgentTuples.get(0).first;
}
 
Example #4
Source File: PriceFeedService.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void requestAllPrices(PriceProvider provider, Runnable resultHandler, FaultHandler faultHandler) {
    PriceRequest priceRequest = new PriceRequest();
    SettableFuture<Tuple2<Map<String, Long>, Map<String, MarketPrice>>> future = priceRequest.requestAllPrices(provider);
    Futures.addCallback(future, new FutureCallback<Tuple2<Map<String, Long>, Map<String, MarketPrice>>>() {
        @Override
        public void onSuccess(@Nullable Tuple2<Map<String, Long>, Map<String, MarketPrice>> result) {
            UserThread.execute(() -> {
                checkNotNull(result, "Result must not be null at requestAllPrices");
                timeStampMap = result.first;
                epochInSecondAtLastRequest = timeStampMap.get("btcAverageTs");
                final Map<String, MarketPrice> priceMap = result.second;

                cache.putAll(priceMap);

                resultHandler.run();
            });
        }

        @Override
        public void onFailure(@NotNull Throwable throwable) {
            UserThread.execute(() -> faultHandler.handleFault("Could not load marketPrices", throwable));
        }
    });
}
 
Example #5
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Label, Label> addConfirmationLabelLabel(GridPane gridPane,
                                                             int rowIndex,
                                                             String title1,
                                                             String title2,
                                                             double top) {
    Label label1 = addLabel(gridPane, rowIndex, title1);
    label1.getStyleClass().add("confirmation-label");
    Label label2 = addLabel(gridPane, rowIndex, title2);
    label2.getStyleClass().add("confirmation-value");
    GridPane.setColumnIndex(label2, 1);
    GridPane.setMargin(label1, new Insets(top, 0, 0, 0));
    GridPane.setHalignment(label1, HPos.LEFT);
    GridPane.setMargin(label2, new Insets(top, 0, 0, 0));

    return new Tuple2<>(label1, label2);
}
 
Example #6
Source File: PriceFeedService.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
private void requestAllPrices(PriceProvider provider, Runnable resultHandler, FaultHandler faultHandler) {
    Log.traceCall();
    PriceRequest priceRequest = new PriceRequest();
    SettableFuture<Tuple2<Map<String, Long>, Map<String, MarketPrice>>> future = priceRequest.requestAllPrices(provider);
    Futures.addCallback(future, new FutureCallback<Tuple2<Map<String, Long>, Map<String, MarketPrice>>>() {
        @Override
        public void onSuccess(@Nullable Tuple2<Map<String, Long>, Map<String, MarketPrice>> result) {
            UserThread.execute(() -> {
                checkNotNull(result, "Result must not be null at requestAllPrices");
                timeStampMap = result.first;
                epochInSecondAtLastRequest = timeStampMap.get("btcAverageTs");
                final Map<String, MarketPrice> priceMap = result.second;

                cache.putAll(priceMap);

                resultHandler.run();
            });
        }

        @Override
        public void onFailure(@NotNull Throwable throwable) {
            UserThread.execute(() -> faultHandler.handleFault("Could not load marketPrices", throwable));
        }
    });
}
 
Example #7
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Label, FlowPane> addTopLabelFlowPane(GridPane gridPane,
                                                          int rowIndex,
                                                          String title,
                                                          double top,
                                                          double bottom) {
    FlowPane flowPane = new FlowPane();
    flowPane.setPadding(new Insets(10, 10, 10, 10));
    flowPane.setVgap(10);
    flowPane.setHgap(10);
    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, flowPane, top);

    GridPane.setMargin(topLabelWithVBox.second, new Insets(top + Layout.FLOATING_LABEL_DISTANCE,
            0, bottom, 0));

    return new Tuple2<>(topLabelWithVBox.first, flowPane);
}
 
Example #8
Source File: BankForm.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void addHolderNameAndId() {
    Tuple2<InputTextField, InputTextField> tuple = addInputTextFieldInputTextField(gridPane,
            ++gridRow, Res.get("payment.account.owner"), BankUtil.getHolderIdLabel(""));
    holderNameInputTextField = tuple.first;
    holderNameInputTextField.setMinWidth(250);
    holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        bankAccountPayload.setHolderName(newValue.trim());
        updateFromInputs();
    });
    holderNameInputTextField.minWidthProperty().bind(currencyComboBox.widthProperty());
    holderNameInputTextField.setValidator(inputValidator);

    useHolderID = true;

    holderIdInputTextField = tuple.second;
    holderIdInputTextField.setVisible(false);
    holderIdInputTextField.setManaged(false);
    holderIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        bankAccountPayload.setHolderTaxId(newValue);
        updateFromInputs();
    });
}
 
Example #9
Source File: MyVoteListService.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
public Tuple2<Long, Long> getMeritAndStakeForProposal(String proposalTxId, MyBlindVoteListService myBlindVoteListService) {
    long merit = 0;
    long stake = 0;
    List<MyVote> list = new ArrayList<>(myVoteList.getList());
    list.sort(Comparator.comparing(MyVote::getDate));
    for (MyVote myVote : list) {
        for (Ballot ballot : myVote.getBallotList()) {
            if (ballot.getTxId().equals(proposalTxId)) {
                merit = myVote.getMerit(myBlindVoteListService, bsqStateService);
                stake = myVote.getBlindVote().getStake();
                break;
            }
        }
    }
    return new Tuple2<>(merit, stake);
}
 
Example #10
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Label, TxIdTextField> addLabelTxIdTextField(GridPane gridPane,
                                                                 int rowIndex,
                                                                 String title,
                                                                 String value,
                                                                 double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);
    label.getStyleClass().add("confirmation-label");
    GridPane.setHalignment(label, HPos.LEFT);

    TxIdTextField txTextField = new TxIdTextField();
    txTextField.setup(value);
    GridPane.setRowIndex(txTextField, rowIndex);
    GridPane.setColumnIndex(txTextField, 1);
    gridPane.getChildren().add(txTextField);

    return new Tuple2<>(label, txTextField);
}
 
Example #11
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Label, TextArea> addConfirmationLabelTextArea(GridPane gridPane,
                                                                   int rowIndex,
                                                                   String title1,
                                                                   String title2,
                                                                   double top) {
    Label label = addLabel(gridPane, rowIndex, title1);
    label.getStyleClass().add("confirmation-label");

    TextArea textArea = addTextArea(gridPane, rowIndex, title2);
    ((JFXTextArea) textArea).setLabelFloat(false);

    GridPane.setColumnIndex(textArea, 1);
    GridPane.setMargin(label, new Insets(top, 0, 0, 0));
    GridPane.setHalignment(label, HPos.LEFT);
    GridPane.setMargin(textArea, new Insets(top, 0, 0, 0));

    return new Tuple2<>(label, textArea);
}
 
Example #12
Source File: VoteListItem.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public Tuple2<AwesomeIcon, String> getIconStyleTuple() {
    Optional<Boolean> isAccepted;
    isAccepted = decryptedBallotsWithMerits.getBallotList().stream()
            .filter(ballot -> ballot.getTxId().equals(proposalTxId))
            .map(Ballot::getVote)
            .map(vote -> vote != null && vote.isAccepted())
            .findAny();
    if (isAccepted.isPresent()) {
        if (isAccepted.get())
            return new Tuple2<>(AwesomeIcon.THUMBS_UP, "dao-accepted-icon");
        else
            return new Tuple2<>(AwesomeIcon.THUMBS_DOWN, "dao-rejected-icon");
    } else {
        return new Tuple2<>(AwesomeIcon.MINUS, "dao-ignored-icon");
    }
}
 
Example #13
Source File: ProposalsView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void onVote() {
    Coin stake = ParsingUtils.parseToCoin(stakeInputTextField.getText(), bsqFormatter);
    try {
        // We create a dummy tx to get the miningFee for displaying it at the confirmation popup
        Tuple2<Coin, Integer> miningFeeAndTxSize = daoFacade.getBlindVoteMiningFeeAndTxSize(stake);
        Coin miningFee = miningFeeAndTxSize.first;
        int txSize = miningFeeAndTxSize.second;
        Coin blindVoteFee = daoFacade.getBlindVoteFeeForCycle();
        if (!DevEnv.isDevMode()) {
            GUIUtil.showBsqFeeInfoPopup(blindVoteFee, miningFee, txSize, bsqFormatter, btcFormatter,
                    Res.get("dao.blindVote"), () -> publishBlindVote(stake));
        } else {
            publishBlindVote(stake);
        }
    } catch (InsufficientMoneyException | WalletException | TransactionVerificationException exception) {
        new Popup().warning(exception.toString()).show();
    }
}
 
Example #14
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Button, CheckBox> addButtonCheckBox(GridPane gridPane,
                                                         int rowIndex,
                                                         String buttonTitle,
                                                         String checkBoxTitle,
                                                         double top) {
    Button button = new AutoTooltipButton(buttonTitle);
    button.setDefaultButton(true);
    CheckBox checkBox = new AutoTooltipCheckBox(checkBoxTitle);
    HBox.setMargin(checkBox, new Insets(6, 0, 0, 0));

    HBox hBox = new HBox();
    hBox.setSpacing(20);
    hBox.getChildren().addAll(button, checkBox);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    hBox.setPadding(new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(hBox);

    return new Tuple2<>(button, checkBox);
}
 
Example #15
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, RadioButton, RadioButton> addTopLabelRadioButtonRadioButton(GridPane gridPane,
                                                                                        int rowIndex,
                                                                                        ToggleGroup toggleGroup,
                                                                                        String title,
                                                                                        String radioButtonTitle1,
                                                                                        String radioButtonTitle2,
                                                                                        double top) {
    RadioButton radioButton1 = new AutoTooltipRadioButton(radioButtonTitle1);
    radioButton1.setToggleGroup(toggleGroup);
    radioButton1.setPadding(new Insets(6, 0, 0, 0));

    RadioButton radioButton2 = new AutoTooltipRadioButton(radioButtonTitle2);
    radioButton2.setToggleGroup(toggleGroup);
    radioButton2.setPadding(new Insets(6, 0, 0, 0));

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(radioButton1, radioButton2);

    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);

    return new Tuple3<>(topLabelWithVBox.first, radioButton1, radioButton2);
}
 
Example #16
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<InputTextField, InputTextField> addInputTextFieldInputTextField(GridPane gridPane,
                                                                                     int rowIndex,
                                                                                     String title1,
                                                                                     String title2) {

    InputTextField inputTextField1 = new InputTextField();
    inputTextField1.setPromptText(title1);
    inputTextField1.setLabelFloat(true);
    InputTextField inputTextField2 = new InputTextField();
    inputTextField2.setLabelFloat(true);
    inputTextField2.setPromptText(title2);

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(inputTextField1, inputTextField2);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 0);
    GridPane.setMargin(hBox, new Insets(Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0));
    gridPane.getChildren().add(hBox);

    return new Tuple2<>(inputTextField1, inputTextField2);
}
 
Example #17
Source File: PriceRequest.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public SettableFuture<Tuple2<Map<String, Long>, Map<String, MarketPrice>>> requestAllPrices(PriceProvider provider) {
    final String baseUrl = provider.getBaseUrl();
    final SettableFuture<Tuple2<Map<String, Long>, Map<String, MarketPrice>>> resultFuture = SettableFuture.create();
    ListenableFuture<Tuple2<Map<String, Long>, Map<String, MarketPrice>>> future = executorService.submit(() -> {
        Thread.currentThread().setName("PriceRequest-" + provider.toString());
        return provider.getAll();
    });

    Futures.addCallback(future, new FutureCallback<Tuple2<Map<String, Long>, Map<String, MarketPrice>>>() {
        public void onSuccess(Tuple2<Map<String, Long>, Map<String, MarketPrice>> marketPriceTuple) {
            log.trace("Received marketPriceTuple of {}\nfrom provider {}", marketPriceTuple, provider);
            resultFuture.set(marketPriceTuple);
        }

        public void onFailure(@NotNull Throwable throwable) {
            resultFuture.setException(new PriceRequestException(throwable, baseUrl));
        }
    });

    return resultFuture;
}
 
Example #18
Source File: UnlockDisputeAgentRegistrationWindow.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void addButtons() {
    final Tuple2<Button, Button> buttonButtonTuple2 = add2ButtonsAfterGroup(gridPane, ++rowIndex,
            Res.get("shared.unlock"), Res.get("shared.close"));
    unlockButton = buttonButtonTuple2.first;
    unlockButton.setDisable(keyInputTextField.getText().length() == 0);
    unlockButton.setOnAction(e -> {
        if (privKeyHandler.checkKey(keyInputTextField.getText()))
            hide();
        else
            new Popup().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
    });

    Button closeButton = buttonButtonTuple2.second;
    closeButton.setOnAction(event -> {
        hide();
        closeHandlerOptional.ifPresent(Runnable::run);
    });
}
 
Example #19
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Label, TextFieldWithCopyIcon> addConfirmationLabelTextFieldWithCopyIcon(GridPane gridPane,
                                                                                             int rowIndex,
                                                                                             String title,
                                                                                             String value,
                                                                                             double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);
    label.getStyleClass().add("confirmation-label");
    GridPane.setHalignment(label, HPos.LEFT);

    TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon("confirmation-text-field-as-label");
    textFieldWithCopyIcon.setText(value);
    GridPane.setRowIndex(textFieldWithCopyIcon, rowIndex);
    GridPane.setColumnIndex(textFieldWithCopyIcon, 1);
    GridPane.setMargin(textFieldWithCopyIcon, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(textFieldWithCopyIcon);

    return new Tuple2<>(label, textFieldWithCopyIcon);
}
 
Example #20
Source File: FeeProvider.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public Tuple2<Map<String, Long>, Map<String, Long>> getFees() throws IOException {
    String json = httpClient.requestWithGET("getFees", "User-Agent", "bisq/" + Version.VERSION);

    LinkedTreeMap<?, ?> linkedTreeMap = new Gson().fromJson(json, LinkedTreeMap.class);
    Map<String, Long> tsMap = new HashMap<>();
    tsMap.put("bitcoinFeesTs", ((Double) linkedTreeMap.get("bitcoinFeesTs")).longValue());

    Map<String, Long> map = new HashMap<>();

    try {
        LinkedTreeMap<?, ?> dataMap = (LinkedTreeMap<?, ?>) linkedTreeMap.get("dataMap");
        Long btcTxFee = ((Double) dataMap.get("btcTxFee")).longValue();

        map.put("BTC", btcTxFee);
    } catch (Throwable t) {
        log.error(t.toString());
        t.printStackTrace();
    }
    return new Tuple2<>(tsMap, map);
}
 
Example #21
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@NotNull
public static Tuple2<Label, VBox> addTopLabelWithVBox(GridPane gridPane,
                                                      int rowIndex,
                                                      int columnIndex,
                                                      String title,
                                                      Node node,
                                                      double top) {
    final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(title, node);
    VBox vBox = topLabelWithVBox.second;

    GridPane.setRowIndex(vBox, rowIndex);
    GridPane.setColumnIndex(vBox, columnIndex);
    GridPane.setMargin(vBox, new Insets(top + Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0));
    gridPane.getChildren().add(vBox);

    return new Tuple2<>(topLabelWithVBox.first, vBox);
}
 
Example #22
Source File: AxisInlierUtils.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private static Tuple2<Double, Double> findInlierRange(
        List<Double> yValues,
        double percentToTrim,
        double howManyStdDevsConstituteOutlier
) {
    Tuple2<Double, Double> inlierThreshold =
            computeInlierThreshold(yValues, percentToTrim, howManyStdDevsConstituteOutlier);

    DoubleSummaryStatistics inlierStatistics =
            yValues
                    .stream()
                    .filter(y -> withinBounds(inlierThreshold, y))
                    .mapToDouble(Double::doubleValue)
                    .summaryStatistics();

    var inlierMin = inlierStatistics.getMin();
    var inlierMax = inlierStatistics.getMax();

    return new Tuple2<>(inlierMin, inlierMax);
}
 
Example #23
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, TextField, Button> addTopLabelTextFieldButton(GridPane gridPane,
                                                                          int rowIndex,
                                                                          String title,
                                                                          String buttonTitle,
                                                                          double top) {

    TextField textField = new BisqTextField();
    textField.setEditable(false);
    textField.setMouseTransparent(true);
    textField.setFocusTraversable(false);
    Button button = new AutoTooltipButton(buttonTitle);
    button.setDefaultButton(true);

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(textField, button);
    HBox.setHgrow(textField, Priority.ALWAYS);

    final Tuple2<Label, VBox> labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);

    return new Tuple3<>(labelVBoxTuple2.first, textField, button);
}
 
Example #24
Source File: TxFeeEstimationService.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public Tuple2<Coin, Integer> getEstimatedFeeAndTxSize(Coin amount,
                                                      FeeService feeService,
                                                      BtcWalletService btcWalletService) {
    Coin txFeePerByte = feeService.getTxFeePerByte();
    // We start with min taker fee size of 260
    int estimatedTxSize = TYPICAL_TX_WITH_1_INPUT_SIZE;
    try {
        estimatedTxSize = getEstimatedTxSize(List.of(amount), estimatedTxSize, txFeePerByte, btcWalletService);
    } catch (InsufficientMoneyException e) {
        log.info("We cannot do the fee estimation because there are not enough funds in the wallet. This is expected " +
                "if the user pays from an external wallet. In that case we use an estimated tx size of {} bytes.", estimatedTxSize);
    }

    Coin txFee = txFeePerByte.multiply(estimatedTxSize);
    log.info("Fee estimation resulted in a tx size of {} bytes and a tx fee of {} Sat.", estimatedTxSize, txFee.value);

    return new Tuple2<>(txFee, estimatedTxSize);
}
 
Example #25
Source File: AltCoinAccountsView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
protected void addNewAccount() {
    paymentAccountsListView.getSelectionModel().clearSelection();
    removeAccountRows();
    addAccountButton.setDisable(true);
    accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 1, Res.get("shared.createNewAccount"), Layout.GROUP_DISTANCE);

    if (paymentMethodForm != null) {
        FormBuilder.removeRowsFromGridPane(root, 3, paymentMethodForm.getGridRow() + 1);
        GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1);
    }
    gridRow = 2;
    paymentMethodForm = getPaymentMethodForm(PaymentMethod.BLOCK_CHAINS);
    paymentMethodForm.addFormForAddAccount();
    gridRow = paymentMethodForm.getGridRow();
    Tuple2<Button, Button> tuple2 = add2ButtonsAfterGroup(root, ++gridRow, Res.get("shared.saveNewAccount"), Res.get("shared.cancel"));
    saveNewAccountButton = tuple2.first;
    saveNewAccountButton.setOnAction(event -> onSaveNewAccount(paymentMethodForm.getPaymentAccount()));
    saveNewAccountButton.disableProperty().bind(paymentMethodForm.allInputsValidProperty().not());
    Button cancelButton = tuple2.second;
    cancelButton.setOnAction(event -> onCancelNewAccount());
    GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1);
}
 
Example #26
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, InputTextField, Button> addTopLabelInputTextFieldButton(GridPane gridPane,
                                                                                    int rowIndex,
                                                                                    String title,
                                                                                    String buttonTitle) {
    InputTextField inputTextField = new InputTextField();
    Button button = new AutoTooltipButton(buttonTitle);
    button.setDefaultButton(true);

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(inputTextField, button);
    HBox.setHgrow(inputTextField, Priority.ALWAYS);

    final Tuple2<Label, VBox> labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, 0);

    return new Tuple3<>(labelVBoxTuple2.first, inputTextField, button);
}
 
Example #27
Source File: JapanBankTransferForm.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void addBankAccountInput() // {{{
{
    gridRow++;
    Tuple2<InputTextField, InputTextField> tuple2 = addInputTextFieldInputTextField(gridPane, gridRow, JapanBankData.getString("account.number"), JapanBankData.getString("account.name"));

    // account number
    bankAccountNumberInputTextField = tuple2.first;
    bankAccountNumberInputTextField.setValidator(japanBankAccountNumberValidator);
    bankAccountNumberInputTextField.setPrefWidth(200);
    bankAccountNumberInputTextField.setMaxWidth(200);
    bankAccountNumberInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        japanBankAccount.setBankAccountNumber(newValue);
        updateFromInputs();
    });

    // account name
    InputTextField bankAccountNameInputTextField = tuple2.second;
    bankAccountNameInputTextField.setValidator(japanBankAccountNameValidator);
    bankAccountNameInputTextField.setPrefWidth(430);
    bankAccountNameInputTextField.setMaxWidth(430);
    bankAccountNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        japanBankAccount.setBankAccountName(newValue);
        updateFromInputs();
    });
}
 
Example #28
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, TextField, VBox> addTopLabelTextField(GridPane gridPane,
                                                                  int rowIndex,
                                                                  String title,
                                                                  String value,
                                                                  double top) {
    TextField textField = new BisqTextField(value);
    textField.setEditable(false);
    textField.setFocusTraversable(false);

    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, textField, top);

    // TOD not 100% sure if that is a good idea....
    //topLabelWithVBox.first.getStyleClass().add("jfx-text-field-top-label");

    return new Tuple3<>(topLabelWithVBox.first, textField, topLabelWithVBox.second);
}
 
Example #29
Source File: TakeOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private Tuple2<Label, VBox> getTradeInputBox(HBox amountValueBox, String promptText) {
    Label descriptionLabel = new AutoTooltipLabel(promptText);
    descriptionLabel.setId("input-description-label");
    descriptionLabel.setPrefWidth(170);

    VBox box = new VBox();
    box.setPadding(new Insets(10, 0, 0, 0));
    box.setSpacing(2);
    box.getChildren().addAll(descriptionLabel, amountValueBox);
    return new Tuple2<>(descriptionLabel, box);
}
 
Example #30
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Tuple2<Label, DatePicker> addTopLabelDatePicker(GridPane gridPane,
                                                              int rowIndex,
                                                              String title,
                                                              double top) {
    DatePicker datePicker = new JFXDatePicker();

    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, datePicker, top);

    return new Tuple2<>(topLabelWithVBox.first, datePicker);
}