+ if (CurrentUser.implies(CmsRole.userAdmin, roleContext)) {
+ SwtSection changePasswordSection = new SwtSection(main, SWT.BORDER);
+ changePasswordSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ changePasswordSection.setLayout(new GridLayout(2, false));
+// SuiteUiUtils.addFormLabel(changePasswordSection, CmsMsg.changePassword)
+// .setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false, 2, 1));
+ SuiteSwtUtils.addFormLabel(changePasswordSection, CmsMsg.newPassword);
+ Text newPasswordT = SuiteSwtUtils.addFormTextField(changePasswordSection, null, null,
+ SWT.PASSWORD | SWT.BORDER);
+ newPasswordT.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ SuiteSwtUtils.addFormLabel(changePasswordSection, CmsMsg.repeatNewPassword);
+ Text repeatNewPasswordT = SuiteSwtUtils.addFormTextField(changePasswordSection, null, null,
+ SWT.PASSWORD | SWT.BORDER);
+ repeatNewPasswordT.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ Button apply = new Button(changePasswordSection, SWT.FLAT);
+ apply.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false, 2, 1));
+ apply.setText(CmsMsg.changePassword.lead());
+ apply.addSelectionListener((Selected) (e) -> {
+ try {
+ char[] newPassword = newPasswordT.getTextChars();
+ char[] repeatNewPassword = repeatNewPasswordT.getTextChars();
+ if (newPassword.length > 0 && Arrays.equals(newPassword, repeatNewPassword)) {
+ cmsUserManager.resetPassword(user.getName(), newPassword);
+ CmsFeedback.show(CmsMsg.passwordChanged.lead());
+ } else {
+ CmsFeedback.error(CmsMsg.invalidPassword.lead(), null);
+ }
+ } catch (Exception e1) {
+ CmsFeedback.error(CmsMsg.invalidPassword.lead(), e1);
+ }
+ });
+ }