ImageSelectPage und ImagePane
Weitere Korrekturen für das EventHandling endlich die image_search.jsp eingecheckt... git-svn-id: https://svn.libreccm.org/ccm/trunk@1774 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
4a543c0f5d
commit
72d0b12f6c
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
||||||
|
*/
|
||||||
|
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));
|
||||||
|
|
||||||
|
// setImageComponent(ps, ImageComponent.LIBRARY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -75,7 +75,6 @@ public class ImageStep extends SecurityPropertyEditor {
|
||||||
new WorkflowLockedComponentAccess( m_add, m_itemSelection );
|
new WorkflowLockedComponentAccess( m_add, m_itemSelection );
|
||||||
addComponent( "add", "Add Image", addCA );
|
addComponent( "add", "Add Image", addCA );
|
||||||
|
|
||||||
|
|
||||||
m_display = new ImageStepDisplay( this );
|
m_display = new ImageStepDisplay( this );
|
||||||
setDisplayComponent(m_display);
|
setDisplayComponent(m_display);
|
||||||
|
|
||||||
|
|
@ -175,4 +174,10 @@ public class ImageStep extends SecurityPropertyEditor {
|
||||||
return m_attachmentOID;
|
return m_attachmentOID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showDisplayPane(PageState state) {
|
||||||
|
super.showDisplayPane(state);
|
||||||
|
m_add.reset(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,11 @@ import com.arsdigita.bebop.Resettable;
|
||||||
import com.arsdigita.bebop.SimpleContainer;
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
import com.arsdigita.bebop.event.ActionEvent;
|
import com.arsdigita.bebop.event.ActionEvent;
|
||||||
import com.arsdigita.bebop.event.ActionListener;
|
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.event.ParameterEvent;
|
import com.arsdigita.bebop.event.ParameterEvent;
|
||||||
import com.arsdigita.bebop.event.ParameterListener;
|
import com.arsdigita.bebop.event.ParameterListener;
|
||||||
import com.arsdigita.bebop.parameters.ParameterData;
|
import com.arsdigita.bebop.parameters.ParameterData;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.ReusableImageAsset;
|
|
||||||
import com.arsdigita.cms.contentassets.ItemImageAttachment;
|
import com.arsdigita.cms.contentassets.ItemImageAttachment;
|
||||||
import com.arsdigita.cms.ui.ImageComponent;
|
import com.arsdigita.cms.ui.ImageComponent;
|
||||||
import com.arsdigita.cms.ui.ImageLibraryComponent;
|
import com.arsdigita.cms.ui.ImageLibraryComponent;
|
||||||
|
|
@ -47,16 +43,18 @@ import java.math.BigDecimal;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
public class ImageStepEdit extends SimpleContainer
|
public class ImageStepEdit extends SimpleContainer
|
||||||
implements Resettable, FormProcessListener, FormInitListener {
|
implements Resettable/*
|
||||||
|
* , FormProcessListener, FormInitListener
|
||||||
|
*/ {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(ImageStepEdit.class);
|
private static final Logger s_log = Logger.getLogger(ImageStepEdit.class);
|
||||||
private final ImageStep m_imageStep;
|
private final ImageStep m_imageStep;
|
||||||
private final StringParameter m_imageComponentKey;
|
private final StringParameter m_imageComponentKey;
|
||||||
private final MapComponentSelectionModel m_imageComponent;
|
private final MapComponentSelectionModel m_imageComponent;
|
||||||
|
private final ImageComponentAttachListener m_attachListener;
|
||||||
|
|
||||||
public ImageStepEdit(ImageStep step) {
|
public ImageStepEdit(ImageStep step) {
|
||||||
m_imageStep = step;
|
m_imageStep = step;
|
||||||
|
|
@ -69,10 +67,11 @@ public class ImageStepEdit extends SimpleContainer
|
||||||
new MapComponentSelectionModel(componentModel, new HashMap());
|
new MapComponentSelectionModel(componentModel, new HashMap());
|
||||||
|
|
||||||
Map selectors = m_imageComponent.getComponentsMap();
|
Map selectors = m_imageComponent.getComponentsMap();
|
||||||
|
m_attachListener = new ImageComponentAttachListener(m_imageComponent, m_imageStep);
|
||||||
|
|
||||||
ImageLibraryComponent library = new ImageLibraryComponent();
|
ImageLibraryComponent library = new ImageLibraryComponent();
|
||||||
library.getForm().addInitListener(this);
|
library.getForm().addInitListener(m_attachListener);
|
||||||
library.getForm().addProcessListener(this);
|
library.getForm().addProcessListener(m_attachListener);
|
||||||
library.addUploadLink(new ActionListener() {
|
library.addUploadLink(new ActionListener() {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent ev) {
|
public void actionPerformed(ActionEvent ev) {
|
||||||
|
|
@ -83,8 +82,8 @@ public class ImageStepEdit extends SimpleContainer
|
||||||
add(library);
|
add(library);
|
||||||
|
|
||||||
ImageUploadComponent upload = new ImageUploadComponent();
|
ImageUploadComponent upload = new ImageUploadComponent();
|
||||||
upload.getForm().addInitListener(this);
|
upload.getForm().addInitListener(m_attachListener);
|
||||||
upload.getForm().addProcessListener(this);
|
upload.getForm().addProcessListener(m_attachListener);
|
||||||
selectors.put(ImageComponent.UPLOAD, upload);
|
selectors.put(ImageComponent.UPLOAD, upload);
|
||||||
add(upload);
|
add(upload);
|
||||||
|
|
||||||
|
|
@ -110,20 +109,6 @@ public class ImageStepEdit extends SimpleContainer
|
||||||
return m_imageComponent.getComponentsMap().values().iterator();
|
return m_imageComponent.getComponentsMap().values().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageComponent getImageComponent(PageState ps) {
|
|
||||||
if (!m_imageComponent.isSelected(ps)) {
|
|
||||||
if (s_log.isDebugEnabled()) {
|
|
||||||
s_log.debug("No component selected");
|
|
||||||
s_log.debug("Selected: " + m_imageComponent.getComponent(ps));
|
|
||||||
}
|
|
||||||
|
|
||||||
m_imageComponent.setSelectedKey(ps, ImageComponent.UPLOAD);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ImageComponent) m_imageComponent.getComponent(ps);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setImageComponent(PageState ps, final String activeKey) {
|
private void setImageComponent(PageState ps, final String activeKey) {
|
||||||
m_imageComponent.setSelectedKey(ps, activeKey);
|
m_imageComponent.setSelectedKey(ps, activeKey);
|
||||||
|
|
||||||
|
|
@ -147,64 +132,34 @@ public class ImageStepEdit extends SimpleContainer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(FormSectionEvent event)
|
// Reset this component and all of it's resettable childs
|
||||||
throws FormProcessException {
|
public void reset(PageState ps) {
|
||||||
PageState ps = event.getPageState();
|
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);
|
||||||
|
|
||||||
ItemImageAttachment attachment = m_imageStep.getAttachment(ps);
|
ps.setVisible(component, ImageComponent.LIBRARY.equals(key));
|
||||||
if (null == attachment) {
|
|
||||||
// XXX: Do something
|
// Reset all components if they are of type Resettable
|
||||||
|
if (component instanceof Resettable) {
|
||||||
|
((Resettable) component).reset(ps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// We only set the description and title based on the UI in
|
||||||
// the case where getIsImageStepDescriptionAndTitleShown is true.
|
// the case where getIsImageStepDescriptionAndTitleShown is true.
|
||||||
// Otherwise, we leave this as the default value. This means
|
// Otherwise, we leave this as the default value. This means
|
||||||
// existing values are not overwritten if the image is edited when
|
// existing values are not overwritten if the image is edited when
|
||||||
// isImageStepDescriptionAndTitleShown is false.
|
// isImageStepDescriptionAndTitleShown is false.
|
||||||
if (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown()) {
|
// if (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown()) {
|
||||||
attachment.setDescription(component.getDescription(event));
|
// attachment.setDescription(component.getDescription(event));
|
||||||
attachment.setTitle(component.getTitle(event));
|
// attachment.setTitle(component.getTitle(event));
|
||||||
}
|
// }
|
||||||
attachment.setUseContext(component.getUseContext(event));
|
// attachment.setUseContext(component.getUseContext(event));
|
||||||
}
|
|
||||||
|
|
||||||
public void reset(PageState state) {
|
|
||||||
Page p = state.getPage();
|
|
||||||
|
|
||||||
Map componentsMap = m_imageComponent.getComponentsMap();
|
|
||||||
Iterator i = componentsMap.keySet().iterator();
|
|
||||||
while (i.hasNext()) {
|
|
||||||
Object key = i.next();
|
|
||||||
Component component = (Component) componentsMap.get(key);
|
|
||||||
|
|
||||||
p.setVisibleDefault(component, ImageComponent.LIBRARY.equals(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class UniqueUseContextListener implements ParameterListener {
|
private class UniqueUseContextListener implements ParameterListener {
|
||||||
|
|
||||||
public void validate(ParameterEvent ev)
|
public void validate(ParameterEvent ev)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue