Search in sources :

Example 26 with AutoTooltipButton

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

the class TraderDisputeView method getSelectColumn.

// /////////////////////////////////////////////////////////////////////////////////////////
// Table
// /////////////////////////////////////////////////////////////////////////////////////////
private TableColumn<Dispute, Dispute> getSelectColumn() {
    TableColumn<Dispute, Dispute> column = new AutoTooltipTableColumn<Dispute, Dispute>(Res.get("shared.select"));
    column.setMinWidth(80);
    column.setMaxWidth(80);
    column.setSortable(false);
    column.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    column.setCellFactory(new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {

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

                Button button;

                @Override
                public void updateItem(final Dispute item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        if (button == null) {
                            button = new AutoTooltipButton(Res.get("shared.select"));
                            setGraphic(button);
                        }
                        button.setOnAction(e -> tableView.getSelectionModel().select(item));
                    } else {
                        setGraphic(null);
                        if (button != null) {
                            button.setOnAction(null);
                            button = null;
                        }
                    }
                }
            };
        }
    });
    return column;
}
Also used : Button(javafx.scene.control.Button) EventHandler(javafx.event.EventHandler) PubKeyRing(bisq.common.crypto.PubKeyRing) BusyAnimation(bisq.desktop.components.BusyAnimation) Utilities(bisq.common.util.Utilities) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) ListCell(javafx.scene.control.ListCell) URL(java.net.URL) Date(java.util.Date) ReadOnlyBooleanProperty(javafx.beans.property.ReadOnlyBooleanProperty) DisputeManager(bisq.core.arbitration.DisputeManager) VBox(javafx.scene.layout.VBox) BSFormatter(bisq.desktop.util.BSFormatter) Contract(bisq.core.trade.Contract) InputTextField(bisq.desktop.components.InputTextField) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) Map(java.util.Map) TableView(javafx.scene.control.TableView) ParseException(java.text.ParseException) DateFormat(java.text.DateFormat) Pane(javafx.scene.layout.Pane) SortedList(javafx.collections.transformation.SortedList) HBox(javafx.scene.layout.HBox) Popup(bisq.desktop.main.overlays.popups.Popup) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) P2PService(bisq.network.p2p.P2PService) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FilteredList(javafx.collections.transformation.FilteredList) KeyEvent(javafx.scene.input.KeyEvent) Subscription(org.fxmisc.easybind.Subscription) SendPrivateNotificationWindow(bisq.desktop.main.overlays.windows.SendPrivateNotificationWindow) Priority(javafx.scene.layout.Priority) List(java.util.List) TradeManager(bisq.core.trade.TradeManager) AnchorPane(javafx.scene.layout.AnchorPane) Paint(javafx.scene.paint.Paint) NodeAddress(bisq.network.p2p.NodeAddress) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AppOptionKeys(bisq.core.app.AppOptionKeys) UserThread(bisq.common.UserThread) ByteStreams(com.google.common.io.ByteStreams) Optional(java.util.Optional) Attachment(bisq.core.arbitration.Attachment) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) GUIUtil(bisq.desktop.util.GUIUtil) Scene(javafx.scene.Scene) ActivatableView(bisq.desktop.common.view.ActivatableView) ListView(javafx.scene.control.ListView) DisputeSummaryWindow(bisq.desktop.main.overlays.windows.DisputeSummaryWindow) TextArea(javafx.scene.control.TextArea) SimpleDateFormat(java.text.SimpleDateFormat) Timer(bisq.common.Timer) HashMap(java.util.HashMap) Dispute(bisq.core.arbitration.Dispute) ContractWindow(bisq.desktop.main.overlays.windows.ContractWindow) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) Lists(com.google.common.collect.Lists) Insets(javafx.geometry.Insets) Connection(bisq.network.p2p.network.Connection) TextAlignment(javafx.scene.text.TextAlignment) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) Nullable(javax.annotation.Nullable) KeyCode(javafx.scene.input.KeyCode) Version(bisq.common.app.Version) Label(javafx.scene.control.Label) TradeDetailsWindow(bisq.desktop.main.overlays.windows.TradeDetailsWindow) MalformedURLException(java.net.MalformedURLException) Trade(bisq.core.trade.Trade) AwesomeDude(de.jensd.fx.fontawesome.AwesomeDude) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) FileChooser(javafx.stage.FileChooser) DisputeCommunicationMessage(bisq.core.arbitration.messages.DisputeCommunicationMessage) Stage(javafx.stage.Stage) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) ArbitratorDisputeView(bisq.desktop.main.disputes.arbitrator.ArbitratorDisputeView) Named(com.google.inject.name.Named) KeyRing(bisq.common.crypto.KeyRing) ChangeListener(javafx.beans.value.ChangeListener) InputStream(java.io.InputStream) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableColumn(javafx.scene.control.TableColumn) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) TableCell(javafx.scene.control.TableCell) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) Dispute(bisq.core.arbitration.Dispute)

