Search in sources :

Example 21 with Popup

use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.

the class FilterWindow method addContent.

private void addContent() {
    InputTextField keyInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("shared.unlock"), 10).second;
    if (useDevPrivilegeKeys)
        keyInputTextField.setText(DevEnv.DEV_PRIVILEGE_PRIV_KEY);
    InputTextField offerIdsInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.offers")).second;
    InputTextField nodesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.onions")).second;
    // Do not translate
    nodesInputTextField.setPromptText("E.g. zqnzx6o3nifef5df.onion:9999");
    InputTextField paymentAccountFilterInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.accounts")).second;
    GridPane.setHalignment(paymentAccountFilterInputTextField, HPos.RIGHT);
    // Do not translate
    paymentAccountFilterInputTextField.setPromptText("E.g. PERFECT_MONEY|getAccountNr|12345");
    InputTextField bannedCurrenciesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.bannedCurrencies")).second;
    InputTextField bannedPaymentMethodsInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.bannedPaymentMethods")).second;
    // Do not translate
    bannedPaymentMethodsInputTextField.setPromptText("E.g. PERFECT_MONEY");
    InputTextField arbitratorsInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.arbitrators")).second;
    InputTextField seedNodesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.seedNode")).second;
    InputTextField priceRelayNodesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.priceRelayNode")).second;
    InputTextField btcNodesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.btcNode")).second;
    CheckBox preventPublicBtcNetworkCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("filterWindow.preventPublicBtcNetwork")).second;
    final Filter filter = filterManager.getDevelopersFilter();
    if (filter != null) {
        offerIdsInputTextField.setText(filter.getBannedOfferIds().stream().collect(Collectors.joining(", ")));
        nodesInputTextField.setText(filter.getBannedNodeAddress().stream().collect(Collectors.joining(", ")));
        if (filter.getBannedPaymentAccounts() != null) {
            StringBuilder sb = new StringBuilder();
            filter.getBannedPaymentAccounts().stream().forEach(e -> {
                if (e != null && e.getPaymentMethodId() != null) {
                    sb.append(e.getPaymentMethodId()).append("|").append(e.getGetMethodName()).append("|").append(e.getValue()).append(", ");
                }
            });
            paymentAccountFilterInputTextField.setText(sb.toString());
        }
        if (filter.getBannedCurrencies() != null)
            bannedCurrenciesInputTextField.setText(filter.getBannedCurrencies().stream().collect(Collectors.joining(", ")));
        if (filter.getBannedPaymentMethods() != null)
            bannedPaymentMethodsInputTextField.setText(filter.getBannedPaymentMethods().stream().collect(Collectors.joining(", ")));
        if (filter.getArbitrators() != null)
            arbitratorsInputTextField.setText(filter.getArbitrators().stream().collect(Collectors.joining(", ")));
        if (filter.getSeedNodes() != null)
            seedNodesInputTextField.setText(filter.getSeedNodes().stream().collect(Collectors.joining(", ")));
        if (filter.getPriceRelayNodes() != null)
            priceRelayNodesInputTextField.setText(filter.getPriceRelayNodes().stream().collect(Collectors.joining(", ")));
        if (filter.getBtcNodes() != null)
            btcNodesInputTextField.setText(filter.getBtcNodes().stream().collect(Collectors.joining(", ")));
        preventPublicBtcNetworkCheckBox.setSelected(filter.isPreventPublicBtcNetwork());
    }
    Button sendButton = new AutoTooltipButton(Res.get("filterWindow.add"));
    sendButton.setOnAction(e -> {
        List<String> offerIds = new ArrayList<>();
        List<String> nodes = new ArrayList<>();
        List<PaymentAccountFilter> paymentAccountFilters = new ArrayList<>();
        List<String> bannedCurrencies = new ArrayList<>();
        List<String> bannedPaymentMethods = new ArrayList<>();
        List<String> arbitrators = new ArrayList<>();
        List<String> seedNodes = new ArrayList<>();
        List<String> priceRelayNodes = new ArrayList<>();
        List<String> btcNodes = new ArrayList<>();
        if (!offerIdsInputTextField.getText().isEmpty()) {
            offerIds = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(offerIdsInputTextField.getText()).split(",")));
        }
        if (!nodesInputTextField.getText().isEmpty()) {
            nodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(nodesInputTextField.getText()).replace(":9999", "").replace(".onion", "").split(",")));
        }
        if (!paymentAccountFilterInputTextField.getText().isEmpty()) {
            paymentAccountFilters = new ArrayList<>(Arrays.asList(paymentAccountFilterInputTextField.getText().replace(", ", ",").split(",")).stream().map(item -> {
                String[] list = item.split("\\|");
                if (list.length == 3)
                    return new PaymentAccountFilter(list[0], list[1], list[2]);
                else
                    return new PaymentAccountFilter("", "", "");
            }).collect(Collectors.toList()));
        }
        if (!bannedCurrenciesInputTextField.getText().isEmpty()) {
            bannedCurrencies = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(bannedCurrenciesInputTextField.getText()).split(",")));
        }
        if (!bannedPaymentMethodsInputTextField.getText().isEmpty()) {
            bannedPaymentMethods = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(bannedPaymentMethodsInputTextField.getText()).split(",")));
        }
        if (!arbitratorsInputTextField.getText().isEmpty()) {
            arbitrators = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(arbitratorsInputTextField.getText()).replace(":9999", "").replace(".onion", "").split(",")));
        }
        if (!seedNodesInputTextField.getText().isEmpty()) {
            seedNodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(seedNodesInputTextField.getText()).replace(":9999", "").replace(".onion", "").split(",")));
        }
        if (!priceRelayNodesInputTextField.getText().isEmpty()) {
            priceRelayNodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(priceRelayNodesInputTextField.getText()).replace(":9999", "").replace(".onion", "").split(",")));
        }
        if (!btcNodesInputTextField.getText().isEmpty()) {
            btcNodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(btcNodesInputTextField.getText()).split(",")));
        }
        if (sendFilterMessageHandler.handle(new Filter(offerIds, nodes, paymentAccountFilters, bannedCurrencies, bannedPaymentMethods, arbitrators, seedNodes, priceRelayNodes, preventPublicBtcNetworkCheckBox.isSelected(), btcNodes), keyInputTextField.getText()))
            hide();
        else
            new Popup<>().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
    });
    Button removeFilterMessageButton = new AutoTooltipButton(Res.get("filterWindow.remove"));
    removeFilterMessageButton.setOnAction(e -> {
        if (keyInputTextField.getText().length() > 0) {
            if (removeFilterMessageHandler.handle(keyInputTextField.getText()))
                hide();
            else
                new Popup<>().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
        }
    });
    closeButton = new AutoTooltipButton(Res.get("shared.close"));
    closeButton.setOnAction(e -> {
        hide();
        closeHandlerOptional.ifPresent(Runnable::run);
    });
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    GridPane.setRowIndex(hBox, ++rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    hBox.getChildren().addAll(sendButton, removeFilterMessageButton, closeButton);
    gridPane.getChildren().add(hBox);
    GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
}
Also used : Button(javafx.scene.control.Button) Scene(javafx.scene.Scene) KeyCode(javafx.scene.input.KeyCode) HBox(javafx.scene.layout.HBox) HPos(javafx.geometry.HPos) Popup(bisq.desktop.main.overlays.popups.Popup) Arrays(java.util.Arrays) PaymentAccountFilter(bisq.core.filter.PaymentAccountFilter) FilterManager(bisq.core.filter.FilterManager) CheckBox(javafx.scene.control.CheckBox) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) FormBuilder.addLabelInputTextField(bisq.desktop.util.FormBuilder.addLabelInputTextField) ArrayList(java.util.ArrayList) List(java.util.List) Insets(javafx.geometry.Insets) InputTextField(bisq.desktop.components.InputTextField) DevEnv(bisq.common.app.DevEnv) Res(bisq.core.locale.Res) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Overlay(bisq.desktop.main.overlays.Overlay) Filter(bisq.core.filter.Filter) FormBuilder.addLabelCheckBox(bisq.desktop.util.FormBuilder.addLabelCheckBox) GridPane(javafx.scene.layout.GridPane) HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) FormBuilder.addLabelInputTextField(bisq.desktop.util.FormBuilder.addLabelInputTextField) InputTextField(bisq.desktop.components.InputTextField) ArrayList(java.util.ArrayList) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) PaymentAccountFilter(bisq.core.filter.PaymentAccountFilter) Filter(bisq.core.filter.Filter) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) CheckBox(javafx.scene.control.CheckBox) FormBuilder.addLabelCheckBox(bisq.desktop.util.FormBuilder.addLabelCheckBox) PaymentAccountFilter(bisq.core.filter.PaymentAccountFilter)

