Search in sources :

Example 1 with PaymentMethod

use of bisq.core.payment.payload.PaymentMethod in project bisq-core by bisq-network.

the class ReceiptPredicatesTest method testIsEqualPaymentMethods.

@Test
public void testIsEqualPaymentMethods() {
    final PaymentMethod method = new PaymentMethod("1");
    Offer offer = mock(Offer.class);
    when(offer.getPaymentMethod()).thenReturn(method);
    PaymentAccount account = mock(PaymentAccount.class);
    when(account.getPaymentMethod()).thenReturn(method);
    assertTrue(predicates.isEqualPaymentMethods(offer, account));
}
Also used : Offer(bisq.core.offer.Offer) PaymentMethod(bisq.core.payment.payload.PaymentMethod) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with PaymentMethod

use of bisq.core.payment.payload.PaymentMethod in project bisq-desktop by bisq-network.

the class FiatAccountsView method addNewAccount.

// Add new account form
private void addNewAccount() {
    paymentAccountsListView.getSelectionModel().clearSelection();
    removeAccountRows();
    addAccountButton.setDisable(true);
    accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 1, Res.get("shared.createNewAccount"), Layout.GROUP_DISTANCE);
    // noinspection unchecked
    paymentMethodComboBox = addLabelComboBox(root, gridRow, Res.getWithCol("shared.paymentMethod"), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
    paymentMethodComboBox.setPromptText(Res.get("shared.selectPaymentMethod"));
    paymentMethodComboBox.setVisibleRowCount(11);
    paymentMethodComboBox.setPrefWidth(250);
    List<PaymentMethod> list = PaymentMethod.getAllValues().stream().filter(paymentMethod -> !paymentMethod.getId().equals(PaymentMethod.BLOCK_CHAINS_ID)).collect(Collectors.toList());
    paymentMethodComboBox.setItems(FXCollections.observableArrayList(list));
    paymentMethodComboBox.setConverter(new StringConverter<PaymentMethod>() {

        @Override
        public String toString(PaymentMethod paymentMethod) {
            return paymentMethod != null ? Res.get(paymentMethod.getId()) : "";
        }

        @Override
        public PaymentMethod fromString(String s) {
            return null;
        }
    });
    paymentMethodComboBox.setOnAction(e -> {
        if (paymentMethodForm != null) {
            FormBuilder.removeRowsFromGridPane(root, 3, paymentMethodForm.getGridRow() + 1);
            GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1);
        }
        gridRow = 2;
        paymentMethodForm = getPaymentMethodForm(paymentMethodComboBox.getSelectionModel().getSelectedItem());
        if (paymentMethodForm != null) {
            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);
        }
    });
}
Also used : Button(javafx.scene.control.Button) PopmoneyValidator(bisq.desktop.util.validation.PopmoneyValidator) Coin(org.bitcoinj.core.Coin) ListCell(javafx.scene.control.ListCell) Layout(bisq.desktop.util.Layout) BSFormatter(bisq.desktop.util.BSFormatter) PaymentAccountFactory(bisq.core.payment.PaymentAccountFactory) WesternUnionAccount(bisq.core.payment.WesternUnionAccount) ComboBox(javafx.scene.control.ComboBox) Res(bisq.core.locale.Res) MoneyBeamValidator(bisq.desktop.util.validation.MoneyBeamValidator) BICValidator(bisq.desktop.util.validation.BICValidator) AliPayForm(bisq.desktop.components.paymentmethods.AliPayForm) PopmoneyForm(bisq.desktop.components.paymentmethods.PopmoneyForm) SwishForm(bisq.desktop.components.paymentmethods.SwishForm) VenmoForm(bisq.desktop.components.paymentmethods.VenmoForm) AliPayValidator(bisq.desktop.util.validation.AliPayValidator) SepaInstantForm(bisq.desktop.components.paymentmethods.SepaInstantForm) Popup(bisq.desktop.main.overlays.popups.Popup) ChaseQuickPayValidator(bisq.desktop.util.validation.ChaseQuickPayValidator) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder(bisq.desktop.util.FormBuilder) ClearXchangeValidator(bisq.desktop.util.validation.ClearXchangeValidator) PaymentMethod(bisq.core.payment.payload.PaymentMethod) Collectors(java.util.stream.Collectors) AccountAgeWitnessService(bisq.core.payment.AccountAgeWitnessService) OKPayForm(bisq.desktop.components.paymentmethods.OKPayForm) OKPayValidator(bisq.desktop.util.validation.OKPayValidator) VenmoValidator(bisq.desktop.util.validation.VenmoValidator) PaymentAccount(bisq.core.payment.PaymentAccount) List(java.util.List) CashDepositForm(bisq.desktop.components.paymentmethods.CashDepositForm) RevolutValidator(bisq.desktop.util.validation.RevolutValidator) AnchorPane(javafx.scene.layout.AnchorPane) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) UpholdForm(bisq.desktop.components.paymentmethods.UpholdForm) UserThread(bisq.common.UserThread) SpecificBankForm(bisq.desktop.components.paymentmethods.SpecificBankForm) IBANValidator(bisq.desktop.util.validation.IBANValidator) FasterPaymentsForm(bisq.desktop.components.paymentmethods.FasterPaymentsForm) MoneyBeamForm(bisq.desktop.components.paymentmethods.MoneyBeamForm) SwishValidator(bisq.desktop.util.validation.SwishValidator) ClearXchangeForm(bisq.desktop.components.paymentmethods.ClearXchangeForm) ListView(javafx.scene.control.ListView) FXCollections(javafx.collections.FXCollections) FxmlView(bisq.desktop.common.view.FxmlView) Inject(javax.inject.Inject) ClearXchangeAccount(bisq.core.payment.ClearXchangeAccount) Tuple2(bisq.common.util.Tuple2) USPostalMoneyOrderValidator(bisq.desktop.util.validation.USPostalMoneyOrderValidator) Tuple3(bisq.common.util.Tuple3) VPos(javafx.geometry.VPos) UpholdValidator(bisq.desktop.util.validation.UpholdValidator) TextAlignment(javafx.scene.text.TextAlignment) Callback(javafx.util.Callback) RevolutForm(bisq.desktop.components.paymentmethods.RevolutForm) TitledGroupBg(bisq.desktop.components.TitledGroupBg) GridPane(javafx.scene.layout.GridPane) NationalBankForm(bisq.desktop.components.paymentmethods.NationalBankForm) SameBankForm(bisq.desktop.components.paymentmethods.SameBankForm) WesternUnionForm(bisq.desktop.components.paymentmethods.WesternUnionForm) Label(javafx.scene.control.Label) InteracETransferValidator(bisq.desktop.util.validation.InteracETransferValidator) PerfectMoneyForm(bisq.desktop.components.paymentmethods.PerfectMoneyForm) BisqEnvironment(bisq.core.app.BisqEnvironment) StringConverter(javafx.util.StringConverter) CashAppValidator(bisq.desktop.util.validation.CashAppValidator) USPostalMoneyOrderForm(bisq.desktop.components.paymentmethods.USPostalMoneyOrderForm) TimeUnit(java.util.concurrent.TimeUnit) PaymentMethodForm(bisq.desktop.components.paymentmethods.PaymentMethodForm) InputValidator(bisq.core.util.validation.InputValidator) ChaseQuickPayForm(bisq.desktop.components.paymentmethods.ChaseQuickPayForm) ImageUtil(bisq.desktop.util.ImageUtil) SepaForm(bisq.desktop.components.paymentmethods.SepaForm) ImageView(javafx.scene.image.ImageView) CashAppForm(bisq.desktop.components.paymentmethods.CashAppForm) InteracETransferForm(bisq.desktop.components.paymentmethods.InteracETransferForm) PerfectMoneyValidator(bisq.desktop.util.validation.PerfectMoneyValidator) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) PaymentMethod(bisq.core.payment.payload.PaymentMethod)