Example 27 with AutoTooltipButton

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

the class TraderDisputeView method onSelectDispute.

private void onSelectDispute(Dispute dispute) {
    removeListenersOnSelectDispute();
    if (dispute == null) {
        if (root.getChildren().size() > 2)
            root.getChildren().remove(2);
        selectedDispute = null;
    } else if (selectedDispute != dispute) {
        this.selectedDispute = dispute;
        boolean isTrader = disputeManager.isTrader(selectedDispute);
        tableGroupHeadline = new TableGroupHeadline();
        tableGroupHeadline.setText(Res.get("support.messages"));
        AnchorPane.setTopAnchor(tableGroupHeadline, 10d);
        AnchorPane.setRightAnchor(tableGroupHeadline, 0d);
        AnchorPane.setBottomAnchor(tableGroupHeadline, 0d);
        AnchorPane.setLeftAnchor(tableGroupHeadline, 0d);
        disputeCommunicationMessages = selectedDispute.getDisputeCommunicationMessages();
        SortedList<DisputeCommunicationMessage> sortedList = new SortedList<>(disputeCommunicationMessages);
        sortedList.setComparator((o1, o2) -> new Date(o1.getDate()).compareTo(new Date(o2.getDate())));
        messageListView = new ListView<>(sortedList);
        messageListView.setId("message-list-view");
        messageListView.setMinHeight(150);
        AnchorPane.setTopAnchor(messageListView, 30d);
        AnchorPane.setRightAnchor(messageListView, 0d);
        AnchorPane.setLeftAnchor(messageListView, 0d);
        messagesAnchorPane = new AnchorPane();
        VBox.setVgrow(messagesAnchorPane, Priority.ALWAYS);
        inputTextArea = new TextArea();
        inputTextArea.setPrefHeight(70);
        inputTextArea.setWrapText(true);
        if (!(this instanceof ArbitratorDisputeView))
            inputTextArea.setPromptText(Res.get("support.input.prompt"));
        sendButton = new AutoTooltipButton(Res.get("support.send"));
        sendButton.setDefaultButton(true);
        sendButton.setOnAction(e -> onTrySendMessage());
        inputTextAreaTextSubscription = EasyBind.subscribe(inputTextArea.textProperty(), t -> sendButton.setDisable(t.isEmpty()));
        Button uploadButton = new AutoTooltipButton(Res.get("support.addAttachments"));
        uploadButton.setOnAction(e -> onRequestUpload());
        sendMsgInfoLabel = new AutoTooltipLabel();
        sendMsgInfoLabel.setVisible(false);
        sendMsgInfoLabel.setManaged(false);
        sendMsgInfoLabel.setPadding(new Insets(5, 0, 0, 0));
        sendMsgBusyAnimation = new BusyAnimation(false);
        if (!selectedDispute.isClosed()) {
            HBox buttonBox = new HBox();
            buttonBox.setSpacing(10);
            buttonBox.getChildren().addAll(sendButton, uploadButton, sendMsgBusyAnimation, sendMsgInfoLabel);
            if (!isTrader) {
                Button closeDisputeButton = new AutoTooltipButton(Res.get("support.closeTicket"));
                closeDisputeButton.setOnAction(e -> onCloseDispute(selectedDispute));
                closeDisputeButton.setDefaultButton(true);
                Pane spacer = new Pane();
                HBox.setHgrow(spacer, Priority.ALWAYS);
                buttonBox.getChildren().addAll(spacer, closeDisputeButton);
            }
            messagesInputBox = new VBox();
            messagesInputBox.setSpacing(10);
            messagesInputBox.getChildren().addAll(inputTextArea, buttonBox);
            VBox.setVgrow(buttonBox, Priority.ALWAYS);
            AnchorPane.setRightAnchor(messagesInputBox, 0d);
            AnchorPane.setBottomAnchor(messagesInputBox, 5d);
            AnchorPane.setLeftAnchor(messagesInputBox, 0d);
            AnchorPane.setBottomAnchor(messageListView, 120d);
            messagesAnchorPane.getChildren().addAll(tableGroupHeadline, messageListView, messagesInputBox);
        } else {
            AnchorPane.setBottomAnchor(messageListView, 0d);
            messagesAnchorPane.getChildren().addAll(tableGroupHeadline, messageListView);
        }
        messageListView.setCellFactory(new Callback<ListView<DisputeCommunicationMessage>, ListCell<DisputeCommunicationMessage>>() {

            @Override
            public ListCell<DisputeCommunicationMessage> call(ListView<DisputeCommunicationMessage> list) {
                return new ListCell<DisputeCommunicationMessage>() {

                    public ChangeListener<Boolean> sendMsgBusyAnimationListener;

                    final Pane bg = new Pane();

                    final ImageView arrow = new ImageView();

                    final Label headerLabel = new AutoTooltipLabel();

                    final Label messageLabel = new AutoTooltipLabel();

                    final Label copyIcon = new Label();

                    final HBox attachmentsBox = new HBox();

                    final AnchorPane messageAnchorPane = new AnchorPane();

                    final Label statusIcon = new Label();

                    final double arrowWidth = 15d;

                    final double attachmentsBoxHeight = 20d;

                    final double border = 10d;

                    final double bottomBorder = 25d;

                    final double padding = border + 10d;

                    final double msgLabelPaddingRight = padding + 20d;

                    {
                        bg.setMinHeight(30);
                        messageLabel.setWrapText(true);
                        headerLabel.setTextAlignment(TextAlignment.CENTER);
                        attachmentsBox.setSpacing(5);
                        statusIcon.getStyleClass().add("small-text");
                        copyIcon.setTooltip(new Tooltip(Res.get("shared.copyToClipboard")));
                        messageAnchorPane.getChildren().addAll(bg, arrow, headerLabel, messageLabel, copyIcon, attachmentsBox, statusIcon);
                        messageLabel.setOnMouseClicked(event -> {
                            if (2 > event.getClickCount()) {
                                return;
                            }
                            GUIUtil.showSelectableTextModal(headerLabel.getText(), messageLabel.getText());
                        });
                    }

                    @Override
                    public void updateItem(final DisputeCommunicationMessage item, boolean empty) {
                        super.updateItem(item, empty);
                        if (item != null && !empty) {
                            copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(messageLabel.getText()));
                            /* messageAnchorPane.prefWidthProperty().bind(EasyBind.map(messageListView.widthProperty(),
                                        w -> (double) w - padding - GUIUtil.getScrollbarWidth(messageListView)));*/
                            if (!messageAnchorPane.prefWidthProperty().isBound())
                                messageAnchorPane.prefWidthProperty().bind(messageListView.widthProperty().subtract(padding + GUIUtil.getScrollbarWidth(messageListView)));
                            AnchorPane.setTopAnchor(bg, 15d);
                            AnchorPane.setBottomAnchor(bg, bottomBorder);
                            AnchorPane.setTopAnchor(headerLabel, 0d);
                            AnchorPane.setBottomAnchor(arrow, bottomBorder + 5d);
                            AnchorPane.setTopAnchor(messageLabel, 25d);
                            AnchorPane.setTopAnchor(copyIcon, 25d);
                            AnchorPane.setBottomAnchor(attachmentsBox, bottomBorder + 10);
                            boolean senderIsTrader = item.isSenderIsTrader();
                            boolean isMyMsg = isTrader ? senderIsTrader : !senderIsTrader;
                            arrow.setVisible(!item.isSystemMessage());
                            arrow.setManaged(!item.isSystemMessage());
                            statusIcon.setVisible(false);
                            headerLabel.getStyleClass().removeAll("message-header", "success-text", "highlight-static");
                            messageLabel.getStyleClass().removeAll("my-message", "message");
                            copyIcon.getStyleClass().removeAll("my-message", "message");
                            if (item.isSystemMessage()) {
                                headerLabel.getStyleClass().addAll("message-header", "success-text");
                                bg.setId("message-bubble-green");
                                messageLabel.getStyleClass().add("my-message");
                                copyIcon.getStyleClass().add("my-message");
                            } else if (isMyMsg) {
                                headerLabel.getStyleClass().add("highlight-static");
                                bg.setId("message-bubble-blue");
                                messageLabel.getStyleClass().add("my-message");
                                copyIcon.getStyleClass().add("my-message");
                                if (isTrader)
                                    arrow.setId("bubble_arrow_blue_left");
                                else
                                    arrow.setId("bubble_arrow_blue_right");
                                if (sendMsgBusyAnimationListener != null)
                                    sendMsgBusyAnimation.isRunningProperty().removeListener(sendMsgBusyAnimationListener);
                                sendMsgBusyAnimationListener = (observable, oldValue, newValue) -> {
                                    if (!newValue) {
                                        if (item.arrivedProperty().get())
                                            showArrivedIcon();
                                        else if (item.storedInMailboxProperty().get())
                                            showMailboxIcon();
                                    }
                                };
                                sendMsgBusyAnimation.isRunningProperty().addListener(sendMsgBusyAnimationListener);
                                if (item.arrivedProperty().get())
                                    showArrivedIcon();
                                else if (item.storedInMailboxProperty().get())
                                    showMailboxIcon();
                            // TODO show that icon on error
                            /*else if (sendMsgProgressIndicator.getProgress() == 0)
                                        showNotArrivedIcon();*/
                            } else {
                                headerLabel.getStyleClass().add("message-header");
                                bg.setId("message-bubble-grey");
                                messageLabel.getStyleClass().add("message");
                                copyIcon.getStyleClass().add("message");
                                if (isTrader)
                                    arrow.setId("bubble_arrow_grey_right");
                                else
                                    arrow.setId("bubble_arrow_grey_left");
                            }
                            if (item.isSystemMessage()) {
                                AnchorPane.setLeftAnchor(headerLabel, padding);
                                AnchorPane.setRightAnchor(headerLabel, padding);
                                AnchorPane.setLeftAnchor(bg, border);
                                AnchorPane.setRightAnchor(bg, border);
                                AnchorPane.setLeftAnchor(messageLabel, padding);
                                AnchorPane.setRightAnchor(messageLabel, msgLabelPaddingRight);
                                AnchorPane.setRightAnchor(copyIcon, padding);
                                AnchorPane.setLeftAnchor(attachmentsBox, padding);
                                AnchorPane.setRightAnchor(attachmentsBox, padding);
                            } else if (senderIsTrader) {
                                AnchorPane.setLeftAnchor(headerLabel, padding + arrowWidth);
                                AnchorPane.setLeftAnchor(bg, border + arrowWidth);
                                AnchorPane.setRightAnchor(bg, border);
                                AnchorPane.setLeftAnchor(arrow, border);
                                AnchorPane.setLeftAnchor(messageLabel, padding + arrowWidth);
                                AnchorPane.setRightAnchor(messageLabel, msgLabelPaddingRight);
                                AnchorPane.setRightAnchor(copyIcon, padding);
                                AnchorPane.setLeftAnchor(attachmentsBox, padding + arrowWidth);
                                AnchorPane.setRightAnchor(attachmentsBox, padding);
                                AnchorPane.setRightAnchor(statusIcon, padding);
                            } else {
                                AnchorPane.setRightAnchor(headerLabel, padding + arrowWidth);
                                AnchorPane.setLeftAnchor(bg, border);
                                AnchorPane.setRightAnchor(bg, border + arrowWidth);
                                AnchorPane.setRightAnchor(arrow, border);
                                AnchorPane.setLeftAnchor(messageLabel, padding);
                                AnchorPane.setRightAnchor(messageLabel, msgLabelPaddingRight + arrowWidth);
                                AnchorPane.setRightAnchor(copyIcon, padding + arrowWidth);
                                AnchorPane.setLeftAnchor(attachmentsBox, padding);
                                AnchorPane.setRightAnchor(attachmentsBox, padding + arrowWidth);
                                AnchorPane.setLeftAnchor(statusIcon, padding);
                            }
                            AnchorPane.setBottomAnchor(statusIcon, 7d);
                            headerLabel.setText(formatter.formatDateTime(new Date(item.getDate())));
                            messageLabel.setText(item.getMessage());
                            attachmentsBox.getChildren().clear();
                            if (item.getAttachments() != null && item.getAttachments().size() > 0) {
                                AnchorPane.setBottomAnchor(messageLabel, bottomBorder + attachmentsBoxHeight + 10);
                                attachmentsBox.getChildren().add(new AutoTooltipLabel(Res.get("support.attachments") + " ") {

                                    {
                                        setPadding(new Insets(0, 0, 3, 0));
                                        if (isMyMsg)
                                            getStyleClass().add("my-message");
                                        else
                                            getStyleClass().add("message");
                                    }
                                });
                                item.getAttachments().stream().forEach(attachment -> {
                                    final Label icon = new Label();
                                    setPadding(new Insets(0, 0, 3, 0));
                                    if (isMyMsg)
                                        icon.getStyleClass().add("attachment-icon");
                                    else
                                        icon.getStyleClass().add("attachment-icon-black");
                                    AwesomeDude.setIcon(icon, AwesomeIcon.FILE_TEXT);
                                    icon.setPadding(new Insets(-2, 0, 0, 0));
                                    icon.setTooltip(new Tooltip(attachment.getFileName()));
                                    icon.setOnMouseClicked(event -> onOpenAttachment(attachment));
                                    attachmentsBox.getChildren().add(icon);
                                });
                            } else {
                                AnchorPane.setBottomAnchor(messageLabel, bottomBorder + 10);
                            }
                            // Need to set it here otherwise style is not correct
                            AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY, "16.0");
                            copyIcon.getStyleClass().addAll("icon", "copy-icon-disputes");
                            // TODO There are still some cell rendering issues on updates
                            setGraphic(messageAnchorPane);
                        } else {
                            if (sendMsgBusyAnimation != null && sendMsgBusyAnimationListener != null)
                                sendMsgBusyAnimation.isRunningProperty().removeListener(sendMsgBusyAnimationListener);
                            messageAnchorPane.prefWidthProperty().unbind();
                            AnchorPane.clearConstraints(bg);
                            AnchorPane.clearConstraints(headerLabel);
                            AnchorPane.clearConstraints(arrow);
                            AnchorPane.clearConstraints(messageLabel);
                            AnchorPane.clearConstraints(copyIcon);
                            AnchorPane.clearConstraints(statusIcon);
                            AnchorPane.clearConstraints(attachmentsBox);
                            copyIcon.setOnMouseClicked(null);
                            setGraphic(null);
                        }
                    }

                    /*  private void showNotArrivedIcon() {
                            statusIcon.setVisible(true);
                            AwesomeDude.setIcon(statusIcon, AwesomeIcon.WARNING_SIGN, "14");
                            Tooltip.install(statusIcon, new Tooltip("Message did not arrive. Please try to send again."));
                            statusIcon.setTextFill(Paint.valueOf("#dd0000"));
                        }*/
                    private void showMailboxIcon() {
                        statusIcon.setVisible(true);
                        AwesomeDude.setIcon(statusIcon, AwesomeIcon.ENVELOPE_ALT, "14");
                        statusIcon.setTooltip(new Tooltip(Res.get("support.savedInMailbox")));
                        statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
                    }

                    private void showArrivedIcon() {
                        statusIcon.setVisible(true);
                        AwesomeDude.setIcon(statusIcon, AwesomeIcon.OK, "14");
                        statusIcon.setTooltip(new Tooltip(Res.get("support.arrived")));
                        statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
                    }
                };
            }
        });
        if (root.getChildren().size() > 2)
            root.getChildren().remove(2);
        root.getChildren().add(2, messagesAnchorPane);
        scrollToBottom();
    }
    addListenersOnSelectDispute();
}
Also used : Button(javafx.scene.control.Button) EventHandler(javafx.event.EventHandler) PubKeyRing(bisq.common.crypto.PubKeyRing) BusyAnimation(bisq.desktop.components.BusyAnimation) Utilities(bisq.common.util.Utilities) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) ListCell(javafx.scene.control.ListCell) URL(java.net.URL) Date(java.util.Date) ReadOnlyBooleanProperty(javafx.beans.property.ReadOnlyBooleanProperty) DisputeManager(bisq.core.arbitration.DisputeManager) VBox(javafx.scene.layout.VBox) BSFormatter(bisq.desktop.util.BSFormatter) Contract(bisq.core.trade.Contract) InputTextField(bisq.desktop.components.InputTextField) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) Map(java.util.Map) TableView(javafx.scene.control.TableView) ParseException(java.text.ParseException) DateFormat(java.text.DateFormat) Pane(javafx.scene.layout.Pane) SortedList(javafx.collections.transformation.SortedList) HBox(javafx.scene.layout.HBox) Popup(bisq.desktop.main.overlays.popups.Popup) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) P2PService(bisq.network.p2p.P2PService) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FilteredList(javafx.collections.transformation.FilteredList) KeyEvent(javafx.scene.input.KeyEvent) Subscription(org.fxmisc.easybind.Subscription) SendPrivateNotificationWindow(bisq.desktop.main.overlays.windows.SendPrivateNotificationWindow) Priority(javafx.scene.layout.Priority) List(java.util.List) TradeManager(bisq.core.trade.TradeManager) AnchorPane(javafx.scene.layout.AnchorPane) Paint(javafx.scene.paint.Paint) NodeAddress(bisq.network.p2p.NodeAddress) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AppOptionKeys(bisq.core.app.AppOptionKeys) UserThread(bisq.common.UserThread) ByteStreams(com.google.common.io.ByteStreams) Optional(java.util.Optional) Attachment(bisq.core.arbitration.Attachment) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) GUIUtil(bisq.desktop.util.GUIUtil) Scene(javafx.scene.Scene) ActivatableView(bisq.desktop.common.view.ActivatableView) ListView(javafx.scene.control.ListView) DisputeSummaryWindow(bisq.desktop.main.overlays.windows.DisputeSummaryWindow) TextArea(javafx.scene.control.TextArea) SimpleDateFormat(java.text.SimpleDateFormat) Timer(bisq.common.Timer) HashMap(java.util.HashMap) Dispute(bisq.core.arbitration.Dispute) ContractWindow(bisq.desktop.main.overlays.windows.ContractWindow) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) Lists(com.google.common.collect.Lists) Insets(javafx.geometry.Insets) Connection(bisq.network.p2p.network.Connection) TextAlignment(javafx.scene.text.TextAlignment) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) Nullable(javax.annotation.Nullable) KeyCode(javafx.scene.input.KeyCode) Version(bisq.common.app.Version) Label(javafx.scene.control.Label) TradeDetailsWindow(bisq.desktop.main.overlays.windows.TradeDetailsWindow) MalformedURLException(java.net.MalformedURLException) Trade(bisq.core.trade.Trade) AwesomeDude(de.jensd.fx.fontawesome.AwesomeDude) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) FileChooser(javafx.stage.FileChooser) DisputeCommunicationMessage(bisq.core.arbitration.messages.DisputeCommunicationMessage) Stage(javafx.stage.Stage) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) ArbitratorDisputeView(bisq.desktop.main.disputes.arbitrator.ArbitratorDisputeView) Named(com.google.inject.name.Named) KeyRing(bisq.common.crypto.KeyRing) ChangeListener(javafx.beans.value.ChangeListener) InputStream(java.io.InputStream) TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) TextArea(javafx.scene.control.TextArea) ListCell(javafx.scene.control.ListCell) SortedList(javafx.collections.transformation.SortedList) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) ArbitratorDisputeView(bisq.desktop.main.disputes.arbitrator.ArbitratorDisputeView) ListView(javafx.scene.control.ListView) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) ListChangeListener(javafx.collections.ListChangeListener) ChangeListener(javafx.beans.value.ChangeListener) ImageView(javafx.scene.image.ImageView) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AnchorPane(javafx.scene.layout.AnchorPane) DisputeCommunicationMessage(bisq.core.arbitration.messages.DisputeCommunicationMessage) BusyAnimation(bisq.desktop.components.BusyAnimation) Tooltip(javafx.scene.control.Tooltip) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Pane(javafx.scene.layout.Pane) AnchorPane(javafx.scene.layout.AnchorPane) Date(java.util.Date) Callback(javafx.util.Callback) VBox(javafx.scene.layout.VBox)

