Search in sources :

Example 1 with TradeCurrency

use of io.bitsquare.locale.TradeCurrency in project bitsquare by bitsquare.

the class GUIUtil method getCurrencyListItemConverter.

public static StringConverter<CurrencyListItem> getCurrencyListItemConverter(String postFix, Preferences preferences) {
    return new StringConverter<CurrencyListItem>() {

        @Override
        public String toString(CurrencyListItem item) {
            TradeCurrency tradeCurrency = item.tradeCurrency;
            String code = tradeCurrency.getCode();
            if (code.equals(GUIUtil.SHOW_ALL_FLAG))
                return "▶ Show all";
            else if (code.equals(GUIUtil.EDIT_FLAG))
                return "▼ Edit currency list";
            else {
                String displayString = CurrencyUtil.getNameByCode(code) + " (" + code + ")";
                if (preferences.getSortMarketCurrenciesNumerically())
                    displayString += " - " + item.numTrades + " " + postFix;
                return tradeCurrency.getDisplayPrefix() + displayString;
            }
        }

        @Override
        public CurrencyListItem fromString(String s) {
            return null;
        }
    };
}
Also used : TradeCurrency(io.bitsquare.locale.TradeCurrency) StringConverter(javafx.util.StringConverter)

Example 2 with TradeCurrency

use of io.bitsquare.locale.TradeCurrency in project bitsquare by bitsquare.

the class AltCoinAccountsView method onSaveNewAccount.

///////////////////////////////////////////////////////////////////////////////////////////
// UI actions
///////////////////////////////////////////////////////////////////////////////////////////
private void onSaveNewAccount(PaymentAccount paymentAccount) {
    TradeCurrency selectedTradeCurrency = paymentAccount.getSelectedTradeCurrency();
    String code = selectedTradeCurrency.getCode();
    if (selectedTradeCurrency instanceof CryptoCurrency && ((CryptoCurrency) selectedTradeCurrency).isAsset()) {
        new Popup().information("Please be sure that you follow the requirements for the usage of " + selectedTradeCurrency.getCodeAndName() + " wallets as described on the " + selectedTradeCurrency.getName() + " web page.\n" + "Using wallets from centralized exchanges where you don't have your keys under your control or " + "using a not compatible wallet software can lead to loss of the traded funds!\n" + "The arbitrator is not a " + selectedTradeCurrency.getName() + " specialist and cannot help in such cases.").closeButtonText("I understand and confirm that I know which wallet I need to use.").show();
    }
    if (code.equals("XMR")) {
        new Popup().information("If you want to trade XMR on Bitsquare please be sure you understand and fulfill " + "the following requirements:\n\n" + "For sending XMR you need to use the Monero simple wallet with the " + "store-tx-info flag enabled (default in new versions).\n" + "Please be sure that you can access the tx key (use the get_tx_key command in simplewallet) as that " + "would be required in case of a dispute to enable the arbitrator to verify the XMR transfer with " + "the XMR checktx tool (http://xmr.llcoins.net/checktx.html).\n" + "At normal block explorers the transfer is not verifiable.\n\n" + "You need to provide the arbitrator the following data in case of a dispute:\n" + "- The tx private key\n" + "- The transaction hash\n" + "- The recipient's public address\n\n" + "If you cannot provide the above data or if you used an incompatible wallet it would result in losing the " + "dispute case. The XMR sender is responsible to be able to verify the XMR transfer to the " + "arbitrator in case of a dispute.\n\n" + "There is no payment ID required, just the normal public address.\n\n" + "If you are not sure about that process visit the Monero forum (https://forum.getmonero.org) to find more information.").closeButtonText("I understand").show();
    } else if (code.equals("ZEC")) {
        new Popup().information("When using ZEC you can only use the transparent addresses (starting with t) not " + "the z-addresses, because the arbitrator would not be able to verify the transaction with z-addresses.").closeButtonText("I understand").show();
    } else if (code.equals("XZC")) {
        new Popup().information("When using XZC you can only use the transparent transactions not " + "the private transactions, because the arbitrator would not be able to verify the private transactions.").closeButtonText("I understand").show();
    }
    if (!model.getPaymentAccounts().stream().filter(e -> {
        if (e.getAccountName() != null)
            return e.getAccountName().equals(paymentAccount.getAccountName());
        else
            return false;
    }).findAny().isPresent()) {
        model.onSaveNewAccount(paymentAccount);
        removeNewAccountForm();
    } else {
        new Popup().warning("That account name is already used in a saved account.\n" + "Please use another name.").show();
    }
}
Also used : Button(javafx.scene.control.Button) PaymentAccountFactory(io.bitsquare.payment.PaymentAccountFactory) PaymentMethod(io.bitsquare.payment.PaymentMethod) Popup(io.bitsquare.gui.main.overlays.popups.Popup) ListView(javafx.scene.control.ListView) ListCell(javafx.scene.control.ListCell) TradeCurrency(io.bitsquare.locale.TradeCurrency) Tuple2(io.bitsquare.common.util.Tuple2) PaymentMethodForm(io.bitsquare.gui.components.paymentmethods.PaymentMethodForm) Inject(javax.inject.Inject) PaymentAccount(io.bitsquare.payment.PaymentAccount) Layout(io.bitsquare.gui.util.Layout) VPos(javafx.geometry.VPos) Callback(javafx.util.Callback) GridPane(javafx.scene.layout.GridPane) BSFormatter(io.bitsquare.gui.util.BSFormatter) Label(javafx.scene.control.Label) CryptoCurrency(io.bitsquare.locale.CryptoCurrency) UserThread(io.bitsquare.common.UserThread) ImageUtil(io.bitsquare.gui.util.ImageUtil) io.bitsquare.gui.util.validation(io.bitsquare.gui.util.validation) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) TimeUnit(java.util.concurrent.TimeUnit) FormBuilder(io.bitsquare.gui.util.FormBuilder) Tuple3(io.bitsquare.common.util.Tuple3) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) CryptoCurrencyForm(io.bitsquare.gui.components.paymentmethods.CryptoCurrencyForm) FxmlView(io.bitsquare.gui.common.view.FxmlView) ChangeListener(javafx.beans.value.ChangeListener) TitledGroupBg(io.bitsquare.gui.components.TitledGroupBg) CryptoCurrency(io.bitsquare.locale.CryptoCurrency) TradeCurrency(io.bitsquare.locale.TradeCurrency) Popup(io.bitsquare.gui.main.overlays.popups.Popup)