Example 3 with PaymentMethod

use of bisq.core.payment.payload.PaymentMethod in project bisq-desktop by bisq-network.

the class OfferBookView method initialize.

@Override
public void initialize() {
    root.setPadding(new Insets(20, 25, 5, 25));
    addTitledGroupBg(root, gridRow, 2, Res.get("offerbook.availableOffers"));
    final Tuple3<HBox, AutoTooltipLabel, ComboBox> filterBoxTuple = addHBoxLabelComboBox(root, gridRow, Res.get("offerbook.filterByCurrency"), Layout.FIRST_ROW_DISTANCE);
    final HBox filterBox = filterBoxTuple.first;
    currencyComboBox = filterBoxTuple.third;
    currencyComboBox.setPromptText(Res.get("list.currency.select"));
    // noinspection unchecked
    paymentMethodComboBox = new ComboBox<>();
    final Label paymentMethodLabel = new AutoTooltipLabel(Res.getWithCol("offerbook.filterByPaymentMethod"));
    paymentMethodLabel.setPadding(new Insets(0, 0, 0, 10));
    filterBox.getChildren().addAll(paymentMethodLabel, paymentMethodComboBox);
    paymentMethodComboBox.setPromptText(Res.get("shared.selectPaymentMethod"));
    paymentMethodComboBox.setVisibleRowCount(20);
    paymentMethodComboBox.setConverter(new StringConverter<PaymentMethod>() {

        @Override
        public String toString(PaymentMethod paymentMethod) {
            String id = paymentMethod.getId();
            if (id.equals(GUIUtil.SHOW_ALL_FLAG))
                return "▶ " + Res.get("list.currency.showAll");
            else if (paymentMethod.equals(PaymentMethod.BLOCK_CHAINS))
                return "✦ " + Res.get(id);
            else
                return "★ " + Res.get(id);
        }

        @Override
        public PaymentMethod fromString(String s) {
            return null;
        }
    });
    tableView = new TableView<>();
    GridPane.setRowIndex(tableView, ++gridRow);
    GridPane.setColumnIndex(tableView, 0);
    GridPane.setColumnSpan(tableView, 2);
    GridPane.setMargin(tableView, new Insets(10, -10, -10, -10));
    GridPane.setVgrow(tableView, Priority.ALWAYS);
    root.getChildren().add(tableView);
    marketColumn = getMarketColumn();
    priceColumn = getPriceColumn();
    tableView.getColumns().add(priceColumn);
    amountColumn = getAmountColumn();
    tableView.getColumns().add(amountColumn);
    volumeColumn = getVolumeColumn();
    tableView.getColumns().add(volumeColumn);
    TableColumn<OfferBookListItem, OfferBookListItem> paymentMethodColumn = getPaymentMethodColumn();
    tableView.getColumns().add(paymentMethodColumn);
    TableColumn<OfferBookListItem, OfferBookListItem> avatarColumn = getAvatarColumn();
    tableView.getColumns().add(avatarColumn);
    tableView.getColumns().add(getActionColumn());
    tableView.getSortOrder().add(priceColumn);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.multipleOffers")));
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);
    marketColumn.setComparator((o1, o2) -> {
        String str1 = formatter.getCurrencyPair(o1.getOffer().getCurrencyCode());
        String str2 = formatter.getCurrencyPair(o2.getOffer().getCurrencyCode());
        return str1 != null && str2 != null ? str1.compareTo(str2) : 0;
    });
    priceColumn.setComparator((o1, o2) -> {
        Price price1 = o1.getOffer().getPrice();
        Price price2 = o2.getOffer().getPrice();
        return price1 != null && price2 != null ? price1.compareTo(price2) : 0;
    });
    amountColumn.setComparator(Comparator.comparing(o -> o.getOffer().getAmount()));
    volumeColumn.setComparator((o1, o2) -> {
        Volume offerVolume1 = o1.getOffer().getVolume();
        Volume offerVolume2 = o2.getOffer().getVolume();
        return offerVolume1 != null && offerVolume2 != null ? offerVolume1.compareTo(offerVolume2) : 0;
    });
    paymentMethodColumn.setComparator(Comparator.comparing(o -> o.getOffer().getPaymentMethod()));
    avatarColumn.setComparator(Comparator.comparing(o -> o.getOffer().getOwnerNodeAddress().getFullAddress()));
    nrOfOffersLabel = new AutoTooltipLabel("");
    nrOfOffersLabel.setId("num-offers");
    GridPane.setHalignment(nrOfOffersLabel, HPos.LEFT);
    GridPane.setVgrow(nrOfOffersLabel, Priority.NEVER);
    GridPane.setValignment(nrOfOffersLabel, VPos.TOP);
    GridPane.setRowIndex(nrOfOffersLabel, ++gridRow);
    GridPane.setColumnIndex(nrOfOffersLabel, 0);
    GridPane.setMargin(nrOfOffersLabel, new Insets(10, 0, 0, -5));
    root.getChildren().add(nrOfOffersLabel);
    createOfferButton = addButton(root, gridRow, "");
    createOfferButton.setMinHeight(40);
    createOfferButton.setPadding(new Insets(0, 20, 0, 20));
    createOfferButton.setGraphicTextGap(10);
    GridPane.setMargin(createOfferButton, new Insets(15, 0, 0, 0));
    GridPane.setHalignment(createOfferButton, HPos.RIGHT);
    GridPane.setVgrow(createOfferButton, Priority.NEVER);
    GridPane.setValignment(createOfferButton, VPos.TOP);
    offerListListener = c -> nrOfOffersLabel.setText(Res.get("offerbook.nrOffers", model.getOfferList().size()));
    // Fixes incorrect ordering of Available offers:
    // https://github.com/bisq-network/exchange/issues/588
    priceFeedUpdateCounterListener = (observable, oldValue, newValue) -> tableView.sort();
}
Also used : Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) ArbitratorSelectionView(bisq.desktop.main.account.content.arbitratorselection.ArbitratorSelectionView) Coin(org.bitcoinj.core.Coin) Layout(bisq.desktop.util.Layout) FiatAccountsView(bisq.desktop.main.account.content.fiataccounts.FiatAccountsView) BSFormatter(bisq.desktop.util.BSFormatter) FormBuilder.getIcon(bisq.desktop.util.FormBuilder.getIcon) ComboBox(javafx.scene.control.ComboBox) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) TableView(javafx.scene.control.TableView) Navigation(bisq.desktop.Navigation) HBox(javafx.scene.layout.HBox) Popup(bisq.desktop.main.overlays.popups.Popup) Offer(bisq.core.offer.Offer) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) Canvas(javafx.scene.canvas.Canvas) Subscription(org.fxmisc.easybind.Subscription) PaymentMethod(bisq.core.payment.payload.PaymentMethod) Priority(javafx.scene.layout.Priority) PaymentAccount(bisq.core.payment.PaymentAccount) NodeAddress(bisq.network.p2p.NodeAddress) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AppOptionKeys(bisq.core.app.AppOptionKeys) AccountSettingsView(bisq.desktop.main.account.settings.AccountSettingsView) Optional(java.util.Optional) MaterialDesignIcon(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon) NotNull(org.jetbrains.annotations.NotNull) GUIUtil(bisq.desktop.util.GUIUtil) Scene(javafx.scene.Scene) TradeCurrency(bisq.core.locale.TradeCurrency) FormBuilder.addHBoxLabelComboBox(bisq.desktop.util.FormBuilder.addHBoxLabelComboBox) OfferDetailsWindow(bisq.desktop.main.overlays.windows.OfferDetailsWindow) FiatCurrency(bisq.core.locale.FiatCurrency) Volume(bisq.core.monetary.Volume) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) InfoAutoTooltipLabel(bisq.desktop.components.InfoAutoTooltipLabel) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) WithdrawalView(bisq.desktop.main.funds.withdrawal.WithdrawalView) OfferPayload(bisq.core.offer.OfferPayload) Tuple3(bisq.common.util.Tuple3) Insets(javafx.geometry.Insets) VPos(javafx.geometry.VPos) ColoredDecimalPlacesWithZerosText(bisq.desktop.components.ColoredDecimalPlacesWithZerosText) Callback(javafx.util.Callback) FundsView(bisq.desktop.main.funds.FundsView) Tooltip(javafx.scene.control.Tooltip) AccountView(bisq.desktop.main.account.AccountView) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) TableRow(javafx.scene.control.TableRow) DontShowAgainLookup(bisq.core.user.DontShowAgainLookup) OfferView(bisq.desktop.main.offer.OfferView) StringConverter(javafx.util.StringConverter) PeerInfoIcon(bisq.desktop.components.PeerInfoIcon) FormBuilder.addButton(bisq.desktop.util.FormBuilder.addButton) MainView(bisq.desktop.main.MainView) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) Price(bisq.core.monetary.Price) ObservableValue(javafx.beans.value.ObservableValue) Named(com.google.inject.name.Named) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) Comparator(java.util.Comparator) ContentDisplay(javafx.scene.control.ContentDisplay) HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) ComboBox(javafx.scene.control.ComboBox) FormBuilder.addHBoxLabelComboBox(bisq.desktop.util.FormBuilder.addHBoxLabelComboBox) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) InfoAutoTooltipLabel(bisq.desktop.components.InfoAutoTooltipLabel) Label(javafx.scene.control.Label) Price(bisq.core.monetary.Price) Volume(bisq.core.monetary.Volume) PaymentMethod(bisq.core.payment.payload.PaymentMethod) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) InfoAutoTooltipLabel(bisq.desktop.components.InfoAutoTooltipLabel)

