mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-18 23:06:02 -04:00
Use Utilities.copyToClipboard, add copy offer/trade ID
This commit is contained in:
parent
dd80d3edf3
commit
edfef9865c
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.gui.components;
|
||||
|
||||
import io.bitsquare.gui.OverlayManager;
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.uri.BitcoinURI;
|
||||
@ -38,7 +39,6 @@ import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.Window;
|
||||
|
||||
@ -91,12 +91,8 @@ public class AddressTextField extends AnchorPane {
|
||||
Tooltip.install(copyIcon, new Tooltip("Copy address to clipboard"));
|
||||
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
|
||||
copyIcon.setOnMouseClicked(e -> {
|
||||
if (address.get() != null && address.get().length() > 0) {
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(address.get());
|
||||
clipboard.setContent(content);
|
||||
}
|
||||
if (address.get() != null && address.get().length() > 0)
|
||||
Utilities.copyToClipboard(address.get());
|
||||
});
|
||||
|
||||
Label qrCode = new Label();
|
||||
|
@ -17,10 +17,11 @@
|
||||
|
||||
package io.bitsquare.gui.components;
|
||||
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.*;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
@ -47,12 +48,8 @@ public class TextFieldWithCopyIcon extends AnchorPane {
|
||||
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
|
||||
AnchorPane.setRightAnchor(copyIcon, 0.0);
|
||||
copyIcon.setOnMouseClicked(e -> {
|
||||
if (getText() != null && getText().length() > 0) {
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(getText());
|
||||
clipboard.setContent(content);
|
||||
}
|
||||
if (getText() != null && getText().length() > 0)
|
||||
Utilities.copyToClipboard(getText());
|
||||
});
|
||||
TextField txIdLabel = new TextField();
|
||||
txIdLabel.setEditable(false);
|
||||
|
@ -25,7 +25,6 @@ import io.bitsquare.util.Utilities;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.scene.layout.*;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
@ -91,14 +90,7 @@ public class TxIdTextField extends AnchorPane {
|
||||
}
|
||||
});
|
||||
|
||||
copyIcon.setOnMouseClicked(e -> {
|
||||
if (txID != null && txID.length() > 0) {
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(txID);
|
||||
clipboard.setContent(content);
|
||||
}
|
||||
});
|
||||
copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(txID));
|
||||
|
||||
walletService.addTxConfidenceListener(new TxConfidenceListener(txID) {
|
||||
@Override
|
||||
|
@ -29,6 +29,7 @@ import io.bitsquare.msg.MessageService;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
@ -50,7 +51,6 @@ import javax.inject.Inject;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
@ -350,10 +350,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
|
||||
|
||||
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
|
||||
copyIcon.setOnMouseClicked(e -> {
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(securityDepositAddress);
|
||||
clipboard.setContent(content);
|
||||
Utilities.copyToClipboard(securityDepositAddress);
|
||||
});
|
||||
|
||||
paymentDoneButton.setDisable(walletService.getArbitratorDepositBalance().isZero());
|
||||
|
@ -109,10 +109,7 @@ public class RegistrationViewCB extends CachedViewCB<RegistrationPM> implements
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent) {
|
||||
getProperties().put("type", "COPY");
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(presentationModel.getTransactionId());
|
||||
clipboard.setContent(content);
|
||||
Utilities.copyToClipboard(presentationModel.getTransactionId());
|
||||
}
|
||||
});*/
|
||||
actions.add(new AbstractAction(BSResources.get("shared.close")) {
|
||||
|
@ -113,6 +113,7 @@ public class TransactionsViewCB extends CachedViewCB {
|
||||
private void openTxDetails(TransactionsListItem item) {
|
||||
// TODO Open popup with details view
|
||||
log.debug("openTxDetails " + item);
|
||||
|
||||
Popups.openWarningPopup("Under construction",
|
||||
"This will open a details popup but that is not implemented yet.");
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import io.bitsquare.btc.listeners.BalanceListener;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
import org.bitcoinj.core.AddressFormatException;
|
||||
import org.bitcoinj.core.Coin;
|
||||
@ -46,7 +47,6 @@ import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.*;
|
||||
import javafx.util.Callback;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
@ -308,12 +308,8 @@ public class WithdrawalViewCB extends CachedViewCB {
|
||||
|
||||
if (item != null && !empty) {
|
||||
setGraphic(copyIcon);
|
||||
copyIcon.setOnMouseClicked(e -> {
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(item.addressStringProperty().get());
|
||||
clipboard.setContent(content);
|
||||
});
|
||||
copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(item
|
||||
.addressStringProperty().get()));
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -19,6 +19,7 @@ package io.bitsquare.gui.main.portfolio.offer;
|
||||
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
@ -104,8 +105,11 @@ public class OffersViewCB extends CachedViewCB<OffersPM> {
|
||||
private void openOfferDetails(OfferListItem item) {
|
||||
// TODO Open popup with details view
|
||||
log.debug("openOfferDetails " + item);
|
||||
Utilities.copyToClipboard(item.getOffer().getId());
|
||||
Popups.openWarningPopup("Under construction",
|
||||
"This will open a details popup but that is not implemented yet.");
|
||||
"The offer ID was copied to the clipboard. " +
|
||||
"Use that to identify your trading peer in the IRC chat room \n\n" +
|
||||
"Later this will open a details popup but that is not implemented yet.");
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,6 +30,7 @@ import io.bitsquare.gui.components.processbar.ProcessStepItem;
|
||||
import io.bitsquare.gui.main.help.Help;
|
||||
import io.bitsquare.gui.main.help.HelpId;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
import io.bitsquare.util.Utilities;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
@ -232,11 +233,14 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
|
||||
Help.openWindow(HelpId.PENDING_TRADE_SUMMARY);
|
||||
}
|
||||
|
||||
private void openOfferDetails(PendingTradesListItem item) {
|
||||
private void openOfferDetails(String id) {
|
||||
// TODO Open popup with details view
|
||||
log.debug("Trade details " + item);
|
||||
Popups.openWarningPopup("Under construction", "This will open a " +
|
||||
"details popup but that is not implemented yet.");
|
||||
log.debug("Trade details " + id);
|
||||
Utilities.copyToClipboard(id);
|
||||
Popups.openWarningPopup("Under construction",
|
||||
"The trader ID was copied to the clipboard. " +
|
||||
"Use that to identify your trading peer in the IRC chat room \n\n" +
|
||||
"Later this will open a details popup but that is not implemented yet.");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -552,20 +556,37 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void setTradeIdColumnCellFactory() {
|
||||
idColumn.setCellFactory(TextFieldTableCell.<PendingTradesListItem, String>forTableColumn(
|
||||
new StringConverter<String>() {
|
||||
@Override
|
||||
public String toString(String value) {
|
||||
return presentationModel.formatTradeId(value);
|
||||
}
|
||||
idColumn.setCellFactory(
|
||||
new Callback<TableColumn<PendingTradesListItem, String>, TableCell<PendingTradesListItem, String>>() {
|
||||
|
||||
@Override
|
||||
public String fromString(String string) {
|
||||
return null;
|
||||
public TableCell<PendingTradesListItem, String> call(TableColumn<PendingTradesListItem,
|
||||
String> column) {
|
||||
return new TableCell<PendingTradesListItem, String>() {
|
||||
private Hyperlink hyperlink;
|
||||
|
||||
@Override
|
||||
public void updateItem(final String id, boolean empty) {
|
||||
super.updateItem(id, empty);
|
||||
|
||||
if (id != null && !empty) {
|
||||
hyperlink = new Hyperlink(presentationModel.formatTradeId(id));
|
||||
hyperlink.setId("id-link");
|
||||
Tooltip.install(hyperlink, new Tooltip(presentationModel.formatTradeId(id)));
|
||||
hyperlink.setOnAction(event -> openOfferDetails(id));
|
||||
setGraphic(hyperlink);
|
||||
}
|
||||
else {
|
||||
setGraphic(null);
|
||||
setId(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void setDateColumnCellFactory() {
|
||||
dateColumn.setCellFactory(TextFieldTableCell.<PendingTradesListItem, Date>forTableColumn(
|
||||
new StringConverter<Date>() {
|
||||
|
@ -364,10 +364,7 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent) {
|
||||
getProperties().put("type", "COPY");
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(presentationModel.transactionId.get());
|
||||
clipboard.setContent(content);
|
||||
Utilities.copyToClipboard(presentationModel.transactionId.get());
|
||||
}
|
||||
});*/
|
||||
actions.add(new AbstractAction(BSResources.get("shared.close")) {
|
||||
|
@ -335,10 +335,7 @@ public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
|
||||
@Override
|
||||
public void handle(ActionEvent actionEvent) {
|
||||
getProperties().put("type", "COPY");
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(presentationModel.transactionId.get());
|
||||
clipboard.setContent(content);
|
||||
Utilities.copyToClipboard(presentationModel.transactionId.get());
|
||||
}
|
||||
});*/
|
||||
actions.add(new AbstractAction(BSResources.get("shared.close")) {
|
||||
|
@ -35,6 +35,7 @@ import java.net.URI;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.scene.input.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -68,6 +69,16 @@ public class Utilities {
|
||||
return System.getProperty("os.name").toLowerCase();
|
||||
}
|
||||
|
||||
public static void copyToClipboard(String content) {
|
||||
if (content != null && content.length() > 0) {
|
||||
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||
ClipboardContent clipboardContent = new ClipboardContent();
|
||||
clipboardContent.putString(content);
|
||||
clipboard.setContent(clipboardContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static <T> T jsonToObject(String jsonString, Class<T> classOfT) {
|
||||
Gson gson =
|
||||
new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).setPrettyPrinting().create();
|
||||
|
@ -84,7 +84,7 @@ public class TomP2PTests {
|
||||
private static final Logger log = LoggerFactory.getLogger(TomP2PTests.class);
|
||||
|
||||
// If you want to test in one specific connection mode define it directly, otherwise use UNKNOWN
|
||||
private static final ConnectionType FORCED_CONNECTION_TYPE = ConnectionType.DIRECT;
|
||||
private static final ConnectionType FORCED_CONNECTION_TYPE = ConnectionType.MANUAL_PORT_FORWARDING;
|
||||
|
||||
// Typically you run the bootstrap node in localhost to test direct connection.
|
||||
// If you have a setup where you are not behind a router you can also use a WAN bootstrap node.
|
||||
@ -586,7 +586,7 @@ public class TomP2PTests {
|
||||
.ports(clientPort)
|
||||
.start();
|
||||
}
|
||||
|
||||
|
||||
PeerNAT peerNAT = new PeerBuilderNAT(peer).start();
|
||||
FutureDiscover futureDiscover = peer.discover().peerAddress(BOOTSTRAP_NODE_ADDRESS).start();
|
||||
FutureNAT futureNAT = peerNAT.startSetupPortforwarding(futureDiscover);
|
||||
|
Loading…
x
Reference in New Issue
Block a user