Disable accept button in AddAccountPage
This commit is contained in:
@@ -67,6 +67,7 @@ public class AddAccountPane extends StackPane {
|
|||||||
@FXML private Label lblAddInjectorServer;
|
@FXML private Label lblAddInjectorServer;
|
||||||
@FXML private Hyperlink linkAddInjectorServer;
|
@FXML private Hyperlink linkAddInjectorServer;
|
||||||
@FXML private JFXDialogLayout layout;
|
@FXML private JFXDialogLayout layout;
|
||||||
|
@FXML private JFXButton btnAccept;
|
||||||
private final Consumer<Region> finalization;
|
private final Consumer<Region> finalization;
|
||||||
|
|
||||||
public AddAccountPane(Consumer<Region> finalization) {
|
public AddAccountPane(Consumer<Region> finalization) {
|
||||||
@@ -83,6 +84,7 @@ public class AddAccountPane extends StackPane {
|
|||||||
cboServers.setVisible(newValue.intValue() == 2);
|
cboServers.setVisible(newValue.intValue() == 2);
|
||||||
linkAddInjectorServer.setVisible(newValue.intValue() == 2);
|
linkAddInjectorServer.setVisible(newValue.intValue() == 2);
|
||||||
lblAddInjectorServer.setVisible(newValue.intValue() == 2);
|
lblAddInjectorServer.setVisible(newValue.intValue() == 2);
|
||||||
|
validateAcceptButton();
|
||||||
});
|
});
|
||||||
cboType.getSelectionModel().select(0);
|
cboType.getSelectionModel().select(0);
|
||||||
|
|
||||||
@@ -94,6 +96,12 @@ public class AddAccountPane extends StackPane {
|
|||||||
txtUsername.setOnAction(e -> onCreationAccept());
|
txtUsername.setOnAction(e -> onCreationAccept());
|
||||||
txtUsername.getValidators().add(new Validator(Launcher.i18n("input.email"), str -> !txtPassword.isVisible() || str.contains("@")));
|
txtUsername.getValidators().add(new Validator(Launcher.i18n("input.email"), str -> !txtPassword.isVisible() || str.contains("@")));
|
||||||
|
|
||||||
|
txtUsername.textProperty().addListener(it -> validateAcceptButton());
|
||||||
|
txtPassword.textProperty().addListener(it -> validateAcceptButton());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateAcceptButton() {
|
||||||
|
btnAccept.setDisable(!txtUsername.validate() || (cboType.getSelectionModel().getSelectedIndex() != 0 && !txtPassword.validate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadServers() {
|
private void loadServers() {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
</body>
|
</body>
|
||||||
<actions>
|
<actions>
|
||||||
<Label fx:id="lblCreationWarning"/>
|
<Label fx:id="lblCreationWarning"/>
|
||||||
<JFXButton onMouseClicked="#onCreationAccept" text="%button.ok" styleClass="dialog-accept"/>
|
<JFXButton fx:id="btnAccept" onMouseClicked="#onCreationAccept" text="%button.ok" styleClass="dialog-accept"/>
|
||||||
<JFXButton onMouseClicked="#onCreationCancel" text="%button.cancel" styleClass="dialog-cancel"/>
|
<JFXButton onMouseClicked="#onCreationCancel" text="%button.cancel" styleClass="dialog-cancel"/>
|
||||||
</actions>
|
</actions>
|
||||||
</JFXDialogLayout>
|
</JFXDialogLayout>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class OfflineAccountFactory extends AccountFactory<OfflineAccount> {
|
|||||||
.orElseThrow(() -> new IllegalStateException("Offline account configuration malformed."));
|
.orElseThrow(() -> new IllegalStateException("Offline account configuration malformed."));
|
||||||
String uuid = Lang.get(storage, "uuid", String.class)
|
String uuid = Lang.get(storage, "uuid", String.class)
|
||||||
.orElse(getUUIDFromUserName(username));
|
.orElse(getUUIDFromUserName(username));
|
||||||
|
|
||||||
// Check if the uuid is vaild
|
// Check if the uuid is vaild
|
||||||
UUIDTypeAdapter.fromString(uuid);
|
UUIDTypeAdapter.fromString(uuid);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user