| 
     
      
      
      From: <pb...@fe...> - 2013-02-03 13:30:58
      
     
   | 
Author: pboy
Date: 2013-02-03 13:30:50 +0000 (Sun, 03 Feb 2013)
New Revision: 2488
Added:
   releases/2.0.0/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ui/ImageComponentAttachListener.java
Log:
Supplementing a missing file.
Added: releases/2.0.0/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ui/ImageComponentAttachListener.java
===================================================================
--- releases/2.0.0/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ui/ImageComponentAttachListener.java	                        (rev 0)
+++ releases/2.0.0/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ui/ImageComponentAttachListener.java	2013-02-03 13:30:50 UTC (rev 2488)
@@ -0,0 +1,50 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.arsdigita.cms.contentassets.ui;
+
+import com.arsdigita.bebop.MapComponentSelectionModel;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.cms.ContentItem;
+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;
+
+/**
+ * A listener to attach an image to a content item.
+ * 
+ * This listerner is used by {@link ImageStepEdit}.
+ * 
+ * @author Sören Bernstein (quasimodo) <sbe...@ze...>
+ */
+public class ImageComponentAttachListener extends ImageComponentAbstractListener {
+
+    private final ImageStep m_imageStep;
+    private static final Logger s_log = Logger.getLogger(ImageComponentAttachListener.class);
+
+    public ImageComponentAttachListener(MapComponentSelectionModel imageComponent, ImageStep imageStep) {
+        super(imageComponent);
+        m_imageStep = imageStep;
+    }
+
+    @Override
+    protected void processImage(FormSectionEvent event, PageState ps, ImageComponent component, ReusableImageAsset image) {
+        ContentItem item = m_imageStep.getItem(ps);
+        if (null == item) {
+            s_log.error("No item selected in ImageStepEdit",
+                    new RuntimeException());
+            return;
+        }
+        ItemImageAttachment attachment = m_imageStep.getAttachment(ps);
+        if (null == attachment) {
+            attachment = new ItemImageAttachment(item, image);
+        }
+
+        attachment.setCaption(component.getCaption(event));
+        
+    }
+}
 |