Example 4 with PaymentMethod

use of bisq.core.payment.payload.PaymentMethod in project bisq-desktop by bisq-network.

the class OfferBookViewModel method getPaymentMethods.

ObservableList<PaymentMethod> getPaymentMethods() {
    ObservableList<PaymentMethod> list = FXCollections.observableArrayList(PaymentMethod.getAllValues());
    list.add(0, new PaymentMethod(GUIUtil.SHOW_ALL_FLAG));
    return list;
}
Also used : PaymentMethod(bisq.core.payment.payload.PaymentMethod)

Example 5 with PaymentMethod

use of bisq.core.payment.payload.PaymentMethod in project bisq-desktop by bisq-network.

the class OfferDetailsWindow method addContent.

private void addContent() {
    int rows = 5;
    List<String> acceptedBanks = offer.getAcceptedBankIds();
    boolean showAcceptedBanks = acceptedBanks != null && !acceptedBanks.isEmpty();
    List<String> acceptedCountryCodes = offer.getAcceptedCountryCodes();
    boolean showAcceptedCountryCodes = acceptedCountryCodes != null && !acceptedCountryCodes.isEmpty();
    if (!takeOfferHandlerOptional.isPresent())
        rows++;
    if (showAcceptedBanks)
        rows++;
    if (showAcceptedCountryCodes)
        rows++;
    addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("shared.Offer"));
    String fiatDirectionInfo = ":";
    String btcDirectionInfo = ":";
    OfferPayload.Direction direction = offer.getDirection();
    String currencyCode = offer.getCurrencyCode();
    String offerTypeLabel = Res.getWithCol("shared.offerType");
    String toReceive = " " + Res.get("shared.toReceive");
    String toSpend = " " + Res.get("shared.toSpend");
    double firstRowDistance = Layout.FIRST_ROW_DISTANCE;
    if (takeOfferHandlerOptional.isPresent()) {
        addLabelTextField(gridPane, rowIndex, offerTypeLabel, formatter.getDirectionForTakeOffer(direction, currencyCode), firstRowDistance);
        fiatDirectionInfo = direction == OfferPayload.Direction.BUY ? toReceive : toSpend;
        btcDirectionInfo = direction == OfferPayload.Direction.SELL ? toReceive : toSpend;
    } else if (placeOfferHandlerOptional.isPresent()) {
        addLabelTextField(gridPane, rowIndex, offerTypeLabel, formatter.getOfferDirectionForCreateOffer(direction, currencyCode), firstRowDistance);
        fiatDirectionInfo = direction == OfferPayload.Direction.SELL ? toReceive : toSpend;
        btcDirectionInfo = direction == OfferPayload.Direction.BUY ? toReceive : toSpend;
    } else {
        addLabelTextField(gridPane, rowIndex, offerTypeLabel, formatter.getDirectionBothSides(direction, currencyCode), firstRowDistance);
    }
    String btcAmount = Res.get("shared.btcAmount");
    if (takeOfferHandlerOptional.isPresent()) {
        addLabelTextField(gridPane, ++rowIndex, btcAmount + btcDirectionInfo, formatter.formatCoinWithCode(tradeAmount));
        addLabelTextField(gridPane, ++rowIndex, formatter.formatVolumeLabel(currencyCode) + fiatDirectionInfo, formatter.formatVolumeWithCode(offer.getVolumeByAmount(tradeAmount)));
    } else {
        addLabelTextField(gridPane, ++rowIndex, btcAmount + btcDirectionInfo, formatter.formatCoinWithCode(offer.getAmount()));
        addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.minBtcAmount"), formatter.formatCoinWithCode(offer.getMinAmount()));
        String volume = formatter.formatVolumeWithCode(offer.getVolume());
        String minVolume = "";
        if (offer.getVolume() != null && offer.getMinVolume() != null && !offer.getVolume().equals(offer.getMinVolume()))
            minVolume = " " + Res.get("offerDetailsWindow.min", formatter.formatVolumeWithCode(offer.getMinVolume()));
        addLabelTextField(gridPane, ++rowIndex, formatter.formatVolumeLabel(currencyCode) + fiatDirectionInfo, volume + minVolume);
    }
    String priceLabel = Res.getWithCol("shared.price");
    if (takeOfferHandlerOptional.isPresent()) {
        addLabelTextField(gridPane, ++rowIndex, priceLabel, formatter.formatPrice(tradePrice));
    } else {
        Price price = offer.getPrice();
        if (offer.isUseMarketBasedPrice()) {
            addLabelTextField(gridPane, ++rowIndex, priceLabel, formatter.formatPrice(price) + " " + Res.get("offerDetailsWindow.distance", formatter.formatPercentagePrice(offer.getMarketPriceMargin())));
        } else {
            addLabelTextField(gridPane, ++rowIndex, priceLabel, formatter.formatPrice(price));
        }
    }
    final PaymentMethod paymentMethod = offer.getPaymentMethod();
    final String makerPaymentAccountId = offer.getMakerPaymentAccountId();
    final PaymentAccount paymentAccount = user.getPaymentAccount(makerPaymentAccountId);
    String bankId = offer.getBankId();
    if (bankId == null || bankId.equals("null"))
        bankId = "";
    else
        bankId = " (" + bankId + ")";
    final boolean isSpecificBanks = paymentMethod.equals(PaymentMethod.SPECIFIC_BANKS);
    final boolean isNationalBanks = paymentMethod.equals(PaymentMethod.NATIONAL_BANK);
    final boolean isSepa = paymentMethod.equals(PaymentMethod.SEPA);
    if (offer.isMyOffer(keyRing) && makerPaymentAccountId != null && paymentAccount != null) {
        addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.myTradingAccount"), paymentAccount.getAccountName());
    } else {
        final String method = Res.get(paymentMethod.getId());
        String paymentMethodLabel = Res.getWithCol("shared.paymentMethod");
        if (isNationalBanks || isSpecificBanks || isSepa) {
            String methodWithBankId = method + bankId;
            if (BankUtil.isBankIdRequired(offer.getCountryCode()))
                addLabelTextField(gridPane, ++rowIndex, paymentMethodLabel + " " + Res.get("offerDetailsWindow.offererBankId"), methodWithBankId);
            else if (BankUtil.isBankNameRequired(offer.getCountryCode()))
                addLabelTextField(gridPane, ++rowIndex, paymentMethodLabel + " " + Res.get("offerDetailsWindow.offerersBankName"), methodWithBankId);
        } else {
            addLabelTextField(gridPane, ++rowIndex, paymentMethodLabel, method);
        }
    }
    if (showAcceptedBanks) {
        if (paymentMethod.equals(PaymentMethod.SAME_BANK)) {
            addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.bankId"), acceptedBanks.get(0));
        } else if (isSpecificBanks) {
            String value = Joiner.on(", ").join(acceptedBanks);
            String acceptedBanksLabel = Res.getWithCol("shared.acceptedBanks");
            Tooltip tooltip = new Tooltip(acceptedBanksLabel + " " + value);
            TextField acceptedBanksTextField = addLabelTextField(gridPane, ++rowIndex, acceptedBanksLabel, value).second;
            acceptedBanksTextField.setMouseTransparent(false);
            acceptedBanksTextField.setTooltip(tooltip);
        }
    }
    if (showAcceptedCountryCodes) {
        String countries;
        Tooltip tooltip = null;
        if (CountryUtil.containsAllSepaEuroCountries(acceptedCountryCodes)) {
            countries = Res.getWithCol("shared.allEuroCountries");
        } else {
            if (acceptedCountryCodes.size() == 1) {
                countries = CountryUtil.getNameAndCode(acceptedCountryCodes.get(0));
                tooltip = new Tooltip(countries);
            } else {
                countries = CountryUtil.getCodesString(acceptedCountryCodes);
                tooltip = new Tooltip(CountryUtil.getNamesByCodesString(acceptedCountryCodes));
            }
        }
        TextField acceptedCountries = addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.acceptedTakerCountries"), countries).second;
        if (tooltip != null) {
            acceptedCountries.setMouseTransparent(false);
            acceptedCountries.setTooltip(tooltip);
        }
    }
    rows = 5;
    String paymentMethodCountryCode = offer.getCountryCode();
    if (paymentMethodCountryCode != null)
        rows++;
    if (offer.getOfferFeePaymentTxId() != null)
        rows++;
    addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("shared.details"), Layout.GROUP_DISTANCE);
    addLabelTextFieldWithCopyIcon(gridPane, rowIndex, Res.getWithCol("shared.offerId"), offer.getId(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("offerDetailsWindow.makersOnion"), offer.getMakerNodeAddress().getFullAddress());
    addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.creationDate"), formatter.formatDateTime(offer.getDate()));
    String value = Res.getWithColAndCap("shared.buyer") + " " + formatter.formatCoinWithCode(offer.getBuyerSecurityDeposit()) + " / " + Res.getWithColAndCap("shared.seller") + " " + formatter.formatCoinWithCode(offer.getSellerSecurityDeposit());
    addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.securityDeposit"), value);
    if (paymentMethodCountryCode != null)
        addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.countryBank"), CountryUtil.getNameAndCode(paymentMethodCountryCode));
    addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("offerDetailsWindow.acceptedArbitrators"), formatter.arbitratorAddressesToString(offer.getArbitratorNodeAddresses()));
    if (offer.getOfferFeePaymentTxId() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.makerFeeTxId"), offer.getOfferFeePaymentTxId());
    if (placeOfferHandlerOptional.isPresent()) {
        addTitledGroupBg(gridPane, ++rowIndex, 1, Res.get("offerDetailsWindow.commitment"), Layout.GROUP_DISTANCE);
        addLabelTextField(gridPane, rowIndex, Res.get("offerDetailsWindow.agree"), Res.get("createOffer.tac"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
        addConfirmAndCancelButtons(true);
    } else if (takeOfferHandlerOptional.isPresent()) {
        addTitledGroupBg(gridPane, ++rowIndex, 1, Res.get("shared.contract"), Layout.GROUP_DISTANCE);
        addLabelTextField(gridPane, rowIndex, Res.get("offerDetailsWindow.tac"), Res.get("takeOffer.tac"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
        addConfirmAndCancelButtons(false);
    } else {
        Button closeButton = addButtonAfterGroup(gridPane, ++rowIndex, Res.get("shared.close"));
        closeButton.setOnAction(e -> {
            closeHandlerOptional.ifPresent(Runnable::run);
            hide();
        });
    }
}
Also used : Button(javafx.scene.control.Button) BusyAnimation(bisq.desktop.components.BusyAnimation) ArbitratorSelectionView(bisq.desktop.main.account.content.arbitratorselection.ArbitratorSelectionView) Coin(org.bitcoinj.core.Coin) LoggerFactory(org.slf4j.LoggerFactory) Layout(bisq.desktop.util.Layout) BSFormatter(bisq.desktop.util.BSFormatter) User(bisq.core.user.User) Inject(javax.inject.Inject) OfferPayload(bisq.core.offer.OfferPayload) Tuple3(bisq.common.util.Tuple3) Insets(javafx.geometry.Insets) Res(bisq.core.locale.Res) Overlay(bisq.desktop.main.overlays.Overlay) Tooltip(javafx.scene.control.Tooltip) AccountView(bisq.desktop.main.account.AccountView) Navigation(bisq.desktop.Navigation) Popup(bisq.desktop.main.overlays.popups.Popup) Offer(bisq.core.offer.Offer) TextField(javafx.scene.control.TextField) Label(javafx.scene.control.Label) Logger(org.slf4j.Logger) FormBuilder(bisq.desktop.util.FormBuilder) PaymentMethod(bisq.core.payment.payload.PaymentMethod) MainView(bisq.desktop.main.MainView) PaymentAccount(bisq.core.payment.PaymentAccount) List(java.util.List) ImageView(javafx.scene.image.ImageView) CountryUtil(bisq.core.locale.CountryUtil) Price(bisq.core.monetary.Price) AccountSettingsView(bisq.desktop.main.account.settings.AccountSettingsView) Optional(java.util.Optional) BankUtil(bisq.core.locale.BankUtil) KeyRing(bisq.common.crypto.KeyRing) Joiner(com.google.common.base.Joiner) PaymentAccount(bisq.core.payment.PaymentAccount) Tooltip(javafx.scene.control.Tooltip) Price(bisq.core.monetary.Price) Button(javafx.scene.control.Button) PaymentMethod(bisq.core.payment.payload.PaymentMethod) TextField(javafx.scene.control.TextField) OfferPayload(bisq.core.offer.OfferPayload)

Aggregations

PaymentMethod (bisq.core.payment.payload.PaymentMethod)7 Tuple3 (bisq.common.util.Tuple3)3 Res (bisq.core.locale.Res)3 Offer (bisq.core.offer.Offer)3 PaymentAccount (bisq.core.payment.PaymentAccount)3 Popup (bisq.desktop.main.overlays.popups.Popup)3 BSFormatter (bisq.desktop.util.BSFormatter)3 Layout (bisq.desktop.util.Layout)3 Button (javafx.scene.control.Button)3 Label (javafx.scene.control.Label)3 ImageView (javafx.scene.image.ImageView)3 Inject (javax.inject.Inject)3 Coin (org.bitcoinj.core.Coin)3 Price (bisq.core.monetary.Price)2 OfferPayload (bisq.core.offer.OfferPayload)2 Navigation (bisq.desktop.Navigation)2 ActivatableViewAndModel (bisq.desktop.common.view.ActivatableViewAndModel)2 FxmlView (bisq.desktop.common.view.FxmlView)2 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)2 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)2