Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix copy of BankName value + BranchId/BankId #5231

Merged
merged 2 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class TextFieldWithCopyIcon extends AnchorPane {
private final StringProperty text = new SimpleStringProperty();
private final TextField textField;
private boolean copyWithoutCurrencyPostFix;

private boolean copyTextAfterDelimiter;

///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
Expand All @@ -65,6 +65,12 @@ public TextFieldWithCopyIcon(String customStyleClass) {
copyText = strings[0]; // exclude the BTC postfix
else
copyText = text;
} else if (copyTextAfterDelimiter) {
String[] strings = text.split(" ");
if (strings.length > 1)
copyText = strings[2]; // exclude the part before / (slash included)
else
copyText = text;
} else {
copyText = text;
}
Expand Down Expand Up @@ -110,4 +116,8 @@ public void setCopyWithoutCurrencyPostFix(boolean copyWithoutCurrencyPostFix) {
this.copyWithoutCurrencyPostFix = copyWithoutCurrencyPostFix;
}

public void setCopyTextAfterDelimiter(boolean copyTextAfterDelimiter) {
this.copyTextAfterDelimiter = copyTextAfterDelimiter;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
28 changes: 28 additions & 0 deletions desktop/src/main/java/bisq/desktop/util/FormBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,15 @@ public static Tuple2<Label, TextFieldWithCopyIcon> addCompactTopLabelTextFieldWi
return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, colIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE);
}

public static Tuple2<Label, TextFieldWithCopyIcon> addCompactTopLabelTextFieldWithCopyIcon(GridPane gridPane,
int rowIndex,
int colIndex,
String title,
String value,
boolean onlyCopyTextAfterDelimiter) {
return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, colIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE, onlyCopyTextAfterDelimiter);
}

public static Tuple2<Label, TextFieldWithCopyIcon> addTopLabelTextFieldWithCopyIcon(GridPane gridPane,
int rowIndex,
String title,
Expand Down Expand Up @@ -1548,6 +1557,25 @@ public static Tuple2<Label, TextFieldWithCopyIcon> addTopLabelTextFieldWithCopyI
return new Tuple2<>(topLabelWithVBox.first, textFieldWithCopyIcon);
}

public static Tuple2<Label, TextFieldWithCopyIcon> addTopLabelTextFieldWithCopyIcon(GridPane gridPane,
int rowIndex,
int colIndex,
String title,
String value,
double top,
boolean onlyCopyTextAfterDelimiter) {

TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon();
textFieldWithCopyIcon.setText(value);
textFieldWithCopyIcon.setCopyTextAfterDelimiter(true);

final Tuple2<Label, VBox> 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<Label, TextFieldWithCopyIcon> addTopLabelTextFieldWithCopyIcon(GridPane gridPane,
int rowIndex,
int colIndex,
Expand Down