X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=security%2Feclipse%2Fplugins%2Forg.argeo.security.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fsecurity%2Fui%2Feditors%2FDefaultUserMainPage.java;fp=security%2Feclipse%2Fplugins%2Forg.argeo.security.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fsecurity%2Fui%2Feditors%2FDefaultUserMainPage.java;h=696d23d6d2a4cebcb53ff068d4e141c76719bbec;hb=11703221f489a07fec8f1ccbfacbe401587e9ce5;hp=ee63e24dbd20bbfdea76c64fc1c5062c8e6ce446;hpb=d685633924a5ee0328f5053b375564ca8fe969e6;p=lgpl%2Fargeo-commons.git diff --git a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/DefaultUserMainPage.java b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/DefaultUserMainPage.java index ee63e24db..696d23d6d 100644 --- a/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/DefaultUserMainPage.java +++ b/security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/editors/DefaultUserMainPage.java @@ -74,6 +74,7 @@ public class DefaultUserMainPage extends FormPage { createGeneralPart(form.getBody()); createRolesPart(form.getBody()); + createPassworPart(form.getBody()); } /** Creates the general section */ @@ -123,6 +124,8 @@ public class DefaultUserMainPage extends FormPage { log.trace("General part committed"); } }; + if (username != null) + username.addModifyListener(new FormPartML(part)); firstName.addModifyListener(new FormPartML(part)); lastName.addModifyListener(new FormPartML(part)); email.addModifyListener(new FormPartML(part)); @@ -130,6 +133,39 @@ public class DefaultUserMainPage extends FormPage { getManagedForm().addPart(part); } + /** Creates the password section */ + protected void createPassworPart(Composite parent) { + FormToolkit tk = getManagedForm().getToolkit(); + Section section = tk.createSection(parent, Section.TITLE_BAR); + section.setText("Password"); + + Composite body = tk.createComposite(section, SWT.WRAP); + section.setClient(body); + GridLayout layout = new GridLayout(); + layout.marginWidth = layout.marginHeight = 0; + layout.numColumns = 2; + body.setLayout(layout); + + // add widgets (view) + final Text password1 = createLP(body, "New password", ""); + final Text password2 = createLP(body, "Repeat password", ""); + // create form part (controller) + AbstractFormPart part = new SectionPart(section) { + public void commit(boolean onSave) { + if (!password1.getText().equals("") + && password1.getText().equals(password2.getText())) { + ((SimpleArgeoUser) user).setPassword(password1.getText()); + } + super.commit(onSave); + if (log.isTraceEnabled()) + log.trace("Password part committed"); + } + }; + password1.addModifyListener(new FormPartML(part)); + password2.addModifyListener(new FormPartML(part)); + getManagedForm().addPart(part); + } + /** Creates the role section */ protected void createRolesPart(Composite parent) { FormToolkit tk = getManagedForm().getToolkit(); @@ -215,6 +251,15 @@ public class DefaultUserMainPage extends FormPage { return text; } + /** Creates label and password. */ + protected Text createLP(Composite body, String label, String value) { + FormToolkit toolkit = getManagedForm().getToolkit(); + toolkit.createLabel(body, label); + Text text = toolkit.createText(body, value, SWT.BORDER | SWT.PASSWORD); + text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + return text; + } + public void setSimpleNatureType(String simpleNatureType) { this.simpleNatureType = simpleNatureType; }