Fileattachment: title-column can be used for captions
git-svn-id: https://svn.libreccm.org/ccm/trunk@3452 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
8760ac5e73
commit
88fb5966da
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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,7 +54,9 @@ 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();
|
||||
|
||||
|
|
@ -127,11 +129,16 @@ 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,
|
||||
|
|
@ -139,7 +146,7 @@ public class FileAttachmentCaptionForm extends Form
|
|||
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
|
||||
|
|
@ -174,7 +180,12 @@ public class FileAttachmentCaptionForm extends Form
|
|||
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();
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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,8 +38,9 @@ import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil;
|
|||
|
||||
/**
|
||||
* 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
|
||||
* 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,
|
||||
|
|
@ -46,18 +49,17 @@ public class FileDescriptionForm extends FormSection implements
|
|||
private static final FileAttachmentConfig s_config = FileAttachmentConfig
|
||||
.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
|
||||
* @param file The FileAttachmentSelectionModel to use to obtain the
|
||||
* FileAttachment to work on
|
||||
*/
|
||||
public FileDescriptionForm(FileAttachmentSelectionModel file) {
|
||||
|
|
@ -79,9 +81,15 @@ 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(),
|
||||
|
|
@ -96,8 +104,7 @@ 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
|
||||
|
|
@ -128,8 +135,7 @@ 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);
|
||||
}
|
||||
|
|
@ -147,8 +165,7 @@ 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));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue