Search in sources :

Example 26 with TradeCurrency

use of bisq.core.locale.TradeCurrency in project bisq-desktop by bisq-network.

the class SepaInstantForm method autoFillNameTextField.

@Override
protected void autoFillNameTextField() {
    if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
        TradeCurrency singleTradeCurrency = this.paymentAccount.getSingleTradeCurrency();
        String currency = singleTradeCurrency != null ? singleTradeCurrency.getCode() : null;
        if (currency != null) {
            String iban = ibanInputTextField.getText();
            if (iban.length() > 9)
                iban = StringUtils.abbreviate(iban, 9);
            String method = Res.get(paymentAccount.getPaymentMethod().getId());
            CountryBasedPaymentAccount countryBasedPaymentAccount = (CountryBasedPaymentAccount) this.paymentAccount;
            String country = countryBasedPaymentAccount.getCountry() != null ? countryBasedPaymentAccount.getCountry().code : null;
            if (country != null)
                accountNameTextField.setText(method.concat(" (").concat(currency).concat("/").concat(country).concat("): ").concat(iban));
        }
    }
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) CountryBasedPaymentAccount(bisq.core.payment.CountryBasedPaymentAccount)

Example 27 with TradeCurrency

use of bisq.core.locale.TradeCurrency in project bisq-desktop by bisq-network.

the class SepaInstantForm method addFormForDisplayAccount.

@Override
public void addFormForDisplayAccount() {
    gridRowFrom = gridRow;
    FormBuilder.addLabelTextField(gridPane, gridRow, Res.get("payment.account.name"), sepaInstantAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    FormBuilder.addLabelTextField(gridPane, ++gridRow, Res.getWithCol("shared.paymentMethod"), Res.get(sepaInstantAccount.getPaymentMethod().getId()));
    FormBuilder.addLabelTextField(gridPane, ++gridRow, Res.getWithCol("payment.account.owner"), sepaInstantAccount.getHolderName());
    FormBuilder.addLabelTextField(gridPane, ++gridRow, "IBAN:", sepaInstantAccount.getIban()).second.setMouseTransparent(false);
    FormBuilder.addLabelTextField(gridPane, ++gridRow, "BIC:", sepaInstantAccount.getBic()).second.setMouseTransparent(false);
    FormBuilder.addLabelTextField(gridPane, ++gridRow, Res.get("payment.bank.country"), sepaInstantAccount.getCountry() != null ? sepaInstantAccount.getCountry().name : "");
    TradeCurrency singleTradeCurrency = sepaInstantAccount.getSingleTradeCurrency();
    String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "null";
    FormBuilder.addLabelTextField(gridPane, ++gridRow, Res.getWithCol("shared.currency"), nameAndCode);
    String countries;
    Tooltip tooltip = null;
    if (CountryUtil.containsAllSepaInstantEuroCountries(sepaInstantAccount.getAcceptedCountryCodes())) {
        countries = Res.getWithCol("shared.allEuroCountries");
    } else {
        countries = CountryUtil.getCodesString(sepaInstantAccount.getAcceptedCountryCodes());
        tooltip = new Tooltip(CountryUtil.getNamesByCodesString(sepaInstantAccount.getAcceptedCountryCodes()));
    }
    TextField acceptedCountries = FormBuilder.addLabelTextField(gridPane, ++gridRow, Res.get("payment.accepted.countries"), countries).second;
    if (tooltip != null) {
        acceptedCountries.setMouseTransparent(false);
        acceptedCountries.setTooltip(tooltip);
    }
    addLimitations();
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) Tooltip(javafx.scene.control.Tooltip) InputTextField(bisq.desktop.components.InputTextField) TextField(javafx.scene.control.TextField)

Example 28 with TradeCurrency

use of bisq.core.locale.TradeCurrency in project bisq-desktop by bisq-network.

the class OfferBookView method setDirectionTitles.

private void setDirectionTitles() {
    TradeCurrency selectedTradeCurrency = model.getSelectedTradeCurrency();
    if (selectedTradeCurrency != null) {
        OfferPayload.Direction direction = model.getDirection();
        String directionText = direction == OfferPayload.Direction.BUY ? Res.get("shared.buy") : Res.get("shared.sell");
        String mirroredDirectionText = direction == OfferPayload.Direction.SELL ? Res.get("shared.buy") : Res.get("shared.sell");
        String code = selectedTradeCurrency.getCode();
        if (model.showAllTradeCurrenciesProperty.get())
            createOfferButton.setText(Res.get("offerbook.createOfferTo", directionText, Res.getBaseCurrencyCode()));
        else if (selectedTradeCurrency instanceof FiatCurrency)
            createOfferButton.setText(Res.get("offerbook.createOfferTo", directionText, Res.getBaseCurrencyCode()) + " " + (direction == OfferPayload.Direction.BUY ? Res.get("offerbook.buyWithOtherCurrency", code) : Res.get("offerbook.sellForOtherCurrency", code)));
        else
            createOfferButton.setText(Res.get("offerbook.createOfferTo", mirroredDirectionText, code) + " (" + directionText + " " + Res.getBaseCurrencyCode() + ")");
    }
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) FiatCurrency(bisq.core.locale.FiatCurrency) OfferPayload(bisq.core.offer.OfferPayload)

Example 29 with TradeCurrency

use of bisq.core.locale.TradeCurrency in project bisq-desktop by bisq-network.

the class OfferView method loadView.

private void loadView(Class<? extends View> viewClass) {
    TabPane tabPane = root;
    View view;
    boolean isBuy = direction == OfferPayload.Direction.BUY;
    if (viewClass == OfferBookView.class && offerBookView == null) {
        view = viewLoader.load(viewClass);
        // Offerbook must not be cached by ViewLoader as we use 2 instances for sell and buy screens.
        offerBookTab = new Tab(isBuy ? Res.get("shared.buyBitcoin") : Res.get("shared.sellBitcoin"));
        offerBookTab.setClosable(false);
        offerBookTab.setContent(view.getRoot());
        tabPane.getTabs().add(offerBookTab);
        offerBookView = (OfferBookView) view;
        offerBookView.onTabSelected(true);
        OfferActionHandler offerActionHandler = new OfferActionHandler() {

            @Override
            public void onCreateOffer(TradeCurrency tradeCurrency) {
                if (!createOfferViewOpen) {
                    OfferView.this.createOfferViewOpen = true;
                    OfferView.this.tradeCurrency = tradeCurrency;
                    // noinspection unchecked
                    OfferView.this.navigation.navigateTo(MainView.class, OfferView.this.getClass(), CreateOfferView.class);
                } else {
                    log.error("You have already a \"Create offer\" tab open.");
                }
            }

            @Override
            public void onTakeOffer(Offer offer) {
                if (!takeOfferViewOpen) {
                    OfferView.this.takeOfferViewOpen = true;
                    OfferView.this.offer = offer;
                    // noinspection unchecked
                    OfferView.this.navigation.navigateTo(MainView.class, OfferView.this.getClass(), TakeOfferView.class);
                } else {
                    log.error("You have already a \"Take offer\" tab open.");
                }
            }
        };
        offerBookView.setOfferActionHandler(offerActionHandler);
        offerBookView.setDirection(direction);
    } else if (viewClass == CreateOfferView.class && createOfferView == null) {
        view = viewLoader.load(viewClass);
        // CreateOffer and TakeOffer must not be cached by ViewLoader as we cannot use a view multiple times
        // in different graphs
        createOfferView = (CreateOfferView) view;
        createOfferView.initWithData(direction, tradeCurrency);
        createOfferPane = createOfferView.getRoot();
        createOfferTab = new Tab(getCreateOfferTabName());
        // close handler from close on create offer action
        createOfferView.setCloseHandler(() -> tabPane.getTabs().remove(createOfferTab));
        createOfferTab.setContent(createOfferPane);
        tabPane.getTabs().add(createOfferTab);
        tabPane.getSelectionModel().select(createOfferTab);
    } else if (viewClass == TakeOfferView.class && takeOfferView == null && offer != null) {
        view = viewLoader.load(viewClass);
        // CreateOffer and TakeOffer must not be cached by ViewLoader as we cannot use a view multiple times
        // in different graphs
        takeOfferView = (TakeOfferView) view;
        takeOfferView.initWithData(offer);
        takeOfferPane = ((TakeOfferView) view).getRoot();
        takeOfferTab = new Tab(getTakeOfferTabName());
        // close handler from close on take offer action
        takeOfferView.setCloseHandler(() -> tabPane.getTabs().remove(takeOfferTab));
        takeOfferTab.setContent(takeOfferPane);
        tabPane.getTabs().add(takeOfferTab);
        tabPane.getSelectionModel().select(takeOfferTab);
    }
}
Also used : TabPane(javafx.scene.control.TabPane) TradeCurrency(bisq.core.locale.TradeCurrency) CreateOfferView(bisq.desktop.main.offer.createoffer.CreateOfferView) Tab(javafx.scene.control.Tab) Offer(bisq.core.offer.Offer) OfferBookView(bisq.desktop.main.offer.offerbook.OfferBookView) ActivatableView(bisq.desktop.common.view.ActivatableView) TakeOfferView(bisq.desktop.main.offer.takeoffer.TakeOfferView) OfferBookView(bisq.desktop.main.offer.offerbook.OfferBookView) View(bisq.desktop.common.view.View) MainView(bisq.desktop.main.MainView) CreateOfferView(bisq.desktop.main.offer.createoffer.CreateOfferView)

Example 30 with TradeCurrency

use of bisq.core.locale.TradeCurrency in project bisq-desktop by bisq-network.

the class PreferencesView method activateDisplayCurrencies.

private void activateDisplayCurrencies() {
    preferredTradeCurrencyComboBox.setItems(tradeCurrencies);
    preferredTradeCurrencyComboBox.getSelectionModel().select(preferences.getPreferredTradeCurrency());
    preferredTradeCurrencyComboBox.setVisibleRowCount(25);
    preferredTradeCurrencyComboBox.setOnAction(e -> {
        TradeCurrency selectedItem = preferredTradeCurrencyComboBox.getSelectionModel().getSelectedItem();
        if (selectedItem != null)
            preferences.setPreferredTradeCurrency(selectedItem);
    });
    fiatCurrenciesComboBox.setItems(allFiatCurrencies);
    fiatCurrenciesListView.setItems(fiatCurrencies);
    fiatCurrenciesComboBox.setOnAction(e -> {
        FiatCurrency selectedItem = fiatCurrenciesComboBox.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            preferences.addFiatCurrency(selectedItem);
            if (allFiatCurrencies.contains(selectedItem)) {
                UserThread.execute(() -> {
                    fiatCurrenciesComboBox.getSelectionModel().clearSelection();
                    allFiatCurrencies.remove(selectedItem);
                });
            }
        }
    });
    cryptoCurrenciesComboBox.setItems(allCryptoCurrencies);
    cryptoCurrenciesListView.setItems(cryptoCurrencies);
    cryptoCurrenciesComboBox.setOnAction(e -> {
        CryptoCurrency selectedItem = cryptoCurrenciesComboBox.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            preferences.addCryptoCurrency(selectedItem);
            if (allCryptoCurrencies.contains(selectedItem)) {
                UserThread.execute(() -> {
                    cryptoCurrenciesComboBox.getSelectionModel().clearSelection();
                    allCryptoCurrencies.remove(selectedItem);
                });
            }
        }
    });
}
Also used : CryptoCurrency(bisq.core.locale.CryptoCurrency) TradeCurrency(bisq.core.locale.TradeCurrency) FiatCurrency(bisq.core.locale.FiatCurrency)

