From 7749c376a5cfcd2763cc00a53b6066184be5f1da Mon Sep 17 00:00:00 2001 From: quasi Date: Thu, 12 Jul 2012 16:12:56 +0000 Subject: [PATCH] ImageSelectPage und ImagePane (1/2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Weitere Änderungen. Restrukturierung, unter anderem interne Klassen aus ImageStepEdit zu normalen Klassen in cms.ui gemacht. git-svn-id: https://svn.libreccm.org/ccm/trunk@1766 8810af33-2d31-482b-a856-94f89814c4df --- .../com/arsdigita/cms/ui/ImageBrowser.java | 23 +-- .../com/arsdigita/cms/ui/ImageChooser.java | 8 +- .../com/arsdigita/cms/ui/ImageComponent.java | 8 + .../cms/ui/ImageLibraryComponent.java | 79 ++++---- .../com/arsdigita/cms/ui/ImageSelectPage.java | 70 +++++++- .../cms/ui/ImageUploadComponent.java | 85 +++++---- .../src/com/arsdigita/cms/ui/ImagesPane.java | 169 ++++++++++-------- 7 files changed, 290 insertions(+), 152 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java b/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java index ff0874812..f4bdeb3d2 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java @@ -34,6 +34,7 @@ import com.arsdigita.cms.CMS; import com.arsdigita.cms.ImageAsset; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.Service; +import com.arsdigita.cms.ui.ImageComponent; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.mimetypes.MimeType; @@ -65,9 +66,6 @@ import org.apache.log4j.Logger; */ public class ImageBrowser extends Table { - public static final int DISPLAY_ONLY = 0; - public static final int SELECT_IMAGE = 1; - public static final int ADMIN_IMAGES = 2; private ImageBrowserModelBuilder m_builder; private static final String[] HEADERS = {"Thumbnail", "Name", "Size", "Type", "Action", ""}; private static final int THUMB = 0; @@ -76,8 +74,8 @@ public class ImageBrowser extends Table { private static final int TYPE = 3; private static final int LINK = 4; private static final int DELETE = 5; - private static int s_numColumns = -1; - private int m_mode = DISPLAY_ONLY; + private int m_numColumns = -1; + private int m_mode; private Dimension m_thumbSize; private static final Logger s_log = Logger.getLogger(ImageBrowser.class); @@ -89,7 +87,7 @@ public class ImageBrowser extends Table { */ public ImageBrowser(ImageBrowserModelBuilder b) { - this(b, ImageBrowser.SELECT_IMAGE); + this(b, ImageComponent.ATTACH_IMAGE); } public ImageBrowser(ImageBrowserModelBuilder b, int mode) { @@ -114,9 +112,13 @@ public class ImageBrowser extends Table { } private void addColumn(TableCellRenderer renderer) { - getColumn(++s_numColumns).setCellRenderer(renderer); + getColumn(++m_numColumns).setCellRenderer(renderer); } + public int getNumColumns() { + return m_numColumns; + } + /** * @return the size, in pixels, of the thumbnail images */ @@ -217,7 +219,7 @@ public class ImageBrowser extends Table { boolean isSelected, Object key, int row, int column) { - if (m_mode == ImageBrowser.SELECT_IMAGE) { + if (m_mode == ImageComponent.SELECT_IMAGE) { return super.getComponent(table, state, value, isSelected, key, row, column); } @@ -239,7 +241,7 @@ public class ImageBrowser extends Table { int row, int column) { // Only show delete link in admin mode - if (m_mode == ADMIN_IMAGES) { + if (m_mode == ImageComponent.ADMIN_IMAGES) { boolean canDelete = false; // SecurityManager sm = Utilities.getSecurityManager(state); @@ -300,7 +302,8 @@ public class ImageBrowser extends Table { @Override public int getColumnCount() { - return ImageBrowser.s_numColumns; + return ((ImageBrowser)m_model).getNumColumns(); + // return ImageBrowser.s_numColumns; } @Override diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImageChooser.java b/ccm-cms/src/com/arsdigita/cms/ui/ImageChooser.java index 55c2a9f77..87c73dd96 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ImageChooser.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ImageChooser.java @@ -95,14 +95,18 @@ public class ImageChooser extends BoxPanel { * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} */ public ImageChooser(String context) { - this(context, ImageBrowser.SELECT_IMAGE); + this(context, ImageComponent.ATTACH_IMAGE); + } + + public ImageChooser(int mode) { + this(ContentItem.DRAFT, mode); } /** * Construct a new ImageChooser */ public ImageChooser() { - this(ContentItem.DRAFT, ImageBrowser.SELECT_IMAGE); + this(ContentItem.DRAFT, ImageComponent.ATTACH_IMAGE); } /** diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImageComponent.java b/ccm-cms/src/com/arsdigita/cms/ui/ImageComponent.java index 2891c4a9a..544b5cb6b 100644 --- a/ccm-cms/src/com/arsdigita/cms/ui/ImageComponent.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ImageComponent.java @@ -16,6 +16,14 @@ import com.arsdigita.cms.ReusableImageAsset; */ public interface ImageComponent { + public static final int DISPLAY_ONLY = 0; + public static final int SELECT_IMAGE = 1; + public static final int ATTACH_IMAGE = 2; + public static final int ADMIN_IMAGES = 3; + + public static final String UPLOAD = "upload"; + public static final String LIBRARY = "library"; + ReusableImageAsset getImage(FormSectionEvent event) throws FormProcessException; String getCaption(FormSectionEvent event); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImageLibraryComponent.java b/ccm-cms/src/com/arsdigita/cms/ui/ImageLibraryComponent.java index b9c686e4d..99c5ebf23 100644 --- a/ccm-cms/src/com/arsdigita/cms/ui/ImageLibraryComponent.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ImageLibraryComponent.java @@ -29,6 +29,7 @@ import java.math.BigDecimal; * @author Sören Bernstein (quasimodo) */ public class ImageLibraryComponent extends SimpleContainer implements ImageComponent { + private final ImageChooser m_chooser; private final ItemSelectionModel m_imageModel; private final BigDecimalParameter m_imageID; @@ -38,11 +39,17 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo private final TextField m_title; private final TextField m_useContext; private final SaveCancelSection m_saveCancel; + private int m_mode; public ImageLibraryComponent() { + this(ImageComponent.SELECT_IMAGE); + } + + public ImageLibraryComponent(int mode) { + m_mode = mode; m_imageID = new BigDecimalParameter("imageID"); m_imageModel = new ItemSelectionModel(m_imageID); - m_chooser = new ImageChooser(ContentItem.DRAFT, ImageBrowser.ADMIN_IMAGES); + m_chooser = new ImageChooser(ContentItem.DRAFT, m_mode); m_chooser.addImageActionListener(new ImageBrowser.LinkActionListener() { public void deleteClicked(PageState ps, BigDecimal imageID) { @@ -62,42 +69,46 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo } }); add(m_chooser); - m_form = new Form("imageStepEditLibrary", new ColumnPanel(2)); + + // Form for additional fields and submit + m_form = new Form("imageLibraryComponent", new ColumnPanel(2)); add(m_form); - m_form.add(new Label("Caption")); + + // Initialize all wisgets m_caption = new TextField("caption"); - m_caption.addValidationListener(new NotNullValidationListener()); - m_caption.setSize(40); - m_form.add(m_caption); m_description = new TextField("description"); - m_description.addValidationListener(new NotNullValidationListener()); - m_description.setSize(40); m_title = new TextField("title"); - m_title.addValidationListener(new NotNullValidationListener()); - m_title.setSize(40); - // Only show the title and description fields where these have - // been explicitly requested. - /* - * if - * (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown()) - * { m_form.add(new Label("Description")); - * m_form.add(m_description); m_form.add(new Label("Title")); - * m_form.add(m_title); } - */ - m_form.add(new Label("Use Context")); m_useContext = new TextField("useContext"); - m_useContext.setSize(40); - m_form.add(m_useContext); + + // Show additional fields only in default mode a.k.a. ATTACH_IMAGE like + // in image-step + if (m_mode == ImageComponent.ATTACH_IMAGE) { + m_form.add(new Label("Caption")); + m_caption.addValidationListener(new NotNullValidationListener()); + m_caption.setSize(40); + m_form.add(m_caption); + m_description.addValidationListener(new NotNullValidationListener()); + m_description.setSize(40); + m_title.addValidationListener(new NotNullValidationListener()); + m_title.setSize(40); + // Only show the title and description fields where these have + // been explicitly requested. + /* + * if + * (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown()) + * { m_form.add(new Label("Description")); + * m_form.add(m_description); m_form.add(new Label("Title")); + * m_form.add(m_title); } + */ + m_form.add(new Label("Use Context")); + m_useContext.setSize(40); + m_form.add(m_useContext); + } + + // save and cancel buttons m_saveCancel = new SaveCancelSection(); m_form.add(m_saveCancel); - ActionLink upload = new ActionLink("Upload a new image"); - upload.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ev) { - // setImageComponent(ev.getPageState(), UPLOAD); - } - }); - add(upload, ColumnPanel.FULL_WIDTH); } public ReusableImageAsset getImage(FormSectionEvent event) { @@ -138,5 +149,13 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo public SaveCancelSection getSaveCancelSection() { return m_saveCancel; } - + + public void addUploadLink(ActionListener actionListener) { + // Add action link to image upload component + if (m_mode != ImageComponent.DISPLAY_ONLY) { + ActionLink upload = new ActionLink("Upload new image"); + upload.addActionListener(actionListener); + add(upload, ColumnPanel.FULL_WIDTH); + } + } } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImageSelectPage.java b/ccm-cms/src/com/arsdigita/cms/ui/ImageSelectPage.java index 71fbe64bd..d2d6e4f95 100644 --- a/ccm-cms/src/com/arsdigita/cms/ui/ImageSelectPage.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ImageSelectPage.java @@ -4,6 +4,7 @@ */ package com.arsdigita.cms.ui; +import com.arsdigita.bebop.Component; import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.bebop.TabbedPane; import com.arsdigita.bebop.parameters.BigDecimalParameter; @@ -19,7 +20,8 @@ public class ImageSelectPage extends CMSPage { private final static String XSL_CLASS = "CMS Admin"; private TabbedPane m_tabbedPane; - private ImagesPane m_imagePane; + private ImageLibraryComponent m_imageLibrary; + private ImageUploadComponent m_imageUpload; private BigDecimalParameter m_sectionId; private static final CMSConfig s_conf = CMSConfig.getInstance(); private static final boolean LIMIT_TO_CONTENT_SECTION = false; @@ -33,6 +35,70 @@ public class ImageSelectPage extends CMSPage { m_sectionId = new BigDecimalParameter(CONTENT_SECTION); addGlobalStateParam(m_sectionId); -// m_imagePane = new ImagesPane(); + m_tabbedPane = createTabbedPane(); + m_tabbedPane.setIdAttr("page-body"); + add(m_tabbedPane); + } + + protected ImageLibraryComponent getImageLibraryPane() { + if (m_imageLibrary == null) { + m_imageLibrary = new ImageLibraryComponent(ImageComponent.SELECT_IMAGE); +// library.getForm().addInitListener(this); +// library.getForm().addProcessListener(this); + } + return m_imageLibrary; + } + + protected ImageUploadComponent getImageUploadPane() { + + if (m_imageUpload == null) { + m_imageUpload = new ImageUploadComponent(ImageComponent.SELECT_IMAGE); +// upload.getForm().addInitListener(this); +// upload.getForm().addProcessListener(this); + } + return m_imageUpload; + } + + protected TabbedPane createTabbedPane() { + TabbedPane pane = new TabbedPane(); + pane.setClassAttr(XSL_CLASS); + + addToPane(pane, "library", getImageLibraryPane()); + addToPane(pane, "upload", getImageUploadPane()); + pane.setDefaultPane(m_imageLibrary); + + return pane; + } + + /** + * Adds the specified component, with the specified tab name, to the tabbed + * pane only if it is not null. + * + * @param pane The pane to which to add the tab + * @param tabName The name of the tab if it's added + * @param comp The component to add to the pane + */ + protected void addToPane(TabbedPane pane, String tabName, Component comp) { + if (comp != null) { + pane.addTab(GlobalizationUtil.globalize("cms.ui.item_search." + tabName).localize().toString(), comp); + } + } + + /* Listeners */ + + /** + * InitListener + * + * this init listener selects the object with the submitted oid + */ +// private init() { +// +// } + + /** + * ProcessListener + * + * this process listener + */ } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImageUploadComponent.java b/ccm-cms/src/com/arsdigita/cms/ui/ImageUploadComponent.java index daf317704..b574b03df 100644 --- a/ccm-cms/src/com/arsdigita/cms/ui/ImageUploadComponent.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ImageUploadComponent.java @@ -25,62 +25,76 @@ import java.io.IOException; * @author Sören Bernstein (quasimodo) */ public class ImageUploadComponent extends Form implements ImageComponent { + private final FileUploadSection m_imageFile; private final TextField m_caption; private final TextField m_title; private final TextArea m_description; private final TextField m_useContext; private final SaveCancelSection m_saveCancel; + private int m_mode; public ImageUploadComponent() { + this(ImageComponent.ATTACH_IMAGE); + } + + public ImageUploadComponent(int mode) { super("imageUploadComponent", new ColumnPanel(2)); + m_mode = mode; setEncType("multipart/form-data"); // Ignoring deprecated constructor. m_imageFile = new FileUploadSection("Image Type", "image", ImageAsset.MIME_JPEG); m_imageFile.getFileUploadWidget().addValidationListener(new NotNullValidationListener()); add(m_imageFile, ColumnPanel.FULL_WIDTH); - add(new Label("Caption")); + + // Initialize all widgets m_caption = new TextField("caption"); - m_caption.addValidationListener(new NotNullValidationListener()); - m_caption.addValidationListener(new StringLengthValidationListener(40)); - m_caption.setSize(40); - add(m_caption); m_title = new TextField("title"); m_description = new TextArea("description"); - // We only show the title and description fields in the case where - // getIsImageStepDescriptionAndTitleShown is false. - /* - * if - * (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown()) - * { add(new Label("Title")); m_title.addValidationListener(new - * NotNullValidationListener()); m_title.setSize(40); - * m_title.addValidationListener(new - * StringLengthValidationListener(40)); add(m_title); - * - * add(new Label("Description")); - * m_description.addValidationListener(new - * NotNullValidationListener()); - * m_description.addValidationListener(new - * StringLengthValidationListener(600)); m_description.setCols(30); - * m_description.setRows(5); add(m_description); - * - * } - */ - add(new Label("Use Context")); m_useContext = new TextField("useContext"); - m_useContext.setSize(40); - add(m_useContext); + + // add widget only if we are in attach mode + if (m_mode == ImageComponent.ATTACH_IMAGE) { + add(new Label("Caption")); + m_caption.addValidationListener(new NotNullValidationListener()); + m_caption.addValidationListener(new StringLengthValidationListener(40)); + m_caption.setSize(40); + add(m_caption); + + // We only show the title and description fields in the case where + // getIsImageStepDescriptionAndTitleShown is false. + +// if (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown()) { +// add(new Label("Title")); +// m_title.addValidationListener(new NotNullValidationListener()); +// m_title.setSize(40); +// m_title.addValidationListener(new StringLengthValidationListener(40)); +// add(m_title); +// +// add(new Label("Description")); +// m_description.addValidationListener(new NotNullValidationListener()); +// m_description.addValidationListener(new StringLengthValidationListener(600)); +// m_description.setCols(30); +// m_description.setRows(5); +// add(m_description); +// +// } + + add(new Label("Use Context")); + m_useContext.setSize(40); + add(m_useContext); + } m_saveCancel = new SaveCancelSection(); add(m_saveCancel); + /* - * Removed by Quasimodo: Changed editing workflow, so that library - * comes first Also, library mode has now a link to upload images - * whixh will link to this form. Consequently, this link will create - * a loop, which isn't fatal but confusing ActionLink library = new - * ActionLink( "Select an existing image" ); - * library.addActionListener( new ActionListener() { public void - * actionPerformed( ActionEvent ev ) { setImageComponent( - * ev.getPageState(), LIBRARY ); } } ); add( library, + * Removed by Quasimodo: Changed editing workflow, so that library comes + * first Also, library mode has now a link to upload images which will + * link to this form. Consequently, this link will create a loop, which + * isn't fatal but confusing. ActionLink library = new ActionLink( + * "Select an existing image" ); library.addActionListener( new + * ActionListener() { public void actionPerformed( ActionEvent ev ) { + * setImageComponent( ev.getPageState(), LIBRARY ); } } ); add( library, * ColumnPanel.FULL_WIDTH ); */ } @@ -127,5 +141,4 @@ public class ImageUploadComponent extends Form implements ImageComponent { public Form getForm() { return this; } - } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImagesPane.java b/ccm-cms/src/com/arsdigita/cms/ui/ImagesPane.java index 95c5281d3..aff16e0c5 100644 --- a/ccm-cms/src/com/arsdigita/cms/ui/ImagesPane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ImagesPane.java @@ -4,9 +4,7 @@ */ package com.arsdigita.cms.ui; -import com.arsdigita.bebop.ActionLink; -import com.arsdigita.bebop.ColumnPanel; -import com.arsdigita.bebop.Form; +import com.arsdigita.bebop.Component; import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.MapComponentSelectionModel; @@ -14,30 +12,21 @@ import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.ParameterSingleSelectionModel; import com.arsdigita.bebop.Resettable; -import com.arsdigita.bebop.SaveCancelSection; import com.arsdigita.bebop.SegmentedPanel; import com.arsdigita.bebop.SimpleComponent; -import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionListener; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.TextArea; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.bebop.parameters.BigDecimalParameter; -import com.arsdigita.bebop.parameters.NotNullValidationListener; -import com.arsdigita.bebop.parameters.StringLengthValidationListener; +import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.ContentItem; -import com.arsdigita.cms.ImageAsset; -import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ReusableImageAsset; import com.arsdigita.cms.util.GlobalizationUtil; -import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.toolbox.ui.LayoutPanel; -import java.io.File; -import java.io.IOException; -import java.math.BigDecimal; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import org.apache.log4j.Logger; @@ -46,14 +35,12 @@ import org.apache.log4j.Logger; * * @author Sören Bernstein (quasimodo) */ -public class ImagesPane extends LayoutPanel implements Resettable { +public class ImagesPane extends LayoutPanel implements Resettable, FormProcessListener, FormInitListener { public static final Logger s_log = Logger.getLogger(BrowsePane.class); //private ImageChooser imageChooser; private final StringParameter m_imageComponentKey; private final MapComponentSelectionModel m_imageComponent; - private final String UPLOAD = "upload"; - private final String LIBRARY = "library"; public ImagesPane() { // Left column is empty, this is only to provide the same layout for all @@ -61,12 +48,8 @@ public class ImagesPane extends LayoutPanel implements Resettable { setLeft(new SimpleComponent()); SegmentedPanel body = new SegmentedPanel(); - body.addSegment( - new Label(GlobalizationUtil.globalize("cms.ui.image_browser")), - new ImageChooser(ContentItem.DRAFT, ImageBrowser.ADMIN_IMAGES)); - setBody(body); - + m_imageComponentKey = new StringParameter("imageComponent"); ParameterSingleSelectionModel componentModel = new ParameterSingleSelectionModel(m_imageComponentKey); @@ -74,24 +57,36 @@ public class ImagesPane extends LayoutPanel implements Resettable { Map selectors = m_imageComponent.getComponentsMap(); -// ImageUploadComponent upload = new ImageUploadComponent(); -// upload.getForm().addInitListener(this); -// upload.getForm().addProcessListener(this); -// selectors.put(UPLOAD, upload); -// add(upload); -// -// ImageLibraryComponent library = new ImageLibraryComponent(); -// library.getForm().addInitListener(this); -// library.getForm().addProcessListener(this); -// selectors.put(LIBRARY, -// library); -// add(library); + ImageUploadComponent upload = new ImageUploadComponent(ImageComponent.ADMIN_IMAGES); + upload.getForm().addInitListener(this); + upload.getForm().addProcessListener(this); + selectors.put(ImageComponent.UPLOAD, upload); + body.addSegment( + new Label(GlobalizationUtil.globalize("cms.ui.image_upload")), + upload); + + ImageLibraryComponent library = new ImageLibraryComponent(ImageComponent.ADMIN_IMAGES); + library.getForm().addInitListener(this); + library.getForm().addProcessListener(this); + library.addUploadLink(new ActionListener() { + + public void actionPerformed(ActionEvent ev) { + setImageComponent(ev.getPageState(), ImageComponent.UPLOAD); + } + }); + selectors.put(ImageComponent.LIBRARY, library); + body.addSegment( + new Label(GlobalizationUtil.globalize("cms.ui.image_browser")), + library); + } + @Override public final void register(Page page) { super.register(page); } + @Override public final void reset(PageState state) { super.reset(state); } @@ -99,43 +94,73 @@ public class ImagesPane extends LayoutPanel implements Resettable { /* * // Private classes and methods private final class ProcessListener * implements FormProcessListener { - * - * public void process(FormSectionEvent event) throws FormProcessException { - * PageState ps = event.getPageState(); ImageComponent component = - * getImageComponent(ps); - * - * if (!component.getSaveCancelSection().getSaveButton().isSelected(ps)) { - * return; } - * - * ContentItem item = m_imageStep.getItem(ps); if (null == item) { - * s_log.error("No item selected in ImageStepEdit", new RuntimeException()); - * return; } - * - * ReusableImageAsset image = component.getImage(event); - * - * ItemImageAttachment attachment = m_imageStep.getAttachment(ps); if (null - * == attachment) { attachment = new ItemImageAttachment(item, image); } - * attachment.setCaption(component.getCaption(event)); - * - * // We only set the description and title based on the UI in // the case - * where getIsImageStepDescriptionAndTitleShown is true. // Otherwise, we - * leave this as the default value. This means // existing values are not - * overwritten if the image is edited when // - * isImageStepDescriptionAndTitleShown is false. if - * (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown()) - * { attachment.setDescription(component.getDescription(event)); - * attachment.setTitle(component.getTitle(event)); } - * attachment.setUseContext(component.getUseContext(event)); } } - * - * private final class SubmissionListener implements FormSubmissionListener - * { - * - * public final void submitted(final FormSectionEvent e) { final PageState s - * = e.getPageState(); - * - * } - * } */ + public void process(FormSectionEvent event) throws FormProcessException { + PageState ps = event.getPageState(); +// ImageComponent component = getImageComponent(ps); +// +// if (!component.getSaveCancelSection().getSaveButton().isSelected(ps)) { +// return; +// } +// +// ContentItem item = m_imageStep.getItem(ps); +// if (null == item) { +// s_log.error("No item selected in ImageStepEdit", new RuntimeException()); +// return; +// } +// +// ReusableImageAsset image = component.getImage(event); +// +// ItemImageAttachment attachment = m_imageStep.getAttachment(ps); +// if (null +// == attachment) { +// attachment = new ItemImageAttachment(item, image); +// } +// attachment.setCaption(component.getCaption(event)); +// +// // We only set the description and title based on the UI in +// // the case where getIsImageStepDescriptionAndTitleShown is true. +// // Otherwise, we leave this as the default value. This means +// // existing values are not overwritten if the image is edited when +// // isImageStepDescriptionAndTitleShown is false. +// if (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown()) { +// attachment.setDescription(component.getDescription(event)); +// attachment.setTitle(component.getTitle(event)); +// } +// attachment.setUseContext(component.getUseContext(event)); + } + + private final class SubmissionListener implements FormSubmissionListener { + + public final void submitted(final FormSectionEvent e) { + final PageState s = e.getPageState(); + + } + } + + 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();