From da31fae9e367ec4eeac95512f8dfb99e8430c7c2 Mon Sep 17 00:00:00 2001 From: pb Date: Fri, 14 Jun 2013 10:11:45 +0000 Subject: [PATCH] Ticket #1747: SecurityPropertyEditor kann jetzt GlobalizedMessage verarbeiten, Labels als String deprecated. git-svn-id: https://svn.libreccm.org/ccm/trunk@2207 8810af33-2d31-482b-a856-94f89814c4df --- .../cms/ui/SecurityPropertyEditor.java | 79 ++++++++- ccm-core/src/com/arsdigita/bebop/Label.java | 23 ++- .../com/arsdigita/bebop/PropertyEditor.java | 162 +++++++++++++++--- 3 files changed, 224 insertions(+), 40 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/ui/SecurityPropertyEditor.java b/ccm-cms/src/com/arsdigita/cms/ui/SecurityPropertyEditor.java index 427b02005..8f0c81157 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/SecurityPropertyEditor.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/SecurityPropertyEditor.java @@ -32,6 +32,7 @@ import com.arsdigita.bebop.form.Submit; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.cms.util.GlobalizationUtil; +import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.toolbox.ui.ComponentAccess; import com.arsdigita.util.Assert; @@ -113,12 +114,28 @@ public class SecurityPropertyEditor extends PropertyEditor { * for this PropertyEditor * @param label The label for the link * @param ca The component access + * @deprecated use addComponent(String,GlobalizedMessage,ComponentAccess) + * instead. */ public void addComponent(String key, String label, ComponentAccess ca) { addComponent(key, ca); getLabelsMap().put(key, label); } + /** + * Add a component to the list of links. It is up to the + * component to correctly call showDisplayPane when it's done. + * + * @param key The symbolic key for the component; must be unique + * for this PropertyEditor + * @param label The label for the link + * @param ca The component access + */ + public void addComponent(String key, GlobalizedMessage label, ComponentAccess ca) { + addComponent(key, ca); + getLabelsMap().put(key, label); + } + /** * Specify a new {@link ComponentAccess} for a component which has already * been added to the SecurityPropertyEditor. @@ -142,10 +159,12 @@ public class SecurityPropertyEditor extends PropertyEditor { * Add a form to the set of forms which could be used to edit the * properties. * - * @param key The symbolic key for the form; must be unique - * for this PropertyEditor - * @param label The label for the link - * @param ca The form ComponentAccess + * @param key The symbolic key for the form; must be unique + * for this PropertyEditor + * @param label The label for the link to access the form + * @param ca The form ComponentAccess + * + * @deprecated use add(String,GlobalizedMessage,ComponentAccess) */ public void add(String key, String label, ComponentAccess ca) { Component c = ca.getComponent(); @@ -165,15 +184,45 @@ public class SecurityPropertyEditor extends PropertyEditor { } } + /** + * Add a form to the set of forms which could be used to edit the + * properties. + * + * @param key The symbolic key for the form; must be unique + * for this PropertyEditor + * @param label The label for the link to access the form + * @param ca The form ComponentAccess + */ + public void add(String key, GlobalizedMessage label, ComponentAccess ca) { + Component c = ca.getComponent(); + if (c instanceof Form) { + Form form = (Form) c; + m_accessChecks.put(key, ca); + add(key, label, form); + addSecurityListener(form); + } else if (c instanceof FormSection) { + FormSection section = (FormSection) ca.getComponent(); + m_accessChecks.put(key, ca); + add(key, label, section); + addSecurityListener(section); + } else { + throw new IllegalArgumentException( + "The ComponentAccess object did not contain a form section."); + } + } + /** * Add a form to the set of forms which could be used to edit the * properties * * @param key The symbolic key for the form; must be unique - * for this PropertyEditor - * @param label The label for the link - * @param ca The form ComponentAccess + * for this PropertyEditor + * @param label The label for the link to access the form. + * @param ca The form ComponentAccess * @param cancelButton The Cancel button on the form. + * + * @deprecated use add(String,GlobalizedMessage,ComponentAccess,Submit) + * instead */ public void add(String key, String label, ComponentAccess ca, Submit cancelButton) { @@ -181,6 +230,22 @@ public class SecurityPropertyEditor extends PropertyEditor { addCancelListener((FormSection) ca.getComponent(), cancelButton); } + /** + * Add a form to the set of forms which could be used to edit the + * properties + * + * @param key The symbolic key for the form; must be unique + * for this PropertyEditor + * @param label The label for the link to access the form. + * @param ca The form ComponentAccess + * @param cancelButton The Cancel button on the form. + */ + public void add(String key, GlobalizedMessage label, + ComponentAccess ca, Submit cancelButton) { + add(key, label, ca); + addCancelListener((FormSection) ca.getComponent(), cancelButton); + } + /** * Add a submission listener to the form that will hide all components * and show the display pane. This method should be used to add diff --git a/ccm-core/src/com/arsdigita/bebop/Label.java b/ccm-core/src/com/arsdigita/bebop/Label.java index 1bd75b9c6..b09da3f38 100755 --- a/ccm-core/src/com/arsdigita/bebop/Label.java +++ b/ccm-core/src/com/arsdigita/bebop/Label.java @@ -59,18 +59,20 @@ public class Label extends BlockStylable implements Cloneable { * Label with the specified text. * * @param label the text to display + * + * @deprecated refactor to use Label(GlobalizedMessage label) instad */ public Label(String label) { this(label, true); } /** - * Creates a new - * Label with the specified text and output escaping turned on - * if + * Creates a new Label with the specified text and + * output escaping turned on if * escaping is - * true. The setting foroutput escaping affects how markup in - * the + * true. + * + * The setting foroutput escaping affects how markup in the * label is handled. For example: