Search in sources :

Example 11 with TitledGroupBg

use of bisq.desktop.components.TitledGroupBg in project bisq-desktop by bisq-network.

the class PreferencesView method initializeDisplayCurrencies.

private void initializeDisplayCurrencies() {
    TitledGroupBg titledGroupBg = addTitledGroupBg(root, ++gridRow, 3, Res.get("setting.preferences.currenciesInList"), Layout.GROUP_DISTANCE);
    GridPane.setColumnSpan(titledGroupBg, 4);
    // noinspection unchecked
    preferredTradeCurrencyComboBox = addLabelComboBox(root, gridRow, Res.get("setting.preferences.prefCurrency"), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
    preferredTradeCurrencyComboBox.setConverter(new StringConverter<TradeCurrency>() {

        @Override
        public String toString(TradeCurrency tradeCurrency) {
            // http://boschista.deviantart.com/journal/Cool-ASCII-Symbols-214218618
            return tradeCurrency.getDisplayPrefix() + tradeCurrency.getNameAndCode();
        }

        @Override
        public TradeCurrency fromString(String s) {
            return null;
        }
    });
    Tuple2<Label, ListView> fiatTuple = addLabelListView(root, ++gridRow, Res.get("setting.preferences.displayFiat"));
    GridPane.setValignment(fiatTuple.first, VPos.TOP);
    // noinspection unchecked
    fiatCurrenciesListView = fiatTuple.second;
    fiatCurrenciesListView.setMinHeight(2 * Layout.LIST_ROW_HEIGHT + 2);
    fiatCurrenciesListView.setPrefHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
    Label placeholder = new AutoTooltipLabel(Res.get("setting.preferences.noFiat"));
    placeholder.setWrapText(true);
    fiatCurrenciesListView.setPlaceholder(placeholder);
    fiatCurrenciesListView.setCellFactory(new Callback<ListView<FiatCurrency>, ListCell<FiatCurrency>>() {

        @Override
        public ListCell<FiatCurrency> call(ListView<FiatCurrency> list) {
            return new ListCell<FiatCurrency>() {

                final Label label = new AutoTooltipLabel();

                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);

                final Button removeButton = new AutoTooltipButton("", icon);

                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final FiatCurrency item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(item.getNameAndCode());
                        removeButton.setOnAction(e -> {
                            if (item.equals(preferences.getPreferredTradeCurrency())) {
                                new Popup<>().warning(Res.get("setting.preferences.cannotRemovePrefCurrency")).show();
                            } else {
                                preferences.removeFiatCurrency(item);
                                if (!allFiatCurrencies.contains(item))
                                    allFiatCurrencies.add(item);
                            }
                        });
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                        removeButton.setOnAction(null);
                    }
                }
            };
        }
    });
    Tuple2<Label, ListView> cryptoCurrenciesTuple = addLabelListView(root, gridRow, Res.get("setting.preferences.displayAltcoins"));
    GridPane.setValignment(cryptoCurrenciesTuple.first, VPos.TOP);
    GridPane.setMargin(cryptoCurrenciesTuple.first, new Insets(0, 0, 0, 20));
    // noinspection unchecked
    cryptoCurrenciesListView = cryptoCurrenciesTuple.second;
    GridPane.setColumnIndex(cryptoCurrenciesTuple.first, 2);
    GridPane.setColumnIndex(cryptoCurrenciesListView, 3);
    cryptoCurrenciesListView.setMinHeight(2 * Layout.LIST_ROW_HEIGHT + 2);
    cryptoCurrenciesListView.setPrefHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
    placeholder = new AutoTooltipLabel(Res.get("setting.preferences.noAltcoins"));
    placeholder.setWrapText(true);
    cryptoCurrenciesListView.setPlaceholder(placeholder);
    cryptoCurrenciesListView.setCellFactory(new Callback<ListView<CryptoCurrency>, ListCell<CryptoCurrency>>() {

        @Override
        public ListCell<CryptoCurrency> call(ListView<CryptoCurrency> list) {
            return new ListCell<CryptoCurrency>() {

                final Label label = new AutoTooltipLabel();

                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);

                final Button removeButton = new AutoTooltipButton("", icon);

                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final CryptoCurrency item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(item.getNameAndCode());
                        removeButton.setOnAction(e -> {
                            if (item.equals(preferences.getPreferredTradeCurrency())) {
                                new Popup<>().warning(Res.get("setting.preferences.cannotRemovePrefCurrency")).show();
                            } else {
                                preferences.removeCryptoCurrency(item);
                                if (!allCryptoCurrencies.contains(item))
                                    allCryptoCurrencies.add(item);
                            }
                        });
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                        removeButton.setOnAction(null);
                    }
                }
            };
        }
    });
    // noinspection unchecked
    fiatCurrenciesComboBox = addLabelComboBox(root, ++gridRow).second;
    fiatCurrenciesComboBox.setPromptText(Res.get("setting.preferences.addFiat"));
    fiatCurrenciesComboBox.setConverter(new StringConverter<FiatCurrency>() {

        @Override
        public String toString(FiatCurrency tradeCurrency) {
            return tradeCurrency.getNameAndCode();
        }

        @Override
        public FiatCurrency fromString(String s) {
            return null;
        }
    });
    Tuple2<Label, ComboBox> labelComboBoxTuple2 = addLabelComboBox(root, gridRow);
    // noinspection unchecked
    cryptoCurrenciesComboBox = labelComboBoxTuple2.second;
    GridPane.setColumnIndex(cryptoCurrenciesComboBox, 3);
    cryptoCurrenciesComboBox.setPromptText(Res.get("setting.preferences.addAltcoin"));
    cryptoCurrenciesComboBox.setConverter(new StringConverter<CryptoCurrency>() {

        @Override
        public String toString(CryptoCurrency tradeCurrency) {
            return tradeCurrency.getNameAndCode();
        }

        @Override
        public CryptoCurrency fromString(String s) {
            return null;
        }
    });
}
Also used : Button(javafx.scene.control.Button) Arrays(java.util.Arrays) Coin(org.bitcoinj.core.Coin) ListCell(javafx.scene.control.ListCell) Layout(bisq.desktop.util.Layout) StringUtils(org.apache.commons.lang3.StringUtils) BSFormatter(bisq.desktop.util.BSFormatter) InputTextField(bisq.desktop.components.InputTextField) ComboBox(javafx.scene.control.ComboBox) Res(bisq.core.locale.Res) BisqApp(bisq.desktop.app.BisqApp) Popup(bisq.desktop.main.overlays.popups.Popup) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder(bisq.desktop.util.FormBuilder) BlockChainExplorer(bisq.core.user.BlockChainExplorer) BaseCurrencyNetwork(bisq.core.btc.BaseCurrencyNetwork) Collectors(java.util.stream.Collectors) List(java.util.List) CryptoCurrency(bisq.core.locale.CryptoCurrency) DevEnv(bisq.common.app.DevEnv) AnchorPane(javafx.scene.layout.AnchorPane) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Preferences(bisq.core.user.Preferences) UserThread(bisq.common.UserThread) CountryUtil(bisq.core.locale.CountryUtil) Activatable(bisq.desktop.common.model.Activatable) FeeService(bisq.core.provider.fee.FeeService) ObservableList(javafx.collections.ObservableList) TradeCurrency(bisq.core.locale.TradeCurrency) ListView(javafx.scene.control.ListView) FXCollections(javafx.collections.FXCollections) FiatCurrency(bisq.core.locale.FiatCurrency) FxmlView(bisq.desktop.common.view.FxmlView) Inject(javax.inject.Inject) Tuple2(bisq.common.util.Tuple2) Tuple3(bisq.common.util.Tuple3) Insets(javafx.geometry.Insets) Country(bisq.core.locale.Country) VPos(javafx.geometry.VPos) CurrencyUtil(bisq.core.locale.CurrencyUtil) Callback(javafx.util.Callback) TitledGroupBg(bisq.desktop.components.TitledGroupBg) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) CheckBox(javafx.scene.control.CheckBox) BisqEnvironment(bisq.core.app.BisqEnvironment) StringConverter(javafx.util.StringConverter) TimeUnit(java.util.concurrent.TimeUnit) ImageUtil(bisq.desktop.util.ImageUtil) ImageView(javafx.scene.image.ImageView) LanguageUtil(bisq.core.locale.LanguageUtil) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) Insets(javafx.geometry.Insets) ListCell(javafx.scene.control.ListCell) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) CryptoCurrency(bisq.core.locale.CryptoCurrency) ListView(javafx.scene.control.ListView) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) FiatCurrency(bisq.core.locale.FiatCurrency) ImageView(javafx.scene.image.ImageView) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AnchorPane(javafx.scene.layout.AnchorPane) TradeCurrency(bisq.core.locale.TradeCurrency) ComboBox(javafx.scene.control.ComboBox) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) TitledGroupBg(bisq.desktop.components.TitledGroupBg)

