Search in sources :

Example 1 with BlockChainExplorer

use of bisq.core.user.BlockChainExplorer in project bisq-desktop by bisq-network.

the class PreferencesView method activateGeneralOptions.

// /////////////////////////////////////////////////////////////////////////////////////////
// Activate
// /////////////////////////////////////////////////////////////////////////////////////////
private void activateGeneralOptions() {
    List<BaseCurrencyNetwork> baseCurrencyNetworks = Arrays.asList(BaseCurrencyNetwork.values());
    // show ony mainnet in production version
    if (!DevEnv.isDevMode())
        baseCurrencyNetworks = baseCurrencyNetworks.stream().filter(e -> !e.isDash()).filter(BaseCurrencyNetwork::isMainnet).collect(Collectors.toList());
    selectBaseCurrencyNetworkComboBox.setItems(FXCollections.observableArrayList(baseCurrencyNetworks));
    selectBaseCurrencyNetworkComboBox.setOnAction(e -> onSelectNetwork());
    selectBaseCurrencyNetworkComboBox.getSelectionModel().select(BisqEnvironment.getBaseCurrencyNetwork());
    boolean useCustomWithdrawalTxFee = preferences.isUseCustomWithdrawalTxFee();
    useCustomFeeCheckbox.setSelected(useCustomWithdrawalTxFee);
    transactionFeeInputTextField.setEditable(useCustomWithdrawalTxFee);
    if (!useCustomWithdrawalTxFee) {
        transactionFeeInputTextField.setText(String.valueOf(feeService.getTxFeePerByte().value));
        feeService.feeUpdateCounterProperty().addListener(transactionFeeChangeListener);
    }
    transactionFeeInputTextField.setText(String.valueOf(getTxFeeForWithdrawalPerByte()));
    ignoreTradersListInputTextField.setText(preferences.getIgnoreTradersList().stream().collect(Collectors.joining(", ")));
    userLanguageComboBox.setItems(languageCodes);
    userLanguageComboBox.getSelectionModel().select(preferences.getUserLanguage());
    userLanguageComboBox.setConverter(new StringConverter<String>() {

        @Override
        public String toString(String code) {
            return LanguageUtil.getDisplayName(code);
        }

        @Override
        public String fromString(String string) {
            return null;
        }
    });
    userLanguageComboBox.setOnAction(e -> {
        String selectedItem = userLanguageComboBox.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            preferences.setUserLanguage(selectedItem);
            new Popup<>().information(Res.get("settings.preferences.languageChange")).closeButtonText(Res.get("shared.ok")).show();
        }
    // Should we apply the changed currency immediately to the language list?
    // If so and the user selects a unknown language he might get lost and it is hard to find
    // again the language he understands
    /* if (selectedItem != null && !selectedItem.equals(preferences.getUserLanguage())) {
                preferences.setUserLanguage(selectedItem);
                UserThread.execute(() -> {
                    languageCodes.clear();
                    languageCodes.addAll(LanguageUtil.getAllLanguageCodes());
                    userLanguageComboBox.getSelectionModel().select(preferences.getUserLanguage());
                });
            }*/
    });
    userCountryComboBox.setItems(countries);
    userCountryComboBox.getSelectionModel().select(preferences.getUserCountry());
    userCountryComboBox.setConverter(new StringConverter<Country>() {

        @Override
        public String toString(Country country) {
            return CountryUtil.getNameByCode(country.code);
        }

        @Override
        public Country fromString(String string) {
            return null;
        }
    });
    userCountryComboBox.setOnAction(e -> {
        Country country = userCountryComboBox.getSelectionModel().getSelectedItem();
        if (country != null) {
            preferences.setUserCountry(country);
        }
    });
    blockChainExplorerComboBox.setItems(blockExplorers);
    blockChainExplorerComboBox.getSelectionModel().select(preferences.getBlockChainExplorer());
    blockChainExplorerComboBox.setConverter(new StringConverter<BlockChainExplorer>() {

        @Override
        public String toString(BlockChainExplorer blockChainExplorer) {
            return blockChainExplorer.name;
        }

        @Override
        public BlockChainExplorer fromString(String string) {
            return null;
        }
    });
    blockChainExplorerComboBox.setOnAction(e -> preferences.setBlockChainExplorer(blockChainExplorerComboBox.getSelectionModel().getSelectedItem()));
    deviationInputTextField.setText(formatter.formatPercentagePrice(preferences.getMaxPriceDistanceInPercent()));
    deviationInputTextField.textProperty().addListener(deviationListener);
    deviationInputTextField.focusedProperty().addListener(deviationFocusedListener);
    transactionFeeInputTextField.focusedProperty().addListener(transactionFeeFocusedListener);
    ignoreTradersListInputTextField.textProperty().addListener(ignoreTradersListListener);
    useCustomFeeCheckbox.selectedProperty().addListener(useCustomFeeCheckboxListener);
}
Also used : BaseCurrencyNetwork(bisq.core.btc.BaseCurrencyNetwork) Country(bisq.core.locale.Country) BlockChainExplorer(bisq.core.user.BlockChainExplorer)

Aggregations

BaseCurrencyNetwork (bisq.core.btc.BaseCurrencyNetwork)1 Country (bisq.core.locale.Country)1 BlockChainExplorer (bisq.core.user.BlockChainExplorer)1