From d3d939889e87b3de8bf1e8b26f962de21267cf65 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 14 Sep 2022 11:06:15 +0200 Subject: [PATCH] increase maximum gap limit, but display warning when gap limit is over 999 --- .../sparrow/wallet/AdvancedController.java | 24 +++++++++++++++++-- .../sparrowwallet/sparrow/wallet/advanced.css | 4 ++++ .../sparrow/wallet/advanced.fxml | 11 ++++++++- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/com/sparrowwallet/sparrow/wallet/advanced.css diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/AdvancedController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/AdvancedController.java index 5cc2aaa2..a57d9e3e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/AdvancedController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/AdvancedController.java @@ -11,6 +11,7 @@ import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.ComboBox; import javafx.scene.control.DatePicker; +import javafx.scene.control.Label; import javafx.util.StringConverter; import java.net.URL; @@ -23,12 +24,18 @@ import java.util.stream.Collectors; public class AdvancedController implements Initializable { private static final List DEFAULT_WATCH_LIST_ITEMS = List.of(-1, 100, 500, 1000, 5000, 10000); + private static final int MAX_GAP_LIMIT = 1000000; + private static final int WARNING_GAP_LIMIT = 1000; + @FXML private DatePicker birthDate; @FXML private IntegerSpinner gapLimit; + @FXML + private Label gapWarning; + @FXML private ComboBox watchLast; @@ -49,12 +56,14 @@ public class AdvancedController implements Initializable { } }); - gapLimit.setValueFactory(new IntegerSpinner.ValueFactory(Wallet.DEFAULT_LOOKAHEAD, 9999, wallet.getGapLimit())); + gapLimit.setValueFactory(new IntegerSpinner.ValueFactory(Wallet.DEFAULT_LOOKAHEAD, MAX_GAP_LIMIT, wallet.getGapLimit())); gapLimit.valueProperty().addListener((observable, oldValue, newValue) -> { - if(newValue == null || newValue < Wallet.DEFAULT_LOOKAHEAD || newValue > 9999) { + if(newValue == null || newValue < Wallet.DEFAULT_LOOKAHEAD || newValue > MAX_GAP_LIMIT) { return; } + gapWarning.setVisible(newValue >= WARNING_GAP_LIMIT); + wallet.setGapLimit(newValue); if(!watchLast.getItems().equals(getWatchListItems(wallet))) { Integer value = watchLast.getValue(); @@ -63,6 +72,17 @@ public class AdvancedController implements Initializable { } EventManager.get().post(new SettingsChangedEvent(wallet, SettingsChangedEvent.Type.GAP_LIMIT)); }); + gapLimit.getEditor().textProperty().addListener((observable, oldValue, newValue) -> { + try { + int gapLimit = Integer.parseInt(newValue); + gapWarning.setVisible(gapLimit >= WARNING_GAP_LIMIT); + } catch(Exception e) { + //ignore + } + }); + + gapWarning.managedProperty().bind(gapWarning.visibleProperty()); + gapWarning.setVisible(wallet.getGapLimit() >= WARNING_GAP_LIMIT); watchLast.setItems(getWatchListItems(wallet)); watchLast.setConverter(new StringConverter<>() { diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/advanced.css b/src/main/resources/com/sparrowwallet/sparrow/wallet/advanced.css new file mode 100644 index 00000000..7b3750c6 --- /dev/null +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/advanced.css @@ -0,0 +1,4 @@ +.gap-warning { + -fx-text-fill: rgb(238, 210, 2); + -fx-padding: 0 0 0 12; +} \ No newline at end of file diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/advanced.fxml b/src/main/resources/com/sparrowwallet/sparrow/wallet/advanced.fxml index 31cbc09e..b14da80c 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/advanced.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/advanced.fxml @@ -11,8 +11,9 @@ + - +
@@ -34,6 +35,14 @@ +