Search in sources :

Example 1 with ChangeUserAttributeEvent

use of de.catma.ui.events.ChangeUserAttributeEvent in project catma by forTEXT.

the class EditAccountDialog method initActions.

private void initActions() {
    btnCancel.addClickListener(evt -> close());
    btnSave.addClickListener(click -> {
        // sanity check the password
        if (!tfPassword.getValue().equals(tfVerifyPassword.getValue())) {
            Notification.show("Passwords don't match", Type.ERROR_MESSAGE);
            return;
        }
        // validate the bean!
        try {
            userBinder.writeBean(userData);
        } catch (ValidationException e) {
            Notification.show(Joiner.on("\n").join(e.getValidationErrors().stream().map(msg -> msg.getErrorMessage()).collect(Collectors.toList())), Type.ERROR_MESSAGE);
            return;
        }
        try {
            gitManagerPrivileged.modifyUserAttributes(userId, userData.getName(), userData.getPassword().isEmpty() ? null : userData.getPassword());
            eventBus.post(new ChangeUserAttributeEvent());
            Notification.show("Profile modification successful", Type.TRAY_NOTIFICATION);
        } catch (IOException e) {
            ((ErrorHandler) UI.getCurrent()).showAndLogError("Couldn't change profile", e);
        }
        this.close();
    });
}
Also used : ChangeUserAttributeEvent(de.catma.ui.events.ChangeUserAttributeEvent) ValidationException(com.vaadin.data.ValidationException) IOException(java.io.IOException)

Aggregations

ValidationException (com.vaadin.data.ValidationException)1 ChangeUserAttributeEvent (de.catma.ui.events.ChangeUserAttributeEvent)1 IOException (java.io.IOException)1