From: <fa...@vh...> - 2005-09-12 15:06:25
|
Author: fabrice Date: 2005-09-12 16:57:17 +0200 (Mon, 12 Sep 2005) New Revision: 779 Modified: ccm-cms-assets-relatedlink/trunk/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java Log: Option to hide extra fields Modified: ccm-cms-assets-relatedlink/trunk/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java =================================================================== --- ccm-cms-assets-relatedlink/trunk/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java 2005-09-12 14:56:21 UTC (rev 778) +++ ccm-cms-assets-relatedlink/trunk/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java 2005-09-12 14:57:17 UTC (rev 779) @@ -24,6 +24,7 @@ import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.Link; import com.arsdigita.cms.contenttypes.ui.LinkPropertyForm; @@ -37,13 +38,21 @@ /** * Form to edit the basic properties of a RelatedLink. This form * extends LinkPropertyForm in order to create items of the correct - * subclass and set the linkOwner propertyl + * subclass and set the linkOwner property. Users have found the additional + * fields confusing at authoring time (resourceSize and resourceType) so we + * have added a configuration parameter that allows us to hide them on a + * site wide basis. * @version $Revision: #3 $ $Date: 2004/03/30 $ * @author Scott Seago (ss...@re...) */ public class RelatedLinkPropertyForm extends LinkPropertyForm { + private static boolean isHideAdditionalResourceFields; + static { + isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields(); + } + /** * Creates a new form to edit the RelatedLink object specified * by the item selection model passed in. @@ -62,6 +71,9 @@ super.addWidgets(); + if ( isHideAdditionalResourceFields ) { + // Do nothing except protect the poor users from themselves. + } else { //Hack to get the form layout right. add(new Label("")); add(new Label( @@ -78,6 +90,7 @@ SingleSelect resType = new SingleSelect(new StringParameter(RelatedLink.RESOURCE_TYPE)); addMimeOptions(resType); add(resType); + } } /** @@ -125,6 +138,9 @@ FormData data = fse.getFormData(); PageState ps = fse.getPageState(); RelatedLink rl; + if ( isHideAdditionalResourceFields ) { + // Do nothing except protect the poor users from themselves. + } else { if ( getLinkSelectionModel().isSelected(ps)) { //We are editing the link , populate our addtional fields. rl = (RelatedLink) getLinkSelectionModel().getSelectedLink(ps); @@ -138,6 +154,7 @@ data.put(RelatedLink.RESOURCE_TYPE , null); } } + } /** * over-ride super class method to set extended properties for @@ -146,10 +163,16 @@ protected void setLinkProperties(Link link , FormSectionEvent fse){ RelatedLink rl = (RelatedLink) (link); FormData data = fse.getFormData(); + if ( isHideAdditionalResourceFields ) { + // We are not using these but let's try to set some reasonable defaults. + rl.setResourceSize( "" ); + rl.setResourceType(MimeType.loadMimeType("text/html")); + } else { rl.setResourceSize( (String) data.get(RelatedLink.RESOURCE_SIZE)); String typeName = (String) data.get(RelatedLink.RESOURCE_TYPE); MimeType mType = MimeType.loadMimeType(typeName); rl.setResourceType(mType); + } super.setLinkProperties(link , fse); } } |