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 5904cc1a4..c6d483dcb 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
@@ -20,3 +20,4 @@ cms.contentassets.file_attachment.table_down=down
cms.contentassets.file_attachment.table_delete=delete
cms.contentassets.file_attachment.description.too_long=The description execceds the limit of {0} characters.
cms.contentassets.file_attachment.caption.too_long=The caption execceds the limit of {0} characters.
+cms.contentassets.file_attachment.title=Title:
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 a2df1f9a4..94a389d5a 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
@@ -19,3 +19,4 @@ cms.contentassets.file_attachment.table_down=nach unten
cms.contentassets.file_attachment.table_delete=l\u00f6schen
cms.contentassets.file_attachment.description.too_long=Die Beschreibung ist l\u00e4nger als {0} Zeichen.
cms.contentassets.file_attachment.caption.too_long=Die Zwischen\u00fcberschrift ist l\u00e4nger als {0} Zeichen.
+cms.contentassets.file_attachment.title=Titel:
diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentCaptionForm.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentCaptionForm.java
index 61774486f..6fee4c962 100644
--- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentCaptionForm.java
+++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentCaptionForm.java
@@ -25,7 +25,7 @@ import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormValidationListener;
-import com.arsdigita.bebop.form.TextArea;
+import com.arsdigita.bebop.form.DHTMLEditor;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.cms.ContentItem;
@@ -54,9 +54,11 @@ public class FileAttachmentCaptionForm extends Form
private FileUploadSection m_fileUploadSection;
private ItemSelectionModel m_itemModel;
private SaveCancelSection m_saveCancelSection;
- private TextArea m_captionText;
+ private DHTMLEditor m_title;
+ private DHTMLEditor m_captionText;
+
private static final FileAttachmentConfig s_config = FileAttachmentConfig
- .instanceOf();
+ .instanceOf();
/**
* Construct a new FileCaptionForm
@@ -127,19 +129,24 @@ public class FileAttachmentCaptionForm extends Form
// Add the widgets
public void addWidgets() {
+ m_title = new DHTMLEditor("captiontitle");
+ m_title.lock();
+ add(new Label(FileAttachmentGlobalizationUtil.globalize(
+ "cms.contentassets.file_attachment.title")));
+ add(m_title);
- m_captionText = new TextArea("caption");
- m_captionText.setCols(10);
- m_captionText.setRows(1);
+ m_captionText = new DHTMLEditor("caption");
+// m_captionText.setCols(10);
+// m_captionText.setRows(1);
m_captionText.addValidationListener(new NotNullValidationListener());
m_captionText.addValidationListener(new StringInRangeValidationListener(
- 0,
- s_config.getFileAttachmentDescriptionMaxLength(),
- FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength())));
+ 0,
+ s_config.getFileAttachmentDescriptionMaxLength(),
+ FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength())));
m_captionText.lock();
add(new Label(FileAttachmentGlobalizationUtil.globalize(
- "cms.contentassets.file_attachment.caption")));
+ "cms.contentassets.file_attachment.caption_or_description")));
add(m_captionText);
}
@@ -150,8 +157,7 @@ public class FileAttachmentCaptionForm extends Form
PageState state = fse.getPageState();
s_log.debug("Init");
m_captionText.setValue(state, null);
-
-
+ m_title.setValue(state, null);
}
@Override
@@ -168,13 +174,18 @@ public class FileAttachmentCaptionForm extends Form
final ContentItem item = getContentItem(state);
final FileAttachment attachment = new FileAttachment();
- try {
- attachment.setCaption();
- } catch (IOException ex) {
- throw new FormProcessException(ex);
- }
- attachment.setDescription((String) m_captionText.getValue(state));
-
+ try {
+ attachment.setCaption();
+ } catch (IOException ex) {
+ throw new FormProcessException(ex);
+ }
+ attachment.setDescription((String) m_captionText.getValue(state));
+ String title = (String) m_title.getValue(state);
+ if (title.isEmpty()) {
+ attachment.setName( "iscaption");
+ } else {
+ attachment.setName((String) m_title.getValue(state));
+ }
attachment.setFileOwner(item);
attachment.save();
item.save();
diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsTable.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsTable.java
index a4abe99bf..cc46c533b 100755
--- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsTable.java
+++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentsTable.java
@@ -270,9 +270,14 @@ public class FileAttachmentsTable extends Table {
final String downloadKey = (String) key;
FileAttachment attachment = new FileAttachment(new BigDecimal(downloadKey));
- if (attachment.getDisplayName().equals("caption")) {
- Link link = new Link(" ", "item");
- return link;
+ String cap = attachment.getAdditionalInfo();
+ if (cap != null) {
+ if (attachment.getAdditionalInfo().equals("caption")) {
+ if (attachment.getDisplayName()!=null && attachment.getDisplayName().equals("iscaption")) {
+ return new Label(" ");
+ }
+ return new Label(attachment.getDisplayName());
+ }
}
return new Link(attachment.getDisplayName(),
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 993376389..dd45cc25a 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
@@ -26,8 +26,10 @@ 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.DHTMLEditor;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.form.TextArea;
+import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.cms.contentassets.FileAttachment;
import com.arsdigita.cms.contentassets.FileAttachmentConfig;
@@ -36,29 +38,29 @@ import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil;
/**
* Form to edit the description of a file attachment. File description edit
- * form, default class for com.arsdigita.cms.contentassets.file_edit_form
- * configuration parameter. Edits property Asset.description
+ * form, default class for
+ * com.arsdigita.cms.contentassets.file_edit_form configuration
+ * parameter. Edits property Asset.description
*/
public class FileDescriptionForm extends FormSection implements
FormInitListener, FormProcessListener, FormValidationListener,
FormSubmissionListener {
private static final FileAttachmentConfig s_config = FileAttachmentConfig
- .instanceOf();
-
+ .instanceOf();
+
+ private TextArea m_title;
private TextArea m_description;
-
private FileAttachmentSelectionModel m_fileModel;
-
private Submit m_cancel;
-
+ private Label titleLabel;
+
/**
* 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
+ *
+ * @param file The FileAttachmentSelectionModel to use to obtain the
+ * FileAttachment to work on
*/
public FileDescriptionForm(FileAttachmentSelectionModel file) {
super(new ColumnPanel(2));
@@ -79,14 +81,20 @@ public class FileDescriptionForm extends FormSection implements
* Adds widgets to the form.
*/
protected void addWidgets() {
- m_description = new TextArea("description");
- m_description.setCols(40);
- m_description.setRows(5);
+
+ m_title = new DHTMLEditor("title");
+ titleLabel = new Label(FileAttachmentGlobalizationUtil
+ .globalize("cms.contentassets.file_attachment.title"));
+ add(titleLabel);
+ add(m_title);
+
+ m_description = new DHTMLEditor("description");
+ m_description.addValidationListener(new NotNullValidationListener());
m_description.addValidationListener(new StringInRangeValidationListener(
- 0,
- s_config.getFileAttachmentDescriptionMaxLength(),
- FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength())));
-
+ 0,
+ s_config.getFileAttachmentDescriptionMaxLength(),
+ FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength())));
+
add(new Label(FileAttachmentGlobalizationUtil
.globalize("cms.contentassets.file_attachment.caption_or_description")));
@@ -95,9 +103,8 @@ public class FileDescriptionForm extends FormSection implements
/**
* Submission listener. Handles cancel events.
- *
- * @param e
- * the FormSectionEvent
+ *
+ * @param e the FormSectionEvent
* @throws com.arsdigita.bebop.FormProcessException
*/
@Override
@@ -106,13 +113,13 @@ public class FileDescriptionForm extends FormSection implements
m_fileModel.clearSelection(e.getPageState());
init(e);
throw new FormProcessException(FileAttachmentGlobalizationUtil.globalize(
- "cms.contentassets.file_attachment.cancelled"));
+ "cms.contentassets.file_attachment.cancelled"));
}
}
/**
* Validation listener.
- *
+ *
* @param event the FormSectionEvent
* @throws com.arsdigita.bebop.FormProcessException
*/
@@ -127,9 +134,8 @@ public class FileDescriptionForm extends FormSection implements
/**
* Init listener.
- *
- * @param fse
- * the FormSectionEvent
+ *
+ * @param fse the FormSectionEvent
*/
@Override
public void init(FormSectionEvent fse) throws FormProcessException {
@@ -139,6 +145,18 @@ public class FileDescriptionForm extends FormSection implements
setVisible(state, true);
FileAttachment file = m_fileModel.getSelectedFileAttachment(state);
m_description.setValue(state, file.getDescription());
+ if (file.getAdditionalInfo() != null && file.getAdditionalInfo().equals("caption")) {
+ String name = file.getName();
+ if (name != null && name.equals("iscaption")) {
+ m_title.setValue(state, null);
+ m_title.setVisible(state, true);
+ } else {
+ m_title.setValue(state, name);
+ }
+ } else {
+ m_title.setVisible(state, false);
+ titleLabel.setVisible(state, false);
+ }
} else {
setVisible(state, false);
}
@@ -146,9 +164,8 @@ public class FileDescriptionForm extends FormSection implements
/**
* Process listener. Edits the file description.
- *
- * @param fse
- * the FormSectionEvent
+ *
+ * @param fse the FormSectionEvent
* @throws com.arsdigita.bebop.FormProcessException
*/
@Override
@@ -164,10 +181,18 @@ public class FileDescriptionForm extends FormSection implements
FileAttachment file = m_fileModel
.getSelectedFileAttachment(state);
file.setDescription((String) m_description.getValue(state));
- }
- }
- m_fileModel.clearSelection(state);
- init(fse);
- }
+ if (file.getAdditionalInfo().equals("caption")) {
+ if (m_title.getValue(state) != null) {
+ file.setName((String) m_title.getValue(state));
+ } else {
+ file.setName("iscaption");
+ }
+
+ }
+ }
+ m_fileModel.clearSelection(state);
+ init(fse);
+ }
+ }
}
diff --git a/ccm-cms/src/com/arsdigita/cms/FileAsset.java b/ccm-cms/src/com/arsdigita/cms/FileAsset.java
index dfc1f7fe4..cc1c04ba5 100755
--- a/ccm-cms/src/com/arsdigita/cms/FileAsset.java
+++ b/ccm-cms/src/com/arsdigita/cms/FileAsset.java
@@ -197,7 +197,7 @@ public class FileAsset extends BinaryAsset {
mime = MimeType.loadMimeType("text/plain");
setMimeType(mime);
mime.setLabel("caption");
- setName(StringUtils.urlize("caption"));
+ setAdditionalInfo("caption");
setContent("caption".getBytes());
}