Example 28 with AutoTooltipButton

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

the class DepositView method setSelectColumnCellFactory.

private void setSelectColumnCellFactory() {
    selectColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    selectColumn.setCellFactory(new Callback<TableColumn<DepositListItem, DepositListItem>, TableCell<DepositListItem, DepositListItem>>() {

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

                Button button;

                @Override
                public void updateItem(final DepositListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        if (button == null) {
                            button = new AutoTooltipButton(Res.get("shared.select"));
                            setGraphic(button);
                        }
                        button.setOnAction(e -> tableView.getSelectionModel().select(item));
                    } else {
                        setGraphic(null);
                        if (button != null) {
                            button.setOnAction(null);
                            button = null;
                        }
                    }
                }
            };
        }
    });
}
Also used : Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) Transaction(org.bitcoinj.core.Transaction) QRCodeWindow(bisq.desktop.main.overlays.windows.QRCodeWindow) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) Coin(org.bitcoinj.core.Coin) Layout(bisq.desktop.util.Layout) VBox(javafx.scene.layout.VBox) BSFormatter(bisq.desktop.util.BSFormatter) InputTextField(bisq.desktop.components.InputTextField) QRCode(net.glxn.qrgen.QRCode) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ByteArrayInputStream(java.io.ByteArrayInputStream) Res(bisq.core.locale.Res) ImageType(net.glxn.qrgen.image.ImageType) TableView(javafx.scene.control.TableView) SortedList(javafx.collections.transformation.SortedList) Popup(bisq.desktop.main.overlays.popups.Popup) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) Subscription(org.fxmisc.easybind.Subscription) FXML(javafx.fxml.FXML) AddressEntry(bisq.core.btc.AddressEntry) DevEnv(bisq.common.app.DevEnv) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Preferences(bisq.core.user.Preferences) UserThread(bisq.common.UserThread) FeeService(bisq.core.provider.fee.FeeService) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) NotNull(org.jetbrains.annotations.NotNull) GUIUtil(bisq.desktop.util.GUIUtil) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) ActivatableView(bisq.desktop.common.view.ActivatableView) FXCollections(javafx.collections.FXCollections) FormBuilder.addLabelInputTextField(bisq.desktop.util.FormBuilder.addLabelInputTextField) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) BalanceListener(bisq.core.btc.listeners.BalanceListener) Tuple2(bisq.common.util.Tuple2) TableCell(javafx.scene.control.TableCell) Insets(javafx.geometry.Insets) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) TitledGroupBg(bisq.desktop.components.TitledGroupBg) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) AddressTextField(bisq.desktop.components.AddressTextField) TimeUnit(java.util.concurrent.TimeUnit) FormBuilder.addButton(bisq.desktop.util.FormBuilder.addButton) EasyBind(org.fxmisc.easybind.EasyBind) FormBuilder.addLabelAddressTextField(bisq.desktop.util.FormBuilder.addLabelAddressTextField) ImageView(javafx.scene.image.ImageView) ChangeListener(javafx.beans.value.ChangeListener) Image(javafx.scene.image.Image) TableCell(javafx.scene.control.TableCell) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) FormBuilder.addButton(bisq.desktop.util.FormBuilder.addButton) TableColumn(javafx.scene.control.TableColumn) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton)