Example 3 with TradeCurrency

use of io.bitsquare.locale.TradeCurrency in project bitsquare by bitsquare.

the class FiatAccountsDataModel method onSaveNewAccount.

///////////////////////////////////////////////////////////////////////////////////////////
// UI actions
///////////////////////////////////////////////////////////////////////////////////////////
public void onSaveNewAccount(PaymentAccount paymentAccount) {
    user.addPaymentAccount(paymentAccount);
    TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
    List<TradeCurrency> tradeCurrencies = paymentAccount.getTradeCurrencies();
    if (singleTradeCurrency != null) {
        if (singleTradeCurrency instanceof FiatCurrency)
            preferences.addFiatCurrency((FiatCurrency) singleTradeCurrency);
        else
            preferences.addCryptoCurrency((CryptoCurrency) singleTradeCurrency);
    } else if (tradeCurrencies != null && !tradeCurrencies.isEmpty()) {
        tradeCurrencies.stream().forEach(tradeCurrency -> {
            if (tradeCurrency instanceof FiatCurrency)
                preferences.addFiatCurrency((FiatCurrency) tradeCurrency);
            else
                preferences.addCryptoCurrency((CryptoCurrency) tradeCurrency);
        });
    }
}
Also used : PaymentMethod(io.bitsquare.payment.PaymentMethod) ActivatableDataModel(io.bitsquare.gui.common.model.ActivatableDataModel) FiatCurrency(io.bitsquare.locale.FiatCurrency) CryptoCurrency(io.bitsquare.locale.CryptoCurrency) Inject(com.google.inject.Inject) SetChangeListener(javafx.collections.SetChangeListener) TradeCurrency(io.bitsquare.locale.TradeCurrency) FXCollections(javafx.collections.FXCollections) Collectors(java.util.stream.Collectors) GUIUtil(io.bitsquare.gui.util.GUIUtil) ArrayList(java.util.ArrayList) PaymentAccount(io.bitsquare.payment.PaymentAccount) TradeManager(io.bitsquare.trade.TradeManager) Preferences(io.bitsquare.user.Preferences) User(io.bitsquare.user.User) List(java.util.List) CryptoCurrencyAccount(io.bitsquare.payment.CryptoCurrencyAccount) Stage(javafx.stage.Stage) OpenOfferManager(io.bitsquare.trade.offer.OpenOfferManager) ObservableList(javafx.collections.ObservableList) CryptoCurrency(io.bitsquare.locale.CryptoCurrency) TradeCurrency(io.bitsquare.locale.TradeCurrency) FiatCurrency(io.bitsquare.locale.FiatCurrency)

Example 4 with TradeCurrency

use of io.bitsquare.locale.TradeCurrency in project bitsquare by bitsquare.

the class AltCoinAccountsDataModel method onSaveNewAccount.