Example 22 with Popup

use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.

the class ManualPayoutTxWindow method addContent.

private void addContent() {
    // We dont translate here as it is for dev only purpose
    InputTextField depositTxHex = addLabelInputTextField(gridPane, ++rowIndex, "depositTxHex:").second;
    InputTextField buyerPayoutAmount = addLabelInputTextField(gridPane, ++rowIndex, "buyerPayoutAmount:").second;
    InputTextField sellerPayoutAmount = addLabelInputTextField(gridPane, ++rowIndex, "sellerPayoutAmount:").second;
    InputTextField arbitratorPayoutAmount = addLabelInputTextField(gridPane, ++rowIndex, "arbitratorPayoutAmount:").second;
    InputTextField txFee = addLabelInputTextField(gridPane, ++rowIndex, "Tx fee:").second;
    InputTextField buyerAddressString = addLabelInputTextField(gridPane, ++rowIndex, "buyerAddressString:").second;
    InputTextField sellerAddressString = addLabelInputTextField(gridPane, ++rowIndex, "sellerAddressString:").second;
    InputTextField arbitratorAddressString = addLabelInputTextField(gridPane, ++rowIndex, "arbitratorAddressString:").second;
    InputTextField buyerPrivateKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "buyerPrivateKeyAsHex:").second;
    InputTextField sellerPrivateKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "sellerPrivateKeyAsHex:").second;
    InputTextField arbitratorPrivateKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "arbitratorPrivateKeyAsHex:").second;
    InputTextField buyerPubKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "buyerPubKeyAsHex:").second;
    InputTextField sellerPubKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "sellerPubKeyAsHex:").second;
    InputTextField arbitratorPubKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "arbitratorPubKeyAsHex:").second;
    InputTextField P2SHMultiSigOutputScript = addLabelInputTextField(gridPane, ++rowIndex, "P2SHMultiSigOutputScript:").second;
    // Notes:
    // Open with alt+g and enable DEV mode
    // Priv key is only visible if pw protection is removed (wallet details data (alt+j))
    // Take P2SHMultiSigOutputScript from depositTx in blockexplorer
    // Take missing buyerPubKeyAsHex and sellerPubKeyAsHex from contract data!
    // Lookup sellerPrivateKeyAsHex associated with sellerPubKeyAsHex (or buyers) in wallet details data
    // sellerPubKeys/buyerPubKeys are auto generated if used the fields below
    // Never set the priv arbitr. key here!
    depositTxHex.setText("");
    P2SHMultiSigOutputScript.setText("");
    buyerPayoutAmount.setText("");
    sellerPayoutAmount.setText("");
    arbitratorPayoutAmount.setText("0");
    buyerAddressString.setText("");
    buyerPubKeyAsHex.setText("");
    buyerPrivateKeyAsHex.setText("");
    sellerAddressString.setText("");
    sellerPubKeyAsHex.setText("");
    sellerPrivateKeyAsHex.setText("");
    arbitratorAddressString.setText("");
    arbitratorPubKeyAsHex.setText("");
    actionButtonText("Sign and publish transaction");
    FutureCallback<Transaction> callback = new FutureCallback<Transaction>() {

        @Override
        public void onSuccess(@Nullable Transaction result) {
            log.error("onSuccess");
            UserThread.execute(() -> {
                String txId = result != null ? result.getHashAsString() : "null";
                new Popup<>().information("Transaction successful published. Transaction ID: " + txId).show();
            });
        }

        @Override
        public void onFailure(@NotNull Throwable t) {
            log.error(t.toString());
            log.error("onFailure");
            UserThread.execute(() -> new Popup<>().warning(t.toString()).show());
        }
    };
    onAction(() -> {
        if (GUIUtil.isReadyForTxBroadcast(p2PService, walletsSetup)) {
            try {
                tradeWalletService.emergencySignAndPublishPayoutTx(depositTxHex.getText(), Coin.parseCoin(buyerPayoutAmount.getText()), Coin.parseCoin(sellerPayoutAmount.getText()), Coin.parseCoin(arbitratorPayoutAmount.getText()), Coin.parseCoin(txFee.getText()), buyerAddressString.getText(), sellerAddressString.getText(), arbitratorAddressString.getText(), buyerPrivateKeyAsHex.getText(), sellerPrivateKeyAsHex.getText(), arbitratorPrivateKeyAsHex.getText(), buyerPubKeyAsHex.getText(), sellerPubKeyAsHex.getText(), arbitratorPubKeyAsHex.getText(), P2SHMultiSigOutputScript.getText(), callback);
            } catch (AddressFormatException | WalletException | TransactionVerificationException e) {
                log.error(e.toString());
                e.printStackTrace();
                UserThread.execute(() -> new Popup<>().warning(e.toString()).show());
            }
        } else {
            GUIUtil.showNotReadyForTxBroadcastPopups(p2PService, walletsSetup);
        }
    });
}
Also used : WalletException(bisq.core.btc.exceptions.WalletException) AddressFormatException(org.bitcoinj.core.AddressFormatException) TransactionVerificationException(bisq.core.btc.exceptions.TransactionVerificationException) FormBuilder.addLabelInputTextField(bisq.desktop.util.FormBuilder.addLabelInputTextField) InputTextField(bisq.desktop.components.InputTextField) NotNull(org.jetbrains.annotations.NotNull) Transaction(org.bitcoinj.core.Transaction) Popup(bisq.desktop.main.overlays.popups.Popup) FutureCallback(com.google.common.util.concurrent.FutureCallback) Nullable(javax.annotation.Nullable)

