Fixing several problems with image attachments (#2484, #2485, #2486)

git-svn-id: https://svn.libreccm.org/ccm/trunk@3450 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2015-06-02 07:38:03 +00:00
parent 2ac2d9a7ff
commit 8760ac5e73
14 changed files with 464 additions and 421 deletions

View File

@ -10,9 +10,9 @@ cms.contentassets.ui.image_step.caption=Caption
cms.contentassets.ui.image_step.image_table.thumbnail=Thumbnail
cms.contentassets.ui.image_step.remove_attached_image.confirm=Are you sure to remove this attached image?
cms.contentassets.ui.image_step.image_table.properties=Image properties
cms.contentassets.ui.image_step.table.edit_attached_image=\u270D
cms.contentassets.ui.image_step.table.move_attached_image_up=\u2B06
cms.contentassets.ui.image_step.table.move_attached_image_down=\u2B07
cms.contentassets.ui.image_step.table.edit_attached_image=\u270d
cms.contentassets.ui.image_step.table.move_attached_image_up=\u2b06
cms.contentassets.ui.image_step.table.move_attached_image_down=\u2b07
cms.contentassets.ui.image_step.table.remove_attached_image=\u2716
cms.contentassets.ui.image_step.table.edit_attached_image.header=
cms.contentassets.ui.image_step.table.move_attached_image_up.header=

View File

@ -10,9 +10,9 @@ cms.contentassets.ui.image_step.caption=Bildunterschrift
cms.contentassets.ui.image_step.image_table.thumbnail=Vorschau
cms.contentassets.ui.image_step.remove_attached_image.confirm=Sind Sie sicher das Sie die Zuordnung dieses Bildes entfernen m\u00f6chten?
cms.contentassets.ui.image_step.image_table.properties=Bildeigenschaften
cms.contentassets.ui.image_step.table.edit_attached_image=\u270D
cms.contentassets.ui.image_step.table.move_attached_image_up=\u2B06
cms.contentassets.ui.image_step.table.move_attached_image_down=\u2B07
cms.contentassets.ui.image_step.table.edit_attached_image=\u270d
cms.contentassets.ui.image_step.table.move_attached_image_up=\u2b06
cms.contentassets.ui.image_step.table.move_attached_image_down=\u2b07
cms.contentassets.ui.image_step.table.remove_attached_image=\u2716
cms.contentassets.ui.image_step.table.edit_attached_image.header=
cms.contentassets.ui.image_step.table.move_attached_image_up.header=

View File

@ -10,9 +10,9 @@ cms.contentassets.ui.image_step.caption=Caption
cms.contentassets.ui.image_step.image_table.thumbnail=Thumbnail
cms.contentassets.ui.image_step.remove_attached_image.confirm=cms.contentassets.ui.image_step.remove_attached_image.confirm
cms.contentassets.ui.image_step.image_table.properties=Image properties
cms.contentassets.ui.image_step.table.edit_attached_image=\u270D
cms.contentassets.ui.image_step.table.move_attached_image_up=\u2B06
cms.contentassets.ui.image_step.table.move_attached_image_down=\u2B07
cms.contentassets.ui.image_step.table.edit_attached_image=\u270d
cms.contentassets.ui.image_step.table.move_attached_image_up=\u2b06
cms.contentassets.ui.image_step.table.move_attached_image_down=\u2b07
cms.contentassets.ui.image_step.table.remove_attached_image=\u2716
cms.contentassets.ui.image_step.table.edit_attached_image.header=
cms.contentassets.ui.image_step.table.move_attached_image_up.header=

View File

@ -9,8 +9,11 @@ import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.contentassets.ItemImageAttachment;
import com.arsdigita.cms.contentassets.util.ImageStepGlobalizationUtil;
import com.arsdigita.cms.util.GlobalizationUtil;
/**
*
@ -19,6 +22,9 @@ import com.arsdigita.cms.contentassets.util.ImageStepGlobalizationUtil;
public class ImageAttachmentEditForm extends Form
implements FormInitListener, FormProcessListener, FormSubmissionListener {
private static final String CAPTION = "caption";
private static final String CONTEXT = "context";
final ImageStep imageStep;
final SaveCancelSection saveCancelSection;
@ -31,9 +37,20 @@ public class ImageAttachmentEditForm extends Form
"cms.contentassets.ui.image_step.caption"));
final TextField captionField = new TextField(CAPTION);
captionField.setLabel(ImageStepGlobalizationUtil.globalize(
"cms.contentassets.ui.image_step.caption"));
captionField.setSize(CMS.getConfig().getImageBrowserCaptionSize());
captionField.addValidationListener(
new StringInRangeValidationListener(1, 100));
final TextField contextField = new TextField(CONTEXT);
contextField.setSize(40);
contextField.setLabel(GlobalizationUtil
.globalize("cms.contentasset.image.ui.use_context"));
add(label);
add(captionField);
add(contextField);
saveCancelSection = new SaveCancelSection();
add(saveCancelSection);
@ -43,20 +60,24 @@ public class ImageAttachmentEditForm extends Form
}
private static final String CAPTION = "caption";
@Override
public void init(final FormSectionEvent event) throws FormProcessException {
final ItemImageAttachment attachment = imageStep.getAttachment(event.getPageState());
final ItemImageAttachment attachment = imageStep.getAttachment(event
.getPageState());
event.getFormData().put(CAPTION, attachment.getCaption());
}
@Override
public void process(final FormSectionEvent event) throws FormProcessException {
final ItemImageAttachment attachment = imageStep.getAttachment(event.getPageState());
public void process(final FormSectionEvent event) throws
FormProcessException {
final ItemImageAttachment attachment = imageStep.getAttachment(event
.getPageState());
attachment.setCaption(event.getFormData().getString(CAPTION));
attachment.setUseContext(event.getFormData().getString(CONTEXT));
attachment.save();
@ -64,7 +85,8 @@ public class ImageAttachmentEditForm extends Form
}
@Override
public void submitted(final FormSectionEvent event) throws FormProcessException {
public void submitted(final FormSectionEvent event) throws
FormProcessException {
if (saveCancelSection.getCancelButton().isSelected(event.getPageState())) {
imageStep.setAttachment(event.getPageState(), null);

View File

@ -19,6 +19,7 @@
package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.MapComponentSelectionModel;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent;
@ -27,6 +28,7 @@ import com.arsdigita.cms.ReusableImageAsset;
import com.arsdigita.cms.contentassets.ItemImageAttachment;
import com.arsdigita.cms.ui.ImageComponent;
import com.arsdigita.cms.ui.ImageComponentAbstractListener;
import org.apache.log4j.Logger;
/**
@ -71,6 +73,7 @@ public class ImageComponentAttachListener extends ImageComponentAbstractListener
new RuntimeException());
return;
}
ItemImageAttachment attachment = m_imageStep.getAttachment(ps);
if (null == attachment) {
attachment = new ItemImageAttachment(item, image);

View File

@ -82,7 +82,6 @@ public class ImageStepEdit extends SimpleContainer
Map selectors = m_imageComponent.getComponentsMap();
m_attachListener = new ImageComponentAttachListener(m_imageComponent,
m_imageStep);
/* Include CMS ImageLibrary to display existing images too select from */
ImageLibraryComponent library = new ImageLibraryComponent();
library.getForm().addInitListener(m_attachListener);

View File

@ -1112,3 +1112,4 @@ cms.ui.type.content_editing_failed=Failed to edit the content type: {0}
cms.contenttyes.link.ui.caption=Caption:
cms.contenttyes.link.ui.option_group.caption=caption
cms.contenttypes.ui.title_is_required=A title is required
images.no_image_selected=No image selected

View File

@ -1106,3 +1106,4 @@ cms.ui.type.content_editing_failed=Bearbeitung des Dokumenttyps: {0} ist fehlges
cms.contenttyes.link.ui.caption=Zwischentitel:
cms.contenttyes.link.ui.option_group.caption=Zwischentitel
cms.contenttypes.ui.title_is_required=Ein Titel wird ben\u00f6tigt
images.no_image_selected=Es wurde kein Bild ausgew\u00e4hlt

View File

@ -150,3 +150,4 @@ cms.ui.type.content_editing_failed=
cms.contenttyes.link.ui.caption=Caption:
cms.contenttyes.link.ui.option_group.caption=caption
cms.contenttypes.ui.title_is_required=A title is required
images.no_image_selected=No image selected

View File

@ -622,3 +622,4 @@ cms.ui.type.content_editing_failed=Impossible de modifier le type de contenu: {0
cms.contenttyes.link.ui.caption=Caption:
cms.contenttyes.link.ui.option_group.caption=caption
cms.contenttypes.ui.title_is_required=A title is required
images.no_image_selected=No image selected

View File

@ -13,15 +13,18 @@ import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.cms.ReusableImageAsset;
import com.arsdigita.cms.util.GlobalizationUtil;
import java.util.Iterator;
import java.util.Map;
import org.apache.log4j.Logger;
/**
* An abstract listener for {@link ImageComponent}.
*
* This listener provides the base implementation which is shared between all listeners of this
* kind.
* This listener provides the base implementation which is shared between all
* listeners of this kind.
*
* This listerner is used by {@link ImageSelectPage}.
*
@ -35,7 +38,8 @@ public abstract class ImageComponentAbstractListener implements FormInitListener
ImageComponentSelectListener.class);
MapComponentSelectionModel m_imageComponent;
public ImageComponentAbstractListener(MapComponentSelectionModel imageComponent) {
public ImageComponentAbstractListener(
MapComponentSelectionModel imageComponent) {
super();
m_imageComponent = imageComponent;
}
@ -50,7 +54,8 @@ public abstract class ImageComponentAbstractListener implements FormInitListener
}
/**
* Call {@link #cancelled(com.arsdigita.bebop.PageState)} if the cancel button was pressed.
* Call {@link #cancelled(com.arsdigita.bebop.PageState)} if the cancel
* button was pressed.
*
* @param event the {@link FormSectionEvent}
*
@ -87,6 +92,10 @@ public abstract class ImageComponentAbstractListener implements FormInitListener
// try {
ReusableImageAsset image = component.getImage(event);
if (image == null) {
throw new FormProcessException("No image selected",
GlobalizationUtil.globalize("images.no_image_selected"));
}
processImage(event, ps, component, image);
// } catch (FormProcessException ex) {
@ -110,7 +119,8 @@ public abstract class ImageComponentAbstractListener implements FormInitListener
* @param image the {@link ReusableImageAsset}
*/
protected abstract void processImage(FormSectionEvent event, PageState ps,
ImageComponent component, ReusableImageAsset image);
ImageComponent component,
ReusableImageAsset image);
protected ImageComponent getImageComponent(PageState ps) {
if (!m_imageComponent.isSelected(ps)) {

View File

@ -18,12 +18,14 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ReusableImageAsset;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.domain.DataObjectNotFoundException;
import java.math.BigDecimal;
/**
@ -93,7 +95,6 @@ public class ImageLibraryComponent extends SimpleContainer
});
// Form for additional fields and submit
m_form = new Form("imageLibraryComponent", new ColumnPanel(2));
add(m_form);
@ -110,6 +111,8 @@ public class ImageLibraryComponent extends SimpleContainer
m_form.add(new Label(GlobalizationUtil
.globalize("cms.contentasset.image.ui.caption")));
m_caption.addValidationListener(new NotNullValidationListener());
m_caption.addValidationListener(new StringInRangeValidationListener(
1, CMS.getConfig().getImageBrowserCaptionSize()));
m_caption.setSize(CMS.getConfig().getImageBrowserCaptionSize());
m_form.add(m_caption);
m_description.addValidationListener(new NotNullValidationListener());
@ -128,10 +131,11 @@ public class ImageLibraryComponent extends SimpleContainer
m_form.add(new Label(GlobalizationUtil
.globalize("cms.contentasset.image.ui.use_context")));
m_useContext.setSize(40);
m_useContext.addValidationListener(
new StringInRangeValidationListener(0, 40));
m_form.add(m_useContext);
}
// if (m_mode == ImageComponent.SELECT_IMAGE) {
// m_form.setOnSubmit("selectImage();");
// }

View File

@ -51,6 +51,7 @@ public class CCMTransformerFactory extends TransformerFactory {
final XMLConfig config = XMLConfig.getConfig();
//Get the classname
final String classname = config.getXSLTransformerFactoryClassname();
LOGGER.warn(String.format("XSL Transformer Factory classname is %s", classname));
if (classname == null || classname.isEmpty()) {
//To make this class errorprone we check for null and empty string. Normally this

View File

@ -50,7 +50,7 @@
<filter-name>profiler</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->
-->
<filter-mapping>
@ -63,7 +63,7 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Context Listener
required and used to initialize the runtime environment before any other
task is performed or any servlet initialized.
@ -129,7 +129,7 @@
<servlet-class>com.arsdigita.web.ResourceServlet</servlet-class>
</servlet>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ADDITIONAL SERVLET DECLARATIONS SECTION
basically requirred by ccm-cms
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
@ -164,7 +164,7 @@
<servlet-class>com.arsdigita.cms.dispatcher.TemplateXSLServlet</servlet-class>
</servlet>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MODULES SERVLET DECLARATIONS SECTION
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
@ -297,7 +297,7 @@
</servlet>
<!-- module ccm-themedirector - servlet declarations END -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MODULES SERVLET MAPPINGS SECTION
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
@ -381,7 +381,7 @@
<!-- module ccm-themedirector - servlet mappings END -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BASE SERVLET MAPPINGS SECTION
basically requirred by ccm-core
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
@ -436,7 +436,7 @@
<url-pattern>/resource/*</url-pattern>
</servlet-mapping>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ADDITIONAL SERVLET MAPPINGS SECTION
basically requirred by ccm-cms
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
@ -471,7 +471,7 @@
<url-pattern>/themes/servlet/template/*</url-pattern>
</servlet-mapping>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ERROR PAGES
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
@ -510,7 +510,7 @@
<location>/error/general.jsp</location>
</error-page>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TAG LIBS
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->