Example 29 with AutoTooltipButton

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

the class CreateOfferView method addFundingGroup.

private void addFundingGroup() {
    // don't increase gridRow as we removed button when this gets visible
    payFundsTitledGroupBg = addTitledGroupBg(gridPane, gridRow, 3, Res.get("createOffer.fundsBox.title"), Layout.GROUP_DISTANCE);
    GridPane.setColumnSpan(payFundsTitledGroupBg, 3);
    payFundsTitledGroupBg.setVisible(false);
    Tuple2<Label, FundsTextField> fundsTuple = addLabelFundsTextfield(gridPane, gridRow, Res.get("shared.totalsNeeded"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    totalToPayLabel = fundsTuple.first;
    totalToPayLabel.setVisible(false);
    totalToPayTextField = fundsTuple.second;
    totalToPayTextField.setVisible(false);
    qrCodeImageView = new ImageView();
    qrCodeImageView.setVisible(false);
    qrCodeImageView.getStyleClass().add("qr-code");
    Tooltip.install(qrCodeImageView, new Tooltip(Res.get("shared.openLargeQRWindow")));
    qrCodeImageView.setOnMouseClicked(e -> GUIUtil.showFeeInfoBeforeExecute(() -> UserThread.runAfter(() -> new QRCodeWindow(getBitcoinURI()).show(), 200, TimeUnit.MILLISECONDS)));
    GridPane.setRowIndex(qrCodeImageView, gridRow);
    GridPane.setColumnIndex(qrCodeImageView, 2);
    GridPane.setRowSpan(qrCodeImageView, 3);
    GridPane.setMargin(qrCodeImageView, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE - 9, 0, 0, 5));
    gridPane.getChildren().add(qrCodeImageView);
    Tuple2<Label, AddressTextField> addressTuple = addLabelAddressTextField(gridPane, ++gridRow, Res.get("shared.tradeWalletAddress"));
    addressLabel = addressTuple.first;
    addressLabel.setVisible(false);
    addressTextField = addressTuple.second;
    addressTextField.setVisible(false);
    Tuple2<Label, BalanceTextField> balanceTuple = addLabelBalanceTextField(gridPane, ++gridRow, Res.get("shared.tradeWalletBalance"));
    balanceLabel = balanceTuple.first;
    balanceLabel.setVisible(false);
    balanceTextField = balanceTuple.second;
    balanceTextField.setVisible(false);
    fundingHBox = new HBox();
    fundingHBox.setVisible(false);
    fundingHBox.setManaged(false);
    fundingHBox.setSpacing(10);
    Button fundFromSavingsWalletButton = new AutoTooltipButton(Res.get("shared.fundFromSavingsWalletButton"));
    fundFromSavingsWalletButton.setDefaultButton(false);
    fundFromSavingsWalletButton.setOnAction(e -> model.fundFromSavingsWallet());
    Label label = new AutoTooltipLabel(Res.get("shared.OR"));
    label.setPadding(new Insets(5, 0, 0, 0));
    Button fundFromExternalWalletButton = new AutoTooltipButton(Res.get("shared.fundFromExternalWalletButton"));
    fundFromExternalWalletButton.setDefaultButton(false);
    fundFromExternalWalletButton.setOnAction(e -> GUIUtil.showFeeInfoBeforeExecute(this::openWallet));
    waitingForFundsBusyAnimation = new BusyAnimation();
    waitingForFundsLabel = new AutoTooltipLabel();
    waitingForFundsLabel.setPadding(new Insets(5, 0, 0, 0));
    fundingHBox.getChildren().addAll(fundFromSavingsWalletButton, label, fundFromExternalWalletButton, waitingForFundsBusyAnimation, waitingForFundsLabel);
    GridPane.setRowIndex(fundingHBox, ++gridRow);
    GridPane.setColumnIndex(fundingHBox, 1);
    GridPane.setMargin(fundingHBox, new Insets(15, 10, 0, 0));
    gridPane.getChildren().add(fundingHBox);
    placeOfferButton = addButtonAfterGroup(gridPane, gridRow, "");
    placeOfferButton.setOnAction(e -> onPlaceOffer());
    placeOfferButton.setMinHeight(40);
    placeOfferButton.setPadding(new Insets(0, 20, 0, 20));
    cancelButton2 = addButton(gridPane, ++gridRow, Res.get("shared.cancel"));
    cancelButton2.setOnAction(e -> {
        if (model.dataModel.getIsBtcWalletFunded().get()) {
            new Popup<>().warning(Res.get("createOffer.warnCancelOffer")).closeButtonText(Res.get("shared.no")).actionButtonText(Res.get("shared.yesCancel")).onAction(() -> {
                close();
                model.dataModel.swapTradeToSavings();
            }).show();
        } else {
            close();
            model.dataModel.swapTradeToSavings();
        }
    });
    cancelButton2.setDefaultButton(false);
    cancelButton2.setVisible(false);
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) BusyAnimation(bisq.desktop.components.BusyAnimation) AddressTextField(bisq.desktop.components.AddressTextField) Tooltip(javafx.scene.control.Tooltip) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) QRCodeWindow(bisq.desktop.main.overlays.windows.QRCodeWindow) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) BalanceTextField(bisq.desktop.components.BalanceTextField) FundsTextField(bisq.desktop.components.FundsTextField) ImageView(javafx.scene.image.ImageView) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel)