Example 23 with Popup

use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.

the class PendingTradesDataModel method doOpenDispute.

private void doOpenDispute(boolean isSupportTicket, Transaction depositTx) {
    Log.traceCall("depositTx=" + depositTx);
    byte[] depositTxSerialized = null;
    byte[] payoutTxSerialized = null;
    String depositTxHashAsString = null;
    String payoutTxHashAsString = null;
    if (depositTx != null) {
        depositTxSerialized = depositTx.bitcoinSerialize();
        depositTxHashAsString = depositTx.getHashAsString();
    } else {
        log.warn("depositTx is null");
    }
    Trade trade = getTrade();
    if (trade != null) {
        Transaction payoutTx = trade.getPayoutTx();
        if (payoutTx != null) {
            payoutTxSerialized = payoutTx.bitcoinSerialize();
            payoutTxHashAsString = payoutTx.getHashAsString();
        } else {
            log.debug("payoutTx is null at doOpenDispute");
        }
        final PubKeyRing arbitratorPubKeyRing = trade.getArbitratorPubKeyRing();
        checkNotNull(arbitratorPubKeyRing, "arbitratorPubKeyRing must no tbe null");
        Dispute dispute = new Dispute(disputeManager.getDisputeStorage(), trade.getId(), // traderId
        keyRing.getPubKeyRing().hashCode(), trade.getOffer().getDirection() == OfferPayload.Direction.BUY ? isMaker : !isMaker, isMaker, keyRing.getPubKeyRing(), trade.getDate().getTime(), trade.getContract(), trade.getContractHash(), depositTxSerialized, payoutTxSerialized, depositTxHashAsString, payoutTxHashAsString, trade.getContractAsJson(), trade.getMakerContractSignature(), trade.getTakerContractSignature(), arbitratorPubKeyRing, isSupportTicket);
        trade.setDisputeState(Trade.DisputeState.DISPUTE_REQUESTED);
        if (p2PService.isBootstrapped()) {
            sendOpenNewDisputeMessage(dispute, false);
        } else {
            new Popup<>().information(Res.get("popup.warning.notFullyConnected")).show();
        }
    } else {
        log.warn("trade is null at doOpenDispute");
    }
}
Also used : SellerTrade(bisq.core.trade.SellerTrade) Trade(bisq.core.trade.Trade) BuyerTrade(bisq.core.trade.BuyerTrade) Transaction(org.bitcoinj.core.Transaction) Popup(bisq.desktop.main.overlays.popups.Popup) PubKeyRing(bisq.common.crypto.PubKeyRing) Dispute(bisq.core.arbitration.Dispute)

