diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java index 5f9f0c515..02c0b6605 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java @@ -44,9 +44,9 @@ public class FileAttachment extends FileAsset { public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contentassets.FileAttachment"; - public static final String FILE_OWNER = "fileOwner"; - public static final String FILE_ATTACHMENTS = "fileAttachments"; - public static final String FILE_ORDER = "fileOrder"; + public static final String FILE_OWNER = "fileOwner"; + public static final String FILE_ATTACHMENTS = "fileAttachments"; + public static final String FILE_ORDER = "fileOrder"; private static final FileAttachmentConfig s_config = new FileAttachmentConfig(); diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java index bf16c7f14..0c1e14dc0 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java @@ -1,8 +1,9 @@ package com.arsdigita.cms.contentassets; import com.arsdigita.cms.contentassets.ui.FileDescriptionForm; +import com.arsdigita.bebop.FormSection; import com.arsdigita.runtime.AbstractConfig; -import com.arsdigita.util.parameter.ClassParameter; +import com.arsdigita.util.parameter.SpecificClassParameter; import com.arsdigita.util.parameter.BooleanParameter; import com.arsdigita.util.parameter.Parameter; @@ -15,12 +16,11 @@ public class FileAttachmentConfig extends AbstractConfig { * Constructor, don't use is directly! */ public FileAttachmentConfig() { - editFormClass = new ClassParameter ("com.arsdigita.cms.contentassets.file_edit_form", + + editFormClass = new SpecificClassParameter ("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 + FileDescriptionForm.class, + FormSection.class ); showAssetID = new BooleanParameter("com.arsdigita.cms.contentassets.file_show_asset_id", Parameter.OPTIONAL, diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentGlobalize.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentGlobalize.java new file mode 100644 index 000000000..e50047ccd --- /dev/null +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentGlobalize.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2010 Peter Boy (pb@zes.uni-remen.de) + * + * The contents of this file are subject to the Open Software License v2.1 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * http://rhea.redhat.com/licenses/osl2.1.html. + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + */ + +package com.arsdigita.cms.contentassets; + +import com.arsdigita.globalization.GlobalizedMessage; + +/** + * Service routine tp provide localized versions of key strings for the + * FileAttachment UI and messages. + * + * @author pb + * @version $Id: $ + */ +public class FileAttachmentGlobalize { + + + /** + * The label for the authoring step + */ + public static GlobalizedMessage AuthoringStepLabel() { + return new GlobalizedMessage( + "com.arsdigita.cms.contentassets.file_attachment_label", + "com.arsdigita.cms.contentassets.FileAttachmentResources"); + } + + /** + * The description for the authoring step + */ + public static GlobalizedMessage AuthoringStepDescription() { + return new GlobalizedMessage( + "com.arsdigita.cms.contentassets.file_attachment_description", + "com.arsdigita.cms.contentassets.FileAttachmentResources"); + } + + /** + * Label for File Type selection box. + */ + public static GlobalizedMessage FileTypeLabel() { + return new GlobalizedMessage( + "com.arsdigita.cms.contentassets.file_type_label", + "com.arsdigita.cms.contentassets.FileAttachmentResources"); + } + + /** + * Label for File Type selection box. + */ + public static GlobalizedMessage NoFilesAssociatedMsg() { + return new GlobalizedMessage( + "com.arsdigita.cms.contentassets.no_files_associated_msg", + "com.arsdigita.cms.contentassets.FileAttachmentResources"); + } + + /** + * Label for File Type selection box. + */ + public static GlobalizedMessage UploadNewFileLabel() { + return new GlobalizedMessage( + "com.arsdigita.cms.contentassets.upload_new_file_label", + "com.arsdigita.cms.contentassets.FileAttachmentResources"); + } + + + +} diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentInitializer.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentInitializer.java index 24b5851b2..6dcb0ffd1 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentInitializer.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentInitializer.java @@ -21,7 +21,6 @@ import com.arsdigita.domain.xml.TraversalHandler; import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.kernel.URLService; import com.arsdigita.runtime.DomainInitEvent; -import com.arsdigita.runtime.LegacyInitEvent; import com.arsdigita.search.MetadataProviderRegistry; import com.arsdigita.xml.XML; @@ -32,54 +31,31 @@ import com.arsdigita.xml.XML; * @version $Revision: 1.1 $ $Date: 2004/12/15 15:37:51 $ * @version $Id: FileAttachmentInitializer.java 1262 2006-07-17 08:15:45Z cgyg9330 $ **/ - public class FileAttachmentInitializer extends ContentAssetInitializer { + /** + * Constructor + */ public FileAttachmentInitializer() { super("ccm-cms-assets-fileattachment.pdl.mf"); } - public String getTraversalXML() { - return "/WEB-INF/traversal-adapters/com/arsdigita/" - + "cms/contentassets/FileAttachment.xml"; - } + /** + * Initializes content asset by parsing traversal xml file and registering + * the specified steps in a transient storage which may be modified during + * operation and has to be re-initialized each system startup). + * Essential part of initializing the systems domain coupling machinery. - public String getProperty() { - return "fileAttachments"; - } - - public String getBaseType() { - return ContentPage.BASE_DATA_OBJECT_TYPE; - } - - public Class getAuthoringStep() { - return FileAttachmentsStep.class; - } - - public GlobalizedMessage getAuthoringStepLabel() { - return new GlobalizedMessage( - "com.arsdigita.cms.contentassets.file_attachment_label", - "com.arsdigita.cms.contentassets.FileAttachmentResources"); - } - - public GlobalizedMessage getAuthoringStepDescription() { - return new GlobalizedMessage( - "com.arsdigita.cms.contentassets.file_attachment_description", - "com.arsdigita.cms.contentassets.FileAttachmentResources"); - } - - public int getAuthoringStepSortKey() { - return 2; // XXX config param please - } - - // public void init(LegacyInitEvent evt) { + * @param evt + */ + @Override public void init(DomainInitEvent evt) { super.init(evt); - + URLService.registerFinder( FileAttachment.BASE_DATA_OBJECT_TYPE, new FileAttachmentURLFinder()); - + /* * cms registers AssetMetadataProvider for type FileAsset and provides * adapter for that context. We register a more specific metadataprovider @@ -91,14 +67,78 @@ public class FileAttachmentInitializer extends ContentAssetInitializer { * their specific adapters * * chris.gilbert@westsussex.gov.uk - */ + */ MetadataProviderRegistry.registerAdapter( FileAttachment.BASE_DATA_OBJECT_TYPE, new FileAttachmentMetadataProvider()); + XML.parseResource( "/WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/" + "FileAttachment-search.xml", new TraversalHandler()); } + + /** + * The base type against which the asset is defined, + * typically com.arsdigita.cms.ContentPage + */ + public String getBaseType() { + return ContentPage.BASE_DATA_OBJECT_TYPE; + } + + /** + * Returns the path to the XML file defintions for the + * asset, + * eg /WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/FileAttachments.xml + */ + public String getTraversalXML() { + return "/WEB-INF/traversal-adapters/com/arsdigita/" + + "cms/contentassets/FileAttachment.xml"; + } + + /** + * The name of the association between the item + * and the asset, eg 'fileAttachments'. + */ + public String getProperty() { + return "fileAttachments"; + } + + /** + * The class of the authoring kit step + */ + public Class getAuthoringStep() { + return FileAttachmentsStep.class; + } + + /** + * The label for the authoring step + * @deprecated has to be replaced to provide LabelKey, see contgentAssetInitializer + */ + public GlobalizedMessage getAuthoringStepLabel() { + return FileAttachmentGlobalize.AuthoringStepLabel(); + // return new GlobalizedMessage( + // "com.arsdigita.cms.contentassets.file_attachment_label", + // "com.arsdigita.cms.contentassets.FileAttachmentResources"); + } + + /** + * The description for the authoring step + * @deprecated has to be replaced to provide DesciptionKey, see contgentAssetInitializer + */ + public GlobalizedMessage getAuthoringStepDescription() { + return FileAttachmentGlobalize.AuthoringStepDescription(); + // return new GlobalizedMessage( + // "com.arsdigita.cms.contentassets.file_attachment_description", + // "com.arsdigita.cms.contentassets.FileAttachmentResources"); + } + + /** + * The sort key for the authoring step + */ + public int getAuthoringStepSortKey() { + return 2; // XXX config param please + } + } diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources.properties b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources.properties index 0140eec71..e8ec28261 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources.properties +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources.properties @@ -1,2 +1,7 @@ -com.arsdigita.cms.contentassets.file_attachment_label=Attach files -com.arsdigita.cms.contentassets.file_attachment_description=Attach files +cms.contentassets.file_attachment_label=Attach files +cms.contentassets.file_attachment_description=Attach files +cms.contentassets.file_type_label=File Type: +cms.contentassets.no_files_associated_msg=This item does not have any associated files. +cms.contentassets.upload_new_file_label=Upload a new file +cms.contentassets.tableheader_file=File +cms.contentassets.tableheader_description=Description diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources_de.properties b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources_de.properties index 585e70e3b..fcfd0d969 100644 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources_de.properties +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources_de.properties @@ -1,2 +1,7 @@ -com.arsdigita.cms.contentassets.file_attachment_label=Dateien anf\u00FCgen -com.arsdigita.cms.contentassets.file_attachment_description=Dateien anf\u00FCgen +cms.contentassets.file_attachment_label=Dateien anf\u00FCgen +cms.contentassets.file_attachment_description=Dateien anf\u00FCgen +cms.contentassets.file_type_label=Datei Typ: +cms.contentassets.no_files_associated_msg=Diesem Dokument sind keine Dateien zum Download zugeordnet. +cms.contentassets.upload_new_file_label=Neue Datei hochladen +cms.contentassets.tableheader_file=Datei +cms.contentassets.tableheader_description=Beschreibung diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentURLFinder.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentURLFinder.java index b676abe07..4b7647358 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentURLFinder.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentURLFinder.java @@ -42,12 +42,11 @@ public class FileAttachmentURLFinder implements URLFinder { private static final AssetURLFinder s_assetFinder = new AssetURLFinder(); /** - * - * find URL for a file attachment by finding its article - * - * @param oid the OID of the file attachment - * @param content the context of the search (ie draft/live) - */ + * Find URL for a file attachment by finding its article + * + * @param oid the OID of the file attachment + * @param content the context of the search (ie draft/live) + */ public String find(OID oid, String context) throws NoValidURLException { if (!"draft".equals(context)) return s_assetFinder.find(oid, context); @@ -74,13 +73,12 @@ public class FileAttachmentURLFinder implements URLFinder { } /** - * - * find URL for the live context of a file attachment. Delegates to - * AssetURLFinder. - * - * @param oid the OID of the file attachment - * - */ + * Find URL for the live context of a file attachment. Delegates to + * AssetURLFinder. + * + * @param oid the OID of the file attachment + * + */ public String find(OID oid) throws NoValidURLException { return s_assetFinder.find(oid); } diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentModelBuilder.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentModelBuilder.java index 1bf3b918f..c6b85b957 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentModelBuilder.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentModelBuilder.java @@ -30,7 +30,7 @@ import com.arsdigita.web.URL; /** * - * Builds a table model of contacts + * Builds a table model of ( copy and paste error:) contacts * * @author Richard Su (richard.su@alum.mit.edu) * @version $Id: FileAttachmentModelBuilder.java 1592 2007-06-21 16:48:55Z lbcfrancois $ @@ -40,6 +40,7 @@ public class FileAttachmentModelBuilder extends AbstractTableModelBuilder { private Table m_table; private ItemSelectionModel m_model; + /** * Constructor **/ diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentUpload.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentUpload.java index 9333e02be..085664198 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentUpload.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentUpload.java @@ -29,6 +29,7 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contentassets.FileAttachment; +import com.arsdigita.cms.contentassets.FileAttachmentGlobalize; import com.arsdigita.cms.ui.FileUploadSection; import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.mimetypes.ImageMimeType; @@ -123,7 +124,8 @@ public class FileAttachmentUpload extends Form // Add the widgets public void addWidgets() { m_fileUploadSection = - new FileUploadSection("File Type:", "file", + new FileUploadSection(FileAttachmentGlobalize.FileTypeLabel(), + "file", ImageMimeType.MIME_IMAGE_JPEG); m_fileUploadSection.getFileUploadWidget() .addValidationListener(new NotNullValidationListener()); diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsStep.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsStep.java index 581ddabf7..42f9d134f 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsStep.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsStep.java @@ -27,6 +27,7 @@ import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contentassets.FileAttachment; +import com.arsdigita.cms.contentassets.FileAttachmentGlobalize; import com.arsdigita.cms.ui.CMSContainer; import com.arsdigita.cms.ui.SecurityPropertyEditor; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; @@ -70,7 +71,7 @@ public class FileAttachmentsStep extends SecurityPropertyEditor { m_fileList = new FileAttachmentsTable(m_item, m_fileModel); m_display = new CMSContainer(); //Main label - Label mainLabel = new Label("This item does not have any associated files."); + Label mainLabel = new Label(FileAttachmentGlobalize.NoFilesAssociatedMsg()); mainLabel.setFontWeight(Label.ITALIC); mainLabel.addPrintListener( new PrintListener() { public void prepare(PrintEvent event) { @@ -81,7 +82,7 @@ public class FileAttachmentsStep extends SecurityPropertyEditor { Label mainTarget = (Label) event.getTarget(); if (files.isEmpty()) { mainTarget.setLabel( - "This item does not have any associated files."); + FileAttachmentGlobalize.NoFilesAssociatedMsg()); } else { mainTarget.setLabel(""); } @@ -94,7 +95,11 @@ public class FileAttachmentsStep extends SecurityPropertyEditor { // The upload form. m_uploadForm = new FileAttachmentUpload(m_item); - add("upload", "Upload a new file", + add("upload", + // XXX todo: use of tostring() is ugly and not supported API. add method + // has to be refactored to accept a GlobalizedMessage as Parameter instead + // of a plain string for the Label (2. parameter) ! + FileAttachmentGlobalize.UploadNewFileLabel().toString(), new WorkflowLockedComponentAccess(m_uploadForm, m_item), m_uploadForm.getSaveCancelSection().getCancelButton()); diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java index ad82f9996..41602c176 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java @@ -1,3 +1,17 @@ +/* + * Copyright (C) 2004 Red Hat Inc. All Rights Reserved. + * + * The contents of this file are subject to the Open Software License v2.1 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * http://rhea.redhat.com/licenses/osl2.1.html. + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + */ package com.arsdigita.cms.contentassets.ui; import com.arsdigita.bebop.ColumnPanel;