From: <ap...@vh...> - 2006-04-18 14:04:29
|
Author: apevec Date: 2006-04-18 16:02:10 +0200 (Tue, 18 Apr 2006) New Revision: 1110 Added: trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig_parameter.properties trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java Modified: trunk/ccm-cms-assets-fileattachment/application.xml trunk/ccm-cms-assets-fileattachment/src/ccm-cms-assets-fileattachment.config trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsStep.java trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsTable.java Log: make File edit form pluggable: new configuration parameter com.arsdigita.cms.contentassets.file_edit_form default is existing com.arsdigita.cms.contentassets.ui.FileDescriptionForm which edits just Asset.description property Modified: trunk/ccm-cms-assets-fileattachment/application.xml =================================================================== --- trunk/ccm-cms-assets-fileattachment/application.xml 2006-04-18 13:57:35 UTC (rev 1109) +++ trunk/ccm-cms-assets-fileattachment/application.xml 2006-04-18 14:02:10 UTC (rev 1110) @@ -2,8 +2,8 @@ <ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project" name="ccm-cms-assets-fileattachment" prettyName="Red Hat CMS Content Asset File Attachment" - version="6.3.0" - release="3" + version="6.3.1" + release="1" webapp="ROOT"> <ccm:dependencies> <ccm:requires name="ccm-core" version="6.2.0" relation="ge"/> @@ -19,6 +19,6 @@ <ccm:contact uri="mailto:cc...@re..." type="support"/> </ccm:contacts> <ccm:description> - The Related Link Asset for the Red Hat CMS. + The Content Asset File Attachment for the Red Hat CMS. </ccm:description> </ccm:application> Modified: trunk/ccm-cms-assets-fileattachment/src/ccm-cms-assets-fileattachment.config =================================================================== --- trunk/ccm-cms-assets-fileattachment/src/ccm-cms-assets-fileattachment.config 2006-04-18 13:57:35 UTC (rev 1109) +++ trunk/ccm-cms-assets-fileattachment/src/ccm-cms-assets-fileattachment.config 2006-04-18 14:02:10 UTC (rev 1110) @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <registry> - <!-- nothing yet --> + <config class="com.arsdigita.cms.contentassets.FileAttachmentConfig" + storage="ccm-cms-assets-fileattachment/fa.properties"/> </registry> Modified: trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java =================================================================== --- trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java 2006-04-18 13:57:35 UTC (rev 1109) +++ trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java 2006-04-18 14:02:10 UTC (rev 1110) @@ -48,9 +48,13 @@ public static final String FILE_ATTACHMENTS = "fileAttachments"; public static final String FILE_ORDER = "fileOrder"; - /** - * Default constructor. This creates a new ProjectSupportBaseItem; - **/ + private static final FileAttachmentConfig s_config = new FileAttachmentConfig(); + + static { + s_config.load(); + } + + public FileAttachment() { super(BASE_DATA_OBJECT_TYPE); } @@ -284,4 +288,9 @@ if( null != fileOwner ) PermissionService.setContext( this, fileOwner ); } + + public static FileAttachmentConfig getConfig() { + return s_config; + } + } Added: trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java =================================================================== --- trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java 2006-04-18 13:57:35 UTC (rev 1109) +++ trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java 2006-04-18 14:02:10 UTC (rev 1110) @@ -0,0 +1,28 @@ +package com.arsdigita.cms.contentassets; + +import com.arsdigita.cms.contentassets.ui.FileDescriptionForm; +import com.arsdigita.runtime.AbstractConfig; +import com.arsdigita.util.parameter.ClassParameter; +import com.arsdigita.util.parameter.Parameter; + +public class FileAttachmentConfig extends AbstractConfig { + + Parameter editFormClass; + + public FileAttachmentConfig() { + editFormClass = new ClassParameter ("com.arsdigita.cms.contentassets.file_edit_form", + Parameter.REQUIRED, + FileDescriptionForm.class + // TODO move *private* class ContentSectionConfig.SpecificClassParameter to c.a.util.parameter + // so we can use it here. + // , FormSection.class + ); + register(editFormClass); + loadInfo(); + } + + public Class getEditFormClass() { + return (Class) get(editFormClass); + } + +} Added: trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig_parameter.properties =================================================================== --- trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig_parameter.properties 2006-04-18 13:57:35 UTC (rev 1109) +++ trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig_parameter.properties 2006-04-18 14:02:10 UTC (rev 1110) @@ -0,0 +1,4 @@ +com.arsdigita.cms.contentassets.file_edit_form.title=File asset edit form +com.arsdigita.cms.contentassets.file_edit_form.purpose=A form for editing file asset properties. Default implementation edits Assets.description property. +com.arsdigita.cms.contentassets.file_edit_form.example=com.arsdigita.cms.contentassets.ui.FileDescriptionForm +com.arsdigita.cms.contentassets.file_edit_form.format=[class] Modified: trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsStep.java =================================================================== --- trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsStep.java 2006-04-18 13:57:35 UTC (rev 1109) +++ trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsStep.java 2006-04-18 14:02:10 UTC (rev 1110) @@ -22,6 +22,7 @@ import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SaveCancelSection; +import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionListener; import com.arsdigita.bebop.event.FormInitListener; @@ -31,9 +32,12 @@ import com.arsdigita.bebop.event.FormValidationListener; import com.arsdigita.bebop.event.PrintEvent; import com.arsdigita.bebop.event.PrintListener; +import com.arsdigita.bebop.form.Submit; import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.parameters.BigDecimalParameter; +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.contentassets.FileAttachment; import com.arsdigita.cms.ui.CMSContainer; @@ -42,7 +46,10 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; import com.arsdigita.cms.ui.workflow.WorkflowLockedContainer; import com.arsdigita.cms.util.GlobalizationUtil; +import com.arsdigita.london.cms.dublin.ui.DublinCoreForm; +import com.arsdigita.london.cms.dublin.ui.DublinCoreFormSection; import com.arsdigita.persistence.DataCollection; +import com.arsdigita.util.Classes; /** * Authoring step for file attachments @@ -62,9 +69,10 @@ private BigDecimalParameter m_fileParam = new BigDecimalParameter("fa"); private FileAttachmentSelectionModel m_fileModel = new FileAttachmentSelectionModel(m_fileParam); + private Submit m_cancel; + private Form m_dcForm; public FileAttachmentsStep(ItemSelectionModel itemModel,AuthoringKitWizard parent) { - super(); m_parent = parent; m_item = itemModel; @@ -91,14 +99,21 @@ m_display.add(mainLabel); m_display.add(m_fileList); setDisplayComponent(m_display); + // The upload form. m_uploadForm = new FileAttachmentUpload(m_item); add("upload", "Upload a new file", new WorkflowLockedComponentAccess(m_uploadForm, m_item), m_uploadForm.getSaveCancelSection().getCancelButton()); - Form form = new Form("descriptionEdit"); - form.add(new FileDescriptionForm(m_item, m_fileModel)); + // File asset metadata form. + Form form = new Form("faEdit"); + Class editFormClass = FileAttachment.getConfig().getEditFormClass(); + FormSection editForm = (FormSection) + Classes.newInstance(editFormClass, + new Class[] { FileAttachmentSelectionModel.class }, + new Object[] { m_fileModel }); + form.add(editForm); WorkflowLockedContainer edit = new WorkflowLockedContainer(m_item); edit.add(form); @@ -127,123 +142,4 @@ return m_item; } - /** - * Form to edit the description of a file attachment. - */ - private class FileDescriptionForm extends FormSection - implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener { - - private TextArea m_description; - private ItemSelectionModel m_itemModel; - private FileAttachmentSelectionModel m_fileModel; - private SaveCancelSection m_saveCancelSection; - - /** - * Creates a new form to edit the FileAttachment description - * by the item selection model passed in. - * @param itemModel The ItemSelectionModel to use to obtain the - * ContentItem to which this file is attached - * @param file The FileAttachmentSelectionModel to use to obtain the - * FileAttachment to work on - */ - public FileDescriptionForm(ItemSelectionModel itemModel, - FileAttachmentSelectionModel file ) { - super(new ColumnPanel(2)); - m_fileModel = file; - m_itemModel = itemModel; - - addWidgets(); - m_saveCancelSection = new SaveCancelSection(); - add(m_saveCancelSection, ColumnPanel.FULL_WIDTH); - - addInitListener(this); - addValidationListener(this); - addProcessListener(this); - addSubmissionListener(this); - } - - /** - * Adds widgets to the form. - */ - protected void addWidgets() { - m_description = new TextArea("description"); - m_description.setCols(40); - m_description.setRows(5); - add(new Label(GlobalizationUtil. - globalize("cms.contenttypes.ui.description"))); - - add(m_description); - } - - /** - * Submission listener. Handles cancel events. - * - * @param e the FormSectionEvent - */ - public void submitted(FormSectionEvent e) - throws FormProcessException { - if (m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) { - m_fileModel.clearSelection(e.getPageState()); - init(e); - throw new FormProcessException("cancelled"); - } - } - - /** - * Validation listener. - * - * @param event the FormSectionEvent - */ - public void validate(FormSectionEvent event) - throws FormProcessException { - PageState state = event.getPageState(); - FormData data = event.getFormData(); - - String description = (String)m_description.getValue(state); - // not performing any check - } - - - /** - * Init listener. - * - * @param fse the FormSectionEvent - */ - public void init( FormSectionEvent fse ) throws FormProcessException { - FormData data = fse.getFormData(); - PageState state = fse.getPageState(); - if (m_fileModel.isSelected(state)) { - setVisible(state, true); - FileAttachment file = m_fileModel.getSelectedFileAttachment(state); - m_description.setValue(state, file.getDescription()); - } else { - setVisible(state, false); - } - } - - - /** - * Process listener. Edits the file description. - * - * @param fse the FormSectionEvent - */ - public void process( FormSectionEvent fse ) throws FormProcessException { - PageState state = fse.getPageState(); - - // save only if save button was pressed - if ( m_saveCancelSection.getCancelButton().isSelected(state) ) { - // cancel button is selected - m_fileModel.clearSelection(state); - } else { - if (m_fileModel.isSelected(state)) { - FileAttachment file = m_fileModel.getSelectedFileAttachment(state); - file.setDescription( (String) m_description.getValue(state)); - } - } - m_fileModel.clearSelection(state); - init(fse); - } - - } - } Modified: trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsTable.java =================================================================== --- trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsTable.java 2006-04-18 13:57:35 UTC (rev 1109) +++ trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsTable.java 2006-04-18 14:02:10 UTC (rev 1110) @@ -251,15 +251,11 @@ Object key, int row, int column) { - SimpleContainer filesc = new SimpleContainer(); final String downloadKey = (String)key; FileAttachment attachment = new FileAttachment(new BigDecimal(downloadKey)); - Link downloadLink = new Link(attachment.getDisplayName(), - Utilities.getAssetURL(attachment)); - filesc.add(downloadLink); - - return filesc; + return new Link(attachment.getDisplayName(), + Utilities.getAssetURL(attachment)); } } } Added: trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java =================================================================== --- trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java 2006-04-18 13:57:35 UTC (rev 1109) +++ trunk/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java 2006-04-18 14:02:10 UTC (rev 1110) @@ -0,0 +1,141 @@ +package com.arsdigita.cms.contentassets.ui; + +import com.arsdigita.bebop.ColumnPanel; +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.FormSection; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.SaveCancelSection; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.FormSubmissionListener; +import com.arsdigita.bebop.event.FormValidationListener; +import com.arsdigita.bebop.form.Submit; +import com.arsdigita.bebop.form.TextArea; +import com.arsdigita.cms.contentassets.FileAttachment; +import com.arsdigita.cms.util.GlobalizationUtil; + +/** + * Form to edit the description of a file attachment. File description edit + * form, default class for <code>com.arsdigita.cms.contentassets.file_edit_form</code> + * configuration parameter. Edits property Asset.description + */ +public class FileDescriptionForm extends FormSection implements + FormInitListener, FormProcessListener, FormValidationListener, + FormSubmissionListener { + + private TextArea m_description; + + private FileAttachmentSelectionModel m_fileModel; + + private Submit m_cancel; + + /** + * Creates a new form to edit the FileAttachment description by the item + * selection model passed in. + * + * @param file + * The FileAttachmentSelectionModel to use to obtain the + * FileAttachment to work on + */ + public FileDescriptionForm(FileAttachmentSelectionModel file) { + super(new ColumnPanel(2)); + m_fileModel = file; + + addWidgets(); + SaveCancelSection saveCancel = new SaveCancelSection(); + m_cancel = saveCancel.getCancelButton(); + add(saveCancel, ColumnPanel.FULL_WIDTH); + + addInitListener(this); + addSubmissionListener(this); + addValidationListener(this); + addProcessListener(this); + } + + /** + * Adds widgets to the form. + */ + protected void addWidgets() { + m_description = new TextArea("description"); + m_description.setCols(40); + m_description.setRows(5); + add(new Label(GlobalizationUtil + .globalize("cms.contenttypes.ui.description"))); + + add(m_description); + } + + /** + * Submission listener. Handles cancel events. + * + * @param e + * the FormSectionEvent + */ + public void submitted(FormSectionEvent e) throws FormProcessException { + if (m_cancel.isSelected(e.getPageState())) { + m_fileModel.clearSelection(e.getPageState()); + init(e); + throw new FormProcessException("cancelled"); + } + } + + /** + * Validation listener. + * + * @param event + * the FormSectionEvent + */ + public void validate(FormSectionEvent event) throws FormProcessException { + PageState state = event.getPageState(); + FormData data = event.getFormData(); + + String description = (String) m_description.getValue(state); + // not performing any check + } + + /** + * Init listener. + * + * @param fse + * the FormSectionEvent + */ + public void init(FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + if (m_fileModel.isSelected(state)) { + setVisible(state, true); + FileAttachment file = m_fileModel.getSelectedFileAttachment(state); + m_description.setValue(state, file.getDescription()); + } else { + setVisible(state, false); + } + } + + /** + * Process listener. Edits the file description. + * + * @param fse + * the FormSectionEvent + */ + public void process(FormSectionEvent fse) throws FormProcessException { + PageState state = fse.getPageState(); + + // save only if save button was pressed + if (m_cancel.isSelected(state)) { + // cancel button is selected + m_fileModel.clearSelection(state); + } else { + if (m_fileModel.isSelected(state)) { + FileAttachment file = m_fileModel + .getSelectedFileAttachment(state); + file.setDescription((String) m_description.getValue(state)); + } + } + m_fileModel.clearSelection(state); + init(fse); + } + +} |