- The list of content types on the NewItemForm is now sorted by the localised

names of the content types
- The length of the description of (releated) link is now limited. The limit 
  can be configured using the com.arsdigita.cms.link_description_max_length 
  property in CMSConfig. The default value are 400 characters.


git-svn-id: https://svn.libreccm.org/ccm/trunk@2769 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-07-22 08:46:01 +00:00
parent 725f60d768
commit 9b70cf8018
12 changed files with 1653 additions and 1516 deletions

View File

@ -42,12 +42,11 @@ import com.arsdigita.util.Assert;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Form to edit the basic properties of a RelatedLink. This form * Form to edit the basic properties of a RelatedLink. This form extends LinkPropertyForm in order
* extends LinkPropertyForm in order to create items of the correct * to create items of the correct subclass and set the linkOwner property. Users have found the
* subclass and set the linkOwner property. Users have found the additional * additional fields confusing at authoring time (resourceSize and resourceType) so we have added a
* fields confusing at authoring time (resourceSize and resourceType) so we * configuration parameter that allows us to hide them on a site wide basis.
* have added a configuration parameter that allows us to hide them on a *
* site wide basis.
* @version $Revision: #3 $ $Date: 2004/03/30 $ * @version $Revision: #3 $ $Date: 2004/03/30 $
* @author Scott Seago (sseago@redhat.com) * @author Scott Seago (sseago@redhat.com)
*/ */
@ -55,21 +54,19 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
private static final Logger logger = Logger.getLogger( private static final Logger logger = Logger.getLogger(
RelatedLinkPropertyForm.class); RelatedLinkPropertyForm.class);
private static boolean isHideNewTargetWindow = private static boolean isHideNewTargetWindow = RelatedLinkConfig.getInstance()
RelatedLinkConfig.getInstance()
.isHideNewTargetWindow(); .isHideNewTargetWindow();
private static boolean isHideAdditionalResourceFields = private static boolean isHideAdditionalResourceFields = RelatedLinkConfig.getInstance()
RelatedLinkConfig.getInstance()
.isHideAdditionalResourceFields(); .isHideAdditionalResourceFields();
private String m_linkListName; private String m_linkListName;
/** /**
* Creates a new form to edit the RelatedLink object specified * Creates a new form to edit the RelatedLink object specified by the item selection model
* by the item selection model passed in. * passed in.
* @param itemModel The ItemSelectionModel to use to obtain the *
* ContentItem to which this link is (or will be) attached * @param itemModel The ItemSelectionModel to use to obtain the ContentItem to which this link
* @param link The LinkSelectionModel to use to obtain the * is (or will be) attached
* Link to work on * @param link The LinkSelectionModel to use to obtain the Link to work on
*/ */
public RelatedLinkPropertyForm(ItemSelectionModel itemModel, public RelatedLinkPropertyForm(ItemSelectionModel itemModel,
LinkSelectionModel link, String linkListName) { LinkSelectionModel link, String linkListName) {
@ -78,7 +75,8 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
} }
public RelatedLinkPropertyForm(ItemSelectionModel itemModel, public RelatedLinkPropertyForm(ItemSelectionModel itemModel,
LinkSelectionModel link, String linkListName, ContentType contentType) { LinkSelectionModel link, String linkListName,
ContentType contentType) {
super(itemModel, link, contentType); super(itemModel, link, contentType);
logger.debug(String.format("linkListName = %s", linkListName)); logger.debug(String.format("linkListName = %s", linkListName));
@ -111,14 +109,12 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
} else { } else {
add(new Label(RelatedLinkGlobalizationUtil.globalize( add(new Label(RelatedLinkGlobalizationUtil.globalize(
"cms.contentassets.ui.related_link.resource_size"))); "cms.contentassets.ui.related_link.resource_size")));
TextField resSize = new TextField(new TextField resSize = new TextField(new StringParameter(RelatedLink.RESOURCE_SIZE));
StringParameter(RelatedLink.RESOURCE_SIZE));
add(resSize); add(resSize);
add(new Label(RelatedLinkGlobalizationUtil.globalize( add(new Label(RelatedLinkGlobalizationUtil.globalize(
"cms.contentassets.ui.related_link.resource_type"))); "cms.contentassets.ui.related_link.resource_type")));
SingleSelect resType = new SingleSelect(new SingleSelect resType = new SingleSelect(new StringParameter(RelatedLink.RESOURCE_TYPE));
StringParameter(RelatedLink.RESOURCE_TYPE));
addMimeOptions(resType); addMimeOptions(resType);
add(resType); add(resType);
} }
@ -129,8 +125,8 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
} }
/** /**
* Add mime-type options to the option group by loading all mime * Add mime-type options to the option group by loading all mime types which match a certain
* types which match a certain prefix from the database * prefix from the database
* *
* @param w The mime type widget to which options should be added * @param w The mime type widget to which options should be added
* *
@ -145,10 +141,11 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
} }
/** /**
* Take care of basic RelatedLink creation steps. Creates the * Take care of basic RelatedLink creation steps. Creates the RelatedLink and sets the linkOwner
* RelatedLink and sets the linkOwner property. * property.
* *
* @param s the PageState * @param s the PageState
*
* @return the newly-created RelatedLink * @return the newly-created RelatedLink
*/ */
@Override @Override
@ -166,8 +163,8 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
} }
/** /**
* Over-ride super class method to initialize addtional fields specific * Over-ride super class method to initialize addtional fields specific to
* to <code>RelatedLink</code> content asset. * <code>RelatedLink</code> content asset.
*/ */
@Override @Override
public void init(FormSectionEvent fse) throws FormProcessException { public void init(FormSectionEvent fse) throws FormProcessException {
@ -197,8 +194,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
} }
/** /**
* over-ride super class method to set extended properties for * over-ride super class method to set extended properties for <code>RelatedLink</code>.
* <code>RelatedLink</code>.
*/ */
@Override @Override
protected void setLinkProperties(Link link, FormSectionEvent fse) { protected void setLinkProperties(Link link, FormSectionEvent fse) {
@ -223,4 +219,5 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
super.setLinkProperties(link, fse); super.setLinkProperties(link, fse);
} }
} }

View File

