- 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.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(

View File

@ -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 {

View File

@ -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;

View File

@ -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);

View File

@ -42,7 +42,8 @@
</xsl:template>
<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>
file-attachment
@ -69,30 +70,50 @@
<xsl:value-of select="concat('file-size = ', ./file-size)"/>
</pre>-->
<xsl:apply-templates select="$files-layout-tree/*">
<xsl:with-param name="file-id"
tunnel="yes"
select="./id"/>
<xsl:with-param name="file-name"
tunnel="yes"
select="./name"/>
<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:choose>
<xsl:when test="./mimeType/mimeType = 'text/plain'
and ./mimeType/label = 'caption'">
<xsl:apply-templates select="$caption-layout-tree/*">
<xsl:with-param name="file-name"
tunnel="yes"
select="./name"/>
<xsl:with-param name="description"
tunnel="yes"
select="./description"/>
<xsl:with-param name="class"
tunnel="yes"
select="'caption'"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="$file-layout-tree/*">
<xsl:with-param name="file-id"
tunnel="yes"
select="./id"/>
<xsl:with-param name="file-name"
tunnel="yes"
select="./name"/>
<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:template>
@ -143,7 +164,8 @@
<xsl:template match="file-attachment//file-description">
<xsl:param name="description" tunnel="yes"/>
<xsl:value-of select="$description"/>
<xsl:value-of disable-output-escaping="yes"
select="$description"/>
</xsl:template>
<xsl:template match="file-attachment//file-label">

View File

@ -81,11 +81,23 @@
<xsl:sort select="linkOrder"/>
<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:variable name="params">
<xsl:choose>
<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:otherwise>
<xsl:value-of select="./targetURI"/>
@ -94,8 +106,12 @@
</xsl:variable>
<xsl:apply-templates select="$links-layout-tree/internal/*">
<xsl:with-param name="link-title" tunnel="yes" select="./linkTitle"/>
<xsl:with-param name="link-desc" tunnel="yes" select="./linkDescription"/>
<xsl:with-param name="link-title"
tunnel="yes"
select="./linkTitle"/>
<xsl:with-param name="link-desc"
tunnel="yes"
select="./linkDescription"/>
<xsl:with-param name="href"
tunnel="yes"
select="concat($context-prefix,
@ -145,7 +161,7 @@
<xsl:template match="related-link//related-link-desc">
<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>
<foundry:doc section="user" type="template-tag">