mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Improve resetValidation method to reset validation result
If text field is empty we apply ValidationResult(true), otherwise we apply the validate result with the text and the given validator.
This commit is contained in:
parent
9ae76b621f
commit
bc6a53d356
3 changed files with 21 additions and 5 deletions
|
@ -76,7 +76,7 @@ public class InputTextField extends JFXTextField {
|
|||
|
||||
validationResult.addListener((ov, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
resetValidation();
|
||||
jfxValidationWrapper.resetValidation();
|
||||
if (!newValue.isValid) {
|
||||
if (!newValue.errorMessageEquals(oldValue)) { // avoid blinking
|
||||
validate(); // ensure that the new error message replaces the old one
|
||||
|
@ -118,6 +118,13 @@ public class InputTextField extends JFXTextField {
|
|||
|
||||
public void resetValidation() {
|
||||
jfxValidationWrapper.resetValidation();
|
||||
|
||||
String input = getText();
|
||||
if (input.isEmpty()) {
|
||||
validationResult.set(new InputValidator.ValidationResult(true));
|
||||
} else {
|
||||
validationResult.set(validator.validate(input));
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshValidation() {
|
||||
|
|
|
@ -176,6 +176,11 @@ public class BsqSendView extends ActivatableView<GridPane, Void> implements BsqB
|
|||
setSendBtcGroupVisibleState(false);
|
||||
bsqBalanceUtil.activate();
|
||||
|
||||
receiversAddressInputTextField.resetValidation();
|
||||
amountInputTextField.resetValidation();
|
||||
receiversBtcAddressInputTextField.resetValidation();
|
||||
btcAmountInputTextField.resetValidation();
|
||||
|
||||
sendBsqButton.setOnAction((event) -> onSendBsq());
|
||||
bsqInputControlButton.setOnAction((event) -> onBsqInputControl());
|
||||
sendBtcButton.setOnAction((event) -> onSendBtc());
|
||||
|
@ -309,12 +314,11 @@ public class BsqSendView extends ActivatableView<GridPane, Void> implements BsqB
|
|||
bsqFormatter,
|
||||
btcFormatter,
|
||||
() -> {
|
||||
receiversAddressInputTextField.setValidator(null);
|
||||
receiversAddressInputTextField.setText("");
|
||||
receiversAddressInputTextField.setValidator(bsqAddressValidator);
|
||||
amountInputTextField.setValidator(null);
|
||||
amountInputTextField.setText("");
|
||||
amountInputTextField.setValidator(bsqValidator);
|
||||
|
||||
receiversAddressInputTextField.resetValidation();
|
||||
amountInputTextField.resetValidation();
|
||||
});
|
||||
} catch (BsqChangeBelowDustException e) {
|
||||
String msg = Res.get("popup.warning.bsqChangeBelowDustException", bsqFormatter.formatCoinWithCode(e.getOutputValue()));
|
||||
|
@ -444,6 +448,10 @@ public class BsqSendView extends ActivatableView<GridPane, Void> implements BsqB
|
|||
() -> {
|
||||
receiversBtcAddressInputTextField.setText("");
|
||||
btcAmountInputTextField.setText("");
|
||||
|
||||
receiversBtcAddressInputTextField.resetValidation();
|
||||
btcAmountInputTextField.resetValidation();
|
||||
|
||||
});
|
||||
}
|
||||
} catch (BsqChangeBelowDustException e) {
|
||||
|
|
|
@ -16,6 +16,7 @@ public class JFXInputValidator extends ValidatorBase {
|
|||
}
|
||||
|
||||
public void resetValidation() {
|
||||
message.set(null);
|
||||
hasErrors.set(false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue