X-Git-Url: http://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=5f99e195bdcb2e802a322b17e209602b7c31c634;hb=3a3d316af102ba410d1d9e6de349d0c8f7ac044f;hp=3581354197e4fc205e60ddd154343e45b1dd9d27;hpb=484dcb1507e4e35cc282e50522ea7eac7e99a7f9;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 358135419..5f99e195b 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 @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.argeo.security.ui.admin.editors; import java.util.Arrays; @@ -46,8 +61,7 @@ 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); form.getBody().setLayout(mainLayout); @@ -71,13 +85,15 @@ public class DefaultUserMainPage extends FormPage implements ArgeoNames { body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); body.setLayout(layout); + 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) @@ -86,6 +102,8 @@ public class DefaultUserMainPage extends FormPage implements ArgeoNames { try { userProfile.getSession().getWorkspace().getVersionManager() .checkout(userProfile.getPath()); + userProfile.setProperty(Property.JCR_TITLE, + commonName.getText()); userProfile.setProperty(ARGEO_FIRST_NAME, firstName.getText()); userProfile @@ -98,6 +116,7 @@ public class DefaultUserMainPage extends FormPage implements ArgeoNames { userProfile.getSession().getWorkspace().getVersionManager() .checkin(userProfile.getPath()); super.commit(onSave); + refreshFormTitle(getManagedForm().getForm()); if (log.isTraceEnabled()) log.trace("General part committed"); } catch (RepositoryException e) { @@ -107,6 +126,7 @@ public class DefaultUserMainPage extends FormPage implements ArgeoNames { }; // if (username != null) // username.addModifyListener(new FormPartML(part)); + commonName.addModifyListener(new FormPartML(part)); firstName.addModifyListener(new FormPartML(part)); lastName.addModifyListener(new FormPartML(part)); email.addModifyListener(new FormPartML(part)); @@ -114,7 +134,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() : ""; @@ -171,6 +197,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();