From 4ae89e748c8f5f1d5bb33ddb751de712dfab489e Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Fri, 5 May 2023 11:11:58 +0700 Subject: [PATCH] Use link icon for cloned offers Signed-off-by: HenrikJannsen --- .../bisq/core/offer/OpenOfferManager.java | 4 +- .../resources/i18n/displayStrings.properties | 17 ++++- desktop/src/main/java/bisq/desktop/bisq.css | 4 ++ .../portfolio/openoffer/OpenOffersView.fxml | 2 +- .../portfolio/openoffer/OpenOffersView.java | 71 ++++++++----------- .../src/main/java/bisq/desktop/theme-dark.css | 4 ++ .../java/bisq/desktop/util/FormBuilder.java | 10 +-- 7 files changed, 60 insertions(+), 52 deletions(-) diff --git a/core/src/main/java/bisq/core/offer/OpenOfferManager.java b/core/src/main/java/bisq/core/offer/OpenOfferManager.java index 94eb41dc1b..d28260cb0d 100644 --- a/core/src/main/java/bisq/core/offer/OpenOfferManager.java +++ b/core/src/main/java/bisq/core/offer/OpenOfferManager.java @@ -463,12 +463,12 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) { if (offersToBeEdited.containsKey(openOffer.getId())) { - errorMessageHandler.handleErrorMessage("You can't activate an offer that is currently edited."); + errorMessageHandler.handleErrorMessage(Res.get("offerbook.cannotActivateEditedOffer.warning")); return; } if (cannotActivateOffer(openOffer.getOffer())) { - errorMessageHandler.handleErrorMessage(Res.get("offerbook.cannotActivate.info")); + errorMessageHandler.handleErrorMessage(Res.get("offerbook.cannotActivate.warning")); return; } diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 369f6c3a1d..9a50123d9c 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -366,11 +366,22 @@ offerbook.timeSinceSigning.tooltip.learnMore=Learn more offerbook.xmrAutoConf=Is auto-confirm enabled offerbook.cloneOffer=Clone offer (with shared maker fee) -offerbook.clonedOffer.info=This is a cloned offer with shared maker fee transaction ID -offerbook.nonClonedOffer.info=Regular offer without shared maker fee transaction ID -offerbook.cannotActivate.info=This cloned offer with shared maker fee cannot be activated because it uses \ +offerbook.clonedOffer.tooltip=This is a cloned offer with shared maker fee transaction ID.\n\Maker fee transaction ID: {0} +offerbook.nonClonedOffer.tooltip=Regular offer without shared maker fee transaction ID.\n\Maker fee transaction ID: {0} +offerbook.cannotActivate.warning=This cloned offer with shared maker fee cannot be activated because it uses \ the same payment method and currency as another active offer. You need to edit the offer and change the \ payment method or currency or deactivate the offer which has the same payment method and currency. +offerbook.cannotActivateEditedOffer.warning=You can't activate an offer that is currently edited. +offerbook.clonedOffer.info=By cloning an offer one creates a copy of the given offer with a new offer ID but using the same \ + maker fee transaction ID.\n\n\ + This means there is no extra maker fee needed to get paid and the funds reserved for that offer can \ + be re-used by the cloned offers. This reduces the liquidity requirements for market makers and allows them to post the \ + same offer in different markets or with different payment methods.\n\n\ + As a consequence if one of the offers sharing the same maker fee transaction is taken all the other offers \ + will get closed as well because the transaction output of that maker fee transaction is spent and would render the \ + other offers invalid. \n\n\ + This feature requires to use the same trade amount and security deposit and is only permitted for offers with different \ + payment methods or currencies. offerbook.timeSinceSigning.help=When you successfully complete a trade with a peer who has a signed payment account, your payment account is signed.\n\ {0} days later, the initial limit of {1} is lifted and your account can sign other peers'' payment accounts. diff --git a/desktop/src/main/java/bisq/desktop/bisq.css b/desktop/src/main/java/bisq/desktop/bisq.css index 02f81d5c99..a082485fbc 100644 --- a/desktop/src/main/java/bisq/desktop/bisq.css +++ b/desktop/src/main/java/bisq/desktop/bisq.css @@ -832,6 +832,10 @@ tree-table-view:focused { -fx-text-fill: -bs-rd-error-red; } +.icon { + -fx-fill: -bs-text-color; +} + .opaque-icon { -fx-fill: -bs-color-gray-bbb; -fx-opacity: 1; diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.fxml b/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.fxml index 2a7d5f2f38..3bda1667ac 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.fxml +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.fxml @@ -41,7 +41,7 @@ - + diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.java index 0f1aaad9b1..a28d242764 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersView.java @@ -391,7 +391,7 @@ public class OpenOffersView extends ActivatableViewAndModel log.debug("Activate offer was successful"), (message) -> { log.error(message); - new Popup().warning(Res.get("offerbook.activateOffer.failed", message)).show(); + new Popup().warning(message).show(); }); updateSelectToggleButtonState(); } @@ -467,6 +467,20 @@ public class OpenOffersView extends ActivatableViewAndModel doCloneOffer(item)) + .show(); + } else { + doCloneOffer(item); + } + } + + private void doCloneOffer(OpenOfferListItem item) { OpenOffer openOffer = item.getOpenOffer(); if (openOffer == null || openOffer.getOffer() == null || openOffer.getOffer().getOfferPayload().isEmpty()) { return; @@ -576,60 +590,35 @@ public class OpenOffersView extends ActivatableViewAndModel call( TableColumn column) { + return new TableCell<>() { - private HyperlinkWithIcon hyperlinkWithIcon = null; - - @Override - public void updateItem(final OpenOfferListItem item, boolean empty) { - super.updateItem(item, empty); - if (item != null && !empty) { - hyperlinkWithIcon = new HyperlinkWithIcon(item.getMakerFeeTxId()); - if (item.isNotPublished()) { - // getStyleClass().add("offer-disabled"); does not work with hyperlinkWithIcon ;-( - hyperlinkWithIcon.setStyle("-fx-text-fill: -bs-color-gray-3;"); - hyperlinkWithIcon.getIcon().setOpacity(0.2); - } - hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBlockExplorer(item.getMakerFeeTxId())); - if (openOfferManager.hasOfferSharedMakerFee(item.getOpenOffer())) { - hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("offerbook.clonedOffer.info"))); - } else { - hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("offerbook.nonClonedOffer.info"))); - } - setGraphic(hyperlinkWithIcon); - } else { - setGraphic(null); - if (hyperlinkWithIcon != null) { - hyperlinkWithIcon.setOnAction(null); - } - } - } - }; - - - /*return new TableCell<>() { @Override public void updateItem(final OpenOfferListItem item, boolean empty) { super.updateItem(item, empty); getStyleClass().removeAll("offer-disabled"); if (item != null) { + + Label label = new Label(item.getMakerFeeTxId()); + Text icon; + if (openOfferManager.hasOfferSharedMakerFee(item.getOpenOffer())) { + icon = getRegularIconForLabel(MaterialDesignIcon.LINK, label, "icon"); + setTooltip(new Tooltip(Res.get("offerbook.clonedOffer.tooltip", item.getMakerFeeTxId()))); + } else { + icon = getRegularIconForLabel(MaterialDesignIcon.LINK_OFF, label, "icon"); + setTooltip(new Tooltip(Res.get("offerbook.nonClonedOffer.tooltip", item.getMakerFeeTxId()))); + } + icon.setVisible(!item.getOffer().isBsqSwapOffer()); + if (item.isNotPublished()) { getStyleClass().add("offer-disabled"); - } - Label label = new AutoTooltipLabel(item.getMakerFeeTxId()); - log.error("{} {}",openOfferManager.hasOfferSharedMakerFee(item.getOpenOffer()),item.getOpenOffer().getId()); - if (openOfferManager.hasOfferSharedMakerFee(item.getOpenOffer())) { - Text icon = getRegularIconForLabel(MaterialDesignIcon.CALENDAR_QUESTION, label); - label.setContentDisplay(ContentDisplay.LEFT); - Tooltip.install(icon, new Tooltip(Res.get("offerbook.sharedMakerFeeTxId"))); - } else { - label.setGraphic(null); + icon.setOpacity(0.2); } setGraphic(label); } else { setGraphic(null); } } - };*/ + }; } }); } diff --git a/desktop/src/main/java/bisq/desktop/theme-dark.css b/desktop/src/main/java/bisq/desktop/theme-dark.css index d5d31af370..1be24acf04 100644 --- a/desktop/src/main/java/bisq/desktop/theme-dark.css +++ b/desktop/src/main/java/bisq/desktop/theme-dark.css @@ -557,3 +557,7 @@ -fx-text-fill: -bs-text-color; -fx-fill: -bs-text-color; } + +.icon { + -fx-fill: #fff; +} diff --git a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java index f91a71d221..ecab5c5f65 100644 --- a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java +++ b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java @@ -2248,12 +2248,12 @@ public class FormBuilder { // Icons /////////////////////////////////////////////////////////////////////////////////////////// - public static Text getIconForLabel(GlyphIcons icon, String iconSize, Label label, String style) { + public static Text getIconForLabel(GlyphIcons icon, String iconSize, Label label, String styleClass) { if (icon.fontFamily().equals(MATERIAL_DESIGN_ICONS)) { final Text textIcon = MaterialDesignIconFactory.get().createIcon(icon, iconSize); textIcon.setOpacity(0.7); - if (style != null) { - textIcon.getStyleClass().add(style); + if (styleClass != null) { + textIcon.getStyleClass().add(styleClass); } label.setContentDisplay(ContentDisplay.LEFT); label.setGraphic(textIcon); @@ -2279,8 +2279,8 @@ public class FormBuilder { return getRegularIconForLabel(icon, label, null); } - public static Text getRegularIconForLabel(GlyphIcons icon, Label label, String style) { - return getIconForLabel(icon, "1.231em", label, style); + public static Text getRegularIconForLabel(GlyphIcons icon, Label label, String styleClass) { + return getIconForLabel(icon, "1.231em", label, styleClass); } public static Text getIcon(GlyphIcons icon) {