- // create form part (controller)
- AbstractFormPart part = new SectionPart((Section) body.getParent()) {
- @SuppressWarnings("unchecked")
- public void commit(boolean onSave) {
- if (!password1.getText().equals("")
- || !password2.getText().equals("")) {
- if (password1.getText().equals(password2.getText())) {
- char[] newPassword = password1.getText().toCharArray();
- // userAdminWrapper.beginTransactionIfNeeded();
- user.getCredentials().put(null, newPassword);
- password1.setText("");
- password2.setText("");
- super.commit(onSave);
- } else {
- password1.setText("");
- password2.setText("");
- throw new CmsException("Passwords are not equals");
- }
- }
+ public ChangePasswordDialog(FormToolkit tk, User user, String title) {
+ super(Display.getDefault().getActiveShell());
+ this.tk = tk;
+ this.user = user;
+ this.title = title;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite dialogarea = (Composite) super.createDialogArea(parent);
+ dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ Composite body = new Composite(dialogarea, SWT.NO_FOCUS);
+ body.setLayoutData(EclipseUiUtils.fillAll());
+ GridLayout layout = new GridLayout(2, false);
+ body.setLayout(layout);
+
+ password1 = createLP(tk, body, "New password", "");
+ password2 = createLP(tk, body, "Repeat password", "");
+ parent.pack();
+ return body;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void okPressed() {
+ String msg = null;
+
+ if (password1.getText().equals(""))
+ msg = "Password cannot be empty";
+ else if (password1.getText().equals(password2.getText())) {
+ char[] newPassword = password1.getText().toCharArray();
+ // userAdminWrapper.beginTransactionIfNeeded();
+ userAdminWrapper.beginTransactionIfNeeded();
+ user.getCredentials().put(null, newPassword);
+ userAdminWrapper.commitOrNotifyTransactionStateChange();
+ super.okPressed();
+ } else {
+ msg = "Passwords are not equals";