Fixed validation error popup location when the first page is invalid

This commit is contained in:
nathan 2015-08-08 22:14:17 +02:00
parent dadda62cab
commit 61b64658e1

View File

@ -334,15 +334,17 @@ public class Wizard {
void validatePopover(final String newValue) { void validatePopover(final String newValue) {
if (newValue != null) { if (newValue != null) {
currentPage.ifPresent(currentPage -> { currentPage.ifPresent(currentPage -> {
final PopOver popOver = this.popOver; Platform.runLater(() -> {
final PopOver popOver = this.popOver;
this.popOverErrorText.setText(newValue); this.popOverErrorText.setText(newValue);
if (!popOver.isShowing()) { if (!popOver.isShowing()) {
popOver.setX(0); popOver.setX(0);
popOver.setY(0); popOver.setY(0);
popOver.show(BUTTON_NEXT, -10); popOver.show(BUTTON_NEXT, -10);
} }
});
}); });
} else { } else {
popOver.hide(); popOver.hide();
@ -685,12 +687,6 @@ public class Wizard {
invalidProperty.bind(currentPage.invalidProperty); invalidProperty.bind(currentPage.invalidProperty);
invalidPropertyStrings.bind(currentPage.invalidPropertyStrings); invalidPropertyStrings.bind(currentPage.invalidPropertyStrings);
if (currentPage.invalidProperty.get()) {
validatePopover(currentPage.invalidPropertyStrings.get());
} else {
popOver.hide();
}
final Node firstFocusElement = currentPage.firstFocusElement; final Node firstFocusElement = currentPage.firstFocusElement;
if (firstFocusElement != null) { if (firstFocusElement != null) {
Platform.runLater(() -> { Platform.runLater(() -> {
@ -736,7 +732,13 @@ public class Wizard {
stage.sizeToScene(); stage.sizeToScene();
} }
currentPage.validationSupport.redecorate(); Platform.runLater(() -> {
if (isInvalid()) {
validatePopover(currentPage.invalidPropertyStrings.get());
} else {
popOver.hide();
}
});
}); });
validateActionState(); validateActionState();