Search in sources :

Example 16 with InputTextField

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

the class PreferencesView method initializeGeneralOptions.

// /////////////////////////////////////////////////////////////////////////////////////////
// Initialize
// /////////////////////////////////////////////////////////////////////////////////////////
private void initializeGeneralOptions() {
    TitledGroupBg titledGroupBg = addTitledGroupBg(root, gridRow, 8, Res.get("setting.preferences.general"));
    GridPane.setColumnSpan(titledGroupBg, 4);
    // selectBaseCurrencyNetwork
    // noinspection unchecked
    selectBaseCurrencyNetworkComboBox = addLabelComboBox(root, gridRow, Res.getWithCol("settings.preferences.selectCurrencyNetwork"), Layout.FIRST_ROW_DISTANCE).second;
    selectBaseCurrencyNetworkComboBox.setConverter(new StringConverter<BaseCurrencyNetwork>() {

        @Override
        public String toString(BaseCurrencyNetwork baseCurrencyNetwork) {
            return DevEnv.isDevMode() ? (baseCurrencyNetwork.getCurrencyName() + "_" + baseCurrencyNetwork.getNetwork()) : baseCurrencyNetwork.getCurrencyName();
        }

        @Override
        public BaseCurrencyNetwork fromString(String string) {
            return null;
        }
    });
    // userLanguage
    // noinspection unchecked
    userLanguageComboBox = addLabelComboBox(root, ++gridRow, Res.getWithCol("shared.language")).second;
    // userCountry
    // noinspection unchecked
    userCountryComboBox = addLabelComboBox(root, ++gridRow, Res.getWithCol("shared.country")).second;
    // blockChainExplorer
    // noinspection unchecked
    blockChainExplorerComboBox = addLabelComboBox(root, ++gridRow, Res.get("setting.preferences.explorer")).second;
    // transactionFee
    Tuple3<Label, InputTextField, CheckBox> tuple = addLabelInputTextFieldCheckBox(root, ++gridRow, Res.get("setting.preferences.txFee"), Res.get("setting.preferences.useCustomValue"));
    transactionFeeInputTextField = tuple.second;
    useCustomFeeCheckbox = tuple.third;
    useCustomFeeCheckboxListener = (observable, oldValue, newValue) -> {
        preferences.setUseCustomWithdrawalTxFee(newValue);
        transactionFeeInputTextField.setEditable(newValue);
        if (!newValue) {
            transactionFeeInputTextField.setText(String.valueOf(feeService.getTxFeePerByte().value));
            try {
                preferences.setWithdrawalTxFeeInBytes(feeService.getTxFeePerByte().value);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        preferences.setUseCustomWithdrawalTxFee(newValue);
    };
    transactionFeeFocusedListener = (o, oldValue, newValue) -> {
        if (oldValue && !newValue) {
            String estimatedFee = String.valueOf(feeService.getTxFeePerByte().value);
            try {
                int withdrawalTxFeePerByte = Integer.parseInt(transactionFeeInputTextField.getText());
                final long minFeePerByte = BisqEnvironment.getBaseCurrencyNetwork().getDefaultMinFeePerByte();
                if (withdrawalTxFeePerByte < minFeePerByte) {
                    new Popup<>().warning(Res.get("setting.preferences.txFeeMin", minFeePerByte)).show();
                    transactionFeeInputTextField.setText(estimatedFee);
                } else if (withdrawalTxFeePerByte > 5000) {
                    new Popup<>().warning(Res.get("setting.preferences.txFeeTooLarge")).show();
                    transactionFeeInputTextField.setText(estimatedFee);
                } else {
                    preferences.setWithdrawalTxFeeInBytes(withdrawalTxFeePerByte);
                }
            } catch (NumberFormatException t) {
                log.error(t.toString());
                t.printStackTrace();
                new Popup<>().warning(Res.get("validation.integerOnly")).show();
                transactionFeeInputTextField.setText(estimatedFee);
            } catch (Throwable t) {
                log.error(t.toString());
                t.printStackTrace();
                new Popup<>().warning(Res.get("validation.inputError", t.getMessage())).show();
                transactionFeeInputTextField.setText(estimatedFee);
            }
        }
    };
    transactionFeeChangeListener = (observable, oldValue, newValue) -> transactionFeeInputTextField.setText(String.valueOf(feeService.getTxFeePerByte().value));
    // deviation
    deviationInputTextField = addLabelInputTextField(root, ++gridRow, Res.get("setting.preferences.deviation")).second;
    deviationListener = (observable, oldValue, newValue) -> {
        try {
            double value = formatter.parsePercentStringToDouble(newValue);
            final double maxDeviation = 0.5;
            if (value <= maxDeviation) {
                preferences.setMaxPriceDistanceInPercent(value);
            } else {
                new Popup<>().warning(Res.get("setting.preferences.deviationToLarge", maxDeviation * 100)).show();
                UserThread.runAfter(() -> deviationInputTextField.setText(formatter.formatPercentagePrice(preferences.getMaxPriceDistanceInPercent())), 100, TimeUnit.MILLISECONDS);
            }
        } catch (NumberFormatException t) {
            log.error("Exception at parseDouble deviation: " + t.toString());
            UserThread.runAfter(() -> deviationInputTextField.setText(formatter.formatPercentagePrice(preferences.getMaxPriceDistanceInPercent())), 100, TimeUnit.MILLISECONDS);
        }
    };
    deviationFocusedListener = (observable1, oldValue1, newValue1) -> {
        if (oldValue1 && !newValue1)
            UserThread.runAfter(() -> deviationInputTextField.setText(formatter.formatPercentagePrice(preferences.getMaxPriceDistanceInPercent())), 100, TimeUnit.MILLISECONDS);
    };
    // autoSelectArbitrators
    autoSelectArbitratorsCheckBox = addLabelCheckBox(root, ++gridRow, Res.get("setting.preferences.autoSelectArbitrators"), "").second;
    // ignoreTraders
    ignoreTradersListInputTextField = addLabelInputTextField(root, ++gridRow, Res.get("setting.preferences.ignorePeers")).second;
    ignoreTradersListListener = (observable, oldValue, newValue) -> preferences.setIgnoreTradersList(Arrays.asList(StringUtils.deleteWhitespace(newValue).replace(":9999", "").replace(".onion", "").split(",")));
}
Also used : InputTextField(bisq.desktop.components.InputTextField) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) CheckBox(javafx.scene.control.CheckBox) Popup(bisq.desktop.main.overlays.popups.Popup) BaseCurrencyNetwork(bisq.core.btc.BaseCurrencyNetwork) TitledGroupBg(bisq.desktop.components.TitledGroupBg)

Example 17 with InputTextField

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

the class BuyerStep4View method addContent.

// /////////////////////////////////////////////////////////////////////////////////////////
// Content
// /////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("PointlessBooleanExpression")
@Override
protected void addContent() {
    FormBuilder.addTitledGroupBg(gridPane, gridRow, 5, Res.get("portfolio.pending.step5_buyer.groupTitle"), 0);
    FormBuilder.addLabelTextField(gridPane, gridRow, getBtcTradeAmountLabel(), model.getTradeVolume(), Layout.FIRST_ROW_DISTANCE);
    FormBuilder.addLabelTextField(gridPane, ++gridRow, getFiatTradeAmountLabel(), model.getFiatVolume());
    FormBuilder.addLabelTextField(gridPane, ++gridRow, Res.get("portfolio.pending.step5_buyer.refunded"), model.getSecurityDeposit());
    FormBuilder.addLabelTextField(gridPane, ++gridRow, Res.get("portfolio.pending.step5_buyer.tradeFee"), model.getTradeFee());
    final String miningFee = model.dataModel.isMaker() ? Res.get("portfolio.pending.step5_buyer.makersMiningFee") : Res.get("portfolio.pending.step5_buyer.takersMiningFee");
    FormBuilder.addLabelTextField(gridPane, ++gridRow, miningFee, model.getTxFee());
    withdrawTitledGroupBg = FormBuilder.addTitledGroupBg(gridPane, ++gridRow, 1, Res.get("portfolio.pending.step5_buyer.withdrawBTC"), Layout.GROUP_DISTANCE);
    FormBuilder.addLabelTextField(gridPane, gridRow, Res.get("portfolio.pending.step5_buyer.amount"), model.getPayoutAmount(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    final Tuple2<Label, InputTextField> tuple2 = FormBuilder.addLabelInputTextField(gridPane, ++gridRow, Res.get("portfolio.pending.step5_buyer.withdrawToAddress"));
    withdrawAddressLabel = tuple2.first;
    withdrawAddressLabel.setManaged(false);
    withdrawAddressLabel.setVisible(false);
    withdrawAddressTextField = tuple2.second;
    withdrawAddressTextField.setManaged(false);
    withdrawAddressTextField.setVisible(false);
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    useSavingsWalletButton = new AutoTooltipButton(Res.get("portfolio.pending.step5_buyer.moveToBisqWallet"));
    useSavingsWalletButton.setDefaultButton(false);
    Label label = new AutoTooltipLabel(Res.get("shared.OR"));
    label.setPadding(new Insets(5, 0, 0, 0));
    withdrawToExternalWalletButton = new AutoTooltipButton(Res.get("portfolio.pending.step5_buyer.withdrawExternal"));
    withdrawToExternalWalletButton.setDefaultButton(false);
    hBox.getChildren().addAll(useSavingsWalletButton, label, withdrawToExternalWalletButton);
    GridPane.setRowIndex(hBox, ++gridRow);
    GridPane.setColumnIndex(hBox, 1);
    GridPane.setMargin(hBox, new Insets(15, 10, 0, 0));
    gridPane.getChildren().add(hBox);
    useSavingsWalletButton.setOnAction(e -> {
        handleTradeCompleted();
        model.dataModel.tradeManager.addTradeToClosedTrades(trade);
    });
    withdrawToExternalWalletButton.setOnAction(e -> onWithdrawal());
    String key = "tradeCompleted" + trade.getId();
    // noinspection ConstantConditions
    if (!DevEnv.isDevMode() && DontShowAgainLookup.showAgain(key)) {
        DontShowAgainLookup.dontShowAgain(key, true);
        new Notification().headLine(Res.get("notification.tradeCompleted.headline")).notification(Res.get("notification.tradeCompleted.msg")).autoClose().show();
    }
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) InputTextField(bisq.desktop.components.InputTextField) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Notification(bisq.desktop.main.overlays.notifications.Notification)

Example 18 with InputTextField

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

the class FormBuilder method addLabelInputTextField.

public static Tuple2<Label, InputTextField> addLabelInputTextField(GridPane gridPane, int rowIndex, String title, double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);
    InputTextField inputTextField = new InputTextField();
    GridPane.setRowIndex(inputTextField, rowIndex);
    GridPane.setColumnIndex(inputTextField, 1);
    GridPane.setMargin(inputTextField, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(inputTextField);
    return new Tuple2<>(label, inputTextField);
}
Also used : Insets(javafx.geometry.Insets) InputTextField(bisq.desktop.components.InputTextField) InfoInputTextField(bisq.desktop.components.InfoInputTextField) Tuple2(bisq.common.util.Tuple2) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label)

Example 19 with InputTextField

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

the class FormBuilder method getAmountCurrencyBox.

public static Tuple3<HBox, InputTextField, Label> getAmountCurrencyBox(String promptText) {
    InputTextField input = new InputTextField();
    input.setPrefWidth(190);
    input.setAlignment(Pos.CENTER_RIGHT);
    input.setId("text-input-with-currency-text-field");
    input.setPromptText(promptText);
    Label currency = new AutoTooltipLabel(Res.getBaseCurrencyCode());
    currency.setId("currency-info-label");
    HBox box = new HBox();
    box.getChildren().addAll(input, currency);
    return new Tuple3<>(box, input, currency);
}
Also used : HBox(javafx.scene.layout.HBox) InputTextField(bisq.desktop.components.InputTextField) InfoInputTextField(bisq.desktop.components.InfoInputTextField) Tuple3(bisq.common.util.Tuple3) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel)

Example 20 with InputTextField

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

the class FormBuilder method addLabelInputTextFieldLabelInputTextField.

// /////////////////////////////////////////////////////////////////////////////////////////
// Label  + InputTextField + Label  + InputTextField
// /////////////////////////////////////////////////////////////////////////////////////////
public static Tuple4<Label, InputTextField, Label, InputTextField> addLabelInputTextFieldLabelInputTextField(GridPane gridPane, int rowIndex, String title1, String title2) {
    Label label1 = addLabel(gridPane, rowIndex, title1, 0);
    InputTextField inputTextField1 = new InputTextField();
    Label label2 = new AutoTooltipLabel(title2);
    HBox.setMargin(label2, new Insets(5, 0, 0, 0));
    InputTextField inputTextField2 = new InputTextField();
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(inputTextField1, label2, inputTextField2);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    gridPane.getChildren().add(hBox);
    return new Tuple4<>(label1, inputTextField1, label2, inputTextField2);
}
Also used : Tuple4(bisq.common.util.Tuple4) HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) InputTextField(bisq.desktop.components.InputTextField) InfoInputTextField(bisq.desktop.components.InfoInputTextField) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel)

Aggregations

InputTextField (bisq.desktop.components.InputTextField)35 Label (javafx.scene.control.Label)23 HBox (javafx.scene.layout.HBox)19 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)17 Insets (javafx.geometry.Insets)15 TradeCurrency (bisq.core.locale.TradeCurrency)11 InfoInputTextField (bisq.desktop.components.InfoInputTextField)11 FormBuilder.addLabelInputTextField (bisq.desktop.util.FormBuilder.addLabelInputTextField)11 Popup (bisq.desktop.main.overlays.popups.Popup)8 Tuple3 (bisq.common.util.Tuple3)6 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)6 Button (javafx.scene.control.Button)5 TextField (javafx.scene.control.TextField)5 CheckBox (javafx.scene.control.CheckBox)4 Country (bisq.core.locale.Country)3 AddressTextField (bisq.desktop.components.AddressTextField)3 VBox (javafx.scene.layout.VBox)3 BalanceTextField (bisq.desktop.components.BalanceTextField)2 FundsTextField (bisq.desktop.components.FundsTextField)2 TitledGroupBg (bisq.desktop.components.TitledGroupBg)2