Aggregations

TradeCurrency (bisq.core.locale.TradeCurrency)57 InputTextField (bisq.desktop.components.InputTextField)26 TextField (javafx.scene.control.TextField)16 FormBuilder.addLabelInputTextField (bisq.desktop.util.FormBuilder.addLabelInputTextField)13 FiatCurrency (bisq.core.locale.FiatCurrency)11 Country (bisq.core.locale.Country)10 FormBuilder.addLabelTextField (bisq.desktop.util.FormBuilder.addLabelTextField)9 CryptoCurrency (bisq.core.locale.CryptoCurrency)8 PaymentAccount (bisq.core.payment.PaymentAccount)7 ComboBox (javafx.scene.control.ComboBox)6 Label (javafx.scene.control.Label)6 CryptoCurrencyAccount (bisq.core.payment.CryptoCurrencyAccount)5 Popup (bisq.desktop.main.overlays.popups.Popup)5 List (java.util.List)5 Tuple2 (bisq.common.util.Tuple2)4 CurrencyUtil (bisq.core.locale.CurrencyUtil)4 OpenOfferManager (bisq.core.offer.OpenOfferManager)4 AccountAgeWitnessService (bisq.core.payment.AccountAgeWitnessService)4 TradeManager (bisq.core.trade.TradeManager)4 User (bisq.core.user.User)4