Example 12 with TitledGroupBg

use of bisq.desktop.components.TitledGroupBg in project bisq-desktop by bisq-network.

the class BuyerStep2View method addContent.

// /////////////////////////////////////////////////////////////////////////////////////////
// Content
// /////////////////////////////////////////////////////////////////////////////////////////
@Override
protected void addContent() {
    addTradeInfoBlock();
    PaymentAccountPayload paymentAccountPayload = model.dataModel.getSellersPaymentAccountPayload();
    String paymentMethodId = paymentAccountPayload != null ? paymentAccountPayload.getPaymentMethodId() : "";
    TitledGroupBg accountTitledGroupBg = FormBuilder.addTitledGroupBg(gridPane, ++gridRow, 1, Res.get("portfolio.pending.step2_buyer.startPaymentUsing", Res.get(paymentMethodId)), Layout.GROUP_DISTANCE);
    TextFieldWithCopyIcon field = FormBuilder.addLabelTextFieldWithCopyIcon(gridPane, gridRow, Res.get("portfolio.pending.step2_buyer.amountToTransfer"), model.getFiatVolume(), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
    field.setCopyWithoutCurrencyPostFix(true);
    switch(paymentMethodId) {
        case PaymentMethod.OK_PAY_ID:
            gridRow = OKPayForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.UPHOLD_ID:
            gridRow = UpholdForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.CASH_APP_ID:
            gridRow = CashAppForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.MONEY_BEAM_ID:
            gridRow = MoneyBeamForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.VENMO_ID:
            gridRow = VenmoForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.POPMONEY_ID:
            gridRow = PopmoneyForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.REVOLUT_ID:
            gridRow = RevolutForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.PERFECT_MONEY_ID:
            gridRow = PerfectMoneyForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.SEPA_ID:
            gridRow = SepaForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.FASTER_PAYMENTS_ID:
            gridRow = FasterPaymentsForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.NATIONAL_BANK_ID:
            gridRow = NationalBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.SAME_BANK_ID:
            gridRow = SameBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.SPECIFIC_BANKS_ID:
            gridRow = SpecificBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.SWISH_ID:
            gridRow = SwishForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.ALI_PAY_ID:
            gridRow = AliPayForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.CLEAR_X_CHANGE_ID:
            gridRow = ClearXchangeForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.CHASE_QUICK_PAY_ID:
            gridRow = ChaseQuickPayForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.INTERAC_E_TRANSFER_ID:
            gridRow = InteracETransferForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.US_POSTAL_MONEY_ORDER_ID:
            gridRow = USPostalMoneyOrderForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.CASH_DEPOSIT_ID:
            gridRow = CashDepositForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.WESTERN_UNION_ID:
            gridRow = WesternUnionForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.BLOCK_CHAINS_ID:
            String labelTitle = Res.get("portfolio.pending.step2_buyer.sellersAddress", CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode()));
            gridRow = CryptoCurrencyForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload, labelTitle);
            break;
        default:
            log.error("Not supported PaymentMethod: " + paymentMethodId);
    }
    if (!(paymentAccountPayload instanceof CryptoCurrencyAccountPayload))
        FormBuilder.addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.getWithCol("shared.reasonForPayment"), model.dataModel.getReference());
    GridPane.setRowSpan(accountTitledGroupBg, gridRow - 3);
    Tuple3<Button, BusyAnimation, Label> tuple3 = FormBuilder.addButtonBusyAnimationLabelAfterGroup(gridPane, ++gridRow, Res.get("portfolio.pending.step2_buyer.paymentStarted"));
    confirmButton = tuple3.first;
    confirmButton.setOnAction(e -> onPaymentStarted());
    busyAnimation = tuple3.second;
    statusLabel = tuple3.third;
}
Also used : BusyAnimation(bisq.desktop.components.BusyAnimation) Button(javafx.scene.control.Button) TextFieldWithCopyIcon(bisq.desktop.components.TextFieldWithCopyIcon) PaymentAccountPayload(bisq.core.payment.payload.PaymentAccountPayload) Label(javafx.scene.control.Label) TitledGroupBg(bisq.desktop.components.TitledGroupBg) CryptoCurrencyAccountPayload(bisq.core.payment.payload.CryptoCurrencyAccountPayload)

