From fdd9c87ecaa0c5ea24279b48446beafe8dc1f552 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 13 Mar 2018 18:21:37 +0100 Subject: [PATCH 1/8] Always use "Take offer" on action button --- .../java/bisq/desktop/main/offer/offerbook/OfferBookView.java | 2 +- .../bisq/desktop/main/offer/offerbook/OfferBookViewModel.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java index 4c24d865c6b..9bfc6776e5b 100644 --- a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java +++ b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java @@ -734,7 +734,7 @@ public void updateItem(final OfferBookListItem item, boolean empty) { } private TableColumn getActionColumn() { - TableColumn column = new AutoTooltipTableColumn(Res.get("offerbook.wantTo")) { + TableColumn column = new AutoTooltipTableColumn("") { { setMinWidth(80); setSortable(false); diff --git a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java index 30a7f4aa524..77767e6c505 100644 --- a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java +++ b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java @@ -456,7 +456,7 @@ else if (offer.getPaymentMethod().equals(PaymentMethod.SPECIFIC_BANKS)) } String getDirectionLabel(Offer offer) { - return formatter.getDirectionWithCode(offer.getMirroredDirection(), offer.getCurrencyCode()); + return Res.get("offerbook.takeOffer"); } String getDirectionLabelTooltip(Offer offer) { From 6ec683fb687b2453df1ad30d8a8989515422c5d0 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 13 Mar 2018 18:22:10 +0100 Subject: [PATCH 2/8] Change order of trader and action button columns --- .../java/bisq/desktop/main/offer/offerbook/OfferBookView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java index 9bfc6776e5b..341413c99bc 100644 --- a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java +++ b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java @@ -192,9 +192,9 @@ public PaymentMethod fromString(String s) { tableView.getColumns().add(volumeColumn); TableColumn paymentMethodColumn = getPaymentMethodColumn(); tableView.getColumns().add(paymentMethodColumn); - tableView.getColumns().add(getActionColumn()); TableColumn avatarColumn = getAvatarColumn(); tableView.getColumns().add(avatarColumn); + tableView.getColumns().add(getActionColumn()); tableView.getSortOrder().add(priceColumn); tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); From 5db43ee11546129e015edc413a392d428d777089 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 13 Mar 2018 18:22:42 +0100 Subject: [PATCH 3/8] Adapt trader column to new column title --- .../bisq/desktop/main/offer/offerbook/OfferBookView.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java index 341413c99bc..ae070be82bd 100644 --- a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java +++ b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java @@ -862,10 +862,10 @@ public void updateItem(final OfferBookListItem newItem, boolean empty) { } private TableColumn getAvatarColumn() { - TableColumn column = new AutoTooltipTableColumn("") { + TableColumn column = new AutoTooltipTableColumn(Res.get("offerbook.trader")) { { - setMinWidth(40); - setMaxWidth(40); + setMinWidth(80); + setMaxWidth(80); setSortable(true); } }; From 2feffea57e80046889acae2fcd4c927c95636aa8 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 14 Mar 2018 15:47:04 +0100 Subject: [PATCH 4/8] Add help popover for amount and volume column --- .../main/offer/offerbook/OfferBookView.java | 26 +++--- .../components/AutoTooltipTableColumn.java | 81 +++++++++++++++++++ 2 files changed, 94 insertions(+), 13 deletions(-) create mode 100644 src/main/java/io/bisq/gui/components/AutoTooltipTableColumn.java diff --git a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java index ae070be82bd..0a59e89f62e 100644 --- a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java +++ b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java @@ -111,7 +111,7 @@ public class OfferBookView extends ActivatableViewAndModel currencyComboBox; private ComboBox paymentMethodComboBox; private Button createOfferButton; - private TableColumn amountColumn, volumeColumn, marketColumn, priceColumn; + private AutoTooltipTableColumn amountColumn, volumeColumn, marketColumn, priceColumn; private TableView tableView; private OfferView.OfferActionHandler offerActionHandler; @@ -285,14 +285,14 @@ protected void activate() { (showAll, code) -> { setDirectionTitles(); if (showAll) { - volumeColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amountMinMax"))); - priceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.price"))); + volumeColumn.setTitleWithHelpText(Res.get("shared.amountMinMax"), Res.get("shared.amountHelp")); + priceColumn.setTitle(Res.get("shared.price")); if (!tableView.getColumns().contains(marketColumn)) tableView.getColumns().add(0, marketColumn); } else { - volumeColumn.setGraphic(new AutoTooltipLabel(Res.get("offerbook.volume", code))); - priceColumn.setGraphic(new AutoTooltipLabel(formatter.getPriceWithCurrencyCode(code))); + volumeColumn.setTitleWithHelpText(Res.get("offerbook.volume", code),Res.get("shared.amountHelp")); + priceColumn.setTitle(formatter.getPriceWithCurrencyCode(code)); if (tableView.getColumns().contains(marketColumn)) tableView.getColumns().remove(marketColumn); @@ -517,8 +517,8 @@ private void openPopupForMissingAccountSetup(String headLine, String message, Cl // Table /////////////////////////////////////////////////////////////////////////////////////////// - private TableColumn getAmountColumn() { - TableColumn column = new AutoTooltipTableColumn(Res.get("shared.BTCMinMax")); + private AutoTooltipTableColumn getAmountColumn() { + AutoTooltipTableColumn column = new AutoTooltipTableColumn<>(Res.get("shared.BTCMinMax"), Res.get("shared.amountHelp")); column.setMinWidth(100); column.getStyleClass().add("number-column"); column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue())); @@ -543,8 +543,8 @@ public void updateItem(final OfferBookListItem item, boolean empty) { return column; } - private TableColumn getMarketColumn() { - TableColumn column = new AutoTooltipTableColumn(Res.get("shared.market")) { + private AutoTooltipTableColumn getMarketColumn() { + AutoTooltipTableColumn column = new AutoTooltipTableColumn(Res.get("shared.market")) { { setMinWidth(40); } @@ -573,8 +573,8 @@ public void updateItem(final OfferBookListItem item, boolean empty) { return column; } - private TableColumn getPriceColumn() { - TableColumn column = new TableColumn() { + private AutoTooltipTableColumn getPriceColumn() { + AutoTooltipTableColumn column = new AutoTooltipTableColumn("") { { setMinWidth(100); } @@ -643,8 +643,8 @@ public void updateItem(final OfferBookListItem item, boolean empty) { return column; } - private TableColumn getVolumeColumn() { - TableColumn column = new TableColumn() { + private AutoTooltipTableColumn getVolumeColumn() { + AutoTooltipTableColumn column = new AutoTooltipTableColumn("") { { setMinWidth(125); } diff --git a/src/main/java/io/bisq/gui/components/AutoTooltipTableColumn.java b/src/main/java/io/bisq/gui/components/AutoTooltipTableColumn.java new file mode 100644 index 00000000000..f239425b583 --- /dev/null +++ b/src/main/java/io/bisq/gui/components/AutoTooltipTableColumn.java @@ -0,0 +1,81 @@ +package io.bisq.gui.components; + +import de.jensd.fx.fontawesome.AwesomeDude; +import de.jensd.fx.fontawesome.AwesomeIcon; +import io.bisq.common.UserThread; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.control.Label; +import javafx.scene.control.TableColumn; +import javafx.scene.layout.HBox; +import org.controlsfx.control.PopOver; + +import java.util.concurrent.TimeUnit; + +public class AutoTooltipTableColumn extends TableColumn { + + private Label helpIcon; + private Boolean hidePopover; + private PopOver infoPopover; + + + public AutoTooltipTableColumn(String text) { + super(); + + setTitle(text); + } + + public AutoTooltipTableColumn(String text, String help) { + + setTitleWithHelpText(text, help); + } + + public void setTitle(String title) { + setGraphic(new AutoTooltipLabel(title)); + } + + public void setTitleWithHelpText(String title, String help) { + + final AutoTooltipLabel label = new AutoTooltipLabel(title); + + helpIcon = new Label(); + AwesomeDude.setIcon(helpIcon, AwesomeIcon.QUESTION_SIGN, "1em"); + helpIcon.setOpacity(0.4); + helpIcon.setOnMouseEntered(e -> { + hidePopover = false; + final Label helpLabel = new Label(help); + helpLabel.setMaxWidth(300); + helpLabel.setWrapText(true); + helpLabel.setPadding(new Insets(10)); + showInfoPopOver(helpLabel); + }); + helpIcon.setOnMouseExited(e -> { + if (infoPopover != null) + infoPopover.hide(); + hidePopover = true; + UserThread.runAfter(() -> { + if (hidePopover) { + infoPopover.hide(); + hidePopover = false; + } + }, 250, TimeUnit.MILLISECONDS); + }); + + final HBox hBox = new HBox(label, helpIcon); + hBox.setStyle("-fx-alignment: center"); + hBox.setSpacing(4); + setGraphic(hBox); + } + + private void showInfoPopOver(Node node) { + node.getStyleClass().add("default-text"); + + infoPopover = new PopOver(node); + if (helpIcon.getScene() != null) { + infoPopover.setDetachable(false); + infoPopover.setArrowLocation(PopOver.ArrowLocation.LEFT_CENTER); + + infoPopover.show(helpIcon, -10); + } + } +} From 5eb5df58e27ff9e5896fb56beccbf5a83e7eb73a Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 14 Mar 2018 16:54:29 +0100 Subject: [PATCH 5/8] Align filters horizontal --- .../java/bisq/desktop/util/FormBuilder.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/bisq/desktop/util/FormBuilder.java b/src/main/java/bisq/desktop/util/FormBuilder.java index 011623c90a1..a167e6a88fc 100644 --- a/src/main/java/bisq/desktop/util/FormBuilder.java +++ b/src/main/java/bisq/desktop/util/FormBuilder.java @@ -657,6 +657,26 @@ public static Tuple2 addLabelSearchComboBox(GridPane grid return new Tuple2<>(label, comboBox); } + /////////////////////////////////////////////////////////////////////////////////////////// + // HBox + Label + ComboBox + /////////////////////////////////////////////////////////////////////////////////////////// + + public static Tuple3 addHBoxLabelComboBox(GridPane gridPane, int rowIndex, String title, double top) { + HBox hBox = new HBox(); + hBox.setAlignment(Pos.CENTER_LEFT); + hBox.setSpacing(4); + + final AutoTooltipLabel label = new AutoTooltipLabel(title); + final ComboBox comboBox = new ComboBox<>(); + hBox.getChildren().addAll(label, comboBox); + + GridPane.setRowIndex(hBox, rowIndex); + GridPane.setColumnSpan(hBox, 2); + GridPane.setMargin(hBox, new Insets(top, 0,0,24)); + gridPane.getChildren().add(hBox); + + return new Tuple3<>(hBox, label, comboBox); + } /////////////////////////////////////////////////////////////////////////////////////////// // Label + ComboBox + ComboBox From e6fd619d1d21717307ea71acc7c191c2bc285eef Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 14 Mar 2018 17:33:56 +0100 Subject: [PATCH 6/8] Fix rebase errors --- .../components/AutoTooltipTableColumn.java | 75 ++++++++++++++++- .../components/AutoTooltipTableColumn.java | 81 ------------------- 2 files changed, 74 insertions(+), 82 deletions(-) delete mode 100644 src/main/java/io/bisq/gui/components/AutoTooltipTableColumn.java diff --git a/src/main/java/bisq/desktop/components/AutoTooltipTableColumn.java b/src/main/java/bisq/desktop/components/AutoTooltipTableColumn.java index 584b27b27d7..9f20b5bfae2 100644 --- a/src/main/java/bisq/desktop/components/AutoTooltipTableColumn.java +++ b/src/main/java/bisq/desktop/components/AutoTooltipTableColumn.java @@ -17,13 +17,86 @@ package bisq.desktop.components; +import bisq.common.UserThread; + +import de.jensd.fx.fontawesome.AwesomeDude; +import de.jensd.fx.fontawesome.AwesomeIcon; + +import org.controlsfx.control.PopOver; + +import javafx.scene.Node; +import javafx.scene.control.Label; import javafx.scene.control.TableColumn; +import javafx.scene.layout.HBox; + +import javafx.geometry.Insets; + +import java.util.concurrent.TimeUnit; public class AutoTooltipTableColumn extends TableColumn { + private Label helpIcon; + private Boolean hidePopover; + private PopOver infoPopover; + + public AutoTooltipTableColumn(String text) { super(); - setGraphic(new AutoTooltipLabel(text)); + setTitle(text); + } + + public AutoTooltipTableColumn(String text, String help) { + + setTitleWithHelpText(text, help); + } + + public void setTitle(String title) { + setGraphic(new AutoTooltipLabel(title)); + } + + public void setTitleWithHelpText(String title, String help) { + + final AutoTooltipLabel label = new AutoTooltipLabel(title); + + helpIcon = new Label(); + AwesomeDude.setIcon(helpIcon, AwesomeIcon.QUESTION_SIGN, "1em"); + helpIcon.setOpacity(0.4); + helpIcon.setOnMouseEntered(e -> { + hidePopover = false; + final Label helpLabel = new Label(help); + helpLabel.setMaxWidth(300); + helpLabel.setWrapText(true); + helpLabel.setPadding(new Insets(10)); + showInfoPopOver(helpLabel); + }); + helpIcon.setOnMouseExited(e -> { + if (infoPopover != null) + infoPopover.hide(); + hidePopover = true; + UserThread.runAfter(() -> { + if (hidePopover) { + infoPopover.hide(); + hidePopover = false; + } + }, 250, TimeUnit.MILLISECONDS); + }); + + final HBox hBox = new HBox(label, helpIcon); + hBox.setStyle("-fx-alignment: center"); + hBox.setSpacing(4); + setGraphic(hBox); + } + + private void showInfoPopOver(Node node) { + node.getStyleClass().add("default-text"); + + infoPopover = new PopOver(node); + if (helpIcon.getScene() != null) { + infoPopover.setDetachable(false); + infoPopover.setArrowLocation(PopOver.ArrowLocation.LEFT_CENTER); + + infoPopover.show(helpIcon, -10); + } } } diff --git a/src/main/java/io/bisq/gui/components/AutoTooltipTableColumn.java b/src/main/java/io/bisq/gui/components/AutoTooltipTableColumn.java deleted file mode 100644 index f239425b583..00000000000 --- a/src/main/java/io/bisq/gui/components/AutoTooltipTableColumn.java +++ /dev/null @@ -1,81 +0,0 @@ -package io.bisq.gui.components; - -import de.jensd.fx.fontawesome.AwesomeDude; -import de.jensd.fx.fontawesome.AwesomeIcon; -import io.bisq.common.UserThread; -import javafx.geometry.Insets; -import javafx.scene.Node; -import javafx.scene.control.Label; -import javafx.scene.control.TableColumn; -import javafx.scene.layout.HBox; -import org.controlsfx.control.PopOver; - -import java.util.concurrent.TimeUnit; - -public class AutoTooltipTableColumn extends TableColumn { - - private Label helpIcon; - private Boolean hidePopover; - private PopOver infoPopover; - - - public AutoTooltipTableColumn(String text) { - super(); - - setTitle(text); - } - - public AutoTooltipTableColumn(String text, String help) { - - setTitleWithHelpText(text, help); - } - - public void setTitle(String title) { - setGraphic(new AutoTooltipLabel(title)); - } - - public void setTitleWithHelpText(String title, String help) { - - final AutoTooltipLabel label = new AutoTooltipLabel(title); - - helpIcon = new Label(); - AwesomeDude.setIcon(helpIcon, AwesomeIcon.QUESTION_SIGN, "1em"); - helpIcon.setOpacity(0.4); - helpIcon.setOnMouseEntered(e -> { - hidePopover = false; - final Label helpLabel = new Label(help); - helpLabel.setMaxWidth(300); - helpLabel.setWrapText(true); - helpLabel.setPadding(new Insets(10)); - showInfoPopOver(helpLabel); - }); - helpIcon.setOnMouseExited(e -> { - if (infoPopover != null) - infoPopover.hide(); - hidePopover = true; - UserThread.runAfter(() -> { - if (hidePopover) { - infoPopover.hide(); - hidePopover = false; - } - }, 250, TimeUnit.MILLISECONDS); - }); - - final HBox hBox = new HBox(label, helpIcon); - hBox.setStyle("-fx-alignment: center"); - hBox.setSpacing(4); - setGraphic(hBox); - } - - private void showInfoPopOver(Node node) { - node.getStyleClass().add("default-text"); - - infoPopover = new PopOver(node); - if (helpIcon.getScene() != null) { - infoPopover.setDetachable(false); - infoPopover.setArrowLocation(PopOver.ArrowLocation.LEFT_CENTER); - - infoPopover.show(helpIcon, -10); - } - } -} From 623dbe94a93aef0a1307df1f85fd03009b1381a2 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 14 Mar 2018 17:58:49 +0100 Subject: [PATCH 7/8] Use shorter lambda expression --- .../bisq/desktop/main/offer/offerbook/OfferBookView.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java index 0a59e89f62e..7c731d7504d 100644 --- a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java +++ b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java @@ -243,9 +243,7 @@ public PaymentMethod fromString(String s) { // Fixes incorrect ordering of Available offers: // https://github.com/bisq-network/exchange/issues/588 - priceFeedUpdateCounterListener = (observable, oldValue, newValue) -> { - tableView.sort(); - }; + priceFeedUpdateCounterListener = (observable, oldValue, newValue) -> tableView.sort(); } @Override @@ -266,9 +264,7 @@ protected void activate() { volumeColumn.sortableProperty().bind(model.showAllTradeCurrenciesProperty.not()); priceColumn.sortableProperty().bind(model.showAllTradeCurrenciesProperty.not()); model.getOfferList().comparatorProperty().bind(tableView.comparatorProperty()); - model.priceSortTypeProperty.addListener((observable, oldValue, newValue) -> { - priceColumn.setSortType(newValue); - }); + model.priceSortTypeProperty.addListener((observable, oldValue, newValue) -> priceColumn.setSortType(newValue)); priceColumn.setSortType(model.priceSortTypeProperty.get()); paymentMethodComboBox.setItems(model.getPaymentMethods()); From ee45c6a2183d120608dbbda69790718827d837bd Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 14 Mar 2018 17:59:17 +0100 Subject: [PATCH 8/8] Align filter horizontal --- .../main/offer/offerbook/OfferBookView.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java index 7c731d7504d..8152fdfc2b0 100644 --- a/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java +++ b/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java @@ -55,6 +55,8 @@ import bisq.network.p2p.NodeAddress; +import bisq.common.util.Tuple3; + import org.bitcoinj.core.Coin; import com.google.inject.name.Named; @@ -73,6 +75,7 @@ import javafx.scene.control.Tooltip; import javafx.scene.image.ImageView; import javafx.scene.layout.GridPane; +import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; import javafx.geometry.HPos; @@ -96,6 +99,7 @@ import java.util.Optional; import static bisq.desktop.util.FormBuilder.addButton; +import static bisq.desktop.util.FormBuilder.addHBoxLabelComboBox; import static bisq.desktop.util.FormBuilder.addLabelComboBox; import static bisq.desktop.util.FormBuilder.addTitledGroupBg; @@ -147,12 +151,16 @@ public void initialize() { addTitledGroupBg(root, gridRow, 3, Res.get("offerbook.availableOffers")); - //noinspection unchecked - currencyComboBox = addLabelComboBox(root, gridRow, Res.get("offerbook.filterByCurrency"), Layout.FIRST_ROW_DISTANCE).second; + final Tuple3 filterBoxTuple = addHBoxLabelComboBox(root, gridRow, Res.get("offerbook.filterByCurrency"), Layout.FIRST_ROW_DISTANCE); + final HBox filterBox = filterBoxTuple.first; + currencyComboBox = filterBoxTuple.third; currencyComboBox.setPromptText(Res.get("list.currency.select")); //noinspection unchecked - paymentMethodComboBox = addLabelComboBox(root, ++gridRow, Res.getWithCol("offerbook.filterByPaymentMethod")).second; + paymentMethodComboBox = new ComboBox<>(); + final Label paymentMethodLabel = new AutoTooltipLabel(Res.getWithCol("offerbook.filterByPaymentMethod")); + paymentMethodLabel.setPadding(new Insets(0,0,0,10)); + filterBox.getChildren().addAll(paymentMethodLabel, paymentMethodComboBox); paymentMethodComboBox.setPromptText(Res.get("shared.selectPaymentMethod")); paymentMethodComboBox.setVisibleRowCount(20); paymentMethodComboBox.setConverter(new StringConverter() {