ImageComponentAdminListener hinzugefügt
git-svn-id: https://svn.libreccm.org/ccm/trunk@1778 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
6f3e2fc118
commit
511c5a9d95
|
|
@ -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) <sbernstein@zes.uni-bremen.de>
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.ui;
|
package com.arsdigita.cms.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.MapComponentSelectionModel;
|
import com.arsdigita.bebop.MapComponentSelectionModel;
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.bebop.Page;
|
||||||
|
|
@ -12,12 +13,11 @@ import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
import com.arsdigita.bebop.Resettable;
|
import com.arsdigita.bebop.Resettable;
|
||||||
import com.arsdigita.bebop.SegmentedPanel;
|
import com.arsdigita.bebop.SegmentedPanel;
|
||||||
import com.arsdigita.bebop.SimpleComponent;
|
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.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
import com.arsdigita.toolbox.ui.LayoutPanel;
|
import com.arsdigita.toolbox.ui.LayoutPanel;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -29,10 +29,9 @@ import org.apache.log4j.Logger;
|
||||||
public class ImagesPane extends LayoutPanel implements Resettable {
|
public class ImagesPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
public static final Logger s_log = Logger.getLogger(ImagesPane.class);
|
public static final Logger s_log = Logger.getLogger(ImagesPane.class);
|
||||||
//private ImageChooser imageChooser;
|
|
||||||
private final StringParameter m_imageComponentKey;
|
private final StringParameter m_imageComponentKey;
|
||||||
private final MapComponentSelectionModel m_imageComponent;
|
private final MapComponentSelectionModel m_imageComponent;
|
||||||
// private final ImageComponentAdminListener m_adminListener;
|
private final ImageComponentAdminListener m_adminListener;
|
||||||
|
|
||||||
public ImagesPane() {
|
public ImagesPane() {
|
||||||
// Left column is empty, this is only to provide the same layout for all
|
// 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());
|
m_imageComponent = new MapComponentSelectionModel(componentModel, new HashMap());
|
||||||
|
|
||||||
Map selectors = m_imageComponent.getComponentsMap();
|
Map selectors = m_imageComponent.getComponentsMap();
|
||||||
// m_adminListener = new ImageComponentAdminListener(m_imageComponent);
|
m_adminListener = new ImageComponentAdminListener(m_imageComponent);
|
||||||
|
|
||||||
ImageUploadComponent upload = new ImageUploadComponent(ImageComponent.ADMIN_IMAGES);
|
ImageUploadComponent upload = new ImageUploadComponent(ImageComponent.ADMIN_IMAGES);
|
||||||
// For future use
|
upload.getForm().addInitListener(m_adminListener);
|
||||||
//upload.getForm().addInitListener(m_adminListener);
|
upload.addProcessListener(m_adminListener);
|
||||||
// upload.addProcessListener(m_adminListener);
|
|
||||||
selectors.put(ImageComponent.UPLOAD, upload);
|
selectors.put(ImageComponent.UPLOAD, upload);
|
||||||
body.addSegment(
|
body.addSegment(
|
||||||
new Label(GlobalizationUtil.globalize("cms.ui.image_upload")),
|
new Label(GlobalizationUtil.globalize("cms.ui.image_upload")),
|
||||||
upload);
|
upload);
|
||||||
|
|
||||||
ImageLibraryComponent library = new ImageLibraryComponent(ImageComponent.ADMIN_IMAGES);
|
ImageLibraryComponent library = new ImageLibraryComponent(ImageComponent.ADMIN_IMAGES);
|
||||||
// For future use
|
library.getForm().addInitListener(m_adminListener);
|
||||||
//library.getForm().addInitListener(m_adminListener);
|
library.getForm().addProcessListener(m_adminListener);
|
||||||
// library.getForm().addProcessListener(m_adminListener);
|
library.addUploadLink(m_adminListener);
|
||||||
// library.addUploadLink(new ActionListener() {
|
|
||||||
//
|
|
||||||
// public void actionPerformed(ActionEvent ev) {
|
|
||||||
// setImageComponent(ev.getPageState(), ImageComponent.UPLOAD);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
selectors.put(ImageComponent.LIBRARY, library);
|
selectors.put(ImageComponent.LIBRARY, library);
|
||||||
body.addSegment(
|
body.addSegment(
|
||||||
new Label(GlobalizationUtil.globalize("cms.ui.image_library")),
|
new Label(GlobalizationUtil.globalize("cms.ui.image_library")),
|
||||||
|
|
@ -81,61 +73,34 @@ public class ImagesPane extends LayoutPanel implements Resettable {
|
||||||
super.register(page);
|
super.register(page);
|
||||||
Map componentsMap = m_imageComponent.getComponentsMap();
|
Map componentsMap = m_imageComponent.getComponentsMap();
|
||||||
|
|
||||||
// Iterator i = componentsMap.keySet().iterator();
|
Iterator i = componentsMap.keySet().iterator();
|
||||||
// while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
// Object key = i.next();
|
Object key = i.next();
|
||||||
// Component component = (Component) componentsMap.get(key);
|
Component component = (Component) componentsMap.get(key);
|
||||||
//
|
|
||||||
// page.setVisibleDefault(component, ImageComponent.LIBRARY.equals(key));
|
page.setVisibleDefault(component, ImageComponent.LIBRARY.equals(key));
|
||||||
// }
|
}
|
||||||
|
|
||||||
page.addComponentStateParam(this, m_imageComponentKey);
|
page.addComponentStateParam(this, m_imageComponentKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void reset(PageState state) {
|
public final void reset(PageState ps) {
|
||||||
super.reset(state);
|
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) {
|
ps.setVisible(component, ImageComponent.LIBRARY.equals(key));
|
||||||
final PageState s = e.getPageState();
|
|
||||||
|
|
||||||
|
// 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
|
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue