+ * If the given group name is not valid, an error is displayed instead.
*
* @since Envoy Client v0.1-beta
*/
@FXML
- private void sendGroupObject() {
- eventBus.dispatch(new SendEvent(new GroupCreation(groupNameBar.getText(),
- contactList.getSelectionModel().getSelectedItems().stream().map(Contact::getID).collect(Collectors.toSet()))));
+ private void createButtonClicked() {
+ final var name = groupNameField.getText();
+ if (!Bounds.isValidContactName(name)) {
+ new Alert(AlertType.ERROR, "The entered group name is not valid (" + Bounds.CONTACT_NAME_PATTERN + ")").showAndWait();
+ groupNameField.clear();
+ } else {
+ eventBus.dispatch(new SendEvent(new GroupCreation(name,
+ contactList.getSelectionModel().getSelectedItems().stream().map(Contact::getID).collect(Collectors.toSet()))));
+ new Alert(AlertType.INFORMATION, String.format("Group '%s' successfully created.", name)).showAndWait();
+ sceneContext.pop();
+ }
}
@FXML
diff --git a/src/main/java/envoy/client/ui/controller/LoginScene.java b/src/main/java/envoy/client/ui/controller/LoginScene.java
index b17fa81..01e456d 100644
--- a/src/main/java/envoy/client/ui/controller/LoginScene.java
+++ b/src/main/java/envoy/client/ui/controller/LoginScene.java
@@ -23,6 +23,7 @@ import envoy.event.EventBus;
import envoy.event.HandshakeRejection;
import envoy.event.MessageStatusChange;
import envoy.exception.EnvoyException;
+import envoy.util.Bounds;
import envoy.util.EnvoyLog;
/**
@@ -115,8 +116,11 @@ public final class LoginScene {
if (registerCheckBox.isSelected() && !passwordField.getText().equals(repeatPasswordField.getText())) {
new Alert(AlertType.ERROR, "The entered password is unequal to the repeated one").showAndWait();
repeatPasswordField.clear();
- }
- else performHandshake(
+ } else if (!Bounds.isValidContactName(userTextField.getText())) {
+ new Alert(AlertType.ERROR, "The entered user name is not valid (" + Bounds.CONTACT_NAME_PATTERN + ")").showAndWait();
+ userTextField.clear();
+ } else
+ performHandshake(
new LoginCredentials(userTextField.getText(), passwordField.getText().toCharArray(), registerCheckBox.isSelected(), Startup.VERSION));
}
diff --git a/src/main/resources/fxml/GroupCreationScene.fxml b/src/main/resources/fxml/GroupCreationScene.fxml
index 8e36d11..7987a63 100644
--- a/src/main/resources/fxml/GroupCreationScene.fxml
+++ b/src/main/resources/fxml/GroupCreationScene.fxml
@@ -14,7 +14,7 @@