@ -51,8 +51,8 @@ import org.apache.log4j.Logger;
/** /**
* A record containing server-session scoped configuration properties. * A record containing server-session scoped configuration properties.
* *
* Accessors of this class may return null. Developers should take care to trap * Accessors of this class may return null. Developers should take care to trap null return values
* null return values in their code. * in their code.
* *
* @see ContentSection#getConfig() * @see ContentSection#getConfig()
* *
@ -71,8 +71,7 @@ public final class CMSConfig extends AbstractConfig {
private static CMSConfig s_config; private static CMSConfig s_config;
/** /**
* Returns the singleton configuration record for the content section * Returns the singleton configuration record for the content section environment.
* environment.
* *
* @return The <code>CMSConfig</code> record; it cannot be null * @return The <code>CMSConfig</code> record; it cannot be null
*/ */
@ -84,47 +83,40 @@ public final class CMSConfig extends AbstractConfig {
return s_config; return s_config;
} }
/** /**
* Storage (map) for method getAssetStepsToSkip(ContentType type) to * Storage (map) for method getAssetStepsToSkip(ContentType type) to store mapping of steps that
* store mapping of steps that are deemed irrelevant for the passid in * are deemed irrelevant for the passid in type.
* type.
*/ */
private static Map s_skipAssetSteps = null; private static Map s_skipAssetSteps = null;
/** /**
* Item category add form specifies Subclass of ItemCategoryForm to use * Item category add form specifies Subclass of ItemCategoryForm to use for the assign
* for the assign categories step. Used in * categories step. Used in c.ad.cms.ui.authoring.ItemCategoryStep
* c.ad.cms.ui.authoring.ItemCategoryStep
*/ */
private final Parameter m_categoryAuthoringAddForm = private final Parameter m_categoryAuthoringAddForm = new SpecificClassParameter(
new SpecificClassParameter(
"com.arsdigita.cms.category_authoring_add_form", "com.arsdigita.cms.category_authoring_add_form",
Parameter.REQUIRED, Parameter.REQUIRED,
ItemCategoryForm.class, ItemCategoryForm.class,
SimpleComponent.class); SimpleComponent.class);
/** /**
* Path for the default item template. Path is relative to the Template * Path for the default item template. Path is relative to the Template Root path.
* Root path.
*/ */
private final Parameter m_defaultItemTemplatePath = private final Parameter m_defaultItemTemplatePath = new StringParameter(
new StringParameter(
"com.arsdigita.cms.default_item_template_path", "com.arsdigita.cms.default_item_template_path",
Parameter.REQUIRED, Parameter.REQUIRED,
"/default/item.jsp"); "/default/item.jsp");
/** /**
* Path for the default folder template. Path is relative to the * Path for the default folder template. Path is relative to the Template Root path.
* Template Root path.
*/ */
private final Parameter m_defaultFolderTemplatePath = private final Parameter m_defaultFolderTemplatePath = new StringParameter(
new StringParameter(
"com.arsdigita.cms.default_folder_template_path", "com.arsdigita.cms.default_folder_template_path",
Parameter.REQUIRED, Parameter.REQUIRED,
"/default/folder.jsp"); "/default/folder.jsp");
/** /**
* Path or the root folter for template folders. Path is relative to * Path or the root folter for template folders. Path is relative to webapp root. Modify with
* webapp root. Modify with care! Usually modified by developers only! * care! Usually modified by developers only!
*/ */
private final Parameter m_templateRootPath = private final Parameter m_templateRootPath = new StringParameter(
new StringParameter(
"com.arsdigita.cms.template_root_path", "com.arsdigita.cms.template_root_path",
Parameter.REQUIRED, Parameter.REQUIRED,
"/templates/ccm-cms/content-section"); "/templates/ccm-cms/content-section");
@ -142,29 +134,27 @@ public final class CMSConfig extends AbstractConfig {
// } // }
// ADD: // ADD:
/** /**
* Item Adapters File, path to an XML resource containing adapter * Item Adapters File, path to an XML resource containing adapter specifications. Path is
* specifications. Path is relative to webapp root. * relative to webapp root.
*/ */
private final Parameter m_itemAdapters = private final Parameter m_itemAdapters = new ResourceParameter(
new ResourceParameter(
"com.arsdigita.cms.item_adapters", "com.arsdigita.cms.item_adapters",
Parameter.REQUIRED, Parameter.REQUIRED,
"/WEB-INF/resources/cms-item-adapters.xml"); "/WEB-INF/resources/cms-item-adapters.xml");
// URL resource: protocol handler removal: END // URL resource: protocol handler removal: END
/** /**
* Use streamlined content creation: upon item creation, automatically * Use streamlined content creation: upon item creation, automatically open authoring steps and
* open authoring steps and forward to the next step * forward to the next step
*/ */
private final Parameter m_useStreamlinedCreation = new BooleanParameter( private final Parameter m_useStreamlinedCreation = new BooleanParameter(
"com.arsdigita.cms.use_streamlined_creation", "com.arsdigita.cms.use_streamlined_creation",
Parameter.REQUIRED, Parameter.REQUIRED,
Boolean.TRUE); Boolean.TRUE);
/** /**
* DHTML Editor Configuration for use in CMS module, lists the config * DHTML Editor Configuration for use in CMS module, lists the config object name and Javascript
* object name and Javascript source location for its definition. * source location for its definition.
*/ */
private final Parameter m_dhtmlEditorConfig = private final Parameter m_dhtmlEditorConfig = new DHTMLEditorConfigParameter(
new DHTMLEditorConfigParameter(
"com.arsdigita.cms.dhtml_editor_config", "com.arsdigita.cms.dhtml_editor_config",
Parameter.REQUIRED, Parameter.REQUIRED,
new DHTMLEditor.Config("Xinha.Config", new DHTMLEditor.Config("Xinha.Config",
@ -180,19 +170,17 @@ public final class CMSConfig extends AbstractConfig {
// be accessable by other modules which use DHTMLeditor. // be accessable by other modules which use DHTMLeditor.
// Would be bad style to configure a cms specific parameter in core. // Would be bad style to configure a cms specific parameter in core.
/** /**
* Defines which plugins to use, e.g.TableOperations,CSS Format: * Defines which plugins to use, e.g.TableOperations,CSS Format: [string,string,string]
* [string,string,string]
*/ */
private final Parameter m_dhtmlEditorPlugins = new StringArrayParameter( private final Parameter m_dhtmlEditorPlugins = new StringArrayParameter(
"com.arsdigita.cms.dhtml_editor_plugins", "com.arsdigita.cms.dhtml_editor_plugins",
Parameter.OPTIONAL, Parameter.OPTIONAL,
null); null);
/** /**
* Prevent undesirable functions from being made available, eg images * Prevent undesirable functions from being made available, eg images should only be added
* should only be added through the cms methods. * through the cms methods.
*/ */
private final Parameter m_dhtmlEditorHiddenButtons = private final Parameter m_dhtmlEditorHiddenButtons = new StringArrayParameter(
new StringArrayParameter(
"com.arsdigita.cms.dhtml_editor_hidden_buttons", "com.arsdigita.cms.dhtml_editor_hidden_buttons",
Parameter.OPTIONAL, Parameter.OPTIONAL,
null); null);
@ -239,8 +227,8 @@ public final class CMSConfig extends AbstractConfig {
Parameter.REQUIRED, Parameter.REQUIRED,
Boolean.FALSE); Boolean.FALSE);
/** /**
* Hide timezone labels (if, for example, all users will be in the same * Hide timezone labels (if, for example, all users will be in the same timezone and such
* timezone and such information would be unnecessary) * information would be unnecessary)
*/ */
private final Parameter m_hideTimezone = new BooleanParameter( private final Parameter m_hideTimezone = new BooleanParameter(
"com.arsdigita.cms.hide_timezone", "com.arsdigita.cms.hide_timezone",
@ -256,47 +244,41 @@ public final class CMSConfig extends AbstractConfig {
/** /**
* Specifies the name of the class to use as a PublishLifecycleListener * Specifies the name of the class to use as a PublishLifecycleListener
*/ */
private final Parameter m_publishLifecycleListenerClass = private final Parameter m_publishLifecycleListenerClass = new StringParameter(
new StringParameter(
"com.arsdigita.cms.publish_lifecycle_listener_class", "com.arsdigita.cms.publish_lifecycle_listener_class",
Parameter.OPTIONAL, Parameter.OPTIONAL,
PublishLifecycleListener.class.getName()); PublishLifecycleListener.class.getName());
/** /**
* Wether the Wysiwyg editor should clear the text of MSWord tags, * Wether the Wysiwyg editor should clear the text of MSWord tags, everytime the user clicks on
* everytime the user clicks on 'Save' * 'Save'
*/ */
private final Parameter m_saveTextCleansWordTags = new BooleanParameter( private final Parameter m_saveTextCleansWordTags = new BooleanParameter(
"com.arsdigita.cms.save_text_cleans_word_tags", "com.arsdigita.cms.save_text_cleans_word_tags",
Parameter.OPTIONAL, Parameter.OPTIONAL,
Boolean.FALSE); Boolean.FALSE);
/** /**
* Get the search indexing not to process FileAssets, eg to avoid PDF * Get the search indexing not to process FileAssets, eg to avoid PDF slowdowns
* slowdowns
*/ */
private final Parameter m_disableFileAssetExtraction = new BooleanParameter( private final Parameter m_disableFileAssetExtraction = new BooleanParameter(
"com.arsdigita.cms.search.disableFileAssetExtraction", "com.arsdigita.cms.search.disableFileAssetExtraction",
Parameter.REQUIRED, Parameter.REQUIRED,
Boolean.FALSE); Boolean.FALSE);
/** /**
* Whether an item's workflow should be deleted, once the item has been * Whether an item's workflow should be deleted, once the item has been (re)published
* (re)published
*/ */
private final Parameter m_deleteWorkflowAfterPublication = private final Parameter m_deleteWorkflowAfterPublication = new BooleanParameter(
new BooleanParameter(
"com.arsdigita.cms.delete_workflow_after_publication", "com.arsdigita.cms.delete_workflow_after_publication",
Parameter.REQUIRED, Parameter.REQUIRED,
Boolean.TRUE); Boolean.TRUE);
/** /**
* Defines the number of days ahead that are covered in the 'Soon * Defines the number of days ahead that are covered in the 'Soon Expired' tab
* Expired' tab
*/ */
private final Parameter m_soonExpiredTimespanDays = new IntegerParameter( private final Parameter m_soonExpiredTimespanDays = new IntegerParameter(
"com.arsdigita.cms.soon_expired_timespan_days", "com.arsdigita.cms.soon_expired_timespan_days",
Parameter.REQUIRED, Parameter.REQUIRED,
new Integer(14)); new Integer(14));
/** /**
* Defines the number of months ahead that are covered in the 'Soon * Defines the number of months ahead that are covered in the 'Soon Expired' tab
* Expired' tab
*/ */
private final Parameter m_soonExpiredTimespanMonths = new IntegerParameter( private final Parameter m_soonExpiredTimespanMonths = new IntegerParameter(
"com.arsdigita.cms.soon_expired_timespan_months", "com.arsdigita.cms.soon_expired_timespan_months",
@ -310,146 +292,126 @@ public final class CMSConfig extends AbstractConfig {
Parameter.REQUIRED, Parameter.REQUIRED,
Boolean.TRUE); Boolean.TRUE);
/** /**
* Links created through browse interfaces should only be within the * Links created through browse interfaces should only be within the same subsite
* same subsite
*/ */
private final Parameter m_linksOnlyInSameSubsite = new BooleanParameter( private final Parameter m_linksOnlyInSameSubsite = new BooleanParameter(
"com.arsdigita.cms.browse_links_in_same_subsite_only", "com.arsdigita.cms.browse_links_in_same_subsite_only",
Parameter.REQUIRED, Parameter.REQUIRED,
Boolean.FALSE); Boolean.FALSE);
/** /**
* Item category step extension hook: Subclass of ItemCategoryExtension * Item category step extension hook: Subclass of ItemCategoryExtension which adds extension
* which adds extension actions for the category authoring step * actions for the category authoring step
*/ */
private final Parameter m_categoryAuthoringExtension = private final Parameter m_categoryAuthoringExtension = new SpecificClassParameter(
new SpecificClassParameter(
"com.arsdigita.cms.category_authoring_extension", "com.arsdigita.cms.category_authoring_extension",
Parameter.REQUIRED, Parameter.REQUIRED,
ItemCategoryExtension.class, ItemCategoryExtension.class,
ItemCategoryExtension.class); ItemCategoryExtension.class);
/** /**
* Link available to reset lifecycle on republish. If false don't * Link available to reset lifecycle on republish. If false don't display the link otherwise
* display the link otherwise display. * display.
*/ */
private final Parameter m_hideResetLifecycleLink = new BooleanParameter( private final Parameter m_hideResetLifecycleLink = new BooleanParameter(
"com.arsdigita.cms.hide_reset_lifecycle_link", "com.arsdigita.cms.hide_reset_lifecycle_link",
Parameter.OPTIONAL, Parameter.OPTIONAL,
Boolean.TRUE); Boolean.TRUE);
/** /**
* Whether to include INPATH operators to contains clause in intermedia * Whether to include INPATH operators to contains clause in intermedia search
* search
*/ */
private final Parameter m_scoreTitleAndKeywords = private final Parameter m_scoreTitleAndKeywords = new BooleanParameter(
new BooleanParameter(
"com.arsdigita.cms.search.score_title_and_keywords", "com.arsdigita.cms.search.score_title_and_keywords",
Parameter.OPTIONAL, Parameter.OPTIONAL,
Boolean.FALSE); Boolean.FALSE);
/** /**
* Title Weight, the relative weight given to title element within * Title Weight, the relative weight given to title element within cms:item when ranking search
* cms:item when ranking search results (only used by interMedia) * results (only used by interMedia)
*/ */
private final Parameter m_titleWeight = new IntegerParameter( private final Parameter m_titleWeight = new IntegerParameter(
"com.arsdigita.cms.search.intermedia.title_weight", "com.arsdigita.cms.search.intermedia.title_weight",
Parameter.OPTIONAL, Parameter.OPTIONAL,
new Integer(1)); new Integer(1));
/** /**
* Keyword Weight, the relative weight given to the dcKeywords element * Keyword Weight, the relative weight given to the dcKeywords element within dublinCore element
* within dublinCore element within cms:item element when ranking search * within cms:item element when ranking search results (only used by interMedia)
* results (only used by interMedia)
*/ */
private final Parameter m_keywordWeight = private final Parameter m_keywordWeight = new IntegerParameter(
new IntegerParameter(
"com.arsdigita.cms.search.intermedia.keyword_weight", "com.arsdigita.cms.search.intermedia.keyword_weight",
Parameter.OPTIONAL, Parameter.OPTIONAL,
new Integer(1)); new Integer(1));
/** /**
* Limit the item search to current content section * Limit the item search to current content section
*/ */
private final Parameter m_limitToContentSection = private final Parameter m_limitToContentSection = new BooleanParameter(
new BooleanParameter(
"com.arsdigita.cms.search.limitToContentSection", "com.arsdigita.cms.search.limitToContentSection",
Parameter.OPTIONAL, Parameter.OPTIONAL,
Boolean.TRUE); Boolean.TRUE);
/** /**
* Asset steps to skip, specify asset steps that are not relevant for * Asset steps to skip, specify asset steps that are not relevant for specific content types.
* specific content types. Each entry in the list is a : separated pair. * Each entry in the list is a : separated pair. The first string is the className for the type
* The first string is the className for the type (refer to classname * (refer to classname column in contenttypes table eg
* column in contenttypes table eg * com.arsdigita.cms.contenttypes.MultiPartArticle Second string is the name of the bebop step
* com.arsdigita.cms.contenttypes.MultiPartArticle Second string is the * component eg com.arsdigita.cms.contenttypes.ui.ImageStep
* name of the bebop step component eg
* com.arsdigita.cms.contenttypes.ui.ImageStep
*/ */
private final Parameter m_skipAssetSteps = new StringArrayParameter( private final Parameter m_skipAssetSteps = new StringArrayParameter(
"com.arsdigita.cms.skip_asset_steps", "com.arsdigita.cms.skip_asset_steps",
Parameter.OPTIONAL, Parameter.OPTIONAL,
null); null);
/** /**
* Mandatory Descriptions Content types may refer to this to decide * Mandatory Descriptions Content types may refer to this to decide whether to validate against
* whether to validate against empty descriptions * empty descriptions
*/ */
private final Parameter m_mandatoryDescriptions = new BooleanParameter( private final Parameter m_mandatoryDescriptions = new BooleanParameter(
"com.arsdigita.cms.mandatory_descriptions", "com.arsdigita.cms.mandatory_descriptions",
Parameter.OPTIONAL, Parameter.OPTIONAL,
Boolean.FALSE); Boolean.FALSE);
/** /**
* Delete Finished Lifecycles. Decide whether lifecycles and their * Delete Finished Lifecycles. Decide whether lifecycles and their phases should be deleted from
* phases should be deleted from the system when finished. * the system when finished.
*/ */
private final Parameter m_deleteLifecycleWhenComplete = private final Parameter m_deleteLifecycleWhenComplete = new BooleanParameter(
new BooleanParameter(
"com.arsdigita.cms.delete_lifecycle_when_complete", "com.arsdigita.cms.delete_lifecycle_when_complete",
Parameter.OPTIONAL, Parameter.OPTIONAL,
Boolean.FALSE); Boolean.FALSE);
/** /**
* Contacts for content items. Allows you to add a Contact authoring * Contacts for content items. Allows you to add a Contact authoring step to all items
* step to all items
*/ */
private final Parameter m_hasContactsAuthoringStep = new BooleanParameter( private final Parameter m_hasContactsAuthoringStep = new BooleanParameter(
"com.arsdigita.cms.has_contacts_authoring_step", "com.arsdigita.cms.has_contacts_authoring_step",
Parameter.REQUIRED, Parameter.REQUIRED,
Boolean.FALSE); Boolean.FALSE);
/** /**
* Ordering for nodes in assign category tree. Decide whether entries * Ordering for nodes in assign category tree. Decide whether entries should be ordered
* should be ordered alphabetically or according to sort key (maintained * alphabetically or according to sort key (maintained in category admin tab in content centre)
* in category admin tab in content centre) SortKey|Alphabetical is * SortKey|Alphabetical is initialized in constructor! See below.
* initialized in constructor! See below.
*/ */
private final Parameter m_categoryTreeOrdering = private final Parameter m_categoryTreeOrdering = new EnumerationParameter(
new EnumerationParameter(
"com.arsdigita.cms.category_tree_order", "com.arsdigita.cms.category_tree_order",
Parameter.OPTIONAL, Parameter.OPTIONAL,
Category.SORT_KEY); Category.SORT_KEY);
/** /**
* Allow creation of a new Use Context in category tab of content * Allow creation of a new Use Context in category tab of content sections. "Use Context" is the
* sections. "Use Context" is the construct to constitute a category * construct to constitute a category hierarchy implementet in core. It is superseded by the
* hierarchy implementet in core. It is superseded by the construct * construct "Category Domain" in Terms (ccm-ldn-terms). Global parameter for all content
* "Category Domain" in Terms (ccm-ldn-terms). Global parameter for all * sections. Default is false because all installation bundles use Terms.
* content sections. Default is false because all installation bundles
* use Terms.
*/ */
private final Parameter m_allowCategoryCreateUseContext = private final Parameter m_allowCategoryCreateUseContext = new BooleanParameter(
new BooleanParameter(
"com.arsdigita.cms.allow_category_create_use_context", "com.arsdigita.cms.allow_category_create_use_context",
Parameter.REQUIRED, Parameter.REQUIRED,
Boolean.FALSE); Boolean.FALSE);
/** /**
* Allow content creation in Workspace (content center) section listing. * Allow content creation in Workspace (content center) section listing. Allows you to turn off
* Allows you to turn off the ability to create content in the section * the ability to create content in the section listing
* listing
*/ */
private final Parameter m_allowContentCreateInSectionListing = private final Parameter m_allowContentCreateInSectionListing = new BooleanParameter(
new BooleanParameter(
"com.arsdigita.cms.allow_content_create_in_section_listing", "com.arsdigita.cms.allow_content_create_in_section_listing",
Parameter.REQUIRED, Parameter.REQUIRED,
Boolean.TRUE); Boolean.TRUE);
/** /**
* Hide the legacy public site link in Workspace (content center) * Hide the legacy public site link in Workspace (content center) section listing. Legacy public
* section listing. Legacy public site display is replaced by navigation * site display is replaced by navigation based presentation (or by portlets) and should be
* based presentation (or by portlets) and should be hidden in the admin * hidden in the admin ui by default now.
* ui by default now.
*/ */
private final Parameter m_hideLegacyPublicSiteLink = private final Parameter m_hideLegacyPublicSiteLink = new BooleanParameter(
new BooleanParameter(
"com.arsdigita.cms.hide_legacy_public_site_link", "com.arsdigita.cms.hide_legacy_public_site_link",
Parameter.REQUIRED, Parameter.REQUIRED,
Boolean.TRUE); Boolean.TRUE);
@ -457,34 +419,31 @@ public final class CMSConfig extends AbstractConfig {
// Notification related parameters // Notification related parameters
// /////////////////////////////////////////// // ///////////////////////////////////////////
/** /**
* Delete Sent Workflow Notifications. Decide whether successfully sent * Delete Sent Workflow Notifications. Decide whether successfully sent notifications and
* notifications and messages should be deleted from the system * messages should be deleted from the system
*/ */
private final Parameter m_deleteWorkflowNotificationsWhenSent = private final Parameter m_deleteWorkflowNotificationsWhenSent = new BooleanParameter(
new BooleanParameter(
"com.arsdigita.cms.delete_workflow_notification_when_sent", "com.arsdigita.cms.delete_workflow_notification_when_sent",
Parameter.OPTIONAL, Parameter.OPTIONAL,
Boolean.FALSE); Boolean.FALSE);
/** /**
* Decide whether successfully sent notifications and messages should be * Decide whether successfully sent notifications and messages should be deleted from the system
* deleted from the system
*/ */
private final Parameter m_deleteExpiryNotificationsWhenSent = private final Parameter m_deleteExpiryNotificationsWhenSent = new BooleanParameter(
new BooleanParameter(
"com.arsdigita.cms.delete_expiry_notification_when_sent", "com.arsdigita.cms.delete_expiry_notification_when_sent",
Parameter.OPTIONAL, Parameter.OPTIONAL,
Boolean.FALSE); Boolean.FALSE);
/** /**
* Amount of time (in hours) before the expiration of a content item * Amount of time (in hours) before the expiration of a content item that users in the Alert
* that users in the Alert Recipient role are alerted via email * Recipient role are alerted via email
*/ */
private final Parameter m_defaultNotificationTime = new IntegerParameter( private final Parameter m_defaultNotificationTime = new IntegerParameter(
"com.arsdigita.cms.default_notification_time", "com.arsdigita.cms.default_notification_time",
Parameter.REQUIRED, Parameter.REQUIRED,
new Integer(0)); new Integer(0));
/** /**
* Wether a content item's author should be notified by the item's * Wether a content item's author should be notified by the item's LifecycleListener; defaults
* LifecycleListener; defaults to true * to true
*/ */
private final Parameter m_notifyAuthorOnLifecycle = new BooleanParameter( private final Parameter m_notifyAuthorOnLifecycle = new BooleanParameter(
"com.arsdigita.cms.notify_author_on_lifecycle", "com.arsdigita.cms.notify_author_on_lifecycle",
@ -494,8 +453,7 @@ public final class CMSConfig extends AbstractConfig {
// Content Center (Workspace) config related parameters // Content Center (Workspace) config related parameters
// //////////////////////////////////////////////////// // ////////////////////////////////////////////////////
/** /**
* XML Mapping of the content center tabs to URLs, see * XML Mapping of the content center tabs to URLs, see {@link ContentCenterDispatcher}
* {@link ContentCenterDispatcher}
*/ */
private final StringParameter m_contentCenterMap = new StringParameter( private final StringParameter m_contentCenterMap = new StringParameter(
"com.arsdigita.cms.loader.content_center_map", "com.arsdigita.cms.loader.content_center_map",
@ -517,14 +475,12 @@ public final class CMSConfig extends AbstractConfig {
// to SectionInitializer. However, it still may be useful to // to SectionInitializer. However, it still may be useful to
// keep these for the default values. // keep these for the default values.
// /////////////////////////////////////////// // ///////////////////////////////////////////
private final Parameter m_defaultItemResolverClass = private final Parameter m_defaultItemResolverClass = new SpecificClassParameter(
new SpecificClassParameter(
"com.arsdigita.cms.default_item_resolver_class", "com.arsdigita.cms.default_item_resolver_class",
Parameter.REQUIRED, Parameter.REQUIRED,
MultilingualItemResolver.class, MultilingualItemResolver.class,
ItemResolver.class); ItemResolver.class);
private final Parameter m_defaultTemplateResolverClass = private final Parameter m_defaultTemplateResolverClass = new SpecificClassParameter(
new SpecificClassParameter(
"com.arsdigita.cms.default_template_resolver_class", "com.arsdigita.cms.default_template_resolver_class",
Parameter.REQUIRED, Parameter.REQUIRED,
DefaultTemplateResolver.class, DefaultTemplateResolver.class,
@ -532,8 +488,7 @@ public final class CMSConfig extends AbstractConfig {
///////////////////////////////////////////// /////////////////////////////////////////////
// ItemSearchWidget // ItemSearchWidget
///////////////////////////////////////////// /////////////////////////////////////////////
private final Parameter m_itemSearchDefaultTab = private final Parameter m_itemSearchDefaultTab = new StringParameter(
new StringParameter(
"com.arsdigita.cms.item_search.default_tab", "com.arsdigita.cms.item_search.default_tab",
Parameter.REQUIRED, "flatBrowse"); Parameter.REQUIRED, "flatBrowse");
// private final Parameter m_itemSearchFlatBrowsePaneEnable = new BooleanParameter( // private final Parameter m_itemSearchFlatBrowsePaneEnable = new BooleanParameter(
@ -563,8 +518,7 @@ public final class CMSConfig extends AbstractConfig {
//republish and withdraw items) is used. Otherwise the new style form is //republish and withdraw items) is used. Otherwise the new style form is
//used, which is more secure against wrong clicks. //used, which is more secure against wrong clicks.
////////////////////////////////////////////// //////////////////////////////////////////////
private final Parameter m_useOldStyleItemLifecycleItemPane = private final Parameter m_useOldStyleItemLifecycleItemPane = new BooleanParameter(
new BooleanParameter(
"com.arsdigita.cms.lifecycle.use_old_style_item_lifecycle_item_pane", "com.arsdigita.cms.lifecycle.use_old_style_item_lifecycle_item_pane",
Parameter.REQUIRED, Parameter.REQUIRED,
false); false);
@ -662,14 +616,18 @@ public final class CMSConfig extends AbstractConfig {
Parameter.REQUIRED, Parameter.REQUIRED,
60 * 60 * 24); 60 * 60 * 24);
/**
* Max length of the description of a link (in database max length are 4000 characters)
*/
private final Parameter m_linkDescMaxLength = new IntegerParameter(
"com.arsdigita.cms.link_description_max_length", Parameter.REQUIRED, 400);
// /////////////////////////////////////////// // ///////////////////////////////////////////
// publishToFile package related parameter // publishToFile package related parameter
// /////////////////////////////////////////// // ///////////////////////////////////////////
// Moved to publishToFile.PublishToFileConfig as of version 6.0.2 // Moved to publishToFile.PublishToFileConfig as of version 6.0.2
// private final Parameter m_disableItemPfs; // private final Parameter m_disableItemPfs;
// private final Parameter m_publishToFileClass; // private final Parameter m_publishToFileClass;
/** /**
* Constructor, but do NOT instantiate this class directly. * Constructor, but do NOT instantiate this class directly.
* *
@ -686,7 +644,6 @@ public final class CMSConfig extends AbstractConfig {
((EnumerationParameter) m_categoryTreeOrdering).put("Alphabetical", ((EnumerationParameter) m_categoryTreeOrdering).put("Alphabetical",
Category.NAME); Category.NAME);
register(m_templateRootPath); register(m_templateRootPath);
register(m_defaultItemTemplatePath); register(m_defaultItemTemplatePath);
register(m_defaultFolderTemplatePath); register(m_defaultFolderTemplatePath);
@ -736,7 +693,6 @@ public final class CMSConfig extends AbstractConfig {
// Content Section config related parameters // Content Section config related parameters
// register(m_defaultSection); // register(m_defaultSection);
// Content Section creation parameters // Content Section creation parameters
register(m_defaultItemResolverClass); register(m_defaultItemResolverClass);
register(m_defaultTemplateResolverClass); register(m_defaultTemplateResolverClass);
@ -768,7 +724,6 @@ public final class CMSConfig extends AbstractConfig {
// Moved to publishToFile.PublishToFileConfig as of version 6.0.2 // Moved to publishToFile.PublishToFileConfig as of version 6.0.2
// register(m_disableItemPfs); // register(m_disableItemPfs);
// register(m_publishToFileClass); // register(m_publishToFileClass);
// register(m_itemSearchFlatBrowsePaneEnable); // register(m_itemSearchFlatBrowsePaneEnable);
register(m_itemSearchFlatBrowsePanePageSize); register(m_itemSearchFlatBrowsePanePageSize);
@ -779,12 +734,13 @@ public final class CMSConfig extends AbstractConfig {
register(m_xmlCacheSize); register(m_xmlCacheSize);
register(m_xmlCacheAge); register(m_xmlCacheAge);
register(m_linkDescMaxLength);
loadInfo(); loadInfo();
} }
/** /**
* Retrieve path of the root folder for template folders. Path is * Retrieve path of the root folder for template folders. Path is relative to webapp root.
* relative to webapp root.
*/ */
public final String getTemplateRoot() { public final String getTemplateRoot() {
return (String) get(m_templateRootPath); return (String) get(m_templateRootPath);
@ -824,9 +780,7 @@ public final class CMSConfig extends AbstractConfig {
/** /**
* *
* @deprecated use * @deprecated use com.arsdigita.cms.ContentSection.getDefaultSection().getName() instead
* com.arsdigita.cms.ContentSection.getDefaultSection().getName()
* instead
*/ */
public final String getDefaultContentSection() { public final String getDefaultContentSection() {
// return (String) get(m_defaultSection); // return (String) get(m_defaultSection);
@ -937,8 +891,7 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* Fetch the file name contaning XML Mapping of the content center tabs * Fetch the file name contaning XML Mapping of the content center tabs to URLs
* to URLs
* *
* @return String containig file name including path component. * @return String containig file name including path component.
*/ */
@ -947,18 +900,15 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* Internal class representing a DHTMLEditor configuration parameter. It * Internal class representing a DHTMLEditor configuration parameter. It creates a new
* creates a new DHMTLEditor Config object (internal class in * DHMTLEditor Config object (internal class in DHTMLEditor).
* DHTMLEditor).
* *
* XXX Method unmarshal is broken and currently does not work correctly. * XXX Method unmarshal is broken and currently does not work correctly. It does not process
* It does not process default values provided by using * default values provided by using DHTMLEditor.Config.Standard (see parameter
* DHTMLEditor.Config.Standard (see parameter m_dhtmlEditorConfig * m_dhtmlEditorConfig above). May be a similiar problem as with ResourceParameter and default
* above). May be a similiar problem as with ResourceParameter and * value, see patch provided by pbrucha. Best solution may be to remove this special parameter
* default value, see patch provided by pbrucha. Best solution may be to * class and use a string parameter instead to directly create a DHTMLEditor.Config object.
* remove this special parameter class and use a string parameter * (pboy, 2010-09-02)
* instead to directly create a DHTMLEditor.Config object. (pboy,
* 2010-09-02)
*/ */
private class DHTMLEditorConfigParameter extends StringParameter { private class DHTMLEditorConfigParameter extends StringParameter {
@ -969,18 +919,20 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* WARNING: Does not correctly process default values, see * WARNING: Does not correctly process default values, see above!
* above!
* *
* @param value * @param value
* @param errors * @param errors
*
* @return * @return
*/ */
@Override @Override
protected Object unmarshal(String value, ErrorList errors) { protected Object unmarshal(String value, ErrorList errors) {
return DHTMLEditor.Config.valueOf(value); return DHTMLEditor.Config.valueOf(value);
} }
} }
protected static HashMap extraXMLGenerators = new HashMap(); protected static HashMap extraXMLGenerators = new HashMap();
/** /**
@ -1011,9 +963,8 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* The relative weight given to the dcKeywords element within dublinCore * The relative weight given to the dcKeywords element within dublinCore element within cms:item
* element within cms:item element when ranking search results Only used * element when ranking search results Only used by the interMedia query engine.
* by the interMedia query engine.
* *
*/ */
public Integer getKeywordSearchWeight() { public Integer getKeywordSearchWeight() {
@ -1025,8 +976,8 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* The relative weight given to title element within cms:item element * The relative weight given to title element within cms:item element when ranking search
* when ranking search results Only used by the interMedia query engine. * results Only used by the interMedia query engine.
* *
*/ */
public Integer getTitleSearchWeight() { public Integer getTitleSearchWeight() {
@ -1034,11 +985,9 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* Whether to include INPATH operators to contains clause in intermedia * Whether to include INPATH operators to contains clause in intermedia search
* search
* *
* NB - if true, INDEX MUST BE CREATED WITH PATH_SECTION_GROUP - upgrade * NB - if true, INDEX MUST BE CREATED WITH PATH_SECTION_GROUP - upgrade 6.5.0 - 6.5.1
* 6.5.0 - 6.5.1
* *
* @return * @return
*/ */
@ -1047,15 +996,15 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* for the given content type, returns a collection of steps that are * for the given content type, returns a collection of steps that are deemed irrelevant for the
* deemed irrelevant for the type. * type.
* *
* If no irrelevant steps, an empty set is returned. * If no irrelevant steps, an empty set is returned.
* *
* Steps are the names of the bebop step components that are used by the * Steps are the names of the bebop step components that are used by the authoring kit wizard
* authoring kit wizard
* *
* @param type * @param type
*
* @return * @return
*/ */
public Collection getAssetStepsToSkip(ContentType type) { public Collection getAssetStepsToSkip(ContentType type) {
@ -1074,8 +1023,7 @@ public final class CMSConfig extends AbstractConfig {
// 1st string is name of content type, 2nd string is name of asset step // 1st string is name of content type, 2nd string is name of asset step
s_log.debug("parameter read - type = " + pair[0] s_log.debug("parameter read - type = " + pair[0]
+ " - step = " + pair[1]); + " - step = " + pair[1]);
Collection typeSteps = Collection typeSteps = (Collection) s_skipAssetSteps.get(pair[0]);
(Collection) s_skipAssetSteps.get(pair[0]);
if (typeSteps == null) { if (typeSteps == null) {
typeSteps = new HashSet(); typeSteps = new HashSet();
s_skipAssetSteps.put(pair[0], typeSteps); s_skipAssetSteps.put(pair[0], typeSteps);
@ -1098,8 +1046,7 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* May be used by any content type creation form to decide whether to * May be used by any content type creation form to decide whether to validate description field
* validate description field
* *
*/ */
public boolean mandatoryDescriptions() { public boolean mandatoryDescriptions() {
@ -1107,22 +1054,21 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* Used to decide whether lifecycles (and all asociated phases) should * Used to decide whether lifecycles (and all asociated phases) should be deleted from the
* be deleted from the system when complete * system when complete
* *
* (Deleting lifecycle means that you lose a bit of historical * (Deleting lifecycle means that you lose a bit of historical information eg when was this item
* information eg when was this item unpublished) * unpublished)
*/ */
public boolean deleteFinishedLifecycles() { public boolean deleteFinishedLifecycles() {
return ((Boolean) get(m_deleteLifecycleWhenComplete)).booleanValue(); return ((Boolean) get(m_deleteLifecycleWhenComplete)).booleanValue();
} }
/** /**
* Used to decide whether to delete old notification records for expiry * Used to decide whether to delete old notification records for expiry notifications.
* notifications.
* *
* If true, notifications and messages are deleted if the notification * If true, notifications and messages are deleted if the notification is successfully sent. Any
* is successfully sent. Any send failures are retained * send failures are retained
* *
*/ */
public boolean deleteExpiryNotifications() { public boolean deleteExpiryNotifications() {
@ -1130,11 +1076,10 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* Used to decide whether to delete old notification records for * Used to decide whether to delete old notification records for workflow notifications.
* workflow notifications.
* *
* If true, notifications and messages are deleted if the notification * If true, notifications and messages are deleted if the notification is successfully sent. Any
* is successfully sent. Any send failures are retained * send failures are retained
* *
*/ */
public boolean deleteWorkflowNotifications() { public boolean deleteWorkflowNotifications() {
@ -1147,13 +1092,11 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* I'am not sure for what this method is. I found it here when I tried * I'am not sure for what this method is. I found it here when I tried figure out how add
* figure out how add multiple parts to an ContentType, like * multiple parts to an ContentType, like ccm-cms-types-contact and the Multipart article do. I
* ccm-cms-types-contact and the Multipart article do. I think this * think this method should not be here because it is only needed by one specific contenttype.
* method should not be here because it is only needed by one specific * Because of this, I think that this method and the contact are violating many rules of modern
* contenttype. Because of this, I think that this method and the * software design. Jens Pelzetter, 2009-06-02.
* contact are violating many rules of modern software design. Jens
* Pelzetter, 2009-06-02.
* *
* @return * @return
*/ */
@ -1166,12 +1109,10 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* Retrieve whether to allow creation of a new Use Context in category * Retrieve whether to allow creation of a new Use Context in category tab of content sections.
* tab of content sections. "Use Context" is used to constitute a * "Use Context" is used to constitute a category hierarchy in core. It is superseded by the
* category hierarchy in core. It is superseded by the construct * construct "Category Domain" in Terms (ccm-ldn-terms). Global parameter for all content
* "Category Domain" in Terms (ccm-ldn-terms). Global parameter for all * sections. Default is false because all installation bundles use Terms.
* content sections. Default is false because all installation bundles
* use Terms.
* *
* @return TRUE if creation is allowed, otherwise FALSE (default) * @return TRUE if creation is allowed, otherwise FALSE (default)
*/ */
@ -1186,8 +1127,8 @@ public final class CMSConfig extends AbstractConfig {
} }
/** /**
* Hide the (no longer used) legacy public site link in Workspace * Hide the (no longer used) legacy public site link in Workspace (content center) section
* (content center) section listing, true by default. * listing, true by default.
*/ */
public final boolean getHideLegacyPublicSiteLink() { public final boolean getHideLegacyPublicSiteLink() {
return ((Boolean) get(m_hideLegacyPublicSiteLink)).booleanValue(); return ((Boolean) get(m_hideLegacyPublicSiteLink)).booleanValue();
@ -1283,4 +1224,9 @@ public final class CMSConfig extends AbstractConfig {
public Integer getXmlCacheAge() { public Integer getXmlCacheAge() {
return (Integer) get(m_xmlCacheAge); return (Integer) get(m_xmlCacheAge);
} }
public Integer getLinkDescMaxLength() {
return (Integer) get(m_linkDescMaxLength);
}
} }

View File

@ -355,3 +355,8 @@ com.arsdigita.cms.xml.cache.age.title=Maximum age of an entry in the XML cache
com.arsdigita.cms.xml.cache.age.purpose=Maximum age of an entry in the XML cache com.arsdigita.cms.xml.cache.age.purpose=Maximum age of an entry in the XML cache
com.arsdigita.cms.xml.cache.age.example=60*60*24 com.arsdigita.cms.xml.cache.age.example=60*60*24
com.arsdigita.cms.xml.cache.age.format=[integer] com.arsdigita.cms.xml.cache.age.format=[integer]
com.arsdigita.cms.link_description_max_length.title=Maximum length of the description of a link.
com.arsdigita.cms.link_description_max_length.purpose=Maximum length of the description of a link.
com.arsdigita.cms.link_description_max_length.example=400
com.arsdigita.cms.link_description_max_length.format={Integer]

View File

@ -41,6 +41,8 @@ import com.arsdigita.bebop.form.Fieldset;
import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringLengthValidationListener;
import com.arsdigita.cms.CMSConfig;
import com.arsdigita.cms.ContentBundle; import com.arsdigita.cms.ContentBundle;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
@ -60,8 +62,8 @@ import java.net.URL;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Form to edit the basic properties of an Link. This form can be extended to * Form to edit the basic properties of an Link. This form can be extended to create forms for Link
* create forms for Link subclasses. * subclasses.
* *
* @version $Revision: #5 $ $Date: 2004/08/17 $ * @version $Revision: #5 $ $Date: 2004/08/17 $
* @author Nobuko Asakai (nasakai@redhat.com) * @author Nobuko Asakai (nasakai@redhat.com)
@ -73,7 +75,9 @@ public class LinkPropertyForm extends FormSection
private static final Logger s_log = Logger.getLogger(LinkPropertyForm.class); private static final Logger s_log = Logger.getLogger(LinkPropertyForm.class);
/** Name of this form */ /**
* Name of this form
*/
public static final String ID = "link_edit"; public static final String ID = "link_edit";
public static final String SSL_PROTOCOL = "https://"; public static final String SSL_PROTOCOL = "https://";
public static final String HTTP_PROTOCOL = "http://"; public static final String HTTP_PROTOCOL = "http://";
@ -90,13 +94,12 @@ public class LinkPropertyForm extends FormSection
private ContentType m_contentType; private ContentType m_contentType;
protected final String ITEM_SEARCH = "contentItem"; protected final String ITEM_SEARCH = "contentItem";
/** /**
* Constructor creates a new form to edit the Link object specified by the * Constructor creates a new form to edit the Link object specified by the item selection model
* item selection model passed in. * passed in.
* *
* @param itemModel The ItemSelectionModel to use to obtain the ContentItem * @param itemModel The ItemSelectionModel to use to obtain the ContentItem to which this link
* to which this link is (or will be) attached * is (or will be) attached
* @param link The LinkSelectionModel to use to obtain the Link to work on * @param link The LinkSelectionModel to use to obtain the Link to work on
*/ */
public LinkPropertyForm(ItemSelectionModel itemModel, public LinkPropertyForm(ItemSelectionModel itemModel,
@ -105,8 +108,8 @@ public class LinkPropertyForm extends FormSection
} }
/** /**
* Constructor creates a new form to edit the Link object specified by the * Constructor creates a new form to edit the Link object specified by the item selection model
* item selection model passed in. * passed in.
* *
* @param itemModel * @param itemModel
* @param link * @param link
@ -149,6 +152,8 @@ public class LinkPropertyForm extends FormSection
m_description = new TextArea("description"); m_description = new TextArea("description");
m_description.setCols(40); m_description.setCols(40);
m_description.setRows(5); m_description.setRows(5);
m_description.addValidationListener(new StringLengthValidationListener(CMSConfig
.getInstanceOf().getLinkDescMaxLength()));
add(new Label(GlobalizationUtil.globalize( add(new Label(GlobalizationUtil.globalize(
"cms.contenttypes.ui.description"))); "cms.contenttypes.ui.description")));
add(m_description); add(m_description);
@ -299,6 +304,7 @@ public class LinkPropertyForm extends FormSection
"cms.contenttyes.link.ui.button_reset")); "cms.contenttyes.link.ui.button_reset"));
} }
} }
}); });
m_saveCancelSection.getSaveButton().addPrintListener( m_saveCancelSection.getSaveButton().addPrintListener(
new PrintListener() { new PrintListener() {
@ -314,6 +320,7 @@ public class LinkPropertyForm extends FormSection
"cms.contenttyes.link.ui.button_create")); "cms.contenttyes.link.ui.button_create"));
} }
} }
}); });
} catch (TooManyListenersException e) { } catch (TooManyListenersException e) {
throw new UncheckedWrapperException("this cannot happen", e); throw new UncheckedWrapperException("this cannot happen", e);
@ -323,6 +330,7 @@ public class LinkPropertyForm extends FormSection
/** /**
* Retrieves the saveCancelSection. * Retrieves the saveCancelSection.
*
* @return Save/Cencel section * @return Save/Cencel section
*/ */
public SaveCancelSection getSaveCancelSection() { public SaveCancelSection getSaveCancelSection() {
@ -340,6 +348,7 @@ public class LinkPropertyForm extends FormSection
* Submission listener. Handles cancel events. * Submission listener. Handles cancel events.
* *
* @param e the FormSectionEvent * @param e the FormSectionEvent
*
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
*/ */
@Override @Override
@ -354,10 +363,10 @@ public class LinkPropertyForm extends FormSection
} }
/** /**
* Validation listener. Ensures consistency of internal vs. external link * Validation listener. Ensures consistency of internal vs. external link data
* data
* *
* @param event the FormSectionEvent * @param event the FormSectionEvent
*
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
*/ */
@Override @Override
@ -398,8 +407,7 @@ public class LinkPropertyForm extends FormSection
} else { } else {
// No idea, just throw the error // No idea, just throw the error
throw new FormProcessException("URL is not valid: " + throw new FormProcessException("URL is not valid: " + ex.getMessage());
ex.getMessage());
} }
try { try {
@ -440,8 +448,7 @@ public class LinkPropertyForm extends FormSection
// Quasimodo // Quasimodo
// The target of the link must not be the same as the owner // The target of the link must not be the same as the owner
if (m_itemModel.getSelectedItem(state).getID().equals( if (m_itemModel.getSelectedItem(state).getID().equals(
((ContentItem) data.get(ITEM_SEARCH)).getID()) ((ContentItem) data.get(ITEM_SEARCH)).getID())) {
) {
throw new FormProcessException("Link target is the same as this object."); throw new FormProcessException("Link target is the same as this object.");
} }
} }
@ -451,6 +458,7 @@ public class LinkPropertyForm extends FormSection
* Get the current ContentItem * Get the current ContentItem
* *
* @param s the PageState * @param s the PageState
*
* @return the ContentItem * @return the ContentItem
*/ */
protected ContentItem getContentItem(PageState s) { protected ContentItem getContentItem(PageState s) {
@ -461,6 +469,7 @@ public class LinkPropertyForm extends FormSection
* Take care of basic Link creation steps * Take care of basic Link creation steps
* *
* @param s the PageState * @param s the PageState
*
* @return the newly-created Link * @return the newly-created Link
*/ */
protected Link createLink(PageState s) { protected Link createLink(PageState s) {
@ -474,6 +483,7 @@ public class LinkPropertyForm extends FormSection
* Init listener. For edit actions, fills the form with current data * Init listener. For edit actions, fills the form with current data
* *
* @param fse the FormSectionEvent * @param fse the FormSectionEvent
*
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
*/ */
@Override @Override
@ -526,6 +536,7 @@ public class LinkPropertyForm extends FormSection
* Process listener. Saves/creates the new or modified Link * Process listener. Saves/creates the new or modified Link
* *
* @param fse the FormSectionEvent * @param fse the FormSectionEvent
*
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
*/ */
@Override @Override
@ -561,8 +572,9 @@ public class LinkPropertyForm extends FormSection
} }
/** /**
* Set various properties of the Link.Child clases can over-ride this method * Set various properties of the Link.Child clases can over-ride this method to add additional
* to add additional properties to Link. * properties to Link.
*
* @param link * @param link
* @param fse * @param fse
*/ */
@ -621,4 +633,5 @@ public class LinkPropertyForm extends FormSection
link.save(); link.save();
} }
} }

View File

@ -49,9 +49,9 @@ import java.math.BigDecimal;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* A form element which displays a select box of all content types available * A form element which displays a select box of all content types available under the given content
* under the given content section, and forwards to the item creation UI when * section, and forwards to the item creation UI when the user selects a content type to
* the user selects a content type to instantiate. * instantiate.
* *
* @author Stanislav Freidin (sfreidin@arsdigtia.com) * @author Stanislav Freidin (sfreidin@arsdigtia.com)
* @version $Revision: #12 $ $DateTime: 2004/08/17 23:15:09 $ * @version $Revision: #12 $ $DateTime: 2004/08/17 23:15:09 $
@ -59,10 +59,11 @@ import org.apache.log4j.Logger;
*/ */
public abstract class NewItemForm extends Form { public abstract class NewItemForm extends Form {
/** Internal logger instance to faciliate debugging. Enable logging output /**
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment * Internal logger instance to faciliate debugging. Enable logging output by editing
* and set com.arsdigita.cms.ui.authoring.NewItemForm=DEBUG by uncommenting * /WEB-INF/conf/log4j.properties int hte runtime environment and set
* or adding the line. */ * com.arsdigita.cms.ui.authoring.NewItemForm=DEBUG by uncommenting or adding the line.
*/
private static final Logger s_log = Logger.getLogger(NewItemForm.class); private static final Logger s_log = Logger.getLogger(NewItemForm.class);
private final SingleSelect m_typeWidget; private final SingleSelect m_typeWidget;
@ -72,8 +73,7 @@ public abstract class NewItemForm extends Form {
public static final String TYPE_ID = "tid"; public static final String TYPE_ID = "tid";
/** /**
* Construct a new NewItemForm. It sets a vertical BoxPanel as the component * Construct a new NewItemForm. It sets a vertical BoxPanel as the component container.
* container.
* *
* @param name the name attribute of the form. * @param name the name attribute of the form.
*/ */
@ -99,7 +99,8 @@ public abstract class NewItemForm extends Form {
m_createLabel.setIdAttr("create_label"); m_createLabel.setIdAttr("create_label");
panel.add(m_createLabel); panel.add(m_createLabel);
m_typeWidget = new SingleSelect(new BigDecimalParameter(TYPE_ID)); m_typeWidget = new SingleSelect(new BigDecimalParameter(TYPE_ID),
OptionGroup.SortMode.ALPHABETICAL_ASCENDING);
try { try {
m_typeWidget.addPrintListener(new PrintListener() { m_typeWidget.addPrintListener(new PrintListener() {
@ -113,9 +114,7 @@ public abstract class NewItemForm extends Form {
ContentSection section = getContentSection(state); ContentSection section = getContentSection(state);
ContentType parentType = null; ContentType parentType = null;
ContentTypeCollection typesCollection = null; ContentTypeCollection typesCollection = null;
BigDecimal singleTypeID = (BigDecimal) BigDecimal singleTypeID = (BigDecimal) state.getValue(new BigDecimalParameter(
state.getValue(new
BigDecimalParameter(
ItemSearch.SINGLE_TYPE_PARAM)); ItemSearch.SINGLE_TYPE_PARAM));
if (singleTypeID != null) { if (singleTypeID != null) {
@ -157,11 +156,9 @@ public abstract class NewItemForm extends Form {
if (party == null) { if (party == null) {
party = Kernel.getPublicUser(); party = Kernel.getPublicUser();
} }
PermissionDescriptor create = PermissionDescriptor create = new PermissionDescriptor(
new PermissionDescriptor(
PrivilegeDescriptor PrivilegeDescriptor
.get(SecurityManager .get(SecurityManager.CMS_NEW_ITEM),
.CMS_NEW_ITEM),
type, type,
party); party);
list = PermissionService.checkPermission(create); list = PermissionService.checkPermission(create);
@ -177,6 +174,7 @@ public abstract class NewItemForm extends Form {
typesCollection.reset(); typesCollection.reset();
} }
} }
}); });
} catch (java.util.TooManyListenersException e) { } catch (java.util.TooManyListenersException e) {
throw new UncheckedWrapperException("Too many listeners: " + e.getMessage(), e); throw new UncheckedWrapperException("Too many listeners: " + e.getMessage(), e);
@ -196,6 +194,7 @@ public abstract class NewItemForm extends Form {
/** /**
* *
* @param state * @param state
*
* @return * @return
*/ */
public BigDecimal getTypeID(PageState state) { public BigDecimal getTypeID(PageState state) {
@ -212,6 +211,7 @@ public abstract class NewItemForm extends Form {
/** /**
* Generate XML - show/hide labels/widgets * Generate XML - show/hide labels/widgets
*
* @param state * @param state
* @param parent * @param parent
*/ */
@ -233,4 +233,5 @@ public abstract class NewItemForm extends Form {
super.generateXML(state, parent); super.generateXML(state, parent);
} }
} }
} }

View File

@ -43,7 +43,7 @@ public class CheckboxGroup extends OptionGroup implements BebopConstants {
public CheckboxGroup(ArrayParameter param) { public CheckboxGroup(ArrayParameter param) {
super(param); super(param);
m_xmlElement = BEBOP_CHECKBOX; //m_xmlElement = BEBOP_CHECKBOX;
} }
/** /**
@ -60,4 +60,9 @@ public class CheckboxGroup extends OptionGroup implements BebopConstants {
protected String getElementTag() { protected String getElementTag() {
return BEBOP_CHECKBOXGROUP; return BEBOP_CHECKBOXGROUP;
} }
@Override
public String getOptionXMLElement() {
return BEBOP_CHECKBOX;
}
} }

View File

@ -133,8 +133,7 @@ public class Option extends DescriptiveComponent {
Assert.isUnlocked(this); Assert.isUnlocked(this);
Assert.exists(group); Assert.exists(group);
m_group = group; m_group = group;
m_isSelectOption = m_isSelectOption = BebopConstants.BEBOP_OPTION.equals(m_group.getOptionXMLElement());
BebopConstants.BEBOP_OPTION.equals(m_group.m_xmlElement);
} }
public final OptionGroup getGroup() { public final OptionGroup getGroup() {
@ -243,7 +242,7 @@ public class Option extends DescriptiveComponent {
*/ */
@Override @Override
public void generateXML(PageState s, Element e) { public void generateXML(PageState s, Element e) {
Element option = e.newChildElement(m_group.m_xmlElement, BEBOP_XML_NS); Element option = e.newChildElement(m_group.getOptionXMLElement(), BEBOP_XML_NS);
if ( ! m_isSelectOption ) { if ( ! m_isSelectOption ) {
option.addAttribute("name", getName()); option.addAttribute("name", getName());
} }

View File

@ -19,17 +19,23 @@
package com.arsdigita.bebop.form; package com.arsdigita.bebop.form;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.RequestLocal; import com.arsdigita.bebop.RequestLocal;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.parameters.ParameterData; import com.arsdigita.bebop.parameters.ParameterData;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.ParameterModelWrapper; import com.arsdigita.bebop.parameters.ParameterModelWrapper;
import com.arsdigita.bebop.util.BebopConstants; import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.text.Collator;
import java.util.Iterator; import java.util.Iterator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletRequestWrapper;
@ -45,71 +51,171 @@ import org.apache.log4j.Logger;
* @author Michael Pih * @author Michael Pih
* @version $Id: OptionGroup.java 738 2005-09-01 12:36:52Z sskracic $ * @version $Id: OptionGroup.java 738 2005-09-01 12:36:52Z sskracic $
*/ */
public abstract class OptionGroup extends Widget public abstract class OptionGroup extends Widget implements BebopConstants {
implements BebopConstants {
private static final Logger s_log = Logger.getLogger(OptionGroup.class); private static final Logger LOGGER = Logger.getLogger(OptionGroup.class);
/** /**
* The XML element to be used by individual options belonging to this group. This variable has * The XML element to be used by individual options belonging to this group. This variable has
* to be initialized by every subclass of OptionGroup. LEGACY: An abstract method would be the * to be initialized by every subclass of OptionGroup. LEGACY: An abstract method would be the
* better design, but changing it would break the API. * better design, but changing it would break the API.
*/ */
protected String m_xmlElement; //protected String m_xmlElement;
// this only needs to be an ArrayList for multiple selection option groups // this only needs to be an ArrayList for multiple selection option groups
private ArrayList m_selected; private List<String> m_selected;
private ArrayList m_options; private List<Option> m_options;
private Widget m_otherOption = null; private Widget m_otherOption = null;
private Form m_form = null; private Form m_form = null;
private boolean m_isDisabled = false; private boolean m_isDisabled = false;
private boolean m_isReadOnly = false; private boolean m_isReadOnly = false;
/**
* Sort Mode for options
*/
private OptionGroup.SortMode sortMode;
/**
* Exclude first option from sorting?
*/
private boolean excludeFirst;
public static final String OTHER_OPTION = "__other__"; public static final String OTHER_OPTION = "__other__";
// request-local copy of selected elements, options // request-local copy of selected elements, options
private RequestLocal m_requestOptions = new RequestLocal() { private RequestLocal m_requestOptions = new RequestLocal() {
@Override @Override
public Object initialValue(PageState ps) { public Object initialValue(final PageState state) {
return new ArrayList(); return new ArrayList<Option>();
} }
}; };
@Override
public final boolean isCompound() { public final boolean isCompound() {
return true; return true;
} }
// this is only used for single selection option groups // this is only used for single selection option groups
private final static String TOO_MANY_OPTIONS_SELECTED private final static String TOO_MANY_OPTIONS_SELECTED
= "Only one option may be selected by default on this option group."; = "Only one option may be selected by default on this option group.";
/** /**
* The ParameterModel for mutliple OptionGroups is always an array parameter * The ParameterModel for mutliple OptionGroups is always an array parameter
*
* @param model
*/ */
protected OptionGroup(ParameterModel model) { protected OptionGroup(final ParameterModel model) {
//super(model);
//m_options = new ArrayList<Option>();
//m_selected = new ArrayList<String>();
this(model, OptionGroup.SortMode.NO_SORT, false);
}
protected OptionGroup(final ParameterModel model,
final OptionGroup.SortMode sortMode) {
this(model, sortMode, false);
}
protected OptionGroup(final ParameterModel model,
final OptionGroup.SortMode sortMode,
final boolean excludeFirst) {
super(model); super(model);
m_options = new ArrayList(); m_options = new ArrayList<Option>();
m_selected = new ArrayList(); m_selected = new ArrayList<String>();
this.sortMode = sortMode;
this.excludeFirst = excludeFirst;
} }
/** /**
* Returns an Iterator of all the default Options in this group. * Returns an Iterator of all the default Options in this group.
*
* @return
*/ */
public Iterator getOptions() { public Iterator<Option> getOptions() {
return m_options.iterator(); return m_options.iterator();
} }
public enum SortMode {
NO_SORT,
ALPHABETICAL_ASCENDING,
ALPHABETICAL_DESENDING
}
public abstract String getOptionXMLElement();
/**
* This {@link Comparator} implementation is used to sort the list of options alphabetical. If
* the sorting is ascending or descending depends on the selected sort mode. The Comparator
* needs the {@link PageState} for retrieving the localised labels from the options.
*/
private class AlphabeticalSortComparator implements Comparator<Option> {
private final PageState state;
/**
* Constructor taking the current {@code PageState}.
*
* @param state
*/
public AlphabeticalSortComparator(final PageState state) {
this.state = state;
}
@Override
public int compare(final Option option1, final Option option2) {
String label1;
String label2;
//Check if the first option to compare has a inner label component. If it has
//store the localised text. Otherwise use the name of the option.
if (option1.getComponent() instanceof Label) {
final Label label = (Label) option1.getComponent();
label1 = label.getLabel(state);
} else {
label1 = option1.getName();
}
// Same for the second option
if (option2.getComponent() instanceof Label) {
final Label label = (Label) option2.getComponent();
label2 = label.getLabel(state);
} else {
label2 = option2.getName();
}
//We are using a Collator instance here instead of String#compare(String) because
//String#compare(String) is not local sensitive. For example in german a word starting
//with the letter 'Ö' should be handled like a word starting with the letter 'O'.
//Using String#compare(String) would put them at the end of the list.
//Depending on the sort mode we compare label1 with label2 (ascending) or label2 with
//label1 (descending).
final Collator collator = Collator
.getInstance(GlobalizationHelper.getNegotiatedLocale());
if (sortMode == SortMode.ALPHABETICAL_ASCENDING) {
return collator.compare(label1, label2);
} else if (sortMode == SortMode.ALPHABETICAL_DESENDING) {
return collator.compare(label2, label1);
} else {
return 0;
}
}
}
/** /**
* Returns an Iterator of all the default Options in this group, plus any request-specific * Returns an Iterator of all the default Options in this group, plus any request-specific
* options. * options.
*
* @param state
*
* @return
*/ */
public Iterator getOptions(PageState ps) { public Iterator<Option> getOptions(final PageState state) {
ArrayList allOptions = new ArrayList(); List<Option> allOptions = new ArrayList<Option>();
allOptions.addAll(m_options); allOptions.addAll(m_options);
ArrayList requestOptions = (ArrayList) m_requestOptions.get(ps); List<Option> requestOptions = (List<Option>) m_requestOptions.get(state);
for (Iterator i = requestOptions.iterator(); i.hasNext();) { for (Iterator<Option> iterator = requestOptions.iterator(); iterator.hasNext();) {
Object obj = i.next(); final Option option = iterator.next();
if (!allOptions.contains(obj)) { if (!allOptions.contains(option)) {
allOptions.add(obj); allOptions.add(option);
} }
} }
return allOptions.iterator(); return allOptions.iterator();
@ -117,74 +223,74 @@ public abstract class OptionGroup extends Widget
public void clearOptions() { public void clearOptions() {
Assert.isUnlocked(this); Assert.isUnlocked(this);
m_options = new ArrayList(); m_options = new ArrayList<Option>();
} }
/** /**
* Adds a new option. * Adds a new option.
* *
* @param opt The {@link Option} to be added. Note: the argument is modified and associated with * @param option The {@link Option} to be added. Note: the argument is modified and associated
* this OptionGroup, regardless of what its group was. * with this OptionGroup, regardless of what its group was.
*/ */
public void addOption(Option opt) { public void addOption(final Option option) {
addOption(opt, null, false); addOption(option, null, false);
} }
public void addOption(Option opt, PageState ps) { public void addOption(final Option option, final PageState state) {
addOption(opt, ps, false); addOption(option, state, false);
} }
/** /**
* Adds a new option.at the beginning of the list * Adds a new option.at the beginning of the list
* *
* @param opt The {@link Option} to be added. Note: the argument is modified and associated with * @param option The {@link Option} to be added. Note: the argument is modified and associated
* this OptionGroup, regardless of what its group was. * with this OptionGroup, regardless of what its group was.
*/ */
public void prependOption(Option opt) { public void prependOption(final Option option) {
addOption(opt, null, true); addOption(option, null, true);
} }
public void prependOption(Option opt, PageState ps) { public void prependOption(final Option option, final PageState state) {
addOption(opt, ps, true); addOption(option, state, true);
} }
public void removeOption(Option opt) { public void removeOption(final Option option) {
removeOption(opt, null); removeOption(option, null);
} }
/** /**
* Adds a new option for the scope of the current request, or to the page as a whole if there is * Adds a new option for the scope of the current request, or to the page as a whole if there is
* no current request. * no current request.
* *
* @param opt The {@link Option} to be added. Note: the argument is modified and associated * @param option The {@link Option} to be added. Note: the argument is modified and associated
* with this OptionGroup, regardless of what its group was. * with this OptionGroup, regardless of what its group was.
* @param ps the current page state. if ps is null, adds option to the default option list. * @param state the current page state. if ps is null, adds option to the default option list.
* @param prepend If true, prepend option to the list instead of appending it * @param prepend If true, prepend option to the list instead of appending it
*/ */
public void addOption(Option opt, PageState ps, boolean prepend) { public void addOption(final Option option, final PageState state, final boolean prepend) {
ArrayList list = m_options; List<Option> list = m_options;
if (ps == null) { if (state == null) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
} else { } else {
list = (ArrayList) m_requestOptions.get(ps); list = (List<Option>) m_requestOptions.get(state);
} }
opt.setGroup(this); option.setGroup(this);
if (prepend == true) { if (prepend == true) {
list.add(0, opt); list.add(0, option);
} else { } else {
list.add(opt); list.add(option);
} }
} }
public void removeOption(Option opt, PageState ps) { public void removeOption(final Option option, final PageState state) {
ArrayList list = m_options; List<Option> list = m_options;
if (ps == null) { if (state == null) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
} else { } else {
list = (ArrayList) m_requestOptions.get(ps); list = (List<Option>) m_requestOptions.get(state);
} }
list.remove(opt); list.remove(option);
} }
public void removeOption(String key) { public void removeOption(String key) {
@ -194,22 +300,22 @@ public abstract class OptionGroup extends Widget
/** /**
* Removes the first option whose key is isEqual to the key that is passed in. * Removes the first option whose key is isEqual to the key that is passed in.
*/ */
public void removeOption(String key, PageState ps) { public void removeOption(final String key, final PageState state) {
// This is not an entirely efficient technique. A more // This is not an entirely efficient technique. A more
// efficient solution is to switch to using a HashMap. // efficient solution is to switch to using a HashMap.
ArrayList list = m_options; List<Option> list = m_options;
if (ps == null) { if (state == null) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
} else { } else {
list = (ArrayList) m_requestOptions.get(ps); list = (List<Option>) m_requestOptions.get(state);
} }
Iterator i = list.iterator(); final Iterator<Option> iterator = list.iterator();
Option o = null; Option option;
while (i.hasNext()) { while (iterator.hasNext()) {
o = (Option) i.next(); option = iterator.next();
if (o.getValue().equals(key)) { if (option.getValue().equals(key)) {
list.remove(o); list.remove(option);
break; break;
} }
} }
@ -219,15 +325,15 @@ public abstract class OptionGroup extends Widget
/** /**
* Add an "Other (please specify)" type option to the widget * Add an "Other (please specify)" type option to the widget
* *
* @param hasOtherOption true is the widget has an "Other" option * @param label
* @param width The width, in characters, of the "Other" entry area * @param width The width, in characters, of the "Other" entry area
* @param height The height, in characters, of the "Other" entry area. If this is 1 then * @param height The height, in characters, of the "Other" entry area. If this is 1 then a
* a TextField is used. Otherwise a TextArea is used. * TextField is used. Otherwise a TextArea is used.
*/ */
public void addOtherOption(String label, int width, int height) { public void addOtherOption(final String label, final int width, final int height) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
Option otherOption = new Option(OTHER_OPTION, label); final Option otherOption = new Option(OTHER_OPTION, label);
addOption(otherOption); addOption(otherOption);
final ParameterModel model = getParameterModel(); final ParameterModel model = getParameterModel();
@ -276,14 +382,14 @@ public abstract class OptionGroup extends Widget
} }
} }
s_log.debug("createParameterData in OptionGroup"); LOGGER.debug("createParameterData in OptionGroup");
return super.createParameterData(new HttpServletRequestWrapper(request) { return super.createParameterData(new HttpServletRequestWrapper(request) {
@Override @Override
public String[] getParameterValues(String key) { public String[] getParameterValues(String key) {
if (s_log.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
s_log.debug("Getting values for " + key); LOGGER.debug("Getting values for " + key);
} }
if (model.getName().equals(key)) { if (model.getName().equals(key)) {
@ -307,12 +413,12 @@ public abstract class OptionGroup extends Widget
* *
* @param value the value of the option to be added to the by-default-selected set. * @param value the value of the option to be added to the by-default-selected set.
*/ */
public void setOptionSelected(String value) { public void setOptionSelected(final String value) {
Assert.isUnlocked(this); Assert.isUnlocked(this);
if (!isMultiple()) { if (!isMultiple()) {
// only one option may be selected // only one option may be selected
// to this selected list better be empty // to this selected list better be empty
Assert.isTrue(m_selected.size() == 0, TOO_MANY_OPTIONS_SELECTED); Assert.isTrue(m_selected.isEmpty(), TOO_MANY_OPTIONS_SELECTED);
m_selected.add(value); m_selected.add(value);
getParameterModel().setDefaultValue(value); getParameterModel().setDefaultValue(value);
} else { } else {
@ -332,9 +438,11 @@ public abstract class OptionGroup extends Widget
@Override @Override
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {
OptionGroup cloned = (OptionGroup) super.clone(); final OptionGroup cloned = (OptionGroup) super.clone();
cloned.m_options = (ArrayList) m_options.clone(); //cloned.m_options = m_options.clone();
cloned.m_selected = (ArrayList) m_selected.clone(); //cloned.m_selected = m_selected.clone();
cloned.m_options.addAll(m_options);
cloned.m_selected.addAll(m_selected);
return cloned; return cloned;
} }
@ -373,7 +481,7 @@ public abstract class OptionGroup extends Widget
} }
@Override @Override
public void setForm(Form form) { public void setForm(final Form form) {
m_form = form; m_form = form;
if (null != m_otherOption) { if (null != m_otherOption) {
m_otherOption.setForm(form); m_otherOption.setForm(form);
@ -387,14 +495,15 @@ public abstract class OptionGroup extends Widget
* <p> * <p>
* Generates DOM fragment: * Generates DOM fragment:
* <p> * <p>
* <pre><code>&lt;bebop:* name=... [onXXX=...]&gt; * <
* pre><code>&lt;bebop:* name=... [onXXX=...]&gt;
* &lt;bebop:option name=... [selected]&gt; option value &lt;/bebop:option%gt; * &lt;bebop:option name=... [selected]&gt; option value &lt;/bebop:option%gt;
* ... * ...
* &lt;/bebop:*select&gt;</code></pre> * &lt;/bebop:*select&gt;</code></pre>
*/ */
@Override @Override
public void generateWidget(PageState state, Element parent) { public void generateWidget(final PageState state, final Element parent) {
Element optionGroup = parent.newChildElement(getElementTag(), BEBOP_XML_NS); final Element optionGroup = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
optionGroup.addAttribute("name", getName()); optionGroup.addAttribute("name", getName());
optionGroup.addAttribute("class", getName().replace(".", " ")); optionGroup.addAttribute("class", getName().replace(".", " "));
if (getLabel() != null) { if (getLabel() != null) {
@ -405,11 +514,35 @@ public abstract class OptionGroup extends Widget
} }
exportAttributes(optionGroup); exportAttributes(optionGroup);
for (Iterator i = getOptions(state); i.hasNext();) { //Build a list of all options we can operator on.
Option o = (Option) i.next(); final List<Option> options = new ArrayList<Option>();
o.generateXML(state, optionGroup); for (Iterator<Option> iterator = getOptions(state); iterator.hasNext();) {
options.add(iterator.next());
} }
//If the sort mode is not {@code NO_SORT}, sort the the list.
if (sortMode != SortMode.NO_SORT) {
//If exclude first is sest to true the first option should stay on the top.
//We simply remove the first option from our list and generate the XML for it here.
if (excludeFirst && !options.isEmpty()) {
final Option first = options.remove(0);
first.generateXML(state, optionGroup);
}
//Sort the list using our {@link AlphabeticalSortComparator}.
Collections.sort(options, new AlphabeticalSortComparator(state));
}
//Generate the XML for the options.
for (Option option : options) {
option.generateXML(state, optionGroup);
}
// for (Iterator<Option> iterator = getOptions(state); iterator.hasNext();) {
// Option option = iterator.next();
// option.generateXML(state, optionGroup);
// }
if (null != m_otherOption) { if (null != m_otherOption) {
m_otherOption.generateXML(state, optionGroup); m_otherOption.generateXML(state, optionGroup);
} }

View File

@ -57,7 +57,7 @@ public class RadioGroup extends OptionGroup implements BebopConstants {
public RadioGroup(ParameterModel model) { public RadioGroup(ParameterModel model) {
super(model); super(model);
m_xmlElement = BEBOP_RADIO; //m_xmlElement = BEBOP_RADIO;
} }
/** /**
@ -74,6 +74,11 @@ public class RadioGroup extends OptionGroup implements BebopConstants {
return BEBOP_RADIOGROUP; return BEBOP_RADIOGROUP;
} }
@Override
public String getOptionXMLElement() {
return BEBOP_RADIO;
}
/** /**
* Is this a multiple (and not single) selection option group? * Is this a multiple (and not single) selection option group?
* *

View File

@ -36,9 +36,20 @@ import com.arsdigita.bebop.util.BebopConstants;
* @version $Id: Select.java 738 2005-09-01 12:36:52Z sskracic $ */ * @version $Id: Select.java 738 2005-09-01 12:36:52Z sskracic $ */
public abstract class Select extends OptionGroup implements BebopConstants { public abstract class Select extends OptionGroup implements BebopConstants {
public Select(ParameterModel model) { public Select(final ParameterModel model) {
super(model); super(model);
m_xmlElement = BEBOP_OPTION; //m_xmlElement = BEBOP_OPTION;
}
public Select(final ParameterModel model,
final OptionGroup.SortMode sortMode) {
super(model, sortMode);
}
public Select(final ParameterModel model,
final OptionGroup.SortMode sortMode,
final boolean excludeFirst) {
super(model, sortMode, excludeFirst);
} }
/** /**
@ -68,4 +79,8 @@ public abstract class Select extends OptionGroup implements BebopConstants {
* @return The tag to be used for the top level DOM element * @return The tag to be used for the top level DOM element
* generated for this type of Widget. */ * generated for this type of Widget. */
protected abstract String getElementTag(); protected abstract String getElementTag();
public String getOptionXMLElement() {
return BEBOP_OPTION;
}
} }

View File

@ -22,8 +22,7 @@ import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
/** /**
* A class representing an HTML <code>SELECT</code> element with * A class representing an HTML <code>SELECT</code> element with a single selection.
* a single selection.
* *
* @author Karl Goldstein * @author Karl Goldstein
* @author Uday Mathur * @author Uday Mathur
@ -34,41 +33,56 @@ import com.arsdigita.bebop.parameters.ParameterModel;
*/ */
public class SingleSelect extends Select { public class SingleSelect extends Select {
/** The XML tag. /**
* @return The tag to be used for the top level DOM element * The XML tag.
* generated for this type of Widget. *
* @return The tag to be used for the top level DOM element generated for this type of Widget.
*/ */
protected String getElementTag() { protected String getElementTag() {
return BEBOP_SELECT; return BEBOP_SELECT;
} }
/** /**
* Creates a new SingleSelect widget, using a StringParameter model * Creates a new SingleSelect widget, using a StringParameter model with the given parameter
* with the given parameter name. Since you can only have one * name. Since you can only have one item selected from a SingleSelect, the string parameter
* item selected from a SingleSelect, the string parameter returns * returns the value of the selected option.
* the value of the selected option. * <p>
* <p>This is equivalent to * This is equivalent to <code>SingleSelect(new StringParameter(name))</code>
* <code>SingleSelect(new StringParameter(name))</code> *
* @param name the name of the string parameter * @param name the name of the string parameter
*/ */
public SingleSelect(String name) { public SingleSelect(final String name) {
super(new StringParameter(name)); super(new StringParameter(name));
} }
/** /**
* Creates a new SingleSelect widget, using the given * Creates a new SingleSelect widget, using the given parameter model.
* parameter model. *
* @param model the parameter model * @param model the parameter model
*/ */
public SingleSelect(ParameterModel model) { public SingleSelect(final ParameterModel model) {
super(model); super(model);
} }
/** State that this is a single select public SingleSelect(final ParameterModel model,
final OptionGroup.SortMode sortMode) {
super(model, sortMode);
}
public SingleSelect(final ParameterModel model,
final OptionGroup.SortMode sortMode,
final boolean excludeFirst) {
super(model, sortMode, excludeFirst);
}
/**
* State that this is a single select
*
* @return false * @return false
*/ */
@Override @Override
public boolean isMultiple() { public boolean isMultiple() {
return false; return false;
} }
} }

View File

@ -41,6 +41,7 @@ import com.arsdigita.cms.ui.CMSDHTMLEditor;
import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.globalization.GlobalizationHelper; import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import java.text.Collator;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.Locale; import java.util.Locale;
@ -105,8 +106,11 @@ public class PublicationPropertyForm
@Override @Override
public int compare(final Locale locale1, final Locale locale2) { public int compare(final Locale locale1, final Locale locale2) {
return locale1.getDisplayName(GlobalizationHelper.getNegotiatedLocale()).compareTo( final Locale negLocale = GlobalizationHelper.getNegotiatedLocale();
locale2.getDisplayName(GlobalizationHelper.getNegotiatedLocale())); final Collator collator = Collator.getInstance(negLocale);
return collator.compare(locale1.getDisplayName(negLocale),
locale2.getDisplayName(negLocale));
} }
}); });