From 511c5a9d95a59aace92c5e8871ed668882d618f9 Mon Sep 17 00:00:00 2001 From: quasi Date: Thu, 19 Jul 2012 14:31:30 +0000 Subject: [PATCH] =?UTF-8?q?ImageComponentAdminListener=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@1778 8810af33-2d31-482b-a856-94f89814c4df --- .../cms/ui/ImageComponentAdminListener.java | 31 ++++++ .../src/com/arsdigita/cms/ui/ImagesPane.java | 95 ++++++------------- 2 files changed, 61 insertions(+), 65 deletions(-) create mode 100644 ccm-cms/src/com/arsdigita/cms/ui/ImageComponentAdminListener.java diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImageComponentAdminListener.java b/ccm-cms/src/com/arsdigita/cms/ui/ImageComponentAdminListener.java new file mode 100644 index 000000000..31cb348ae --- /dev/null +++ b/ccm-cms/src/com/arsdigita/cms/ui/ImageComponentAdminListener.java @@ -0,0 +1,31 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.arsdigita.cms.ui; + +import com.arsdigita.bebop.MapComponentSelectionModel; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.ActionEvent; +import com.arsdigita.bebop.event.ActionListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.cms.ReusableImageAsset; + +/** + * + * @author Sören Bernstein (quasimodo) + */ +class ImageComponentAdminListener extends ImageComponentAbstractListener implements ActionListener { + + public ImageComponentAdminListener(MapComponentSelectionModel imageComponent) { + super(imageComponent); + } + + @Override + protected void processImage(FormSectionEvent event, PageState ps, ImageComponent component, ReusableImageAsset image) { + } + + public void actionPerformed(ActionEvent ev) { + setImageComponent(ev.getPageState(), ImageComponent.UPLOAD); + } +} diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImagesPane.java b/ccm-cms/src/com/arsdigita/cms/ui/ImagesPane.java index 95fbef715..b0cf72c0e 100644 --- a/ccm-cms/src/com/arsdigita/cms/ui/ImagesPane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ImagesPane.java @@ -4,6 +4,7 @@ */ package com.arsdigita.cms.ui; +import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.MapComponentSelectionModel; import com.arsdigita.bebop.Page; @@ -12,12 +13,11 @@ import com.arsdigita.bebop.ParameterSingleSelectionModel; import com.arsdigita.bebop.Resettable; import com.arsdigita.bebop.SegmentedPanel; import com.arsdigita.bebop.SimpleComponent; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.toolbox.ui.LayoutPanel; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import org.apache.log4j.Logger; @@ -29,10 +29,9 @@ import org.apache.log4j.Logger; public class ImagesPane extends LayoutPanel implements Resettable { public static final Logger s_log = Logger.getLogger(ImagesPane.class); - //private ImageChooser imageChooser; private final StringParameter m_imageComponentKey; private final MapComponentSelectionModel m_imageComponent; -// private final ImageComponentAdminListener m_adminListener; + private final ImageComponentAdminListener m_adminListener; public ImagesPane() { // Left column is empty, this is only to provide the same layout for all @@ -48,27 +47,20 @@ public class ImagesPane extends LayoutPanel implements Resettable { m_imageComponent = new MapComponentSelectionModel(componentModel, new HashMap()); Map selectors = m_imageComponent.getComponentsMap(); -// m_adminListener = new ImageComponentAdminListener(m_imageComponent); - + m_adminListener = new ImageComponentAdminListener(m_imageComponent); + ImageUploadComponent upload = new ImageUploadComponent(ImageComponent.ADMIN_IMAGES); - // For future use - //upload.getForm().addInitListener(m_adminListener); - // upload.addProcessListener(m_adminListener); + upload.getForm().addInitListener(m_adminListener); + upload.addProcessListener(m_adminListener); selectors.put(ImageComponent.UPLOAD, upload); body.addSegment( new Label(GlobalizationUtil.globalize("cms.ui.image_upload")), upload); ImageLibraryComponent library = new ImageLibraryComponent(ImageComponent.ADMIN_IMAGES); - // For future use - //library.getForm().addInitListener(m_adminListener); - // library.getForm().addProcessListener(m_adminListener); -// library.addUploadLink(new ActionListener() { -// -// public void actionPerformed(ActionEvent ev) { -// setImageComponent(ev.getPageState(), ImageComponent.UPLOAD); -// } -// }); + library.getForm().addInitListener(m_adminListener); + library.getForm().addProcessListener(m_adminListener); + library.addUploadLink(m_adminListener); selectors.put(ImageComponent.LIBRARY, library); body.addSegment( new Label(GlobalizationUtil.globalize("cms.ui.image_library")), @@ -81,61 +73,34 @@ public class ImagesPane extends LayoutPanel implements Resettable { super.register(page); Map componentsMap = m_imageComponent.getComponentsMap(); -// Iterator i = componentsMap.keySet().iterator(); -// while (i.hasNext()) { -// Object key = i.next(); -// Component component = (Component) componentsMap.get(key); -// -// page.setVisibleDefault(component, ImageComponent.LIBRARY.equals(key)); -// } + Iterator i = componentsMap.keySet().iterator(); + while (i.hasNext()) { + Object key = i.next(); + Component component = (Component) componentsMap.get(key); + + page.setVisibleDefault(component, ImageComponent.LIBRARY.equals(key)); + } page.addComponentStateParam(this, m_imageComponentKey); } @Override - public final void reset(PageState state) { - super.reset(state); - } + public final void reset(PageState ps) { + super.reset(ps); - private final class SubmissionListener implements FormSubmissionListener { + Map componentsMap = m_imageComponent.getComponentsMap(); + m_imageComponent.setSelectedKey(ps, ImageComponent.LIBRARY); + Iterator i = componentsMap.keySet().iterator(); + while (i.hasNext()) { + Object key = i.next(); + Component component = (Component) componentsMap.get(key); - public final void submitted(final FormSectionEvent e) { - final PageState s = e.getPageState(); + ps.setVisible(component, ImageComponent.LIBRARY.equals(key)); + // Reset all components if they are of type Resettable + if (component instanceof Resettable) { + ((Resettable) component).reset(ps); + } } } - -// private void setImageComponent(PageState ps, final String activeKey) { -// m_imageComponent.setSelectedKey(ps, activeKey); -// -// if (s_log.isDebugEnabled()) { -// s_log.debug("Selected component: " + activeKey); -// } -// -// Map componentsMap = m_imageComponent.getComponentsMap(); -// Iterator i = componentsMap.keySet().iterator(); -// while (i.hasNext()) { -// Object key = i.next(); -// Component component = (Component) componentsMap.get(key); -// -// boolean isVisible = activeKey.equals(key); -// -// if (s_log.isDebugEnabled()) { -// s_log.debug("Key: " + key + "; Visibility: " + isVisible); -// } -// -// ps.setVisible(component, isVisible); -// } -// } - -// public void init(FormSectionEvent event) -// throws FormProcessException { -// PageState ps = event.getPageState(); -// setImageComponent(ps, ImageComponent.LIBRARY); -// -//// ItemImageAttachment attachment = m_imageStep.getAttachment(ps); -//// if (null == attachment) { -// // XXX: Do something -//// } -// } }