Kommentare und einige Aufräumarbeiten

git-svn-id: https://svn.libreccm.org/ccm/trunk@1790 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2012-07-31 05:42:04 +00:00
parent 8b3c8f37b9
commit c4969bff47
4 changed files with 51 additions and 29 deletions

View File

@ -15,7 +15,10 @@ import com.arsdigita.cms.ui.ImageComponentAbstractListener;
import org.apache.log4j.Logger; 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) <sbernstein@zes.uni-bremen.de> * @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/ */
public class ImageComponentAttachListener extends ImageComponentAbstractListener { public class ImageComponentAttachListener extends ImageComponentAbstractListener {
@ -43,6 +46,5 @@ public class ImageComponentAttachListener extends ImageComponentAbstractListener
attachment.setCaption(component.getCaption(event)); attachment.setCaption(component.getCaption(event));
// setImageComponent(ps, ImageComponent.LIBRARY);
} }
} }

View File

@ -18,8 +18,6 @@
package com.arsdigita.cms.contentassets.ui; package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.cms.contentassets.ItemImageAttachment;
import com.arsdigita.bebop.AbstractSingleSelectionModel; import com.arsdigita.bebop.AbstractSingleSelectionModel;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
@ -29,6 +27,7 @@ import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.ItemImageAttachment;
import com.arsdigita.cms.ui.ImageComponent; import com.arsdigita.cms.ui.ImageComponent;
import com.arsdigita.cms.ui.SecurityPropertyEditor; import com.arsdigita.cms.ui.SecurityPropertyEditor;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
@ -36,15 +35,14 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.toolbox.ui.OIDParameter; import com.arsdigita.toolbox.ui.OIDParameter;
import java.util.Iterator; import java.util.Iterator;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Pluggable authoring step to add an ImageAsset to a content item * Pluggable authoring step to add an ImageAsset to a content item.
* Currently only supports adding one image though the PDL has *
* association for multiple. * @author unknown
* @author Sören Bernstein (quasimodo) <sbernstein@quasiweb.de>
*/ */
public class ImageStep extends SecurityPropertyEditor { public class ImageStep extends SecurityPropertyEditor {
@ -175,6 +173,13 @@ public class ImageStep extends SecurityPropertyEditor {
} }
} }
/**
* Show display pane.
*
* Also, reset the forms for reuse.
*
* @param state
*/
@Override @Override
public void showDisplayPane(PageState state) { public void showDisplayPane(PageState state) {
super.showDisplayPane(state); super.showDisplayPane(state);

View File

@ -18,8 +18,6 @@
package com.arsdigita.cms.contentassets.ui; package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.cms.contentassets.ItemImageAttachment;
import com.arsdigita.bebop.BoxPanel; import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink; import com.arsdigita.bebop.ControlLink;
@ -35,25 +33,25 @@ import com.arsdigita.bebop.list.ListModelBuilder;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ImageAsset; import com.arsdigita.cms.ImageAsset;
import com.arsdigita.cms.ReusableImageAsset; import com.arsdigita.cms.ReusableImageAsset;
import com.arsdigita.cms.contentassets.ItemImageAttachment;
import com.arsdigita.cms.ui.ImageDisplay; import com.arsdigita.cms.ui.ImageDisplay;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.util.LockableImpl; import com.arsdigita.util.LockableImpl;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Pluggable authoring step to add an ImageAsset to a content item * Pluggable authoring step to add an ImageAsset to a content item.
* Currently only supports adding one image though the PDL has *
* association for multiple. * @author unknown
* @author Sören Bernstein (quasimodo) <sbernstein@quasiweb.de>
*/ */
public class ImageStepDisplay extends SimpleContainer { public class ImageStepDisplay extends SimpleContainer {
private static final Logger s_log = Logger.getLogger(ImageStepDisplay.class); private static final Logger S_LOG = Logger.getLogger(ImageStepDisplay.class);
private final ImageStep m_imageStep; private final ImageStep m_imageStep;
@ -69,6 +67,7 @@ public class ImageStepDisplay extends SimpleContainer {
mainLabel.setFontWeight(Label.ITALIC); mainLabel.setFontWeight(Label.ITALIC);
List imageList = new List( new ImageListModelBuilder() ) { List imageList = new List( new ImageListModelBuilder() ) {
@Override
public void respond( PageState ps ) throws ServletException { public void respond( PageState ps ) throws ServletException {
if( DELETE.equals( ps.getControlEventName() ) ) { if( DELETE.equals( ps.getControlEventName() ) ) {
String attachment = ps.getControlEventValue(); String attachment = ps.getControlEventValue();
@ -168,6 +167,7 @@ public class ImageStepDisplay extends SimpleContainer {
} }
@Override
protected ImageAsset getImageAsset( PageState ps ) { protected ImageAsset getImageAsset( PageState ps ) {
return attachment.getImage(); return attachment.getImage();
} }
@ -191,6 +191,7 @@ public class ImageStepDisplay extends SimpleContainer {
container.add( useContextPanel ); container.add( useContextPanel );
ControlLink delete = new ControlLink( "Delete" ) { ControlLink delete = new ControlLink( "Delete" ) {
@Override
public void setControlEvent( PageState ps ) { public void setControlEvent( PageState ps ) {
String oid = ps.getControlEventValue(); String oid = ps.getControlEventValue();
ps.setControlEvent( list, DELETE, oid ); ps.setControlEvent( list, DELETE, oid );

View File

@ -45,17 +45,26 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/**
* Pluggable authoring step to add an ImageAsset to a content item.
*
* @author unknown
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/
public class ImageStepEdit extends SimpleContainer public class ImageStepEdit extends SimpleContainer
implements Resettable/* 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; private final ImageComponentAttachListener m_attachListener;
/**
* Creates a new ImageStepEidt form.
*
* @param step the parent {@link ImageStep} form
*/
public ImageStepEdit(ImageStep step) { public ImageStepEdit(ImageStep step) {
m_imageStep = step; m_imageStep = step;
@ -73,7 +82,6 @@ public class ImageStepEdit extends SimpleContainer
library.getForm().addInitListener(m_attachListener); library.getForm().addInitListener(m_attachListener);
library.getForm().addProcessListener(m_attachListener); library.getForm().addProcessListener(m_attachListener);
library.addUploadLink(new ActionListener() { library.addUploadLink(new ActionListener() {
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
setImageComponent(ev.getPageState(), ImageComponent.UPLOAD); setImageComponent(ev.getPageState(), ImageComponent.UPLOAD);
} }
@ -105,15 +113,15 @@ public class ImageStepEdit extends SimpleContainer
p.addComponentStateParam(this, m_imageComponentKey); p.addComponentStateParam(this, m_imageComponentKey);
} }
Iterator getImageComponents() { protected Iterator getImageComponents() {
return m_imageComponent.getComponentsMap().values().iterator(); return m_imageComponent.getComponentsMap().values().iterator();
} }
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);
if (s_log.isDebugEnabled()) { if (S_LOG.isDebugEnabled()) {
s_log.debug("Selected component: " + activeKey); S_LOG.debug("Selected component: " + activeKey);
} }
Map componentsMap = m_imageComponent.getComponentsMap(); Map componentsMap = m_imageComponent.getComponentsMap();
@ -124,15 +132,19 @@ public class ImageStepEdit extends SimpleContainer
boolean isVisible = activeKey.equals(key); boolean isVisible = activeKey.equals(key);
if (s_log.isDebugEnabled()) { if (S_LOG.isDebugEnabled()) {
s_log.debug("Key: " + key + "; Visibility: " + isVisible); S_LOG.debug("Key: " + key + "; Visibility: " + isVisible);
} }
ps.setVisible(component, isVisible); ps.setVisible(component, isVisible);
} }
} }
// Reset this component and all of it's resettable childs /**
* Reset this component and all of it's resettable childs.
*
* @param ps Page state
*/
public void reset(PageState ps) { public void reset(PageState ps) {
Map componentsMap = m_imageComponent.getComponentsMap(); Map componentsMap = m_imageComponent.getComponentsMap();
m_imageComponent.setSelectedKey(ps, ImageComponent.LIBRARY); m_imageComponent.setSelectedKey(ps, ImageComponent.LIBRARY);
@ -142,7 +154,7 @@ public class ImageStepEdit extends SimpleContainer
Component component = (Component) componentsMap.get(key); Component component = (Component) componentsMap.get(key);
ps.setVisible(component, ImageComponent.LIBRARY.equals(key)); ps.setVisible(component, ImageComponent.LIBRARY.equals(key));
// Reset all components if they are of type Resettable // Reset all components if they are of type Resettable
if (component instanceof Resettable) { if (component instanceof Resettable) {
((Resettable) component).reset(ps); ((Resettable) component).reset(ps);
@ -160,6 +172,8 @@ public class ImageStepEdit extends SimpleContainer
// attachment.setTitle(component.getTitle(event)); // attachment.setTitle(component.getTitle(event));
// } // }
// attachment.setUseContext(component.getUseContext(event)); // attachment.setUseContext(component.getUseContext(event));
@Deprecated
private class UniqueUseContextListener implements ParameterListener { private class UniqueUseContextListener implements ParameterListener {
public void validate(ParameterEvent ev) public void validate(ParameterEvent ev)