Aggregations

TitledGroupBg (bisq.desktop.components.TitledGroupBg)12 Label (javafx.scene.control.Label)8 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)5 Insets (javafx.geometry.Insets)5 InputTextField (bisq.desktop.components.InputTextField)4 FormBuilder.addTitledGroupBg (bisq.desktop.util.FormBuilder.addTitledGroupBg)3 Button (javafx.scene.control.Button)3 ImageView (javafx.scene.image.ImageView)3 BaseCurrencyNetwork (bisq.core.btc.BaseCurrencyNetwork)2 TradeCurrency (bisq.core.locale.TradeCurrency)2 CryptoCurrencyAccountPayload (bisq.core.payment.payload.CryptoCurrencyAccountPayload)2 PaymentAccountPayload (bisq.core.payment.payload.PaymentAccountPayload)2 BusyAnimation (bisq.desktop.components.BusyAnimation)2 TextFieldWithCopyIcon (bisq.desktop.components.TextFieldWithCopyIcon)2 Popup (bisq.desktop.main.overlays.popups.Popup)2 ComboBox (javafx.scene.control.ComboBox)2 UserThread (bisq.common.UserThread)1 DevEnv (bisq.common.app.DevEnv)1 Tuple2 (bisq.common.util.Tuple2)1 Tuple3 (bisq.common.util.Tuple3)1