Example 24 with Popup

use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.

the class SendAlertMessageWindow method addContent.

private void addContent() {
    InputTextField keyInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("shared.unlock"), 10).second;
    if (useDevPrivilegeKeys)
        keyInputTextField.setText(DevEnv.DEV_PRIVILEGE_PRIV_KEY);
    Tuple2<Label, TextArea> labelTextAreaTuple2 = addLabelTextArea(gridPane, ++rowIndex, Res.get("sendAlertMessageWindow.alertMsg"), Res.get("sendAlertMessageWindow.enterMsg"));
    TextArea alertMessageTextArea = labelTextAreaTuple2.second;
    Label first = labelTextAreaTuple2.first;
    first.setMinWidth(150);
    CheckBox isUpdateCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("sendAlertMessageWindow.isUpdate"), "").second;
    isUpdateCheckBox.setSelected(true);
    InputTextField versionInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("sendAlertMessageWindow.version")).second;
    versionInputTextField.disableProperty().bind(isUpdateCheckBox.selectedProperty().not());
    Button sendButton = new AutoTooltipButton(Res.get("sendAlertMessageWindow.send"));
    sendButton.setOnAction(e -> {
        final String version = versionInputTextField.getText();
        boolean versionOK = false;
        final boolean isUpdate = isUpdateCheckBox.isSelected();
        if (isUpdate) {
            final String[] split = version.split("\\.");
            versionOK = split.length == 3;
            if (// Do not translate as only used by devs
            !versionOK)
                new Popup<>().warning("Version number must be in semantic version format (contain 2 '.'). version=" + version).onClose(this::blurAgain).show();
        }
        if (!isUpdate || versionOK) {
            if (alertMessageTextArea.getText().length() > 0 && keyInputTextField.getText().length() > 0) {
                if (sendAlertMessageHandler.handle(new Alert(alertMessageTextArea.getText(), isUpdate, version), keyInputTextField.getText()))
                    hide();
                else
                    new Popup<>().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
            }
        }
    });
    Button removeAlertMessageButton = new AutoTooltipButton(Res.get("sendAlertMessageWindow.remove"));
    removeAlertMessageButton.setOnAction(e -> {
        if (keyInputTextField.getText().length() > 0) {
            if (removeAlertMessageHandler.handle(keyInputTextField.getText()))
                hide();
            else
                new Popup<>().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
        }
    });
    closeButton = new AutoTooltipButton(Res.get("shared.close"));
    closeButton.setOnAction(e -> {
        hide();
        closeHandlerOptional.ifPresent(Runnable::run);
    });
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    GridPane.setRowIndex(hBox, ++rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    hBox.getChildren().addAll(sendButton, removeAlertMessageButton, closeButton);
    gridPane.getChildren().add(hBox);
    GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) TextArea(javafx.scene.control.TextArea) FormBuilder.addLabelTextArea(bisq.desktop.util.FormBuilder.addLabelTextArea) FormBuilder.addLabelInputTextField(bisq.desktop.util.FormBuilder.addLabelInputTextField) InputTextField(bisq.desktop.components.InputTextField) Label(javafx.scene.control.Label) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) CheckBox(javafx.scene.control.CheckBox) FormBuilder.addLabelCheckBox(bisq.desktop.util.FormBuilder.addLabelCheckBox) Popup(bisq.desktop.main.overlays.popups.Popup) Alert(bisq.core.alert.Alert)

