update block explorer preferences for xmr, remove address url

This commit is contained in:
woodser 2023-10-04 09:53:06 -04:00
parent 9aea5e0c58
commit 75f5255050
10 changed files with 20 additions and 132 deletions

View file

@ -22,9 +22,7 @@ import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import haveno.common.util.Utilities;
import haveno.core.locale.Res;
import haveno.core.user.BlockChainExplorer;
import haveno.core.user.Preferences;
import haveno.desktop.util.GUIUtil;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
@ -40,7 +38,7 @@ public class ExplorerAddressTextField extends AnchorPane {
@Getter
private final TextField textField;
private final Label copyIcon, blockExplorerIcon, missingAddressWarningIcon;
private final Label copyIcon, missingAddressWarningIcon;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
@ -56,14 +54,6 @@ public class ExplorerAddressTextField extends AnchorPane {
Tooltip tooltip = new Tooltip(Res.get("explorerAddressTextField.blockExplorerIcon.tooltip"));
blockExplorerIcon = new Label();
blockExplorerIcon.getStyleClass().addAll("icon", "highlight");
blockExplorerIcon.setTooltip(tooltip);
AwesomeDude.setIcon(blockExplorerIcon, AwesomeIcon.EXTERNAL_LINK);
blockExplorerIcon.setMinWidth(20);
AnchorPane.setRightAnchor(blockExplorerIcon, 52.0);
AnchorPane.setTopAnchor(blockExplorerIcon, 4.0);
missingAddressWarningIcon = new Label();
missingAddressWarningIcon.getStyleClass().addAll("icon", "error-icon");
AwesomeDude.setIcon(missingAddressWarningIcon, AwesomeIcon.WARNING_SIGN);
@ -81,15 +71,13 @@ public class ExplorerAddressTextField extends AnchorPane {
AnchorPane.setRightAnchor(textField, 80.0);
AnchorPane.setLeftAnchor(textField, 0.0);
textField.focusTraversableProperty().set(focusTraversableProperty().get());
getChildren().addAll(textField, missingAddressWarningIcon, blockExplorerIcon, copyIcon);
getChildren().addAll(textField, missingAddressWarningIcon, copyIcon);
}
public void setup(@Nullable String address) {
if (address == null) {
textField.setText(Res.get("shared.na"));
textField.setId("address-text-field-error");
blockExplorerIcon.setVisible(false);
blockExplorerIcon.setManaged(false);
copyIcon.setVisible(false);
copyIcon.setManaged(false);
missingAddressWarningIcon.setVisible(true);
@ -98,26 +86,12 @@ public class ExplorerAddressTextField extends AnchorPane {
}
textField.setText(address);
textField.setOnMouseClicked(mouseEvent -> openBlockExplorer(address));
blockExplorerIcon.setOnMouseClicked(mouseEvent -> openBlockExplorer(address));
copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(address));
}
public void cleanup() {
textField.setOnMouseClicked(null);
blockExplorerIcon.setOnMouseClicked(null);
copyIcon.setOnMouseClicked(null);
textField.setText("");
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
private void openBlockExplorer(String address) {
if (preferences != null) {
BlockChainExplorer blockChainExplorer = preferences.getBlockChainExplorer();
GUIUtil.openWebPage(blockChainExplorer.addressUrl + address, false);
}
}
}

View file

@ -33,7 +33,6 @@ import haveno.desktop.common.view.ActivatableView;
import haveno.desktop.common.view.FxmlView;
import haveno.desktop.components.AddressTextField;
import haveno.desktop.components.AutoTooltipLabel;
import haveno.desktop.components.ExternalHyperlink;
import haveno.desktop.components.HyperlinkWithIcon;
import haveno.desktop.components.InputTextField;
import haveno.desktop.components.TitledGroupBg;
@ -308,11 +307,6 @@ public class DepositView extends ActivatableView<VBox, Void> {
}
}
private void openBlockExplorer(DepositListItem item) {
if (item.getAddressString() != null)
GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
@ -391,13 +385,7 @@ public class DepositView extends ActivatableView<VBox, Void> {
if (item != null && !empty) {
String address = item.getAddressString();
field = new ExternalHyperlink(address);
field.setOnAction(event -> {
openBlockExplorer(item);
tableView.getSelectionModel().select(item);
});
field.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address)));
setGraphic(field);
setGraphic(new AutoTooltipLabel(address));
} else {
setGraphic(null);
if (field != null)

View file

@ -35,7 +35,6 @@ import haveno.desktop.common.view.ActivatableView;
import haveno.desktop.common.view.FxmlView;
import haveno.desktop.components.AutoTooltipButton;
import haveno.desktop.components.AutoTooltipLabel;
import haveno.desktop.components.ExternalHyperlink;
import haveno.desktop.components.HyperlinkWithIcon;
import haveno.desktop.main.overlays.windows.OfferDetailsWindow;
import haveno.desktop.main.overlays.windows.TradeDetailsWindow;
@ -222,10 +221,6 @@ public class LockedView extends ActivatableView<VBox, Void> {
.collect(Collectors.toList()));
}
private void openBlockExplorer(LockedListItem item) {
GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false);
}
private Optional<Tradable> getTradable(LockedListItem item) {
String offerId = item.getAddressEntry().getOfferId();
Optional<Trade> tradeOptional = tradeManager.getOpenTrade(offerId);
@ -330,7 +325,6 @@ public class LockedView extends ActivatableView<VBox, Void> {
public TableCell<LockedListItem, LockedListItem> call(TableColumn<LockedListItem,
LockedListItem> column) {
return new TableCell<>() {
private HyperlinkWithIcon hyperlinkWithIcon;
@Override
public void updateItem(final LockedListItem item, boolean empty) {
@ -338,14 +332,9 @@ public class LockedView extends ActivatableView<VBox, Void> {
if (item != null && !empty) {
String address = item.getAddressString();
hyperlinkWithIcon = new ExternalHyperlink(address);
hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address)));
setGraphic(hyperlinkWithIcon);
setGraphic(new AutoTooltipLabel(address));
} else {
setGraphic(null);
if (hyperlinkWithIcon != null)
hyperlinkWithIcon.setOnAction(null);
}
}
};

View file

@ -35,7 +35,6 @@ import haveno.desktop.common.view.ActivatableView;
import haveno.desktop.common.view.FxmlView;
import haveno.desktop.components.AutoTooltipButton;
import haveno.desktop.components.AutoTooltipLabel;
import haveno.desktop.components.ExternalHyperlink;
import haveno.desktop.components.HyperlinkWithIcon;
import haveno.desktop.main.overlays.windows.OfferDetailsWindow;
import haveno.desktop.main.overlays.windows.TradeDetailsWindow;
@ -221,10 +220,6 @@ public class ReservedView extends ActivatableView<VBox, Void> {
.collect(Collectors.toList()));
}
private void openBlockExplorer(ReservedListItem item) {
GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false);
}
private Optional<Tradable> getTradable(ReservedListItem item) {
String offerId = item.getAddressEntry().getOfferId();
Optional<Trade> tradeOptional = tradeManager.getOpenTrade(offerId);
@ -329,7 +324,6 @@ public class ReservedView extends ActivatableView<VBox, Void> {
public TableCell<ReservedListItem, ReservedListItem> call(TableColumn<ReservedListItem,
ReservedListItem> column) {
return new TableCell<>() {
private HyperlinkWithIcon hyperlinkWithIcon;
@Override
public void updateItem(final ReservedListItem item, boolean empty) {
@ -337,14 +331,9 @@ public class ReservedView extends ActivatableView<VBox, Void> {
if (item != null && !empty) {
String address = item.getAddressString();
hyperlinkWithIcon = new ExternalHyperlink(address);
hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", address)));
setGraphic(hyperlinkWithIcon);
setGraphic(new AutoTooltipLabel(address));
} else {
setGraphic(null);
if (hyperlinkWithIcon != null)
hyperlinkWithIcon.setOnAction(null);
}
}
};

View file

@ -244,12 +244,6 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
GUIUtil.openWebPage(preferences.getBlockChainExplorer().txUrl + item.getTxId(), false);
}
private void openAddressInBlockExplorer(TransactionsListItem item) {
if (item.getAddressString() != null) {
GUIUtil.openWebPage(preferences.getBlockChainExplorer().addressUrl + item.getAddressString(), false);
}
}
private void openDetailPopup(TransactionsListItem item) {
if (item.getTradable() instanceof OpenOffer)
offerDetailsWindow.show(item.getTradable().getOffer());
@ -349,7 +343,6 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
String addressString = item.getAddressString();
field = new AddressWithIconAndDirection(item.getDirection(), addressString,
item.getReceived());
field.setOnAction(event -> openAddressInBlockExplorer(item));
field.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", addressString)));
setGraphic(field);
} else {

View file

@ -54,7 +54,7 @@ import static javafx.beans.binding.Bindings.createBooleanBinding;
public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow> {
private InputTextField nameInputTextField, txUrlInputTextField, addressUrlInputTextField;
private InputTextField nameInputTextField, txUrlInputTextField;
private UrlInputValidator urlInputValidator;
private BlockChainExplorer currentExplorer;
private ListView<BlockChainExplorer> listView;
@ -70,9 +70,10 @@ public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow>
public BlockChainExplorer getEditedBlockChainExplorer() {
return new BlockChainExplorer(nameInputTextField.getText(),
txUrlInputTextField.getText(), addressUrlInputTextField.getText());
txUrlInputTextField.getText());
}
@Override
public void show() {
width = 1000;
@ -83,20 +84,17 @@ public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow>
urlInputValidator = new UrlInputValidator();
txUrlInputTextField.setValidator(urlInputValidator);
addressUrlInputTextField.setValidator(urlInputValidator);
nameInputTextField.setValidator(new LengthValidator(1, 50));
actionButton.disableProperty().bind(createBooleanBinding(() -> {
String name = nameInputTextField.getText();
String txUrl = txUrlInputTextField.getText();
String addressUrl = addressUrlInputTextField.getText();
// Otherwise we require that input is valid
return !nameInputTextField.getValidator().validate(name).isValid ||
!txUrlInputTextField.getValidator().validate(txUrl).isValid ||
!addressUrlInputTextField.getValidator().validate(addressUrl).isValid;
!txUrlInputTextField.getValidator().validate(txUrl).isValid;
},
nameInputTextField.textProperty(), txUrlInputTextField.textProperty(), addressUrlInputTextField.textProperty()));
nameInputTextField.textProperty(), txUrlInputTextField.textProperty()));
applyStyles();
display();
@ -127,7 +125,6 @@ public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow>
if (blockChainExplorer != null) {
nameInputTextField.setText(blockChainExplorer.name);
txUrlInputTextField.setText(blockChainExplorer.txUrl);
addressUrlInputTextField.setText(blockChainExplorer.addressUrl);
}
});
button.setStyle("-fx-pref-width: 50px; -fx-pref-height: 30; -fx-padding: 3 3 3 3;");
@ -169,7 +166,6 @@ public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow>
BlockChainExplorer blockChainExplorer = listView.getSelectionModel().getSelectedItem();
nameInputTextField.setText(blockChainExplorer.name);
txUrlInputTextField.setText(blockChainExplorer.txUrl);
addressUrlInputTextField.setText(blockChainExplorer.addressUrl);
}
}
});
@ -186,9 +182,7 @@ public class EditCustomExplorerWindow extends Overlay<EditCustomExplorerWindow>
nameInputTextField = addInputTextField(autoConfirmGridPane, ++localRowIndex, Res.get("settings.preferences.editCustomExplorer.name"), Layout.FIRST_ROW_DISTANCE);
nameInputTextField.setPrefWidth(Layout.INITIAL_WINDOW_WIDTH);
txUrlInputTextField = addInputTextField(autoConfirmGridPane, ++localRowIndex, Res.get("settings.preferences.editCustomExplorer.txUrl"));
addressUrlInputTextField = addInputTextField(autoConfirmGridPane, ++localRowIndex, Res.get("settings.preferences.editCustomExplorer.addressUrl"));
nameInputTextField.setText(currentExplorer.name);
txUrlInputTextField.setText(currentExplorer.txUrl);
addressUrlInputTextField.setText(currentExplorer.addressUrl);
}
}

View file

@ -771,7 +771,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
resetDontShowAgainButton.setOnAction(e -> preferences.resetDontShowAgain());
editCustomBtcExplorer.setOnAction(e -> {
EditCustomExplorerWindow urlWindow = new EditCustomExplorerWindow("BTC",
EditCustomExplorerWindow urlWindow = new EditCustomExplorerWindow("XMR",
preferences.getBlockChainExplorer(), preferences.getBlockChainExplorers());
urlWindow
.actionButtonText(Res.get("shared.save"))