From d2dd99fdb35d3222b7a658908f7d5d8bb732d320 Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Wed, 24 Feb 2021 12:17:27 +0100 Subject: [PATCH 1/2] fix #5200 --- .../components/TextFieldWithCopyIcon.java | 12 +++++++- .../components/paymentmethods/BankForm.java | 4 +-- .../java/bisq/desktop/util/FormBuilder.java | 28 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/TextFieldWithCopyIcon.java b/desktop/src/main/java/bisq/desktop/components/TextFieldWithCopyIcon.java index 7f2892379ca..d01d410259b 100644 --- a/desktop/src/main/java/bisq/desktop/components/TextFieldWithCopyIcon.java +++ b/desktop/src/main/java/bisq/desktop/components/TextFieldWithCopyIcon.java @@ -39,7 +39,7 @@ public class TextFieldWithCopyIcon extends AnchorPane { private final StringProperty text = new SimpleStringProperty(); private final TextField textField; private boolean copyWithoutCurrencyPostFix; - + private boolean copyWithoutBeforeSlash; /////////////////////////////////////////////////////////////////////////////////////////// // Constructor @@ -65,6 +65,12 @@ public TextFieldWithCopyIcon(String customStyleClass) { copyText = strings[0]; // exclude the BTC postfix else copyText = text; + } else if (copyWithoutBeforeSlash) { + String[] strings = text.split(" "); + if (strings.length > 1) + copyText = strings[2]; // exclude the part before / (slash included) + else + copyText = text; } else { copyText = text; } @@ -110,4 +116,8 @@ public void setCopyWithoutCurrencyPostFix(boolean copyWithoutCurrencyPostFix) { this.copyWithoutCurrencyPostFix = copyWithoutCurrencyPostFix; } + public void setCopyWithoutBeforeSlash(boolean copyWithoutBeforeSlash) { + this.copyWithoutBeforeSlash = copyWithoutBeforeSlash; + } + } diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/BankForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/BankForm.java index 8e6b11b719b..15508227d3e 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/BankForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/BankForm.java @@ -105,13 +105,13 @@ static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload addCompactTopLabelTextFieldWithCopyIcon(gridPane, getIndexOfColumn(colIndex) == 0 ? ++gridRow : gridRow, getIndexOfColumn(colIndex++), bankNameLabel + " / " + bankIdLabel + ":", - data.getBankName() + " / " + data.getBankId()); + data.getBankName() + " / " + data.getBankId(), true); } if (bankNameBranchIdCombined) { addCompactTopLabelTextFieldWithCopyIcon(gridPane, getIndexOfColumn(colIndex) == 0 ? ++gridRow : gridRow, getIndexOfColumn(colIndex++), bankNameLabel + " / " + branchIdLabel + ":", - data.getBankName() + " / " + data.getBranchId()); + data.getBankName() + " / " + data.getBranchId(), true); } if (!bankNameBankIdCombined && !bankNameBranchIdCombined && BankUtil.isBankNameRequired(countryCode)) diff --git a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java index fac6954f0c9..02765555295 100644 --- a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java +++ b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java @@ -1519,6 +1519,15 @@ public static Tuple2 addCompactTopLabelTextFieldWi return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, colIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE); } + public static Tuple2 addCompactTopLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + int colIndex, + String title, + String value, + boolean withoutBeforeSlash) { + return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, colIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE, withoutBeforeSlash); + } + public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, String title, @@ -1548,6 +1557,25 @@ public static Tuple2 addTopLabelTextFieldWithCopyI return new Tuple2<>(topLabelWithVBox.first, textFieldWithCopyIcon); } + public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + int colIndex, + String title, + String value, + double top, + boolean withoutBeforeSlash) { + + TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon(); + textFieldWithCopyIcon.setText(value); + textFieldWithCopyIcon.setCopyWithoutBeforeSlash(true); + + final Tuple2 topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, textFieldWithCopyIcon, top); + topLabelWithVBox.second.setAlignment(Pos.TOP_LEFT); + GridPane.setColumnIndex(topLabelWithVBox.second, colIndex); + + return new Tuple2<>(topLabelWithVBox.first, textFieldWithCopyIcon); + } + public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, int colIndex, From fbf7af809378f3742e420b4a326aba5bbc938630 Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Thu, 11 Mar 2021 17:37:32 +0100 Subject: [PATCH 2/2] Change naming of variables and methods --- .../bisq/desktop/components/TextFieldWithCopyIcon.java | 8 ++++---- desktop/src/main/java/bisq/desktop/util/FormBuilder.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/TextFieldWithCopyIcon.java b/desktop/src/main/java/bisq/desktop/components/TextFieldWithCopyIcon.java index d01d410259b..5d5323bf180 100644 --- a/desktop/src/main/java/bisq/desktop/components/TextFieldWithCopyIcon.java +++ b/desktop/src/main/java/bisq/desktop/components/TextFieldWithCopyIcon.java @@ -39,7 +39,7 @@ public class TextFieldWithCopyIcon extends AnchorPane { private final StringProperty text = new SimpleStringProperty(); private final TextField textField; private boolean copyWithoutCurrencyPostFix; - private boolean copyWithoutBeforeSlash; + private boolean copyTextAfterDelimiter; /////////////////////////////////////////////////////////////////////////////////////////// // Constructor @@ -65,7 +65,7 @@ public TextFieldWithCopyIcon(String customStyleClass) { copyText = strings[0]; // exclude the BTC postfix else copyText = text; - } else if (copyWithoutBeforeSlash) { + } else if (copyTextAfterDelimiter) { String[] strings = text.split(" "); if (strings.length > 1) copyText = strings[2]; // exclude the part before / (slash included) @@ -116,8 +116,8 @@ public void setCopyWithoutCurrencyPostFix(boolean copyWithoutCurrencyPostFix) { this.copyWithoutCurrencyPostFix = copyWithoutCurrencyPostFix; } - public void setCopyWithoutBeforeSlash(boolean copyWithoutBeforeSlash) { - this.copyWithoutBeforeSlash = copyWithoutBeforeSlash; + public void setCopyTextAfterDelimiter(boolean copyTextAfterDelimiter) { + this.copyTextAfterDelimiter = copyTextAfterDelimiter; } } diff --git a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java index 02765555295..5eabd281dc6 100644 --- a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java +++ b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java @@ -1524,8 +1524,8 @@ public static Tuple2 addCompactTopLabelTextFieldWi int colIndex, String title, String value, - boolean withoutBeforeSlash) { - return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, colIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE, withoutBeforeSlash); + boolean onlyCopyTextAfterDelimiter) { + return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, colIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE, onlyCopyTextAfterDelimiter); } public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, @@ -1563,11 +1563,11 @@ public static Tuple2 addTopLabelTextFieldWithCopyI String title, String value, double top, - boolean withoutBeforeSlash) { + boolean onlyCopyTextAfterDelimiter) { TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon(); textFieldWithCopyIcon.setText(value); - textFieldWithCopyIcon.setCopyWithoutBeforeSlash(true); + textFieldWithCopyIcon.setCopyTextAfterDelimiter(true); final Tuple2 topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, textFieldWithCopyIcon, top); topLabelWithVBox.second.setAlignment(Pos.TOP_LEFT);