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.table_delete=delete
|
||||||
cms.contentassets.file_attachment.description.too_long=The description execceds the limit of {0} characters.
|
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.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.table_delete=l\u00f6schen
|
||||||
cms.contentassets.file_attachment.description.too_long=Die Beschreibung ist l\u00e4nger als {0} Zeichen.
|
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.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.FormProcessListener;
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
import com.arsdigita.bebop.event.FormValidationListener;
|
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.NotNullValidationListener;
|
||||||
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
|
@ -54,9 +54,11 @@ public class FileAttachmentCaptionForm extends Form
|
||||||
private FileUploadSection m_fileUploadSection;
|
private FileUploadSection m_fileUploadSection;
|
||||||
private ItemSelectionModel m_itemModel;
|
private ItemSelectionModel m_itemModel;
|
||||||
private SaveCancelSection m_saveCancelSection;
|
private SaveCancelSection m_saveCancelSection;
|
||||||
private TextArea m_captionText;
|
private DHTMLEditor m_title;
|
||||||
|
private DHTMLEditor m_captionText;
|
||||||
|
|
||||||
private static final FileAttachmentConfig s_config = FileAttachmentConfig
|
private static final FileAttachmentConfig s_config = FileAttachmentConfig
|
||||||
.instanceOf();
|
.instanceOf();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new FileCaptionForm
|
* Construct a new FileCaptionForm
|
||||||
|
|
@ -127,19 +129,24 @@ public class FileAttachmentCaptionForm extends Form
|
||||||
|
|
||||||
// Add the widgets
|
// Add the widgets
|
||||||
public void addWidgets() {
|
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 = new DHTMLEditor("caption");
|
||||||
m_captionText.setCols(10);
|
// m_captionText.setCols(10);
|
||||||
m_captionText.setRows(1);
|
// m_captionText.setRows(1);
|
||||||
m_captionText.addValidationListener(new NotNullValidationListener());
|
m_captionText.addValidationListener(new NotNullValidationListener());
|
||||||
m_captionText.addValidationListener(new StringInRangeValidationListener(
|
m_captionText.addValidationListener(new StringInRangeValidationListener(
|
||||||
0,
|
0,
|
||||||
s_config.getFileAttachmentDescriptionMaxLength(),
|
s_config.getFileAttachmentDescriptionMaxLength(),
|
||||||
FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength())));
|
FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength())));
|
||||||
m_captionText.lock();
|
m_captionText.lock();
|
||||||
add(new Label(FileAttachmentGlobalizationUtil.globalize(
|
add(new Label(FileAttachmentGlobalizationUtil.globalize(
|
||||||
"cms.contentassets.file_attachment.caption")));
|
"cms.contentassets.file_attachment.caption_or_description")));
|
||||||
add(m_captionText);
|
add(m_captionText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,8 +157,7 @@ public class FileAttachmentCaptionForm extends Form
|
||||||
PageState state = fse.getPageState();
|
PageState state = fse.getPageState();
|
||||||
s_log.debug("Init");
|
s_log.debug("Init");
|
||||||
m_captionText.setValue(state, null);
|
m_captionText.setValue(state, null);
|
||||||
|
m_title.setValue(state, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -168,13 +174,18 @@ public class FileAttachmentCaptionForm extends Form
|
||||||
final ContentItem item = getContentItem(state);
|
final ContentItem item = getContentItem(state);
|
||||||
final FileAttachment attachment = new FileAttachment();
|
final FileAttachment attachment = new FileAttachment();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
attachment.setCaption();
|
attachment.setCaption();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new FormProcessException(ex);
|
throw new FormProcessException(ex);
|
||||||
}
|
}
|
||||||
attachment.setDescription((String) m_captionText.getValue(state));
|
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.setFileOwner(item);
|
||||||
attachment.save();
|
attachment.save();
|
||||||
item.save();
|
item.save();
|
||||||
|
|
|
||||||
|
|
@ -270,9 +270,14 @@ public class FileAttachmentsTable extends Table {
|
||||||
final String downloadKey = (String) key;
|
final String downloadKey = (String) key;
|
||||||
FileAttachment attachment = new FileAttachment(new BigDecimal(downloadKey));
|
FileAttachment attachment = new FileAttachment(new BigDecimal(downloadKey));
|
||||||
|
|
||||||
if (attachment.getDisplayName().equals("caption")) {
|
String cap = attachment.getAdditionalInfo();
|
||||||
Link link = new Link(" ", "item");
|
if (cap != null) {
|
||||||
return link;
|
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(),
|
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.FormSectionEvent;
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
import com.arsdigita.bebop.event.FormValidationListener;
|
import com.arsdigita.bebop.event.FormValidationListener;
|
||||||
|
import com.arsdigita.bebop.form.DHTMLEditor;
|
||||||
import com.arsdigita.bebop.form.Submit;
|
import com.arsdigita.bebop.form.Submit;
|
||||||
import com.arsdigita.bebop.form.TextArea;
|
import com.arsdigita.bebop.form.TextArea;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||||
import com.arsdigita.cms.contentassets.FileAttachment;
|
import com.arsdigita.cms.contentassets.FileAttachment;
|
||||||
import com.arsdigita.cms.contentassets.FileAttachmentConfig;
|
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 to edit the description of a file attachment. File description edit
|
||||||
* form, default class for <code>com.arsdigita.cms.contentassets.file_edit_form</code>
|
* form, default class for
|
||||||
* configuration parameter. Edits property Asset.description
|
* <code>com.arsdigita.cms.contentassets.file_edit_form</code> configuration
|
||||||
|
* parameter. Edits property Asset.description
|
||||||
*/
|
*/
|
||||||
public class FileDescriptionForm extends FormSection implements
|
public class FileDescriptionForm extends FormSection implements
|
||||||
FormInitListener, FormProcessListener, FormValidationListener,
|
FormInitListener, FormProcessListener, FormValidationListener,
|
||||||
FormSubmissionListener {
|
FormSubmissionListener {
|
||||||
|
|
||||||
private static final FileAttachmentConfig s_config = FileAttachmentConfig
|
private static final FileAttachmentConfig s_config = FileAttachmentConfig
|
||||||
.instanceOf();
|
.instanceOf();
|
||||||
|
|
||||||
|
private TextArea m_title;
|
||||||
private TextArea m_description;
|
private TextArea m_description;
|
||||||
|
|
||||||
private FileAttachmentSelectionModel m_fileModel;
|
private FileAttachmentSelectionModel m_fileModel;
|
||||||
|
|
||||||
private Submit m_cancel;
|
private Submit m_cancel;
|
||||||
|
private Label titleLabel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new form to edit the FileAttachment description by the item
|
* Creates a new form to edit the FileAttachment description by the item
|
||||||
* selection model passed in.
|
* selection model passed in.
|
||||||
*
|
*
|
||||||
* @param file
|
* @param file The FileAttachmentSelectionModel to use to obtain the
|
||||||
* The FileAttachmentSelectionModel to use to obtain the
|
* FileAttachment to work on
|
||||||
* FileAttachment to work on
|
|
||||||
*/
|
*/
|
||||||
public FileDescriptionForm(FileAttachmentSelectionModel file) {
|
public FileDescriptionForm(FileAttachmentSelectionModel file) {
|
||||||
super(new ColumnPanel(2));
|
super(new ColumnPanel(2));
|
||||||
|
|
@ -79,13 +81,19 @@ public class FileDescriptionForm extends FormSection implements
|
||||||
* Adds widgets to the form.
|
* Adds widgets to the form.
|
||||||
*/
|
*/
|
||||||
protected void addWidgets() {
|
protected void addWidgets() {
|
||||||
m_description = new TextArea("description");
|
|
||||||
m_description.setCols(40);
|
m_title = new DHTMLEditor("title");
|
||||||
m_description.setRows(5);
|
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(
|
m_description.addValidationListener(new StringInRangeValidationListener(
|
||||||
0,
|
0,
|
||||||
s_config.getFileAttachmentDescriptionMaxLength(),
|
s_config.getFileAttachmentDescriptionMaxLength(),
|
||||||
FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength())));
|
FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength())));
|
||||||
|
|
||||||
add(new Label(FileAttachmentGlobalizationUtil
|
add(new Label(FileAttachmentGlobalizationUtil
|
||||||
.globalize("cms.contentassets.file_attachment.caption_or_description")));
|
.globalize("cms.contentassets.file_attachment.caption_or_description")));
|
||||||
|
|
@ -96,8 +104,7 @@ public class FileDescriptionForm extends FormSection implements
|
||||||
/**
|
/**
|
||||||
* Submission listener. Handles cancel events.
|
* Submission listener. Handles cancel events.
|
||||||
*
|
*
|
||||||
* @param e
|
* @param e the FormSectionEvent
|
||||||
* the FormSectionEvent
|
|
||||||
* @throws com.arsdigita.bebop.FormProcessException
|
* @throws com.arsdigita.bebop.FormProcessException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -106,7 +113,7 @@ public class FileDescriptionForm extends FormSection implements
|
||||||
m_fileModel.clearSelection(e.getPageState());
|
m_fileModel.clearSelection(e.getPageState());
|
||||||
init(e);
|
init(e);
|
||||||
throw new FormProcessException(FileAttachmentGlobalizationUtil.globalize(
|
throw new FormProcessException(FileAttachmentGlobalizationUtil.globalize(
|
||||||
"cms.contentassets.file_attachment.cancelled"));
|
"cms.contentassets.file_attachment.cancelled"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,8 +135,7 @@ public class FileDescriptionForm extends FormSection implements
|
||||||
/**
|
/**
|
||||||
* Init listener.
|
* Init listener.
|
||||||
*
|
*
|
||||||
* @param fse
|
* @param fse the FormSectionEvent
|
||||||
* the FormSectionEvent
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||||
|
|
@ -139,6 +145,18 @@ public class FileDescriptionForm extends FormSection implements
|
||||||
setVisible(state, true);
|
setVisible(state, true);
|
||||||
FileAttachment file = m_fileModel.getSelectedFileAttachment(state);
|
FileAttachment file = m_fileModel.getSelectedFileAttachment(state);
|
||||||
m_description.setValue(state, file.getDescription());
|
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 {
|
} else {
|
||||||
setVisible(state, false);
|
setVisible(state, false);
|
||||||
}
|
}
|
||||||
|
|
@ -147,8 +165,7 @@ public class FileDescriptionForm extends FormSection implements
|
||||||
/**
|
/**
|
||||||
* Process listener. Edits the file description.
|
* Process listener. Edits the file description.
|
||||||
*
|
*
|
||||||
* @param fse
|
* @param fse the FormSectionEvent
|
||||||
* the FormSectionEvent
|
|
||||||
* @throws com.arsdigita.bebop.FormProcessException
|
* @throws com.arsdigita.bebop.FormProcessException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -164,10 +181,18 @@ public class FileDescriptionForm extends FormSection implements
|
||||||
FileAttachment file = m_fileModel
|
FileAttachment file = m_fileModel
|
||||||
.getSelectedFileAttachment(state);
|
.getSelectedFileAttachment(state);
|
||||||
file.setDescription((String) m_description.getValue(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ public class FileAsset extends BinaryAsset {
|
||||||
mime = MimeType.loadMimeType("text/plain");
|
mime = MimeType.loadMimeType("text/plain");
|
||||||
setMimeType(mime);
|
setMimeType(mime);
|
||||||
mime.setLabel("caption");
|
mime.setLabel("caption");
|
||||||
setName(StringUtils.urlize("caption"));
|
setAdditionalInfo("caption");
|
||||||
setContent("caption".getBytes());
|
setContent("caption".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue