Merge pull request #5747 from jmacxx/display_fields_allow_mark_copy

Allow standard mark & copy functionality for displayed text fields
This commit is contained in:
Christoph Atteneder 2021-10-12 10:47:17 +02:00 committed by GitHub
commit e5d73e90a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 79 additions and 72 deletions

View file

@ -29,13 +29,9 @@ import javafx.scene.text.TextAlignment;
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
@ -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);

View file

@ -61,7 +61,6 @@ import javafx.stage.Window;
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;
@ -152,18 +151,18 @@ public class ContractWindow extends Overlay<ContractWindow> {
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()));
@ -174,17 +173,17 @@ public class ContractWindow extends Overlay<ContractWindow> {
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(),
@ -194,24 +193,22 @@ public class ContractWindow extends Overlay<ContractWindow> {
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 = "";
@ -237,7 +234,7 @@ public class ContractWindow extends Overlay<ContractWindow> {
NodeAddress agentNodeAddress = disputeManager.getAgentNodeAddress(dispute);
if (agentNodeAddress != null) {
String value = agentKeyBaseUserName + " (" + agentNodeAddress.getFullAddress() + ")";
addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, title, value);
addConfirmationLabelTextField(gridPane, ++rowIndex, title, value);
}
}
@ -250,25 +247,18 @@ public class ContractWindow extends Overlay<ContractWindow> {
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);
}
}

View file

@ -286,16 +286,16 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
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") +
" " +
@ -304,7 +304,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
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) {
@ -320,7 +320,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
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;

View file

@ -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;
@ -155,26 +154,26 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
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;
@ -214,9 +213,9 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
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") +
" " +
@ -225,29 +224,29 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
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()));
}
@ -262,10 +261,9 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
"";
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();
@ -275,13 +273,12 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
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()));
}
@ -327,7 +324,7 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
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,

View file

@ -22,7 +22,6 @@ import bisq.desktop.components.AutoTooltipLabel;
import bisq.desktop.components.BisqTextArea;
import bisq.desktop.components.BusyAnimation;
import bisq.desktop.components.TableGroupHeadline;
import bisq.desktop.components.TextFieldWithIcon;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.util.DisplayUtils;
import bisq.desktop.util.GUIUtil;
@ -102,7 +101,7 @@ import lombok.Setter;
import javax.annotation.Nullable;
public class ChatView extends AnchorPane {
public static final Logger log = LoggerFactory.getLogger(TextFieldWithIcon.class);
public static final Logger log = LoggerFactory.getLogger(ChatView.class);
// UI
private TextArea inputTextArea;
@ -416,7 +415,7 @@ public class ChatView extends AnchorPane {
String metaData = DisplayUtils.formatDateTime(new Date(message.getDate()));
if (!message.isSystemMessage())
metaData = (isMyMsg ? "Sent " : "Received ") + metaData
+ (isMyMsg ? "" : " from " + counterpartyName);
+ (isMyMsg ? "" : " from " + counterpartyName);
headerLabel.setText(metaData);
messageLabel.setText(message.getMessage());
attachmentsBox.getChildren().clear();

View file

@ -393,6 +393,33 @@ public class FormBuilder {
return new Tuple2<>(label1, label2);
}
public static Tuple2<Label, TextField> addConfirmationLabelTextField(GridPane gridPane,
int rowIndex,
String title1,
String title2) {
return addConfirmationLabelTextField(gridPane, rowIndex, title1, title2, 0);
}
public static Tuple2<Label, TextField> addConfirmationLabelTextField(GridPane gridPane,
int rowIndex,
String title1,
String title2,
double top) {
Label label1 = addLabel(gridPane, rowIndex, title1);
label1.getStyleClass().add("confirmation-label");
TextField label2 = new BisqTextField(title2);
gridPane.getChildren().add(label2);
label2.getStyleClass().add("confirmation-text-field-as-label");
label2.setEditable(false);
label2.setFocusTraversable(false);
GridPane.setRowIndex(label2, rowIndex);
GridPane.setColumnIndex(label2, 1);
GridPane.setMargin(label1, new Insets(top, 0, 0, 0));
GridPane.setHalignment(label1, HPos.LEFT);
GridPane.setMargin(label2, new Insets(top, 0, 0, 0));
return new Tuple2<>(label1, label2);
}
public static Tuple2<Label, TextFieldWithCopyIcon> addConfirmationLabelLabelWithCopyIcon(GridPane gridPane,
int rowIndex,
String title1,
@ -446,7 +473,6 @@ public class FormBuilder {
double top) {
TextFieldWithIcon textFieldWithIcon = new TextFieldWithIcon();
textFieldWithIcon.setMouseTransparent(true);
textFieldWithIcon.setFocusTraversable(false);
return new Tuple2<>(addTopLabelWithVBox(gridPane, rowIndex, columnIndex, title, textFieldWithIcon, top).first, textFieldWithIcon);