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

Allow standard mark & copy functionality for displayed text fields #5747

Merged
merged 2 commits into from Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -29,13 +29,9 @@

import javafx.geometry.Pos;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import lombok.Getter;

public class TextFieldWithIcon extends AnchorPane {
public static final Logger log = LoggerFactory.getLogger(TextFieldWithIcon.class);
@Getter
private final Label iconLabel;
@Getter
Expand All @@ -45,7 +41,6 @@ public class TextFieldWithIcon extends AnchorPane {
public TextFieldWithIcon() {
textField = new JFXTextField();
textField.setEditable(false);
textField.setMouseTransparent(true);
textField.setFocusTraversable(false);
setLeftAnchor(textField, 0d);
setRightAnchor(textField, 0d);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@

import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.Tooltip;
import javafx.scene.input.KeyCode;
Expand Down Expand Up @@ -152,18 +151,18 @@ private void addContent() {

PaymentAccountPayload sellerPaymentAccountPayload = contract.getSellerPaymentAccountPayload();
addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("contractWindow.title"));
addConfirmationLabelTextFieldWithCopyIcon(gridPane, rowIndex, Res.get("shared.offerId"), offer.getId(),
Layout.TWICE_FIRST_ROW_DISTANCE).second.setMouseTransparent(false);
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("contractWindow.dates"),
addConfirmationLabelTextField(gridPane, rowIndex, Res.get("shared.offerId"), offer.getId(),
Layout.TWICE_FIRST_ROW_DISTANCE);
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("contractWindow.dates"),
DisplayUtils.formatDateTime(offer.getDate()) + " / " + DisplayUtils.formatDateTime(dispute.getTradeDate()));
String currencyCode = offer.getCurrencyCode();
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.offerType"),
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.offerType"),
DisplayUtils.getDirectionBothSides(offer.getDirection(), currencyCode));
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradePrice"),
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.tradePrice"),
FormattingUtils.formatPrice(contract.getTradePrice()));
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeAmount"),
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.tradeAmount"),
formatter.formatCoinWithCode(contract.getTradeAmount()));
addConfirmationLabelLabel(gridPane,
addConfirmationLabelTextField(gridPane,
++rowIndex,
VolumeUtil.formatVolumeLabel(currencyCode, ":"),
VolumeUtil.formatVolumeWithCode(contract.getTradeVolume()));
Expand All @@ -174,17 +173,17 @@ private void addContent() {
Res.getWithColAndCap("shared.seller") +
" " +
formatter.formatCoinWithCode(offer.getSellerSecurityDeposit());
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.securityDeposit"), securityDeposit);
addConfirmationLabelTextFieldWithCopyIcon(gridPane,
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.securityDeposit"), securityDeposit);
addConfirmationLabelTextField(gridPane,
++rowIndex,
Res.get("contractWindow.btcAddresses"),
contract.getBuyerPayoutAddressString() + " / " + contract.getSellerPayoutAddressString()).second.setMouseTransparent(false);
addConfirmationLabelTextFieldWithCopyIcon(gridPane,
contract.getBuyerPayoutAddressString() + " / " + contract.getSellerPayoutAddressString());
addConfirmationLabelTextField(gridPane,
++rowIndex,
Res.get("contractWindow.onions"),
contract.getBuyerNodeAddress().getFullAddress() + " / " + contract.getSellerNodeAddress().getFullAddress());

addConfirmationLabelTextFieldWithCopyIcon(gridPane,
addConfirmationLabelTextField(gridPane,
++rowIndex,
Res.get("contractWindow.accountAge"),
getAccountAge(contract.getBuyerPaymentAccountPayload(),
Expand All @@ -194,24 +193,22 @@ private void addContent() {
DisputeManager<? extends DisputeList<Dispute>> disputeManager = getDisputeManager(dispute);
String nrOfDisputesAsBuyer = disputeManager != null ? disputeManager.getNrOfDisputes(true, contract) : "";
String nrOfDisputesAsSeller = disputeManager != null ? disputeManager.getNrOfDisputes(false, contract) : "";
addConfirmationLabelTextFieldWithCopyIcon(gridPane,
addConfirmationLabelTextField(gridPane,
++rowIndex,
Res.get("contractWindow.numDisputes"),
nrOfDisputesAsBuyer + " / " + nrOfDisputesAsSeller);
addConfirmationLabelTextFieldWithCopyIcon(gridPane,
addConfirmationLabelTextField(gridPane,
++rowIndex,
Res.get("shared.paymentDetails", Res.get("shared.buyer")),
contract.getBuyerPaymentAccountPayload() != null
? contract.getBuyerPaymentAccountPayload().getPaymentDetails()
: "NA")
.second.setMouseTransparent(false);
addConfirmationLabelTextFieldWithCopyIcon(gridPane,
: "NA");
addConfirmationLabelTextField(gridPane,
++rowIndex,
Res.get("shared.paymentDetails", Res.get("shared.seller")),
sellerPaymentAccountPayload != null
? sellerPaymentAccountPayload.getPaymentDetails()
: "NA")
.second.setMouseTransparent(false);
: "NA");

String title = "";
String agentKeyBaseUserName = "";
Expand All @@ -237,7 +234,7 @@ private void addContent() {
NodeAddress agentNodeAddress = disputeManager.getAgentNodeAddress(dispute);
if (agentNodeAddress != null) {
String value = agentKeyBaseUserName + " (" + agentNodeAddress.getFullAddress() + ")";
addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, title, value);
addConfirmationLabelTextField(gridPane, ++rowIndex, title, value);
}
}

Expand All @@ -250,25 +247,18 @@ private void addContent() {
countries = CountryUtil.getCodesString(acceptedCountryCodes);
tooltip = new Tooltip(CountryUtil.getNamesByCodesString(acceptedCountryCodes));
}
Label acceptedCountries = addConfirmationLabelLabel(gridPane,
++rowIndex,
Res.get("shared.acceptedTakerCountries"),
countries).second;
if (tooltip != null) acceptedCountries.setTooltip(new Tooltip());
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.acceptedTakerCountries"), countries)
.second.setTooltip(tooltip);
}

if (showAcceptedBanks) {
if (offer.getPaymentMethod().equals(PaymentMethod.SAME_BANK)) {
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.bankName"), acceptedBanks.get(0));
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.bankName"), acceptedBanks.get(0));
} else if (offer.getPaymentMethod().equals(PaymentMethod.SPECIFIC_BANKS)) {
String value = Joiner.on(", ").join(acceptedBanks);
Tooltip tooltip = new Tooltip(Res.get("shared.acceptedBanks") + value);
Label acceptedBanksTextField = addConfirmationLabelLabel(gridPane,
++rowIndex,
Res.get("shared.acceptedBanks"),
value).second;
acceptedBanksTextField.setMouseTransparent(false);
acceptedBanksTextField.setTooltip(tooltip);
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.acceptedBanks"), value)
.second.setTooltip(tooltip);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,16 @@ private void addContent() {
private void addInfoPane() {
Contract contract = dispute.getContract();
addTitledGroupBg(gridPane, ++rowIndex, 17, Res.get("disputeSummaryWindow.title")).getStyleClass().add("last");
addConfirmationLabelLabel(gridPane, rowIndex, Res.get("shared.tradeId"), dispute.getShortTradeId(),
addConfirmationLabelTextField(gridPane, rowIndex, Res.get("shared.tradeId"), dispute.getShortTradeId(),
Layout.TWICE_FIRST_ROW_DISTANCE);
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.openDate"), DisplayUtils.formatDateTime(dispute.getOpeningDate()));
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.openDate"), DisplayUtils.formatDateTime(dispute.getOpeningDate()));
role = dispute.getRoleString();
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.role"), role);
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeAmount"),
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.role"), role);
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.tradeAmount"),
formatter.formatCoinWithCode(contract.getTradeAmount()));
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradePrice"),
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.tradePrice"),
FormattingUtils.formatPrice(contract.getTradePrice()));
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeVolume"),
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.tradeVolume"),
VolumeUtil.formatVolumeWithCode(contract.getTradeVolume()));
String securityDeposit = Res.getWithColAndCap("shared.buyer") +
" " +
Expand All @@ -304,7 +304,7 @@ private void addInfoPane() {
Res.getWithColAndCap("shared.seller") +
" " +
formatter.formatCoinWithCode(contract.getOfferPayload().getSellerSecurityDeposit());
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.securityDeposit"), securityDeposit);
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.securityDeposit"), securityDeposit);

boolean isMediationDispute = getDisputeManager(dispute) instanceof MediationManager;
if (isMediationDispute) {
Expand All @@ -320,7 +320,7 @@ private void addInfoPane() {
for (Map.Entry<String, String> entry : dispute.getExtraDataMap().entrySet()) {
extraDataSummary += "[" + entry.getKey() + ":" + entry.getValue() + "] ";
}
addConfirmationLabelLabelWithCopyIcon(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.extraInfo"), extraDataSummary);
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.extraInfo"), extraDataSummary);
}
} else {
delayedPayoutTxStatus = addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.delayedPayoutStatus"), "Checking...").second;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package bisq.desktop.main.overlays.windows;

import bisq.desktop.components.BisqTextArea;
import bisq.desktop.components.TextFieldWithCopyIcon;
import bisq.desktop.components.TxIdTextField;
import bisq.desktop.main.MainView;
import bisq.desktop.main.overlays.Overlay;
Expand Down Expand Up @@ -155,26 +154,26 @@ private void addContent() {
String toSpend = " " + Res.get("shared.toSpend");
String offerType = Res.get("shared.offerType");
if (tradeManager.isBuyer(offer)) {
addConfirmationLabelLabel(gridPane, rowIndex, offerType,
addConfirmationLabelTextField(gridPane, rowIndex, offerType,
DisplayUtils.getDirectionForBuyer(myOffer, offer.getCurrencyCode()), Layout.TWICE_FIRST_ROW_DISTANCE);
fiatDirectionInfo = toSpend;
btcDirectionInfo = toReceive;
} else {
addConfirmationLabelLabel(gridPane, rowIndex, offerType,
addConfirmationLabelTextField(gridPane, rowIndex, offerType,
DisplayUtils.getDirectionForSeller(myOffer, offer.getCurrencyCode()), Layout.TWICE_FIRST_ROW_DISTANCE);
fiatDirectionInfo = toReceive;
btcDirectionInfo = toSpend;
}

addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.btcAmount") + btcDirectionInfo,
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.btcAmount") + btcDirectionInfo,
formatter.formatCoinWithCode(trade.getTradeAmount()));
addConfirmationLabelLabel(gridPane, ++rowIndex,
addConfirmationLabelTextField(gridPane, ++rowIndex,
VolumeUtil.formatVolumeLabel(offer.getCurrencyCode()) + fiatDirectionInfo,
VolumeUtil.formatVolumeWithCode(trade.getTradeVolume()));
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradePrice"),
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.tradePrice"),
FormattingUtils.formatPrice(trade.getTradePrice()));
String paymentMethodText = Res.get(offer.getPaymentMethod().getId());
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.paymentMethod"), paymentMethodText);
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.paymentMethod"), paymentMethodText);

// second group
rows = 7;
Expand Down Expand Up @@ -214,9 +213,9 @@ private void addContent() {
rows++;

addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("shared.details"), Layout.GROUP_DISTANCE);
addConfirmationLabelTextFieldWithCopyIcon(gridPane, rowIndex, Res.get("shared.tradeId"),
addConfirmationLabelTextField(gridPane, rowIndex, Res.get("shared.tradeId"),
trade.getId(), Layout.TWICE_FIRST_ROW_AND_GROUP_DISTANCE);
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradeDate"),
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradeDate"),
DisplayUtils.formatDateTime(trade.getDate()));
String securityDeposit = Res.getWithColAndCap("shared.buyer") +
" " +
Expand All @@ -225,29 +224,29 @@ private void addContent() {
Res.getWithColAndCap("shared.seller") +
" " +
formatter.formatCoinWithCode(offer.getSellerSecurityDeposit());
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.securityDeposit"), securityDeposit);
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.securityDeposit"), securityDeposit);

String txFee = Res.get("shared.makerTxFee", formatter.formatCoinWithCode(offer.getTxFee())) +
" / " +
Res.get("shared.takerTxFee", formatter.formatCoinWithCode(trade.getTxFee().multiply(3)));
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.txFee"), txFee);
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.txFee"), txFee);

NodeAddress arbitratorNodeAddress = trade.getArbitratorNodeAddress();
NodeAddress mediatorNodeAddress = trade.getMediatorNodeAddress();
if (arbitratorNodeAddress != null && mediatorNodeAddress != null) {
addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex,
addConfirmationLabelTextField(gridPane, ++rowIndex,
Res.get("tradeDetailsWindow.agentAddresses"),
arbitratorNodeAddress.getFullAddress() + " / " + mediatorNodeAddress.getFullAddress());
}

if (trade.getTradingPeerNodeAddress() != null)
addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradingPeersOnion"),
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradingPeersOnion"),
trade.getTradingPeerNodeAddress().getFullAddress());

if (showXmrProofResult) {
// As the window is already overloaded we replace the tradingPeersPubKeyHash field with the auto-conf state
// if XMR is the currency
addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex,
addConfirmationLabelTextField(gridPane, ++rowIndex,
Res.get("portfolio.pending.step3_seller.autoConf.status.label"),
GUIUtil.getProofResultAsString(trade.getAssetTxProofResult()));
}
Expand All @@ -262,10 +261,9 @@ private void addContent() {
"";

String postFix = buyersAccountAge.isEmpty() ? "" : " / " + buyersAccountAge;
TextFieldWithCopyIcon tf = addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex,
addConfirmationLabelTextField(gridPane, ++rowIndex,
Res.get("shared.paymentDetails", Res.get("shared.buyer")),
paymentDetails + postFix).second;
tf.setTooltip(new Tooltip(tf.getText()));
paymentDetails + postFix).second.setTooltip(new Tooltip(paymentDetails + postFix));
}
if (sellerPaymentAccountPayload != null) {
String paymentDetails = sellerPaymentAccountPayload.getPaymentDetails();
Expand All @@ -275,13 +273,12 @@ private void addContent() {
Res.get("peerInfoIcon.tooltip.unknownAge") :
"";
String postFix = sellersAccountAge.isEmpty() ? "" : " / " + sellersAccountAge;
TextFieldWithCopyIcon tf = addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex,
addConfirmationLabelTextField(gridPane, ++rowIndex,
Res.get("shared.paymentDetails", Res.get("shared.seller")),
paymentDetails + postFix).second;
tf.setTooltip(new Tooltip(tf.getText()));
paymentDetails + postFix).second.setTooltip(new Tooltip(paymentDetails + postFix));
}
if (buyerPaymentAccountPayload == null && sellerPaymentAccountPayload == null)
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.paymentMethod"),
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.paymentMethod"),
Res.get(contract.getPaymentMethodId()));
}

Expand Down Expand Up @@ -327,7 +324,7 @@ private void addContent() {
textArea.scrollTopProperty().addListener(changeListener);
textArea.setScrollTop(30);

addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradeState"), trade.getState().getPhase().name());
addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradeState"), trade.getState().getPhase().name());
}

Tuple3<Button, Button, HBox> tuple = add2ButtonsWithBox(gridPane, ++rowIndex,
Expand Down
Loading