- 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
master
jensp 2015-06-22 09:45:32 +00:00
parent c9db46ce01
commit fac695044f
6 changed files with 146 additions and 94 deletions

View File

@ -26,7 +26,7 @@ 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.DHTMLEditor; 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.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
@ -54,7 +54,8 @@ 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 DHTMLEditor m_title; //private DHTMLEditor m_title;
private TextField m_title;
private DHTMLEditor m_captionText; private DHTMLEditor m_captionText;
private static final FileAttachmentConfig s_config = FileAttachmentConfig private static final FileAttachmentConfig s_config = FileAttachmentConfig
@ -129,7 +130,9 @@ public class FileAttachmentCaptionForm extends Form
// Add the widgets // Add the widgets
public void addWidgets() { 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(); m_title.lock();
add(new Label(FileAttachmentGlobalizationUtil.globalize( add(new Label(FileAttachmentGlobalizationUtil.globalize(

View File

@ -29,7 +29,7 @@ import com.arsdigita.bebop.event.FormValidationListener;
import com.arsdigita.bebop.form.DHTMLEditor; 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.form.TextField;
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;
@ -49,7 +49,8 @@ public class FileDescriptionForm extends FormSection implements
private static final FileAttachmentConfig s_config = FileAttachmentConfig private static final FileAttachmentConfig s_config = FileAttachmentConfig
.instanceOf(); .instanceOf();
private TextArea m_title; //private TextArea m_title;
private TextField m_title;
private TextArea m_descriptionDHTML; private TextArea m_descriptionDHTML;
private TextArea m_description; private TextArea m_description;
private FileAttachmentSelectionModel m_fileModel; private FileAttachmentSelectionModel m_fileModel;
@ -84,7 +85,9 @@ public class FileDescriptionForm extends FormSection implements
*/ */
protected void addWidgets() { 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 titleLabel = new Label(FileAttachmentGlobalizationUtil
.globalize("cms.contentassets.file_attachment.title")); .globalize("cms.contentassets.file_attachment.title"));
add(titleLabel); add(titleLabel);
@ -175,6 +178,7 @@ public class FileDescriptionForm extends FormSection implements
m_descriptionDHTML.setVisible(state, true); m_descriptionDHTML.setVisible(state, true);
String name = file.getName(); String name = file.getName();
m_title.setVisible(state, true); m_title.setVisible(state, true);
titleLabel.setVisible(state, true);
if (name != null && name.equals("iscaption")) { if (name != null && name.equals("iscaption")) {
m_title.setValue(state, null); m_title.setValue(state, null);
} else { } else {

View File

@ -9,7 +9,6 @@ import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.RelatedLink; import com.arsdigita.cms.contentassets.RelatedLink;
import com.arsdigita.cms.contenttypes.ui.LinkSelectionModel; import com.arsdigita.cms.contenttypes.ui.LinkSelectionModel;

View File

@ -35,6 +35,7 @@ import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.DHTMLEditor; 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.form.TextField;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringLengthValidationListener; import com.arsdigita.bebop.parameters.StringLengthValidationListener;
import com.arsdigita.cms.CMSConfig; import com.arsdigita.cms.CMSConfig;
@ -63,10 +64,11 @@ import org.apache.log4j.Logger;
* @author konerman (konerman@tzi.de) * @author konerman (konerman@tzi.de)
*/ */
public class RelatedLinkCaptionForm extends FormSection public class RelatedLinkCaptionForm extends FormSection
implements FormInitListener, FormProcessListener, implements FormInitListener, FormProcessListener,
FormValidationListener, FormSubmissionListener { 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 * Name of this form
@ -75,7 +77,8 @@ public class RelatedLinkCaptionForm extends FormSection
public static final String SSL_PROTOCOL = "https://"; public static final String SSL_PROTOCOL = "https://";
public static final String HTTP_PROTOCOL = "http://"; public static final String HTTP_PROTOCOL = "http://";
protected TextArea m_description; protected TextArea m_description;
protected TextArea m_title; //protected TextArea m_title;
protected TextField m_title;
protected ItemSelectionModel m_itemModel; protected ItemSelectionModel m_itemModel;
protected LinkSelectionModel m_linkModel; protected LinkSelectionModel m_linkModel;
private SaveCancelSection m_saveCancelSection; 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 * Constructor creates a new form to edit the Link object specified by the
* item selection model passed in. * item selection model passed in.
* *
* @param itemModel The ItemSelectionModel to use to obtain the ContentItem * @param itemModel The ItemSelectionModel to use to obtain the
* to which this link is (or will be) attached * ContentItem to which this link is (or will be)
* @param link The LinkSelectionModel to use to obtain the Link to work on * attached
* @param link The LinkSelectionModel to use to obtain the Link to
* work on
* @param linkListName * @param linkListName
*/ */
public RelatedLinkCaptionForm(ItemSelectionModel itemModel, public RelatedLinkCaptionForm(ItemSelectionModel itemModel,
LinkSelectionModel link, String linkListName) { LinkSelectionModel link, String linkListName) {
this(itemModel, link, linkListName, null); this(itemModel, link, linkListName, null);
} }
@ -106,8 +111,8 @@ public class RelatedLinkCaptionForm extends FormSection
* @param contentType * @param contentType
*/ */
public RelatedLinkCaptionForm(ItemSelectionModel itemModel, public RelatedLinkCaptionForm(ItemSelectionModel itemModel,
LinkSelectionModel link, String linkListName, LinkSelectionModel link, String linkListName,
ContentType contentType) { ContentType contentType) {
super(new ColumnPanel(2)); super(new ColumnPanel(2));
m_linkListName = linkListName; m_linkListName = linkListName;
@ -131,17 +136,20 @@ public class RelatedLinkCaptionForm extends FormSection
* Adds widgets to the form. * Adds widgets to the form.
*/ */
protected void addWidgets() { protected void addWidgets() {
m_title = new DHTMLEditor("captiontitle"); //m_title = new DHTMLEditor("captiontitle");
add(new Label(RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.title"))); m_title = new TextField("captiontitle");
add(new Label(RelatedLinkGlobalizationUtil.globalize(
"cms.contentassets.ui.related_link.title")));
add(m_title); add(m_title);
/* Add the standard description field */ /* Add the standard description field */
m_description = new DHTMLEditor("description"); m_description = new DHTMLEditor("description");
// m_description.addValidationListener(new NotNullValidationListener()); // m_description.addValidationListener(new NotNullValidationListener());
m_description.addValidationListener(new StringLengthValidationListener(CMSConfig m_description.addValidationListener(new StringLengthValidationListener(
.getInstanceOf().getLinkDescMaxLength())); CMSConfig
add(new Label(RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.Description"))); .getInstanceOf().getLinkDescMaxLength()));
add(new Label(RelatedLinkGlobalizationUtil.globalize(
"cms.contentassets.ui.related_link.Description")));
add(m_description); add(m_description);
} }
@ -153,37 +161,37 @@ public class RelatedLinkCaptionForm extends FormSection
m_saveCancelSection = new SaveCancelSection(); m_saveCancelSection = new SaveCancelSection();
try { try {
m_saveCancelSection.getCancelButton().addPrintListener( m_saveCancelSection.getCancelButton().addPrintListener(
new PrintListener() { new PrintListener() {
@Override @Override
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
Submit target = (Submit) e.getTarget(); Submit target = (Submit) e.getTarget();
if (m_linkModel.isSelected(e.getPageState())) { if (m_linkModel.isSelected(e.getPageState())) {
target.setButtonLabel(GlobalizationUtil.globalize( target.setButtonLabel(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.button_cancel")); "cms.contenttyes.link.ui.button_cancel"));
} else { } else {
target.setButtonLabel(GlobalizationUtil.globalize( target.setButtonLabel(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.button_reset")); "cms.contenttyes.link.ui.button_reset"));
}
} }
}
}); });
m_saveCancelSection.getSaveButton().addPrintListener( m_saveCancelSection.getSaveButton().addPrintListener(
new PrintListener() { new PrintListener() {
@Override @Override
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
Submit target = (Submit) e.getTarget(); Submit target = (Submit) e.getTarget();
if (m_linkModel.isSelected(e.getPageState())) { if (m_linkModel.isSelected(e.getPageState())) {
target.setButtonLabel(GlobalizationUtil.globalize( target.setButtonLabel(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.button_save")); "cms.contenttyes.link.ui.button_save"));
} else { } else {
target.setButtonLabel(GlobalizationUtil.globalize( target.setButtonLabel(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.button_create")); "cms.contenttyes.link.ui.button_create"));
}
} }
}
}); });
} catch (TooManyListenersException e) { } catch (TooManyListenersException e) {
throw new UncheckedWrapperException("this cannot happen", e); throw new UncheckedWrapperException("this cannot happen", e);
} }
@ -215,13 +223,13 @@ public class RelatedLinkCaptionForm extends FormSection
*/ */
@Override @Override
public void submitted(FormSectionEvent e) public void submitted(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
if (m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) { if (m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) {
s_log.debug("cancel in submission listener"); s_log.debug("cancel in submission listener");
m_linkModel.clearSelection(e.getPageState()); m_linkModel.clearSelection(e.getPageState());
init(e); init(e);
throw new FormProcessException( 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 @Override
public void validate(FormSectionEvent event) public void validate(FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
// test if the user has made an input // test if the user has made an input
PageState state = event.getPageState(); PageState state = event.getPageState();
String title = (String) m_title.getValue(state); String title = (String) m_title.getValue(state);
String desc = (String) m_description.getValue(state); String desc = (String) m_description.getValue(state);
if ((title.length() + desc.length()) <= 0) { if ((title.length() + desc.length()) <= 0) {
throw new FormProcessException(RelatedLinkGlobalizationUtil throw new FormProcessException(RelatedLinkGlobalizationUtil
.globalize( .globalize(
"cms.contentassets.ui.related_link.input_mandatory")); "cms.contentassets.ui.related_link.input_mandatory"));
} }
} }
@ -293,7 +301,7 @@ public class RelatedLinkCaptionForm extends FormSection
s_log.debug("Init"); s_log.debug("Init");
s_log.debug("new link"); s_log.debug("new link");
m_description.setValue(state, null); 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. //call to set various properties of Link.
setLinkProperties(link, fse); setLinkProperties(link, fse);
s_log.debug("Created Link with ID: " + link.getOID().toString() s_log.debug("Created Link with ID: " + link.getOID().toString()
+ "Title " + link.getTitle()); + "Title " + link.getTitle());
} }
// XXX Initialize the form // XXX Initialize the form
m_linkModel.clearSelection(state); m_linkModel.clearSelection(state);
@ -344,13 +352,13 @@ public class RelatedLinkCaptionForm extends FormSection
protected void setLinkProperties(RelatedLink link, FormSectionEvent fse) { protected void setLinkProperties(RelatedLink link, FormSectionEvent fse) {
PageState state = fse.getPageState(); PageState state = fse.getPageState();
FormData data = fse.getFormData(); FormData data = fse.getFormData();
String title = (String) m_title.getValue(state); String title = (String) m_title.getValue(state);
if(!title.isEmpty()){ if (!title.isEmpty()) {
link.setTitle(title); link.setTitle(title);
} else { } else {
//if user did not typed in a title //if user did not typed in a title
link.setTitle(" "); link.setTitle(" ");
} }
link.setDescription((String) m_description.getValue(state)); link.setDescription((String) m_description.getValue(state));
link.setTargetType(RelatedLink.EXTERNAL_LINK); link.setTargetType(RelatedLink.EXTERNAL_LINK);
@ -361,8 +369,8 @@ public class RelatedLinkCaptionForm extends FormSection
link.setTargetItem(null); link.setTargetItem(null);
link.setLinkListName(m_linkListName); link.setLinkListName(m_linkListName);
DataCollection links = RelatedLink.getRelatedLinks( DataCollection links = RelatedLink.getRelatedLinks(
getContentItem(fse.getPageState()), getContentItem(fse.getPageState()),
m_linkListName); m_linkListName);
//Only change link order if we are creating a new link //Only change link order if we are creating a new link
if (!getLinkSelectionModel().isSelected(fse.getPageState())) { if (!getLinkSelectionModel().isSelected(fse.getPageState())) {
link.setOrder((int) links.size() + 1); link.setOrder((int) links.size() + 1);

View File

@ -42,7 +42,8 @@
</xsl:template> </xsl:template>
<xsl:template match="file-attachments//file-attachment"> <xsl:template match="file-attachments//file-attachment">
<xsl:variable name="files-layout-tree" select="current()"/> <xsl:variable name="caption-layout-tree" select="current()/caption-layout"/>
<xsl:variable name="file-layout-tree" select="current()/file-layout"/>
<!--<pre> <!--<pre>
file-attachment file-attachment
@ -69,30 +70,50 @@
<xsl:value-of select="concat('file-size = ', ./file-size)"/> <xsl:value-of select="concat('file-size = ', ./file-size)"/>
</pre>--> </pre>-->
<xsl:apply-templates select="$files-layout-tree/*"> <xsl:choose>
<xsl:with-param name="file-id" <xsl:when test="./mimeType/mimeType = 'text/plain'
tunnel="yes" and ./mimeType/label = 'caption'">
select="./id"/> <xsl:apply-templates select="$caption-layout-tree/*">
<xsl:with-param name="file-name" <xsl:with-param name="file-name"
tunnel="yes" tunnel="yes"
select="./name"/> select="./name"/>
<xsl:with-param name="mime-type" <xsl:with-param name="description"
tunnel="yes" tunnel="yes"
select="./mimeType/mimeType"/> select="./description"/>
<xsl:with-param name="file-size" <xsl:with-param name="class"
tunnel="yes" tunnel="yes"
select="./length"/> select="'caption'"/>
<xsl:with-param name="description" </xsl:apply-templates>
tunnel="yes" </xsl:when>
select="./description"/> <xsl:otherwise>
<xsl:with-param name="href" <xsl:apply-templates select="$file-layout-tree/*">
tunnel="yes" <xsl:with-param name="file-id"
select="concat($context-prefix, tunnel="yes"
'/ccm/cms-service/stream/asset/', ./name, '?asset_id=', ./id)"/> select="./id"/>
<xsl:with-param name="class" <xsl:with-param name="file-name"
tunnel="yes" tunnel="yes"
select="concat('mime-type-', replace(./mimeType/mimeType, '/', '-'))"/> select="./name"/>
</xsl:apply-templates> <xsl:with-param name="mime-type"
tunnel="yes"
select="./mimeType/mimeType"/>
<xsl:with-param name="file-size"
tunnel="yes"
select="./length"/>
<xsl:with-param name="description"
tunnel="yes"
select="./description"/>
<xsl:with-param name="href"
tunnel="yes"
select="concat($context-prefix,
'/ccm/cms-service/stream/asset/',
./name, '?asset_id=', ./id)"/>
<xsl:with-param name="class"
tunnel="yes"
select="concat('mime-type-',
replace(./mimeType/mimeType, '/', '-'))"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each> </xsl:for-each>
</xsl:template> </xsl:template>
@ -143,7 +164,8 @@
<xsl:template match="file-attachment//file-description"> <xsl:template match="file-attachment//file-description">
<xsl:param name="description" tunnel="yes"/> <xsl:param name="description" tunnel="yes"/>
<xsl:value-of select="$description"/> <xsl:value-of disable-output-escaping="yes"
select="$description"/>
</xsl:template> </xsl:template>
<xsl:template match="file-attachment//file-label"> <xsl:template match="file-attachment//file-label">

View File

@ -81,11 +81,23 @@
<xsl:sort select="linkOrder"/> <xsl:sort select="linkOrder"/>
<xsl:choose> <xsl:choose>
<xsl:when test="./targetType = 'externalLink'
and ./targetURI = 'caption'">
<xsl:apply-templates select="$links-layout-tree/caption/*">
<xsl:with-param name="link-title"
tunnel="yes"
select="./linkTitle"/>
<xsl:with-param name="link-desc"
tunnel="yes"
select="./linkDescription"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="./targetType = 'internalLink'"> <xsl:when test="./targetType = 'internalLink'">
<xsl:variable name="params"> <xsl:variable name="params">
<xsl:choose> <xsl:choose>
<xsl:when test="starts-with(./targetURI, '&amp;?')"> <xsl:when test="starts-with(./targetURI, '&amp;?')">
<xsl:value-of select="concat('&amp;', substring(./targetURI, 3))"/> <xsl:value-of select="concat('&amp;',
substring(./targetURI, 3))"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="./targetURI"/> <xsl:value-of select="./targetURI"/>
@ -94,8 +106,12 @@
</xsl:variable> </xsl:variable>
<xsl:apply-templates select="$links-layout-tree/internal/*"> <xsl:apply-templates select="$links-layout-tree/internal/*">
<xsl:with-param name="link-title" tunnel="yes" select="./linkTitle"/> <xsl:with-param name="link-title"
<xsl:with-param name="link-desc" tunnel="yes" select="./linkDescription"/> tunnel="yes"
select="./linkTitle"/>
<xsl:with-param name="link-desc"
tunnel="yes"
select="./linkDescription"/>
<xsl:with-param name="href" <xsl:with-param name="href"
tunnel="yes" tunnel="yes"
select="concat($context-prefix, select="concat($context-prefix,
@ -145,7 +161,7 @@
<xsl:template match="related-link//related-link-desc"> <xsl:template match="related-link//related-link-desc">
<xsl:param name="link-desc" tunnel="yes"/> <xsl:param name="link-desc" tunnel="yes"/>
<xsl:value-of select="$link-desc"/> <xsl:value-of disable-output-escaping="yes" select="$link-desc"/>
</xsl:template> </xsl:template>
<foundry:doc section="user" type="template-tag"> <foundry:doc section="user" type="template-tag">