Added ability to change the user name on the client side
This commit is contained in:
parent
1f5d5b0054
commit
2af098fb28
@ -1,7 +1,11 @@
|
||||
package envoy.client.ui.settings;
|
||||
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.input.InputEvent;
|
||||
import javafx.scene.layout.HBox;
|
||||
|
||||
import envoy.client.event.SendEvent;
|
||||
import envoy.client.ui.SceneContext;
|
||||
@ -30,7 +34,22 @@ public class UserSettingsPane extends SettingsPane {
|
||||
* @param user the user who wants to customize his profile
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public UserSettingsPane(SceneContext sceneContext, User user) { super("User"); }
|
||||
public UserSettingsPane(SceneContext sceneContext, User user) {
|
||||
super("User"); // Display of profile picture change mechanism
|
||||
final var hbox = new HBox();
|
||||
|
||||
// Displaying the username change mechanism
|
||||
final var username = user.getName();
|
||||
final var usernameTextField = new TextField(username);
|
||||
final EventHandler<? super InputEvent> textChanged = e -> {
|
||||
newUsername = usernameTextField.getText();
|
||||
usernameChanged = newUsername != username;
|
||||
};
|
||||
usernameTextField.setOnInputMethodTextChanged(textChanged);
|
||||
usernameTextField.setOnKeyTyped(textChanged);
|
||||
hbox.getChildren().add(usernameTextField);
|
||||
vbox.getChildren().add(hbox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the given input and sends the changed input to the server
|
||||
|
@ -70,7 +70,8 @@ public class Startup {
|
||||
new IDGeneratorRequestProcessor(),
|
||||
new UserSearchProcessor(),
|
||||
new ContactOperationProcessor(),
|
||||
new IsTypingProcessor())));
|
||||
new IsTypingProcessor(),
|
||||
new NameChangeProcessor())));
|
||||
|
||||
// Initialize the current message ID
|
||||
final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
|
Reference in New Issue
Block a user