From fac695044f10f63cb7d63571af878d8373239792 Mon Sep 17 00:00:00 2001 From: jensp Date: Mon, 22 Jun 2015 09:45:32 +0000 Subject: [PATCH] - Support for captions in the list of FileAttachments and RelatedLinks - Some finetuning for the forms editing them in Content Centre git-svn-id: https://svn.libreccm.org/ccm/trunk@3494 8810af33-2d31-482b-a856-94f89814c4df --- .../ui/FileAttachmentCaptionForm.java | 9 +- .../contentassets/ui/FileDescriptionForm.java | 10 +- .../ui/RelatedLinkCaptionEditForm.java | 1 - .../ui/RelatedLinkCaptionForm.java | 122 ++++++++++-------- .../content-items/assets/file-attachments.xsl | 74 +++++++---- .../content-items/assets/related-links.xsl | 24 +++- 6 files changed, 146 insertions(+), 94 deletions(-) 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 9a547e33b..fb2b42c6d 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 @@ -26,7 +26,7 @@ import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormValidationListener; import com.arsdigita.bebop.form.DHTMLEditor; -import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.parameters.StringInRangeValidationListener; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ItemSelectionModel; @@ -54,7 +54,8 @@ public class FileAttachmentCaptionForm extends Form private FileUploadSection m_fileUploadSection; private ItemSelectionModel m_itemModel; private SaveCancelSection m_saveCancelSection; - private DHTMLEditor m_title; + //private DHTMLEditor m_title; + private TextField m_title; private DHTMLEditor m_captionText; private static final FileAttachmentConfig s_config = FileAttachmentConfig @@ -129,7 +130,9 @@ public class FileAttachmentCaptionForm extends Form // Add the widgets public void addWidgets() { - m_title = new DHTMLEditor("captiontitle"); + //m_title = new DHTMLEditor("captiontitle"); + m_title = new TextField("captiontitle"); + m_title.setSize(32); m_title.lock(); add(new Label(FileAttachmentGlobalizationUtil.globalize( 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 a7bfb0485..886ba11fa 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 @@ -29,7 +29,7 @@ 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.form.TextField; import com.arsdigita.bebop.parameters.StringInRangeValidationListener; import com.arsdigita.cms.contentassets.FileAttachment; import com.arsdigita.cms.contentassets.FileAttachmentConfig; @@ -49,7 +49,8 @@ public class FileDescriptionForm extends FormSection implements private static final FileAttachmentConfig s_config = FileAttachmentConfig .instanceOf(); - private TextArea m_title; + //private TextArea m_title; + private TextField m_title; private TextArea m_descriptionDHTML; private TextArea m_description; private FileAttachmentSelectionModel m_fileModel; @@ -84,7 +85,9 @@ public class FileDescriptionForm extends FormSection implements */ protected void addWidgets() { - m_title = new DHTMLEditor("title"); + //m_title = new DHTMLEditor("title"); + m_title = new TextField("title"); + m_title.setSize(32); titleLabel = new Label(FileAttachmentGlobalizationUtil .globalize("cms.contentassets.file_attachment.title")); add(titleLabel); @@ -175,6 +178,7 @@ public class FileDescriptionForm extends FormSection implements m_descriptionDHTML.setVisible(state, true); String name = file.getName(); m_title.setVisible(state, true); + titleLabel.setVisible(state, true); if (name != null && name.equals("iscaption")) { m_title.setValue(state, null); } else { diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionEditForm.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionEditForm.java index 9888f4edf..b75018882 100644 --- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionEditForm.java +++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionEditForm.java @@ -9,7 +9,6 @@ import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contentassets.RelatedLink; import com.arsdigita.cms.contenttypes.ui.LinkSelectionModel; diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionForm.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionForm.java index 47fadb6ee..ca0bca766 100644 --- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionForm.java +++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionForm.java @@ -35,6 +35,7 @@ import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.form.DHTMLEditor; import com.arsdigita.bebop.form.Submit; import com.arsdigita.bebop.form.TextArea; +import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.StringLengthValidationListener; import com.arsdigita.cms.CMSConfig; @@ -63,10 +64,11 @@ import org.apache.log4j.Logger; * @author konerman (konerman@tzi.de) */ public class RelatedLinkCaptionForm extends FormSection - implements FormInitListener, FormProcessListener, - FormValidationListener, FormSubmissionListener { + implements FormInitListener, FormProcessListener, + FormValidationListener, FormSubmissionListener { - private static final Logger s_log = Logger.getLogger(RelatedLinkCaptionForm.class); + private static final Logger s_log = Logger.getLogger( + RelatedLinkCaptionForm.class); /** * Name of this form @@ -75,7 +77,8 @@ public class RelatedLinkCaptionForm extends FormSection public static final String SSL_PROTOCOL = "https://"; public static final String HTTP_PROTOCOL = "http://"; protected TextArea m_description; - protected TextArea m_title; + //protected TextArea m_title; + protected TextField m_title; protected ItemSelectionModel m_itemModel; protected LinkSelectionModel m_linkModel; private SaveCancelSection m_saveCancelSection; @@ -87,13 +90,15 @@ public class RelatedLinkCaptionForm extends FormSection * Constructor creates a new form to edit the Link object specified by the * item selection model passed in. * - * @param itemModel The ItemSelectionModel to use to obtain the ContentItem - * to which this link is (or will be) attached - * @param link The LinkSelectionModel to use to obtain the Link to work on + * @param itemModel The ItemSelectionModel to use to obtain the + * ContentItem to which this link is (or will be) + * attached + * @param link The LinkSelectionModel to use to obtain the Link to + * work on * @param linkListName */ public RelatedLinkCaptionForm(ItemSelectionModel itemModel, - LinkSelectionModel link, String linkListName) { + LinkSelectionModel link, String linkListName) { this(itemModel, link, linkListName, null); } @@ -106,8 +111,8 @@ public class RelatedLinkCaptionForm extends FormSection * @param contentType */ public RelatedLinkCaptionForm(ItemSelectionModel itemModel, - LinkSelectionModel link, String linkListName, - ContentType contentType) { + LinkSelectionModel link, String linkListName, + ContentType contentType) { super(new ColumnPanel(2)); m_linkListName = linkListName; @@ -131,17 +136,20 @@ public class RelatedLinkCaptionForm extends FormSection * Adds widgets to the form. */ protected void addWidgets() { - m_title = new DHTMLEditor("captiontitle"); - add(new Label(RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.title"))); + //m_title = new DHTMLEditor("captiontitle"); + m_title = new TextField("captiontitle"); + add(new Label(RelatedLinkGlobalizationUtil.globalize( + "cms.contentassets.ui.related_link.title"))); add(m_title); - - + /* Add the standard description field */ m_description = new DHTMLEditor("description"); // m_description.addValidationListener(new NotNullValidationListener()); - m_description.addValidationListener(new StringLengthValidationListener(CMSConfig - .getInstanceOf().getLinkDescMaxLength())); - add(new Label(RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.Description"))); + m_description.addValidationListener(new StringLengthValidationListener( + CMSConfig + .getInstanceOf().getLinkDescMaxLength())); + add(new Label(RelatedLinkGlobalizationUtil.globalize( + "cms.contentassets.ui.related_link.Description"))); add(m_description); } @@ -153,37 +161,37 @@ public class RelatedLinkCaptionForm extends FormSection m_saveCancelSection = new SaveCancelSection(); try { m_saveCancelSection.getCancelButton().addPrintListener( - new PrintListener() { + new PrintListener() { - @Override - public void prepare(PrintEvent e) { - Submit target = (Submit) e.getTarget(); - if (m_linkModel.isSelected(e.getPageState())) { - target.setButtonLabel(GlobalizationUtil.globalize( - "cms.contenttyes.link.ui.button_cancel")); - } else { - target.setButtonLabel(GlobalizationUtil.globalize( - "cms.contenttyes.link.ui.button_reset")); - } + @Override + public void prepare(PrintEvent e) { + Submit target = (Submit) e.getTarget(); + if (m_linkModel.isSelected(e.getPageState())) { + target.setButtonLabel(GlobalizationUtil.globalize( + "cms.contenttyes.link.ui.button_cancel")); + } else { + target.setButtonLabel(GlobalizationUtil.globalize( + "cms.contenttyes.link.ui.button_reset")); } + } - }); + }); m_saveCancelSection.getSaveButton().addPrintListener( - new PrintListener() { + new PrintListener() { - @Override - public void prepare(PrintEvent e) { - Submit target = (Submit) e.getTarget(); - if (m_linkModel.isSelected(e.getPageState())) { - target.setButtonLabel(GlobalizationUtil.globalize( - "cms.contenttyes.link.ui.button_save")); - } else { - target.setButtonLabel(GlobalizationUtil.globalize( - "cms.contenttyes.link.ui.button_create")); - } + @Override + public void prepare(PrintEvent e) { + Submit target = (Submit) e.getTarget(); + if (m_linkModel.isSelected(e.getPageState())) { + target.setButtonLabel(GlobalizationUtil.globalize( + "cms.contenttyes.link.ui.button_save")); + } else { + target.setButtonLabel(GlobalizationUtil.globalize( + "cms.contenttyes.link.ui.button_create")); } + } - }); + }); } catch (TooManyListenersException e) { throw new UncheckedWrapperException("this cannot happen", e); } @@ -215,13 +223,13 @@ public class RelatedLinkCaptionForm extends FormSection */ @Override public void submitted(FormSectionEvent e) - throws FormProcessException { + throws FormProcessException { if (m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) { s_log.debug("cancel in submission listener"); m_linkModel.clearSelection(e.getPageState()); init(e); throw new FormProcessException( - GlobalizationUtil.globalize("cms.contenttypes.ui.cancelled")); + GlobalizationUtil.globalize("cms.contenttypes.ui.cancelled")); } } @@ -235,16 +243,16 @@ public class RelatedLinkCaptionForm extends FormSection */ @Override public void validate(FormSectionEvent event) - throws FormProcessException { - - // test if the user has made an input + throws FormProcessException { + + // test if the user has made an input PageState state = event.getPageState(); String title = (String) m_title.getValue(state); String desc = (String) m_description.getValue(state); if ((title.length() + desc.length()) <= 0) { throw new FormProcessException(RelatedLinkGlobalizationUtil - .globalize( - "cms.contentassets.ui.related_link.input_mandatory")); + .globalize( + "cms.contentassets.ui.related_link.input_mandatory")); } } @@ -293,7 +301,7 @@ public class RelatedLinkCaptionForm extends FormSection s_log.debug("Init"); s_log.debug("new link"); m_description.setValue(state, null); - m_title.setValue(state,null); + m_title.setValue(state, null); } /** @@ -327,7 +335,7 @@ public class RelatedLinkCaptionForm extends FormSection //call to set various properties of Link. setLinkProperties(link, fse); s_log.debug("Created Link with ID: " + link.getOID().toString() - + "Title " + link.getTitle()); + + "Title " + link.getTitle()); } // XXX Initialize the form m_linkModel.clearSelection(state); @@ -344,13 +352,13 @@ public class RelatedLinkCaptionForm extends FormSection protected void setLinkProperties(RelatedLink link, FormSectionEvent fse) { PageState state = fse.getPageState(); FormData data = fse.getFormData(); - + String title = (String) m_title.getValue(state); - if(!title.isEmpty()){ - link.setTitle(title); + if (!title.isEmpty()) { + link.setTitle(title); } else { - //if user did not typed in a title - link.setTitle(" "); + //if user did not typed in a title + link.setTitle(" "); } link.setDescription((String) m_description.getValue(state)); link.setTargetType(RelatedLink.EXTERNAL_LINK); @@ -361,8 +369,8 @@ public class RelatedLinkCaptionForm extends FormSection link.setTargetItem(null); link.setLinkListName(m_linkListName); DataCollection links = RelatedLink.getRelatedLinks( - getContentItem(fse.getPageState()), - m_linkListName); + getContentItem(fse.getPageState()), + m_linkListName); //Only change link order if we are creating a new link if (!getLinkSelectionModel().isSelected(fse.getPageState())) { link.setOrder((int) links.size() + 1); diff --git a/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items/assets/file-attachments.xsl b/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items/assets/file-attachments.xsl index 7735afe7b..3cc75d63b 100644 --- a/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items/assets/file-attachments.xsl +++ b/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items/assets/file-attachments.xsl @@ -42,7 +42,8 @@ - + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -143,7 +164,8 @@ - + diff --git a/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items/assets/related-links.xsl b/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items/assets/related-links.xsl index 4a034eaac..43309b646 100644 --- a/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items/assets/related-links.xsl +++ b/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items/assets/related-links.xsl @@ -81,11 +81,23 @@ + + + + + + - + @@ -94,8 +106,12 @@ - - + + - +