X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=security%2Fplugins%2Forg.argeo.security.ui.admin%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fsecurity%2Fui%2Fadmin%2Feditors%2FDefaultUserMainPage.java;h=9d08d89ca7eff6f69d5f77adbc7c1ef52825a1e1;hb=4d665b0700136573b05879aa19897d8f448d8ca4;hp=5a20377cabce94977ba7e811a62ef94cfa291bfb;hpb=8b8ee149b20e2578a55e17413fa5f7399ff7ba14;p=lgpl%2Fargeo-commons.git diff --git a/security/plugins/org.argeo.security.ui.admin/src/main/java/org/argeo/security/ui/admin/editors/DefaultUserMainPage.java b/security/plugins/org.argeo.security.ui.admin/src/main/java/org/argeo/security/ui/admin/editors/DefaultUserMainPage.java index 5a20377ca..9d08d89ca 100644 --- a/security/plugins/org.argeo.security.ui.admin/src/main/java/org/argeo/security/ui/admin/editors/DefaultUserMainPage.java +++ b/security/plugins/org.argeo.security.ui.admin/src/main/java/org/argeo/security/ui/admin/editors/DefaultUserMainPage.java @@ -46,16 +46,8 @@ public class DefaultUserMainPage extends FormPage implements ArgeoNames { protected void createFormContent(final IManagedForm mf) { try { ScrolledForm form = mf.getForm(); - form.setText(getProperty(ARGEO_FIRST_NAME) + " " - + getProperty(ARGEO_LAST_NAME)); + refreshFormTitle(form); GridLayout mainLayout = new GridLayout(1, true); - // ColumnLayout mainLayout = new ColumnLayout(); - // mainLayout.minNumColumns = 1; - // mainLayout.maxNumColumns = 4; - // mainLayout.topMargin = 0; - // mainLayout.bottomMargin = 5; - // mainLayout.leftMargin = mainLayout.rightMargin = - // mainLayout.horizontalSpacing = mainLayout.verticalSpacing = 10; form.getBody().setLayout(mainLayout); createGeneralPart(form.getBody()); @@ -78,37 +70,25 @@ public class DefaultUserMainPage extends FormPage implements ArgeoNames { body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); body.setLayout(layout); - // add widgets (view) - // final Text username; - // if (user.getUsername() != null) { - // tk.createLabel(body, "Username"); - // tk.createLabel(body, user.getUsername()); - // username = null; - // } else { - // username = createLT(body, "Username", ""); - // } + final Text commonName = createLT(body, "Displayed Name", + getProperty(Property.JCR_TITLE)); final Text firstName = createLT(body, "First name", getProperty(ARGEO_FIRST_NAME)); final Text lastName = createLT(body, "Last name", getProperty(ARGEO_LAST_NAME)); final Text email = createLT(body, "Email", getProperty(ARGEO_PRIMARY_EMAIL)); - final Text description = createLT(body, "Description", + final Text description = createLMT(body, "Description", getProperty(Property.JCR_DESCRIPTION)); // create form part (controller) AbstractFormPart part = new SectionPart(section) { public void commit(boolean onSave) { - // if (username != null) { - // ((SimpleArgeoUser) user).setUsername(username.getText()); - // username.setEditable(false); - // username.setEnabled(false); - // } - // simpleNature.setFirstName(firstName.getText()); - // simpleNature.setLastName(lastName.getText()); - // simpleNature.setEmail(email.getText()); - // simpleNature.setDescription(description.getText()); try { + userProfile.getSession().getWorkspace().getVersionManager() + .checkout(userProfile.getPath()); + userProfile.setProperty(Property.JCR_TITLE, + commonName.getText()); userProfile.setProperty(ARGEO_FIRST_NAME, firstName.getText()); userProfile @@ -118,7 +98,10 @@ public class DefaultUserMainPage extends FormPage implements ArgeoNames { userProfile.setProperty(Property.JCR_DESCRIPTION, description.getText()); userProfile.getSession().save(); + userProfile.getSession().getWorkspace().getVersionManager() + .checkin(userProfile.getPath()); super.commit(onSave); + refreshFormTitle(getManagedForm().getForm()); if (log.isTraceEnabled()) log.trace("General part committed"); } catch (RepositoryException e) { @@ -135,7 +118,13 @@ public class DefaultUserMainPage extends FormPage implements ArgeoNames { getManagedForm().addPart(part); } - /** @return the property, or teh empty string if not set */ + private void refreshFormTitle(ScrolledForm form) throws RepositoryException { + form.setText(getProperty(Property.JCR_TITLE) + + (userProfile.getProperty(ARGEO_ENABLED).getBoolean() ? "" + : " [DISABLED]")); + } + + /** @return the property, or the empty string if not set */ protected String getProperty(String name) throws RepositoryException { return userProfile.hasProperty(name) ? userProfile.getProperty(name) .getString() : ""; @@ -192,6 +181,16 @@ public class DefaultUserMainPage extends FormPage implements ArgeoNames { return text; } + /** Creates label and multiline text. */ + protected Text createLMT(Composite body, String label, String value) { + FormToolkit toolkit = getManagedForm().getToolkit(); + Label lbl = toolkit.createLabel(body, label); + lbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); + Text text = toolkit.createText(body, value, SWT.BORDER | SWT.MULTI); + text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true)); + return text; + } + /** Creates label and password. */ protected Text createLP(Composite body, String label, String value) { FormToolkit toolkit = getManagedForm().getToolkit();