Example 25 with Popup

use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.

the class TorNetworkSettingsWindow method addContent.

private void addContent() {
    addTitledGroupBg(gridPane, ++rowIndex, 1, Res.get("torNetworkSettingWindow.deleteFiles.header"));
    Label deleteFilesLabel = addLabel(gridPane, rowIndex, Res.get("torNetworkSettingWindow.deleteFiles.info"), Layout.FIRST_ROW_DISTANCE);
    deleteFilesLabel.setWrapText(true);
    GridPane.setColumnIndex(deleteFilesLabel, 0);
    GridPane.setColumnSpan(deleteFilesLabel, 2);
    GridPane.setHalignment(deleteFilesLabel, HPos.LEFT);
    GridPane.setValignment(deleteFilesLabel, VPos.TOP);
    Tuple3<Button, BusyAnimation, Label> tuple = addButtonBusyAnimationLabelAfterGroup(gridPane, ++rowIndex, Res.get("torNetworkSettingWindow.deleteFiles.button"));
    Button deleteFilesButton = tuple.first;
    deleteFilesButton.setOnAction(e -> {
        tuple.second.play();
        tuple.third.setText(Res.get("torNetworkSettingWindow.deleteFiles.progress"));
        gridPane.setMouseTransparent(true);
        deleteFilesButton.setDisable(true);
        cleanTorDir(() -> {
            tuple.second.stop();
            tuple.third.setText("");
            new Popup<>().feedback(Res.get("torNetworkSettingWindow.deleteFiles.success")).useShutDownButton().hideCloseButton().show();
        });
    });
    addTitledGroupBg(gridPane, ++rowIndex, 7, Res.get("torNetworkSettingWindow.bridges.header"), Layout.GROUP_DISTANCE);
    Label bridgesLabel = addLabel(gridPane, rowIndex, Res.get("torNetworkSettingWindow.bridges.info"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    bridgesLabel.setWrapText(true);
    GridPane.setColumnIndex(bridgesLabel, 0);
    GridPane.setColumnSpan(bridgesLabel, 2);
    GridPane.setHalignment(bridgesLabel, HPos.LEFT);
    GridPane.setValignment(bridgesLabel, VPos.TOP);
    // addLabelTextArea(gridPane, rowIndex, Res.get("torNetworkSettingWindow.info"), "", Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    ToggleGroup toggleGroup = new ToggleGroup();
    // noBridges
    noBridgesRadioButton = addRadioButton(gridPane, ++rowIndex, toggleGroup, Res.get("torNetworkSettingWindow.noBridges"));
    noBridgesRadioButton.setUserData(BridgeOption.NONE);
    GridPane.setMargin(noBridgesRadioButton, new Insets(20, 0, 0, 0));
    // providedBridges
    providedBridgesRadioButton = addRadioButton(gridPane, ++rowIndex, toggleGroup, Res.get("torNetworkSettingWindow.providedBridges"));
    providedBridgesRadioButton.setUserData(BridgeOption.PROVIDED);
    final Tuple2<Label, ComboBox> labelComboBoxTuple2 = addLabelComboBox(gridPane, ++rowIndex, Res.get("torNetworkSettingWindow.transportType"));
    transportTypeLabel = labelComboBoxTuple2.first;
    transportTypeComboBox = labelComboBoxTuple2.second;
    transportTypeComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(Transport.OBFS_4, Transport.OBFS_3, Transport.MEEK_AMAZON, Transport.MEEK_AZURE)));
    transportTypeComboBox.setConverter(new StringConverter<Transport>() {

        @Override
        public String toString(Transport transport) {
            switch(transport) {
                case OBFS_3:
                    return Res.get("torNetworkSettingWindow.obfs3");
                case MEEK_AMAZON:
                    return Res.get("torNetworkSettingWindow.meekAmazon");
                case MEEK_AZURE:
                    return Res.get("torNetworkSettingWindow.meekAzure");
                default:
                case OBFS_4:
                    return Res.get("torNetworkSettingWindow.obfs4");
            }
        }

        @Override
        public Transport fromString(String string) {
            return null;
        }
    });
    // customBridges
    customBridgesRadioButton = addRadioButton(gridPane, ++rowIndex, toggleGroup, Res.get("torNetworkSettingWindow.customBridges"));
    customBridgesRadioButton.setUserData(BridgeOption.CUSTOM);
    final Tuple2<Label, TextArea> labelTextAreaTuple2 = addLabelTextArea(gridPane, ++rowIndex, Res.get("torNetworkSettingWindow.enterBridge"), Res.get("torNetworkSettingWindow.enterBridgePrompt"));
    enterBridgeLabel = labelTextAreaTuple2.first;
    bridgeEntriesTextArea = labelTextAreaTuple2.second;
    Label label2 = addLabel(gridPane, ++rowIndex, Res.get("torNetworkSettingWindow.restartInfo"));
    label2.setWrapText(true);
    GridPane.setColumnIndex(label2, 1);
    GridPane.setColumnSpan(label2, 2);
    GridPane.setHalignment(label2, HPos.LEFT);
    GridPane.setValignment(label2, VPos.TOP);
    GridPane.setMargin(label2, new Insets(10, 10, 20, 0));
    // init persisted values
    selectedBridgeOption = BridgeOption.values()[preferences.getBridgeOptionOrdinal()];
    switch(selectedBridgeOption) {
        case PROVIDED:
            toggleGroup.selectToggle(providedBridgesRadioButton);
            break;
        case CUSTOM:
            toggleGroup.selectToggle(customBridgesRadioButton);
            break;
        default:
        case NONE:
            toggleGroup.selectToggle(noBridgesRadioButton);
            break;
    }
    applyToggleSelection();
    selectedTorTransportOrdinal = Transport.values()[preferences.getTorTransportOrdinal()];
    transportTypeComboBox.getSelectionModel().select(selectedTorTransportOrdinal);
    customBridges = preferences.getCustomBridges();
    bridgeEntriesTextArea.setText(customBridges);
    toggleGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
        selectedBridgeOption = (BridgeOption) newValue.getUserData();
        preferences.setBridgeOptionOrdinal(selectedBridgeOption.ordinal());
        applyToggleSelection();
    });
    transportTypeComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        selectedTorTransportOrdinal = newValue;
        preferences.setTorTransportOrdinal(selectedTorTransportOrdinal.ordinal());
        setBridgeAddressesByTransport();
    });
    bridgeEntriesTextArea.textProperty().addListener((observable, oldValue, newValue) -> {
        customBridges = newValue;
        preferences.setCustomBridges(customBridges);
        setBridgeAddressesByCustomBridges();
    });
}
Also used : BusyAnimation(bisq.desktop.components.BusyAnimation) Insets(javafx.geometry.Insets) TextArea(javafx.scene.control.TextArea) ComboBox(javafx.scene.control.ComboBox) Label(javafx.scene.control.Label) Button(javafx.scene.control.Button) RadioButton(javafx.scene.control.RadioButton) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Popup(bisq.desktop.main.overlays.popups.Popup) ToggleGroup(javafx.scene.control.ToggleGroup)

Aggregations

Popup (bisq.desktop.main.overlays.popups.Popup)57 Label (javafx.scene.control.Label)22 Coin (org.bitcoinj.core.Coin)17 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)16 Button (javafx.scene.control.Button)16 Res (bisq.core.locale.Res)13 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)13 Insets (javafx.geometry.Insets)13 InputTextField (bisq.desktop.components.InputTextField)12 BSFormatter (bisq.desktop.util.BSFormatter)12 Transaction (org.bitcoinj.core.Transaction)12 List (java.util.List)11 UserThread (bisq.common.UserThread)10 ChangeListener (javafx.beans.value.ChangeListener)9 BusyAnimation (bisq.desktop.components.BusyAnimation)8 ObservableList (javafx.collections.ObservableList)8 HBox (javafx.scene.layout.HBox)8 Tuple2 (bisq.common.util.Tuple2)7 FxmlView (bisq.desktop.common.view.FxmlView)7 TradeCurrency (bisq.core.locale.TradeCurrency)6