Example 30 with AutoTooltipButton

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

the class TransactionsView method setRevertTxColumnCellFactory.

private void setRevertTxColumnCellFactory() {
    revertTxColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    revertTxColumn.setCellFactory(new Callback<TableColumn<TransactionsListItem, TransactionsListItem>, TableCell<TransactionsListItem, TransactionsListItem>>() {

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

                Button button;

                @Override
                public void updateItem(final TransactionsListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        TransactionConfidence confidence = btcWalletService.getConfidenceForTxId(item.getTxId());
                        if (confidence != null) {
                            if (confidence.getConfidenceType() == TransactionConfidence.ConfidenceType.PENDING) {
                                if (button == null) {
                                    button = new AutoTooltipButton(Res.get("funds.tx.revert"));
                                    setGraphic(button);
                                }
                                button.setOnAction(e -> revertTransaction(item.getTxId(), item.getTradable()));
                            } else {
                                setGraphic(null);
                                if (button != null) {
                                    button.setOnAction(null);
                                    button = null;
                                }
                            }
                        }
                    } else {
                        setGraphic(null);
                        if (button != null) {
                            button.setOnAction(null);
                            button = null;
                        }
                    }
                }
            };
        }
    });
}
Also used : Button(javafx.scene.control.Button) EventHandler(javafx.event.EventHandler) Transaction(org.bitcoinj.core.Transaction) OpenOffer(bisq.core.offer.OpenOffer) Utilities(bisq.common.util.Utilities) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) Coin(org.bitcoinj.core.Coin) Date(java.util.Date) CSVEntryConverter(com.googlecode.jcsv.writer.CSVEntryConverter) VBox(javafx.scene.layout.VBox) BSFormatter(bisq.desktop.util.BSFormatter) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Res(bisq.core.locale.Res) Locale(java.util.Locale) Map(java.util.Map) TableView(javafx.scene.control.TableView) DateFormat(java.text.DateFormat) SortedList(javafx.collections.transformation.SortedList) Popup(bisq.desktop.main.overlays.popups.Popup) P2PService(bisq.network.p2p.P2PService) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) KeyEvent(javafx.scene.input.KeyEvent) Collectors(java.util.stream.Collectors) ECKey(org.bitcoinj.core.ECKey) FXML(javafx.fxml.FXML) List(java.util.List) Script(org.bitcoinj.script.Script) WalletsSetup(bisq.core.btc.wallet.WalletsSetup) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Preferences(bisq.core.user.Preferences) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) GUIUtil(bisq.desktop.util.GUIUtil) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) Scene(javafx.scene.Scene) WalletEventListener(org.bitcoinj.wallet.listeners.WalletEventListener) ActivatableView(bisq.desktop.common.view.ActivatableView) TransactionConfidence(org.bitcoinj.core.TransactionConfidence) OfferDetailsWindow(bisq.desktop.main.overlays.windows.OfferDetailsWindow) Wallet(org.bitcoinj.wallet.Wallet) HashMap(java.util.HashMap) Tradable(bisq.core.trade.Tradable) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) ArrayList(java.util.ArrayList) Tuple4(bisq.common.util.Tuple4) Inject(javax.inject.Inject) Tuple2(bisq.common.util.Tuple2) TableCell(javafx.scene.control.TableCell) AddressWithIconAndDirection(bisq.desktop.components.AddressWithIconAndDirection) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) Nullable(javax.annotation.Nullable) KeyCode(javafx.scene.input.KeyCode) TradeDetailsWindow(bisq.desktop.main.overlays.windows.TradeDetailsWindow) Trade(bisq.core.trade.Trade) Stage(javafx.stage.Stage) Comparator(java.util.Comparator) TableColumn(javafx.scene.control.TableColumn) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) TableCell(javafx.scene.control.TableCell) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) TransactionConfidence(org.bitcoinj.core.TransactionConfidence)

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