Asset AttachFile: captions can now be added to the fileattachmenttable
git-svn-id: https://svn.libreccm.org/ccm/trunk@3361 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
93bf5882cc
commit
aa3758cb9b
|
|
@ -8,3 +8,13 @@ cms.contentassets.file_attachment.tableheader_description=Description
|
|||
cms.contentassets.file_attachment.list_label=File attachments
|
||||
cms.contentassets.file_attachment.already_attached=A file with the name {0} as already been attached.
|
||||
cms.contentassets.file_attachment.cancelled=Cancelled
|
||||
cms.contentassets.file_attachment.caption=caption
|
||||
cms.contentassets.file_attachment.file=file
|
||||
cms.contentassets.file_attachment.table.edit_attached_file=\u270d
|
||||
#Beschreibung/Zwischentitel:
|
||||
cms.contentassets.file_attachment.caption_or_description=description/caption:
|
||||
cms.contentassets.file_attachment.upload_new_caption=add a caption
|
||||
cms.contentassets.file_attachment.table_edit=edit
|
||||
cms.contentassets.file_attachment.table_up=up
|
||||
cms.contentassets.file_attachment.table_down=down
|
||||
cms.contentassets.file_attachment.table_delete=delete
|
||||
|
|
|
|||
|
|
@ -8,3 +8,12 @@ cms.contentassets.file_attachment.tableheader_description=Beschreibung
|
|||
cms.contentassets.file_attachment.list_label=Dateianh\u00e4nge
|
||||
cms.contentassets.file_attachment.already_attached=Eine Datei mit dem Namen {0} wurde bereits hinzugef\u00fcgt.
|
||||
cms.contentassets.file_attachment.cancelled=Abgebrochen
|
||||
cms.contentassets.file_attachment.caption=Zwischentitel
|
||||
cms.contentassets.file_attachment.file=Datei
|
||||
cms.contentassets.file_attachment.table.edit_attached_file=\u270d
|
||||
cms.contentassets.file_attachment.caption_or_description=Beschreibung/Zwischentitel:
|
||||
cms.contentassets.file_attachment.upload_new_caption=Zwischentitel hinzuf\u00fcgen
|
||||
cms.contentassets.file_attachment.table_edit=bearbeiten
|
||||
cms.contentassets.file_attachment.table_up=nach oben
|
||||
cms.contentassets.file_attachment.table_down=nach unten
|
||||
cms.contentassets.file_attachment.table_delete=l\u00f6schen
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public class FileAttachmentModelBuilder extends AbstractTableModelBuilder {
|
|||
**/
|
||||
@Override
|
||||
public Object getElementAt(int columnIndex) {
|
||||
if (columnIndex == 4) {
|
||||
if (columnIndex == 1) {
|
||||
if(FileAttachment.getConfig().isShowAssetIDEnabled()){
|
||||
// TODO provide API for asset URL
|
||||
ParameterMap params = new ParameterMap();
|
||||
|
|
@ -135,9 +135,11 @@ public class FileAttachmentModelBuilder extends AbstractTableModelBuilder {
|
|||
.there(Service.getURL()+"/download/asset", params )
|
||||
.getURL();
|
||||
}else{
|
||||
|
||||
return _file.getDescription();
|
||||
}
|
||||
} else {
|
||||
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ package com.arsdigita.cms.contentassets.ui;
|
|||
|
||||
import com.arsdigita.bebop.ColumnPanel;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
|
|
@ -39,11 +40,10 @@ import com.arsdigita.persistence.DataCollection;
|
|||
import com.arsdigita.persistence.DataObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A form for uploading file attachments. Displays a mime-type selection box.
|
||||
*
|
||||
|
|
@ -60,12 +60,13 @@ public class FileAttachmentUpload extends Form
|
|||
private TextArea m_description;
|
||||
private ItemSelectionModel m_itemModel;
|
||||
private SaveCancelSection m_saveCancelSection;
|
||||
private TextArea m_captionText;
|
||||
|
||||
/**
|
||||
* Construct a new FileAttachmentUpload
|
||||
*
|
||||
* @param itemModel The {@link ItemSelectionModel} which will be responsible for loading the
|
||||
* current item
|
||||
* @param itemModel The {@link ItemSelectionModel} which will be responsible
|
||||
* for loading the current item
|
||||
*
|
||||
*/
|
||||
public FileAttachmentUpload(ItemSelectionModel itemModel) {
|
||||
|
|
@ -141,12 +142,18 @@ public class FileAttachmentUpload extends Form
|
|||
m_description.setRows(5);
|
||||
m_description.setCols(60);
|
||||
add(new Label(GlobalizationUtil.globalize("cms.contentassets.ui.description")));
|
||||
m_description.lock();
|
||||
add(m_description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent event) throws FormProcessException {
|
||||
// Do nothing.
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
s_log.debug("Init");
|
||||
m_description.setValue(state, null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -154,8 +161,8 @@ public class FileAttachmentUpload extends Form
|
|||
final PageState state = event.getPageState();
|
||||
final ContentItem item = getContentItem(state);
|
||||
final String fileName = m_fileUploadSection.getFileName(event);
|
||||
|
||||
final DataCollection attachments = FileAttachment.getAttachments(item);
|
||||
|
||||
while (attachments.next()) {
|
||||
final DataObject attachment = attachments.getDataObject();
|
||||
if (attachment.get(FileAttachment.NAME).equals(fileName)) {
|
||||
|
|
@ -175,34 +182,25 @@ public class FileAttachmentUpload extends Form
|
|||
|
||||
final PageState state = event.getPageState();
|
||||
final ContentItem item = getContentItem(state);
|
||||
|
||||
// try {
|
||||
// Get the text asset or create a new one
|
||||
final String fileName = m_fileUploadSection.getFileName(event);
|
||||
final File file = m_fileUploadSection.getFile(event);
|
||||
final FileAttachment attachment = new FileAttachment();
|
||||
final File file = m_fileUploadSection.getFile(event);
|
||||
final String fileName = m_fileUploadSection.getFileName(event);
|
||||
|
||||
// Load the asset from file
|
||||
attachment.setFileOwner(item);
|
||||
try {
|
||||
attachment.loadFromFile(fileName, file, "application/octet-stream");
|
||||
} catch (IOException ex) {
|
||||
throw new FormProcessException(ex);
|
||||
}
|
||||
attachment.setDescription((String) m_description.getValue(state));
|
||||
attachment.setFileOwner(item);
|
||||
attachment.save();
|
||||
|
||||
item.save();
|
||||
|
||||
// Save everything
|
||||
this.setFileAttachment(state);
|
||||
DispatcherHelper.cacheDisable(state.getResponse());
|
||||
s_log.debug("File Uploaded");
|
||||
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// throw new FormProcessException(e);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ 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.contentassets.util.FileAttachmentGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.CMSContainer;
|
||||
import com.arsdigita.cms.ui.SecurityPropertyEditor;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
|
|
@ -47,14 +48,13 @@ public class FileAttachmentsStep extends SecurityPropertyEditor {
|
|||
|
||||
private final ItemSelectionModel m_item;
|
||||
private final AuthoringKitWizard m_parent;
|
||||
|
||||
private CMSContainer m_display;
|
||||
private FileAttachmentsTable m_fileList;
|
||||
private FileAttachmentUpload m_uploadForm;
|
||||
|
||||
private FileCaptionForm m_captionForm;
|
||||
private BigDecimalParameter m_fileParam = new BigDecimalParameter("fa");
|
||||
private FileAttachmentSelectionModel m_fileModel =
|
||||
new FileAttachmentSelectionModel(m_fileParam);
|
||||
private FileAttachmentSelectionModel m_fileModel
|
||||
= new FileAttachmentSelectionModel(m_fileParam);
|
||||
private Submit m_cancel;
|
||||
private Form m_dcForm;
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ public class FileAttachmentsStep extends SecurityPropertyEditor {
|
|||
//Main label
|
||||
Label mainLabel = new Label(FileAttachmentGlobalize.NoFilesAssociatedMsg());
|
||||
mainLabel.setFontWeight(Label.ITALIC);
|
||||
mainLabel.addPrintListener( new PrintListener() {
|
||||
mainLabel.addPrintListener(new PrintListener() {
|
||||
public void prepare(PrintEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
ContentItem item = (ContentItem) m_item.getSelectedObject(state);
|
||||
|
|
@ -100,13 +100,21 @@ public class FileAttachmentsStep extends SecurityPropertyEditor {
|
|||
new WorkflowLockedComponentAccess(m_uploadForm, m_item),
|
||||
m_uploadForm.getSaveCancelSection().getCancelButton());
|
||||
|
||||
// The caption form
|
||||
m_captionForm = new FileCaptionForm(m_item);
|
||||
add("caption",
|
||||
FileAttachmentGlobalizationUtil.globalize(
|
||||
"cms.contentassets.file_attachment.upload_new_caption"),
|
||||
new WorkflowLockedComponentAccess(m_captionForm, m_item),
|
||||
m_captionForm.getSaveCancelSection().getCancelButton());
|
||||
addSecurityListener(m_captionForm);
|
||||
|
||||
// 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 });
|
||||
FormSection editForm = (FormSection) Classes.newInstance(editFormClass,
|
||||
new Class[]{FileAttachmentSelectionModel.class},
|
||||
new Object[]{m_fileModel});
|
||||
form.add(editForm);
|
||||
|
||||
WorkflowLockedContainer edit = new WorkflowLockedContainer(m_item);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.arsdigita.cms.ContentItem;
|
|||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.contentassets.FileAttachment;
|
||||
import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -38,7 +39,8 @@ import org.apache.log4j.Logger;
|
|||
* A Table for displaying File attachments
|
||||
*
|
||||
* @author Scott Seago (sseago@redhat.com)
|
||||
* @version $Id: FileAttachmentsTable.java 1592 2007-06-21 16:48:55Z lbcfrancois $
|
||||
* @version $Id: FileAttachmentsTable.java 1592 2007-06-21 16:48:55Z lbcfrancois
|
||||
* $
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
|
@ -46,12 +48,14 @@ public class FileAttachmentsTable extends Table {
|
|||
|
||||
private static final Logger s_log = Logger.getLogger(FileAttachmentsTable.class);
|
||||
|
||||
public static final String[] s_tableHeaders = {"File", " ", " ", " ", "Description", " "};
|
||||
public static final String[] s_tableHeaders = {"File", "Description/Caption", " ", " ", " ", " "};
|
||||
|
||||
private static final String DELETE_EVENT = "delete";
|
||||
private static final String UP_EVENT = "up";
|
||||
private static final String DOWN_EVENT = "down";
|
||||
private static final String EDIT_EVENT = "edit";
|
||||
// private static final String EDIT_EVENT = FileAttachmentGlobalizationUtil.globalize("cms.contentassets.file_attachment.table.edit_attached_file");
|
||||
|
||||
private ItemSelectionModel m_model;
|
||||
private FileAttachmentSelectionModel m_fileModel;
|
||||
private RequestLocal m_size;
|
||||
|
|
@ -63,9 +67,10 @@ public class FileAttachmentsTable extends Table {
|
|||
m_fileModel = fileModel;
|
||||
setRowSelectionModel(m_fileModel);
|
||||
getColumn(0).setCellRenderer(new FileLinkCellRenderer());
|
||||
getColumn(1).setCellRenderer(new MoveUpLinkCellRenderer());
|
||||
getColumn(2).setCellRenderer(new MoveDownLinkCellRenderer());
|
||||
getColumn(3).setCellRenderer(new EditLinkCellRenderer());
|
||||
//column 1 is description/caption
|
||||
getColumn(2).setCellRenderer(new MoveUpLinkCellRenderer());
|
||||
getColumn(3).setCellRenderer(new MoveDownLinkCellRenderer());
|
||||
getColumn(4).setCellRenderer(new EditLinkCellRenderer());
|
||||
getColumn(5).setCellRenderer(new DeleteLinkCellRenderer());
|
||||
m_size = new RequestLocal();
|
||||
m_editor = new RequestLocal() {
|
||||
|
|
@ -81,9 +86,7 @@ public class FileAttachmentsTable extends Table {
|
|||
));
|
||||
return val;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
setWidth("100%");
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +143,8 @@ public class FileAttachmentsTable extends Table {
|
|||
final String modKey = (String) key;
|
||||
|
||||
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||
ControlLink delLink = new ControlLink("Delete") {
|
||||
ControlLink delLink = new ControlLink(new Label(FileAttachmentGlobalizationUtil.globalize(
|
||||
"cms.contentassets.file_attachment.table_delete"))) {
|
||||
|
||||
public void setControlEvent(PageState s) {
|
||||
s.setControlEvent(table, DELETE_EVENT, modKey);
|
||||
|
|
@ -172,21 +176,18 @@ public class FileAttachmentsTable extends Table {
|
|||
if (isSelected) {
|
||||
sc.add(new Label("edit", Label.BOLD));
|
||||
} else {
|
||||
ControlLink delLink = new ControlLink("edit") {
|
||||
ControlLink delLink = new ControlLink(new Label(FileAttachmentGlobalizationUtil.globalize(
|
||||
"cms.contentassets.file_attachment.table_edit"))) {
|
||||
|
||||
public void setControlEvent(PageState s) {
|
||||
s.setControlEvent(table, EDIT_EVENT, modKey);
|
||||
}
|
||||
|
||||
};
|
||||
sc.add(delLink);
|
||||
}
|
||||
|
||||
}
|
||||
return sc;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class MoveUpLinkCellRenderer implements TableCellRenderer {
|
||||
|
|
@ -204,7 +205,8 @@ public class FileAttachmentsTable extends Table {
|
|||
final String modKey = (String) key;
|
||||
|
||||
if (!isFirst && Boolean.TRUE.equals(m_editor.get(state))) {
|
||||
ControlLink delLink = new ControlLink("up") {
|
||||
ControlLink delLink = new ControlLink(new Label(FileAttachmentGlobalizationUtil.globalize(
|
||||
"cms.contentassets.file_attachment.table_up"))) {
|
||||
|
||||
public void setControlEvent(PageState s) {
|
||||
s.setControlEvent(table, UP_EVENT, modKey);
|
||||
|
|
@ -239,7 +241,8 @@ public class FileAttachmentsTable extends Table {
|
|||
final String modKey = (String) key;
|
||||
|
||||
if (!isLast && Boolean.TRUE.equals(m_editor.get(state))) {
|
||||
ControlLink delLink = new ControlLink("down") {
|
||||
ControlLink delLink = new ControlLink(new Label(FileAttachmentGlobalizationUtil.globalize(
|
||||
"cms.contentassets.file_attachment.table_down"))) {
|
||||
|
||||
public void setControlEvent(PageState s) {
|
||||
s.setControlEvent(table, DOWN_EVENT, modKey);
|
||||
|
|
@ -266,14 +269,14 @@ public class FileAttachmentsTable extends Table {
|
|||
int column) {
|
||||
final String downloadKey = (String) key;
|
||||
FileAttachment attachment = new FileAttachment(new BigDecimal(downloadKey));
|
||||
final Link link = new Link(attachment.getDisplayName(),
|
||||
Utilities.getAssetURL(attachment));
|
||||
|
||||
if (attachment.getDisplayName().equals("caption")) {
|
||||
Link link = new Link(" ", "item");
|
||||
return link;
|
||||
// Utilities.getAssetURL(attachment));
|
||||
//return new Link(attachment.getDisplayName(),
|
||||
// Utilities.getAssetURL(attachment));
|
||||
}
|
||||
|
||||
return new Link(attachment.getDisplayName(),
|
||||
Utilities.getAssetURL(attachment));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,211 @@
|
|||
/*
|
||||
* 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;
|
||||
import com.arsdigita.bebop.Embedded;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
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.FormValidationListener;
|
||||
import com.arsdigita.bebop.form.CheckboxGroup;
|
||||
import com.arsdigita.bebop.form.DHTMLEditor;
|
||||
import com.arsdigita.bebop.form.Option;
|
||||
import com.arsdigita.bebop.form.RadioGroup;
|
||||
import com.arsdigita.bebop.form.TextArea;
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.FileAsset;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contentassets.FileAttachment;
|
||||
import com.arsdigita.cms.contentassets.FileAttachmentGlobalize;
|
||||
import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil;
|
||||
import com.arsdigita.cms.contenttypes.Link;
|
||||
import com.arsdigita.cms.ui.FileUploadSection;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
import com.arsdigita.mimetypes.ImageMimeType;
|
||||
import com.arsdigita.mimetypes.MimeType;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* A form for uploading file attachments. Displays a mime-type selection box.
|
||||
*
|
||||
* @author Scott Seago (sseago@redhat.com)
|
||||
* @version $Revision: #2 $ $DateTime: 2004/03/30 18:21:14 $
|
||||
* @version $Id: FileAttachmentUpload.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
public class FileCaptionForm extends Form
|
||||
implements FormInitListener, FormProcessListener, FormValidationListener {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(FileAttachmentUpload.class);
|
||||
|
||||
private FileUploadSection m_fileUploadSection;
|
||||
private TextArea m_description;
|
||||
private ItemSelectionModel m_itemModel;
|
||||
private SaveCancelSection m_saveCancelSection;
|
||||
private Boolean isFile;
|
||||
private TextArea m_captionText;
|
||||
private RadioGroup m_dType;
|
||||
private Option m_file;
|
||||
private CheckboxGroup m_checkbox;
|
||||
private DHTMLEditor content;
|
||||
|
||||
/**
|
||||
* Construct a new FileAttachmentUpload
|
||||
*
|
||||
* @param itemModel The {@link ItemSelectionModel} which will be responsible
|
||||
* for loading the current item
|
||||
*
|
||||
*/
|
||||
public FileCaptionForm(ItemSelectionModel itemModel) {
|
||||
super("CaptionAttachmentUpload", new ColumnPanel(2));
|
||||
m_itemModel = itemModel;
|
||||
|
||||
ColumnPanel panel = (ColumnPanel) getPanel();
|
||||
panel.setBorder(false);
|
||||
panel.setPadColor("#FFFFFF");
|
||||
panel.setColumnWidth(1, "20%");
|
||||
panel.setColumnWidth(2, "80%");
|
||||
panel.setWidth("2%");
|
||||
|
||||
addWidgets();
|
||||
|
||||
m_saveCancelSection = new SaveCancelSection();
|
||||
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||
|
||||
addInitListener(this);
|
||||
addProcessListener(this);
|
||||
addValidationListener(this);
|
||||
setMethod(Form.POST);
|
||||
setEncType("multipart/form-data");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the item selection model used in this form
|
||||
*/
|
||||
public ItemSelectionModel getItemSelectionModel() {
|
||||
return m_itemModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the save/cancel section for this form
|
||||
*/
|
||||
public SaveCancelSection getSaveCancelSection() {
|
||||
return m_saveCancelSection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param state The page state
|
||||
*
|
||||
* @return the currently selected item
|
||||
*/
|
||||
public ContentItem getContentItem(PageState state) {
|
||||
return (ContentItem) m_itemModel.getSelectedObject(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the image asset. This will probably be done in the process listener
|
||||
*
|
||||
* @param state The page state
|
||||
* @param asset The image asset
|
||||
*/
|
||||
// this may not be needed at all -- it was in the medqic code for some reason.
|
||||
// we should remove if possible
|
||||
public void setFileAttachment(PageState state) {
|
||||
ContentItem item = getContentItem(state);
|
||||
// Force the item to reload, since the assets query is cached ?
|
||||
// ?
|
||||
}
|
||||
|
||||
// Add the widgets
|
||||
public void addWidgets() {
|
||||
|
||||
|
||||
m_captionText = new TextArea("caption");
|
||||
m_captionText.setCols(10);
|
||||
m_captionText.setRows(1);
|
||||
m_captionText.addValidationListener(new NotNullValidationListener());
|
||||
m_captionText.lock();
|
||||
add(new Label(FileAttachmentGlobalizationUtil.globalize(
|
||||
"cms.contentassets.file_attachment.caption")));
|
||||
add(m_captionText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
s_log.debug("Init");
|
||||
m_captionText.setValue(state, null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(final FormSectionEvent event) throws FormProcessException {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// process: update the mime type and content
|
||||
@Override
|
||||
public void process(final FormSectionEvent event) throws FormProcessException {
|
||||
s_log.debug("Uploading File");
|
||||
|
||||
final PageState state = event.getPageState();
|
||||
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));
|
||||
|
||||
attachment.setFileOwner(item);
|
||||
attachment.save();
|
||||
item.save();
|
||||
|
||||
// Save everything
|
||||
this.setFileAttachment(state);
|
||||
DispatcherHelper.cacheDisable(state.getResponse());
|
||||
s_log.debug("File Uploaded");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the save/cancel section for this form
|
||||
*/
|
||||
public FileUploadSection getFileUploadSection() {
|
||||
return m_fileUploadSection;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,7 +30,6 @@ import com.arsdigita.bebop.form.Submit;
|
|||
import com.arsdigita.bebop.form.TextArea;
|
||||
import com.arsdigita.cms.contentassets.FileAttachment;
|
||||
import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
|
||||
/**
|
||||
* Form to edit the description of a file attachment. File description edit
|
||||
|
|
@ -77,8 +76,9 @@ public class FileDescriptionForm extends FormSection implements
|
|||
m_description = new TextArea("description");
|
||||
m_description.setCols(40);
|
||||
m_description.setRows(5);
|
||||
add(new Label(GlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.description")));
|
||||
|
||||
add(new Label(FileAttachmentGlobalizationUtil
|
||||
.globalize("cms.contentassets.file_attachment.caption_or_description")));
|
||||
|
||||
add(m_description);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue