Search in sources :

Example 16 with AutoTooltipButton

use of bisq.desktop.components.AutoTooltipButton 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 17 with AutoTooltipButton

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

the class TorNetworkSettingsWindow method addCloseButton.

protected void addCloseButton() {
    closeButton = new AutoTooltipButton(closeButtonText == null ? Res.get("shared.close") : closeButtonText);
    closeButton.setOnAction(event -> doClose());
    if (actionHandlerOptional.isPresent()) {
        actionButton = new AutoTooltipButton(Res.get("shared.shutDown"));
        actionButton.setDefaultButton(true);
        // TODO app wide focus
        // actionButton.requestFocus();
        actionButton.setOnAction(event -> saveAndShutDown());
        Button urlButton = new AutoTooltipButton(Res.get("torNetworkSettingWindow.openTorWebPage"));
        urlButton.setOnAction(event -> {
            try {
                Utilities.openURI(URI.create("https://bridges.torproject.org/bridges"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
        Pane spacer = new Pane();
        HBox hBox = new HBox();
        hBox.setSpacing(10);
        hBox.getChildren().addAll(spacer, urlButton, closeButton, actionButton);
        HBox.setHgrow(spacer, Priority.ALWAYS);
        GridPane.setHalignment(hBox, HPos.RIGHT);
        GridPane.setRowIndex(hBox, ++rowIndex);
        GridPane.setColumnSpan(hBox, 2);
        GridPane.setMargin(hBox, new Insets(buttonDistance, 0, 0, 0));
        gridPane.getChildren().add(hBox);
    } else if (!hideCloseButton) {
        closeButton.setDefaultButton(true);
        GridPane.setHalignment(closeButton, HPos.RIGHT);
        GridPane.setMargin(closeButton, new Insets(buttonDistance, 0, 0, 0));
        GridPane.setRowIndex(closeButton, rowIndex);
        GridPane.setColumnIndex(closeButton, 1);
        gridPane.getChildren().add(closeButton);
    }
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Button(javafx.scene.control.Button) RadioButton(javafx.scene.control.RadioButton) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) IOException(java.io.IOException) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) GridPane(javafx.scene.layout.GridPane) Pane(javafx.scene.layout.Pane)

Example 18 with AutoTooltipButton

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

the class UnlockArbitrationRegistrationWindow method addButtons.

private void addButtons() {
    unlockButton = new AutoTooltipButton(Res.get("shared.unlock"));
    unlockButton.setDefaultButton(true);
    unlockButton.setDisable(keyInputTextField.getText().length() == 0);
    unlockButton.setOnAction(e -> {
        if (privKeyHandler.checkKey(keyInputTextField.getText()))
            hide();
        else
            new Popup<>().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
    });
    Button closeButton = new AutoTooltipButton(Res.get("shared.close"));
    closeButton.setOnAction(event -> {
        hide();
        closeHandlerOptional.ifPresent(Runnable::run);
    });
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    GridPane.setRowIndex(hBox, ++rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    hBox.getChildren().addAll(unlockButton, closeButton);
    gridPane.getChildren().add(hBox);
}
Also used : HBox(javafx.scene.layout.HBox) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton)

Example 19 with AutoTooltipButton

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

the class WalletPasswordWindow method addButtons.

private void addButtons() {
    BusyAnimation busyAnimation = new BusyAnimation(false);
    Label deriveStatusLabel = new AutoTooltipLabel();
    unlockButton = new AutoTooltipButton(Res.get("shared.unlock"));
    unlockButton.setDefaultButton(true);
    unlockButton.setDisable(true);
    unlockButton.setOnAction(e -> {
        String password = passwordTextField.getText();
        checkArgument(password.length() < 500, Res.get("password.tooLong"));
        KeyCrypterScrypt keyCrypterScrypt = walletsManager.getKeyCrypterScrypt();
        if (keyCrypterScrypt != null) {
            busyAnimation.play();
            deriveStatusLabel.setText(Res.get("password.deriveKey"));
            ScryptUtil.deriveKeyWithScrypt(keyCrypterScrypt, password, aesKey -> {
                if (walletsManager.checkAESKey(aesKey)) {
                    if (aesKeyHandler != null)
                        aesKeyHandler.onAesKey(aesKey);
                    hide();
                } else {
                    busyAnimation.stop();
                    deriveStatusLabel.setText("");
                    UserThread.runAfter(() -> new Popup<>().warning(Res.get("password.wrongPw")).onClose(this::blurAgain).show(), Transitions.DEFAULT_DURATION, TimeUnit.MILLISECONDS);
                }
            });
        } else {
            log.error("wallet.getKeyCrypter() is null, that must not happen.");
        }
    });
    forgotPasswordButton = new AutoTooltipButton(Res.get("password.forgotPassword"));
    forgotPasswordButton.setOnAction(e -> {
        forgotPasswordButton.setDisable(true);
        unlockButton.setDefaultButton(false);
        showRestoreScreen();
    });
    Button cancelButton = new AutoTooltipButton(Res.get("shared.cancel"));
    cancelButton.setOnAction(event -> {
        hide();
        closeHandlerOptional.ifPresent(Runnable::run);
    });
    HBox hBox = new HBox();
    hBox.setMinWidth(560);
    hBox.setSpacing(10);
    GridPane.setRowIndex(hBox, ++rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    hBox.setAlignment(Pos.CENTER_LEFT);
    if (hideCloseButton)
        hBox.getChildren().addAll(unlockButton, forgotPasswordButton, busyAnimation, deriveStatusLabel);
    else
        hBox.getChildren().addAll(unlockButton, cancelButton);
    gridPane.getChildren().add(hBox);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
}
Also used : HBox(javafx.scene.layout.HBox) BusyAnimation(bisq.desktop.components.BusyAnimation) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) FormBuilder.addButton(bisq.desktop.util.FormBuilder.addButton) ColumnConstraints(javafx.scene.layout.ColumnConstraints) Popup(bisq.desktop.main.overlays.popups.Popup) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) KeyCrypterScrypt(org.bitcoinj.crypto.KeyCrypterScrypt) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton)

Example 20 with AutoTooltipButton

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

the class OfferBookChartView method getOfferTable.

private Tuple4<TableView<OfferListItem>, VBox, Button, Label> getOfferTable(OfferPayload.Direction direction) {
    TableView<OfferListItem> tableView = new TableView<>();
    tableView.setMinHeight(initialOfferTableViewHeight);
    tableView.setPrefHeight(121);
    tableView.setMinWidth(480);
    tableView.getStyleClass().add("offer-table");
    // price
    TableColumn<OfferListItem, OfferListItem> priceColumn = new TableColumn<>();
    priceColumn.textProperty().bind(priceColumnLabel);
    priceColumn.setMinWidth(115);
    priceColumn.setMaxWidth(115);
    priceColumn.setSortable(false);
    priceColumn.getStyleClass().add("number-column");
    priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    priceColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {

        @Override
        public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
            return new TableCell<OfferListItem, OfferListItem>() {

                private Offer offer;

                final ChangeListener<Number> listener = new ChangeListener<Number>() {

                    @Override
                    public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                        if (offer != null && offer.getPrice() != null) {
                            setText("");
                            setGraphic(new ColoredDecimalPlacesWithZerosText(model.getPrice(offer), model.getZeroDecimalsForPrice(offer)));
                            model.priceFeedService.updateCounterProperty().removeListener(listener);
                        }
                    }
                };

                @Override
                public void updateItem(final OfferListItem offerListItem, boolean empty) {
                    super.updateItem(offerListItem, empty);
                    if (offerListItem != null && !empty) {
                        final Offer offer = offerListItem.offer;
                        if (offer.getPrice() == null) {
                            this.offer = offer;
                            model.priceFeedService.updateCounterProperty().addListener(listener);
                            setText(Res.get("shared.na"));
                        } else {
                            setGraphic(new ColoredDecimalPlacesWithZerosText(model.getPrice(offer), model.getZeroDecimalsForPrice(offer)));
                        }
                    } else {
                        if (listener != null)
                            model.priceFeedService.updateCounterProperty().removeListener(listener);
                        this.offer = null;
                        setText("");
                        setGraphic(null);
                    }
                }
            };
        }
    });
    // volume
    TableColumn<OfferListItem, OfferListItem> volumeColumn = new TableColumn<>();
    volumeColumn.setMinWidth(115);
    volumeColumn.setSortable(false);
    volumeColumn.textProperty().bind(volumeColumnLabel);
    volumeColumn.getStyleClass().add("number-column");
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {

        @Override
        public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
            return new TableCell<OfferListItem, OfferListItem>() {

                private Offer offer;

                final ChangeListener<Number> listener = new ChangeListener<Number>() {

                    @Override
                    public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                        if (offer != null && offer.getPrice() != null) {
                            setText("");
                            setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offer), model.getMaxNumberOfPriceZeroDecimalsToColorize(offer)));
                            model.priceFeedService.updateCounterProperty().removeListener(listener);
                        }
                    }
                };

                @Override
                public void updateItem(final OfferListItem offerListItem, boolean empty) {
                    super.updateItem(offerListItem, empty);
                    if (offerListItem != null && !empty) {
                        this.offer = offerListItem.offer;
                        if (offer.getPrice() == null) {
                            this.offer = offerListItem.offer;
                            model.priceFeedService.updateCounterProperty().addListener(listener);
                            setText(Res.get("shared.na"));
                        } else {
                            setText("");
                            setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offer), model.getMaxNumberOfPriceZeroDecimalsToColorize(offer)));
                        }
                    } else {
                        if (listener != null)
                            model.priceFeedService.updateCounterProperty().removeListener(listener);
                        this.offer = null;
                        setText("");
                        setGraphic(null);
                    }
                }
            };
        }
    });
    // amount
    TableColumn<OfferListItem, OfferListItem> amountColumn = new AutoTooltipTableColumn<>(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode()));
    amountColumn.setMinWidth(115);
    amountColumn.setSortable(false);
    amountColumn.getStyleClass().add("number-column");
    amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    amountColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {

        @Override
        public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
            return new TableCell<OfferListItem, OfferListItem>() {

                @Override
                public void updateItem(final OfferListItem offerListItem, boolean empty) {
                    super.updateItem(offerListItem, empty);
                    if (offerListItem != null && !empty) {
                        setGraphic(new ColoredDecimalPlacesWithZerosText(formatter.formatCoin(offerListItem.offer.getAmount(), 4), GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    tableView.getColumns().add(volumeColumn);
    tableView.getColumns().add(amountColumn);
    tableView.getColumns().add(priceColumn);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.multipleOffers")));
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);
    Label titleLabel = new AutoTooltipLabel();
    titleLabel.getStyleClass().add("table-title");
    UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty()));
    boolean isSellOffer = direction == OfferPayload.Direction.SELL;
    Button button = new AutoTooltipButton();
    ImageView iconView = new ImageView();
    iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
    button.setGraphic(iconView);
    button.setGraphicTextGap(10);
    button.setText(isSellOffer ? Res.get("market.offerBook.buy") : Res.get("market.offerBook.sell"));
    button.setMinHeight(40);
    button.setId(isSellOffer ? "buy-button-big" : "sell-button-big");
    button.setOnAction(e -> {
        if (isSellOffer) {
            model.preferences.setBuyScreenCurrencyCode(model.getCurrencyCode());
            // noinspection unchecked
            navigation.navigateTo(MainView.class, BuyOfferView.class);
        } else {
            model.preferences.setSellScreenCurrencyCode(model.getCurrencyCode());
            // noinspection unchecked
            navigation.navigateTo(MainView.class, SellOfferView.class);
        }
    });
    VBox vBox = new VBox();
    vBox.setSpacing(10);
    vBox.setFillWidth(true);
    vBox.setMinHeight(190);
    vBox.setVgrow(tableView, Priority.ALWAYS);
    vBox.getChildren().addAll(titleLabel, tableView, button);
    button.prefWidthProperty().bind(vBox.widthProperty());
    return new Tuple4<>(tableView, vBox, button, titleLabel);
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) TableCell(javafx.scene.control.TableCell) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) ListChangeListener(javafx.collections.ListChangeListener) ChangeListener(javafx.beans.value.ChangeListener) ImageView(javafx.scene.image.ImageView) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) TableView(javafx.scene.control.TableView) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableColumn(javafx.scene.control.TableColumn) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Tuple4(bisq.common.util.Tuple4) Offer(bisq.core.offer.Offer) ColoredDecimalPlacesWithZerosText(bisq.desktop.components.ColoredDecimalPlacesWithZerosText) VBox(javafx.scene.layout.VBox)

Aggregations

AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)43 Button (javafx.scene.control.Button)37 Insets (javafx.geometry.Insets)31 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)28 Label (javafx.scene.control.Label)27 HBox (javafx.scene.layout.HBox)26 Popup (bisq.desktop.main.overlays.popups.Popup)17 ImageView (javafx.scene.image.ImageView)17 Res (bisq.core.locale.Res)15 FxmlView (bisq.desktop.common.view.FxmlView)13 Callback (javafx.util.Callback)13 Inject (javax.inject.Inject)13 InputTextField (bisq.desktop.components.InputTextField)12 ChangeListener (javafx.beans.value.ChangeListener)12 Tooltip (javafx.scene.control.Tooltip)12 VBox (javafx.scene.layout.VBox)12 Tuple2 (bisq.common.util.Tuple2)11 GridPane (javafx.scene.layout.GridPane)11 TableCell (javafx.scene.control.TableCell)10 TableColumn (javafx.scene.control.TableColumn)10