///////////////////////////////////////////////////////////////////////////////////////////
// UI actions
///////////////////////////////////////////////////////////////////////////////////////////
public void onSaveNewAccount(PaymentAccount paymentAccount) {
    user.addPaymentAccount(paymentAccount);
    TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
    List<TradeCurrency> tradeCurrencies = paymentAccount.getTradeCurrencies();
    if (singleTradeCurrency != null) {
        if (singleTradeCurrency instanceof FiatCurrency)
            preferences.addFiatCurrency((FiatCurrency) singleTradeCurrency);
        else
            preferences.addCryptoCurrency((CryptoCurrency) singleTradeCurrency);
    } else if (tradeCurrencies != null && !tradeCurrencies.isEmpty()) {
        tradeCurrencies.stream().forEach(tradeCurrency -> {
            if (tradeCurrency instanceof FiatCurrency)
                preferences.addFiatCurrency((FiatCurrency) tradeCurrency);
            else
                preferences.addCryptoCurrency((CryptoCurrency) tradeCurrency);
        });
    }
}
Also used : PaymentMethod(io.bitsquare.payment.PaymentMethod) ActivatableDataModel(io.bitsquare.gui.common.model.ActivatableDataModel) FiatCurrency(io.bitsquare.locale.FiatCurrency) CryptoCurrency(io.bitsquare.locale.CryptoCurrency) Inject(com.google.inject.Inject) SetChangeListener(javafx.collections.SetChangeListener) TradeCurrency(io.bitsquare.locale.TradeCurrency) FXCollections(javafx.collections.FXCollections) Collectors(java.util.stream.Collectors) GUIUtil(io.bitsquare.gui.util.GUIUtil) ArrayList(java.util.ArrayList) PaymentAccount(io.bitsquare.payment.PaymentAccount) TradeManager(io.bitsquare.trade.TradeManager) Preferences(io.bitsquare.user.Preferences) User(io.bitsquare.user.User) List(java.util.List) CryptoCurrencyAccount(io.bitsquare.payment.CryptoCurrencyAccount) Stage(javafx.stage.Stage) OpenOfferManager(io.bitsquare.trade.offer.OpenOfferManager) ObservableList(javafx.collections.ObservableList) CryptoCurrency(io.bitsquare.locale.CryptoCurrency) TradeCurrency(io.bitsquare.locale.TradeCurrency) FiatCurrency(io.bitsquare.locale.FiatCurrency)

Example 5 with TradeCurrency

use of io.bitsquare.locale.TradeCurrency in project bitsquare by bitsquare.

the class OfferView method loadView.

private void loadView(Class<? extends View> viewClass) {
    TabPane tabPane = root;
    View view;
    boolean isBuy = direction == Offer.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 ? "Buy bitcoin" : "Sell bitcoin");
        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;
                    OfferView.this.navigation.navigateTo(MainView.class, OfferView.this.getClass(), CreateOfferView.class);
                } else {
                    new Popup().information("You have already a \"Create offer\" tab open.").show();
                }
            }

            @Override
            public void onTakeOffer(Offer offer) {
                if (!takeOfferViewOpen) {
                    OfferView.this.takeOfferViewOpen = true;
                    OfferView.this.offer = offer;
                    OfferView.this.navigation.navigateTo(MainView.class, OfferView.this.getClass(), TakeOfferView.class);
                } else {
                    new Popup().information("You have already a \"Take offer\" tab open.").show();
                }
            }
        };
        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(io.bitsquare.locale.TradeCurrency) CreateOfferView(io.bitsquare.gui.main.offer.createoffer.CreateOfferView) Tab(javafx.scene.control.Tab) Offer(io.bitsquare.trade.offer.Offer) Popup(io.bitsquare.gui.main.overlays.popups.Popup) OfferBookView(io.bitsquare.gui.main.offer.offerbook.OfferBookView) MainView(io.bitsquare.gui.main.MainView) TakeOfferView(io.bitsquare.gui.main.offer.takeoffer.TakeOfferView) View(io.bitsquare.gui.common.view.View) ActivatableView(io.bitsquare.gui.common.view.ActivatableView) CreateOfferView(io.bitsquare.gui.main.offer.createoffer.CreateOfferView) OfferBookView(io.bitsquare.gui.main.offer.offerbook.OfferBookView)

Aggregations

TradeCurrency (io.bitsquare.locale.TradeCurrency)7 PaymentAccount (io.bitsquare.payment.PaymentAccount)4 CryptoCurrency (io.bitsquare.locale.CryptoCurrency)3 FiatCurrency (io.bitsquare.locale.FiatCurrency)3 PaymentMethod (io.bitsquare.payment.PaymentMethod)3 Inject (com.google.inject.Inject)2 ActivatableDataModel (io.bitsquare.gui.common.model.ActivatableDataModel)2 Popup (io.bitsquare.gui.main.overlays.popups.Popup)2 GUIUtil (io.bitsquare.gui.util.GUIUtil)2 CryptoCurrencyAccount (io.bitsquare.payment.CryptoCurrencyAccount)2 TradeManager (io.bitsquare.trade.TradeManager)2 Offer (io.bitsquare.trade.offer.Offer)2 OpenOfferManager (io.bitsquare.trade.offer.OpenOfferManager)2 Preferences (io.bitsquare.user.Preferences)2 User (io.bitsquare.user.User)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 FXCollections (javafx.collections.FXCollections)2 ObservableList (javafx.collections.ObservableList)2