ImageSelectPage und ImagePane
Erste Korrekturen für das EventHandling endlich die image_search.jsp eingecheckt... git-svn-id: https://svn.libreccm.org/ccm/trunk@1770 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
2e137a3c94
commit
b1dbb388d7
|
|
@ -1103,5 +1103,9 @@ cms.ui.item_search.flat.filter.submit=Filter
|
|||
cms.ui.item_search.selected=Selected content item (id)
|
||||
cms.ui.item_search.create=Create new
|
||||
cms.ui.item_search.create.folder_select=Select folder
|
||||
cms.ui.image_library=Image Library
|
||||
cms.ui.image_upload=Upload Image
|
||||
cms.ui.images=Images
|
||||
cms.ui.search.create.select_close=Select item and close
|
||||
cms.ui.search.create.select_edit=Select item and edit
|
||||
|
||||
|
|
|
|||
|
|
@ -1094,5 +1094,9 @@ cms.ui.item_search.flat.filter.submit=Filtern
|
|||
cms.ui.item_search.selected=Ausgew\u00e4hltes Content Item (ID)
|
||||
cms.ui.item_search.create=Neu anlegen
|
||||
cms.ui.item_search.create.folder_select=Ordner ausw\u00e4hlen
|
||||
cms.ui.image_library=Bilderauswahl
|
||||
cms.ui.image_upload=Bild hochladen
|
||||
cms.ui.images=Bilder
|
||||
cms.ui.search.create.select_close=Item ausw\u00e4hlen und schlie\u00dfen
|
||||
cms.ui.search.create.select_edit=Item ausw\u00e4hlen und weiter bearbeiten
|
||||
|
||||
|
|
|
|||
|
|
@ -42,5 +42,9 @@ cms.ui.item_search.flat.filter.submit=
|
|||
cms.ui.item_search.selected=
|
||||
cms.ui.item_search.create=
|
||||
cms.ui.item_search.create.folder_select=
|
||||
cms.ui.image_library=Image Library
|
||||
cms.ui.image_upload=Upload Image
|
||||
cms.ui.images=Images
|
||||
cms.ui.search.create.select_close=
|
||||
cms.ui.search.create.select_edit=
|
||||
|
||||
|
|
|
|||
|
|
@ -573,5 +573,9 @@ cms.ui.item_search.flat.filter.submit=
|
|||
cms.ui.item_search.selected=
|
||||
cms.ui.item_search.create=
|
||||
cms.ui.item_search.create.folder_select=
|
||||
cms.ui.image_library=Image Library
|
||||
cms.ui.image_upload=Upload Image
|
||||
cms.ui.images=Images
|
||||
cms.ui.search.create.select_close=
|
||||
cms.ui.search.create.select_edit=
|
||||
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ public class ImageBrowser extends Table {
|
|||
boolean isSelected, Object key,
|
||||
int row, int column) {
|
||||
|
||||
if (m_mode == ImageComponent.SELECT_IMAGE) {
|
||||
if (m_mode == ImageComponent.SELECT_IMAGE || m_mode == ImageComponent.ATTACH_IMAGE) {
|
||||
return super.getComponent(table, state, value, isSelected, key, row, column);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.MapComponentSelectionModel;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.cms.ReusableImageAsset;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
||||
*/
|
||||
public class ImageComponentAttachListener implements FormInitListener, FormProcessListener {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(ImageComponentSelectListener.class);
|
||||
MapComponentSelectionModel m_imageComponent;
|
||||
|
||||
public ImageComponentAttachListener(MapComponentSelectionModel imageComponent) {
|
||||
super();
|
||||
m_imageComponent = imageComponent;
|
||||
}
|
||||
|
||||
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
|
||||
// }
|
||||
}
|
||||
|
||||
public void process(FormSectionEvent event) throws FormProcessException {
|
||||
PageState ps = event.getPageState();
|
||||
ImageComponent component = getImageComponent(ps);
|
||||
|
||||
if (!component.getSaveCancelSection().getSaveButton().isSelected(ps)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ReusableImageAsset image = component.getImage(event);
|
||||
|
||||
|
||||
// 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));
|
||||
|
||||
// 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 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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.MapComponentSelectionModel;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.cms.ReusableImageAsset;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
||||
*/
|
||||
public class ImageComponentSelectListener implements FormInitListener, FormProcessListener {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(ImageComponentSelectListener.class);
|
||||
MapComponentSelectionModel m_imageComponent;
|
||||
|
||||
public ImageComponentSelectListener(MapComponentSelectionModel imageComponent) {
|
||||
super();
|
||||
m_imageComponent = imageComponent;
|
||||
}
|
||||
|
||||
public void init(FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
PageState ps = event.getPageState();
|
||||
|
||||
this.m_imageComponent.getComponent(ps);
|
||||
setImageComponent(ps, ImageComponent.LIBRARY);
|
||||
}
|
||||
|
||||
public void process(FormSectionEvent event) throws FormProcessException {
|
||||
PageState ps = event.getPageState();
|
||||
ImageComponent component = getImageComponent(ps);
|
||||
|
||||
if (!component.getSaveCancelSection().getSaveButton().isSelected(ps)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ReusableImageAsset image = component.getImage(event);
|
||||
|
||||
// SELECT {
|
||||
String name = image.getDisplayName();
|
||||
BigDecimal id = image.getID();
|
||||
BigDecimal width = image.getWidth();
|
||||
BigDecimal height = image.getHeight();
|
||||
// SELECT }
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,6 @@ import com.arsdigita.bebop.Page;
|
|||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.event.ActionEvent;
|
||||
import com.arsdigita.bebop.event.ActionListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
|
|
@ -42,7 +41,7 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
|
|||
private int m_mode;
|
||||
|
||||
public ImageLibraryComponent() {
|
||||
this(ImageComponent.SELECT_IMAGE);
|
||||
this(ImageComponent.ATTACH_IMAGE);
|
||||
}
|
||||
|
||||
public ImageLibraryComponent(int mode) {
|
||||
|
|
@ -107,8 +106,9 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
|
|||
|
||||
// save and cancel buttons
|
||||
m_saveCancel = new SaveCancelSection();
|
||||
if (m_mode == ImageComponent.SELECT_IMAGE || m_mode == ImageComponent.ATTACH_IMAGE) {
|
||||
m_form.add(m_saveCancel);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ReusableImageAsset getImage(FormSectionEvent event) {
|
||||
|
|
|
|||
|
|
@ -5,12 +5,17 @@
|
|||
package com.arsdigita.cms.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.MapComponentSelectionModel;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.TabbedPane;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.CMSConfig;
|
||||
import com.arsdigita.cms.dispatcher.CMSPage;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import java.util.HashMap;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -18,34 +23,47 @@ import com.arsdigita.cms.util.GlobalizationUtil;
|
|||
*/
|
||||
public class ImageSelectPage extends CMSPage {
|
||||
|
||||
public static final Logger s_log = Logger.getLogger(ImagesPane.class);
|
||||
private final static String XSL_CLASS = "CMS Admin";
|
||||
private TabbedPane m_tabbedPane;
|
||||
private ImageLibraryComponent m_imageLibrary;
|
||||
private ImageUploadComponent m_imageUpload;
|
||||
private BigDecimalParameter m_sectionId;
|
||||
private final StringParameter m_imageComponentKey;
|
||||
private final MapComponentSelectionModel m_imageComponent;
|
||||
private static final CMSConfig s_conf = CMSConfig.getInstance();
|
||||
private static final boolean LIMIT_TO_CONTENT_SECTION = false;
|
||||
public static final String CONTENT_SECTION = "section_id";
|
||||
|
||||
public ImageSelectPage() {
|
||||
super(GlobalizationUtil.globalize("cms.ui.item_search.page_title").localize().toString(), new SimpleContainer());
|
||||
super(GlobalizationUtil.globalize("cms.ui.image_selelect.page_title").localize().toString(), new SimpleContainer());
|
||||
|
||||
setClassAttr("cms-admin");
|
||||
|
||||
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
||||
addGlobalStateParam(m_sectionId);
|
||||
|
||||
m_imageComponentKey = new StringParameter("imageComponent");
|
||||
|
||||
ParameterSingleSelectionModel componentModel =
|
||||
new ParameterSingleSelectionModel(m_imageComponentKey);
|
||||
m_imageComponent =
|
||||
new MapComponentSelectionModel(componentModel, new HashMap());
|
||||
|
||||
m_tabbedPane = createTabbedPane();
|
||||
m_tabbedPane.setIdAttr("page-body");
|
||||
|
||||
add(m_tabbedPane);
|
||||
|
||||
addGlobalStateParam(m_imageComponentKey);
|
||||
}
|
||||
|
||||
protected ImageLibraryComponent getImageLibraryPane() {
|
||||
if (m_imageLibrary == null) {
|
||||
m_imageLibrary = new ImageLibraryComponent(ImageComponent.SELECT_IMAGE);
|
||||
// library.getForm().addInitListener(this);
|
||||
// library.getForm().addProcessListener(this);
|
||||
m_imageLibrary.getForm().addInitListener(new ImageComponentSelectListener(m_imageComponent));
|
||||
m_imageLibrary.getForm().addProcessListener(new ImageComponentSelectListener(m_imageComponent));
|
||||
m_imageComponent.getComponentsMap().put(ImageComponent.LIBRARY, m_imageLibrary);
|
||||
}
|
||||
return m_imageLibrary;
|
||||
}
|
||||
|
|
@ -54,8 +72,9 @@ public class ImageSelectPage extends CMSPage {
|
|||
|
||||
if (m_imageUpload == null) {
|
||||
m_imageUpload = new ImageUploadComponent(ImageComponent.SELECT_IMAGE);
|
||||
// upload.getForm().addInitListener(this);
|
||||
// upload.getForm().addProcessListener(this);
|
||||
m_imageUpload.getForm().addInitListener(new ImageComponentSelectListener(m_imageComponent));
|
||||
m_imageUpload.getForm().addProcessListener(new ImageComponentSelectListener(m_imageComponent));
|
||||
m_imageComponent.getComponentsMap().put(ImageComponent.UPLOAD, m_imageUpload);
|
||||
}
|
||||
return m_imageUpload;
|
||||
}
|
||||
|
|
@ -81,24 +100,7 @@ public class ImageSelectPage extends CMSPage {
|
|||
*/
|
||||
protected void addToPane(TabbedPane pane, String tabName, Component comp) {
|
||||
if (comp != null) {
|
||||
pane.addTab(GlobalizationUtil.globalize("cms.ui.item_search." + tabName).localize().toString(), comp);
|
||||
pane.addTab(GlobalizationUtil.globalize("cms.ui.image_" + tabName).localize().toString(), comp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Listeners */
|
||||
|
||||
/**
|
||||
* InitListener
|
||||
*
|
||||
* this init listener selects the object with the submitted oid
|
||||
*/
|
||||
// private init() {
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* ProcessListener
|
||||
*
|
||||
* this process listener
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.arsdigita.bebop.ColumnPanel;
|
|||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.MapComponentSelectionModel;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
|
|
@ -110,7 +111,7 @@ public class ImageUploadComponent extends Form implements ImageComponent {
|
|||
try {
|
||||
ReusableImageAsset image = new ReusableImageAsset();
|
||||
image.loadFromFile(filename, imageFile, ImageAsset.MIME_JPEG);
|
||||
image.setDescription((String) m_caption.getValue(ps));
|
||||
// image.setDescription((String) m_caption.getValue(ps));
|
||||
return image;
|
||||
} catch (IOException ex) {
|
||||
ImagesPane.s_log.error("Error loading image from file", ex);
|
||||
|
|
@ -141,4 +142,5 @@ public class ImageUploadComponent extends Form implements ImageComponent {
|
|||
public Form getForm() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
*/
|
||||
package com.arsdigita.cms.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.MapComponentSelectionModel;
|
||||
import com.arsdigita.bebop.Page;
|
||||
|
|
@ -14,19 +12,12 @@ 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.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.event.FormSubmissionListener;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ReusableImageAsset;
|
||||
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;
|
||||
|
||||
|
|
@ -35,9 +26,9 @@ import org.apache.log4j.Logger;
|
|||
*
|
||||
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
||||
*/
|
||||
public class ImagesPane extends LayoutPanel implements Resettable, FormProcessListener, FormInitListener {
|
||||
public class ImagesPane extends LayoutPanel implements Resettable {
|
||||
|
||||
public static final Logger s_log = Logger.getLogger(BrowsePane.class);
|
||||
public static final Logger s_log = Logger.getLogger(ImagesPane.class);
|
||||
//private ImageChooser imageChooser;
|
||||
private final StringParameter m_imageComponentKey;
|
||||
private final MapComponentSelectionModel m_imageComponent;
|
||||
|
|
@ -58,25 +49,27 @@ public class ImagesPane extends LayoutPanel implements Resettable, FormProcessLi
|
|||
Map selectors = m_imageComponent.getComponentsMap();
|
||||
|
||||
ImageUploadComponent upload = new ImageUploadComponent(ImageComponent.ADMIN_IMAGES);
|
||||
upload.getForm().addInitListener(this);
|
||||
upload.getForm().addProcessListener(this);
|
||||
//upload.getForm().addInitListener(new ImageComponentAdminListener(m_imageComponent));
|
||||
// For future use
|
||||
// upload.addProcessListener(new ImageComponentAdminListener(m_imageComponent));
|
||||
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);
|
||||
}
|
||||
});
|
||||
//library.getForm().addInitListener(new ImageComponentAdminListener(m_imageComponent));
|
||||
// For future use
|
||||
// library.getForm().addProcessListener(new ImageComponentAdminListener);
|
||||
// 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")),
|
||||
new Label(GlobalizationUtil.globalize("cms.ui.image_library")),
|
||||
library);
|
||||
|
||||
}
|
||||
|
|
@ -84,6 +77,17 @@ public class ImagesPane extends LayoutPanel implements Resettable, FormProcessLi
|
|||
@Override
|
||||
public final void register(Page page) {
|
||||
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));
|
||||
// }
|
||||
|
||||
page.addComponentStateParam(this, m_imageComponentKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -91,45 +95,6 @@ public class ImagesPane extends LayoutPanel implements Resettable, FormProcessLi
|
|||
super.reset(state);
|
||||
}
|
||||
|
||||
/*
|
||||
* // 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) {
|
||||
|
|
@ -138,36 +103,37 @@ public class ImagesPane extends LayoutPanel implements Resettable, FormProcessLi
|
|||
}
|
||||
}
|
||||
|
||||
private void setImageComponent(PageState ps, final String activeKey) {
|
||||
m_imageComponent.setSelectedKey(ps, activeKey);
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
|
||||
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();
|
||||
|
||||
// ItemImageAttachment attachment = m_imageStep.getAttachment(ps);
|
||||
// if (null == attachment) {
|
||||
// XXX: Do something
|
||||
// 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
|
||||
//// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@
|
|||
width: 8em;
|
||||
}
|
||||
|
||||
fieldset.preview {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.value {
|
||||
margin-left: 5.5em;
|
||||
margin-right: 1em;
|
||||
|
|
@ -48,6 +52,14 @@
|
|||
width: 100% !important;
|
||||
}
|
||||
|
||||
div.preview {
|
||||
magirn:
|
||||
}
|
||||
|
||||
label.preview {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.itemname {
|
||||
margin: 0.1em;
|
||||
|
|
@ -152,11 +164,13 @@
|
|||
</div>
|
||||
<input type="hidden" name="[aspect]" id="[aspect]"/>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<l10n>Image Preview:</l10n><br />
|
||||
<iframe id="[ipreview]" frameborder="0" style="border : 1px solid gray;" height="200" width="100%" src="about:blank"></iframe>
|
||||
<fieldset id="[preview]" class="preview">
|
||||
<legend>
|
||||
<l10n>Preview</l10n>
|
||||
</legend>
|
||||
<img src="about:blank" id="[ipreview]">
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="buttons" id="[buttons]">
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ OpenCCM.prototype.showImageDialog = function(image)
|
|||
data.caption = (image.parentNode.nextSibling.tagName.toLowerCase() == "span") ? image.parentNode.nextSibling.firstChild.nodeValue : "";
|
||||
}
|
||||
|
||||
// Calculate aspect ratio
|
||||
data.aspect = data.width / data.height;
|
||||
}
|
||||
|
||||
|
|
@ -72,21 +73,34 @@ OpenCCM.prototype.prepareImageDialog = function()
|
|||
var dialog = this.dialogs["images"] = new Xinha.Dialog(editor, OpenCCM.imagesHtml, 'Xinha',{width:410})
|
||||
|
||||
// Connect the OK and Cancel buttons
|
||||
dialog.getElementById('ok').onclick = function() {self.imageApply();}
|
||||
dialog.getElementById('remove').onclick = function() { self.imageRemove(); };
|
||||
dialog.getElementById('cancel').onclick = function() { self.dialogs["images"].hide()};
|
||||
dialog.getElementById("ok").onclick = function() {self.imageApply();}
|
||||
dialog.getElementById("remove").onclick = function() { self.imageRemove(); };
|
||||
dialog.getElementById("cancel").onclick = function() { self.dialogs["images"].hide()};
|
||||
|
||||
// Connect the Select button
|
||||
dialog.getElementById('browse').onclick = function() { self.imageBrowse(window); };
|
||||
dialog.getElementById("browse").onclick = function() { self.imageBrowse(window); };
|
||||
|
||||
// Connect onkeyup ecent handler with dimension filed to recalculate the size according to aspect ratio
|
||||
dialog.getElementById('width').onkeyup = function() { self.calcHeight(); };
|
||||
dialog.getElementById('height').onkeyup = function() { self.calcWidth(); };
|
||||
// Connect onkeyup event handler with dimension filed to recalculate the size according to aspect ratio
|
||||
dialog.getElementById("width").onkeyup = function() { self.calcHeight(); };
|
||||
dialog.getElementById("height").onkeyup = function() { self.calcWidth(); };
|
||||
|
||||
// OnResize
|
||||
this.dialogs["images"].onresize = function ()
|
||||
{
|
||||
var newHeightForPreview =
|
||||
parseInt(this.height, 10)
|
||||
// - this.getElementById("h1").offsetHeight
|
||||
// - this.getElementById("buttons").offsetHeight
|
||||
// - this.getElementById("inputs").offsetHeight
|
||||
- parseInt(this.rootElem.style.paddingBottom, 10);
|
||||
this.getElementById("preview").style.height = ((newHeightForPreview > 0) ? newHeightForPreview : 0) + "px";
|
||||
this.getElementById("preview").style.width = "98%";
|
||||
};
|
||||
|
||||
this.imageDialogReady = true;
|
||||
};
|
||||
|
||||
//
|
||||
// Write HTML code
|
||||
OpenCCM.prototype.imageApply = function()
|
||||
{
|
||||
|
||||
|
|
@ -271,13 +285,28 @@ OpenCCM.prototype.imageRemove = function() {
|
|||
};
|
||||
|
||||
OpenCCM.prototype.imageBrowse = function(window)
|
||||
{
|
||||
this.imageSet({
|
||||
src : "/theme/mandalay/ccm/cms-service/stream/image/?image_id=9001",
|
||||
width : "304",
|
||||
height : "420",
|
||||
name : "Schild.jpg"
|
||||
});
|
||||
};
|
||||
|
||||
OpenCCM.prototype.imageSet = function(imageData)
|
||||
{
|
||||
var dialog = this.dialogs["images"];
|
||||
dialog.getElementById(dialog.id["src"]).value = "/theme/mandalay/ccm/cms-service/stream/image/?image_id=9001";
|
||||
dialog.getElementById(dialog.id["width"]).value = "304";
|
||||
dialog.getElementById(dialog.id["height"]).value = "420";
|
||||
dialog.getElementById(dialog.id["name"]).value = "Schild.jpg";
|
||||
dialog.getElementById(dialog.id["src"]).value = imageData.src;
|
||||
dialog.getElementById(dialog.id["ipreview"]).src = imageData.src;
|
||||
dialog.getElementById(dialog.id["width"]).value = imageData.width;
|
||||
dialog.getElementById(dialog.id["height"]).value = imageData.height;
|
||||
dialog.getElementById(dialog.id["name"]).value = imageData.name;
|
||||
dialog.getElementById(dialog.id["aspect"]).value = dialog.getElementById(dialog.id["width"]).value / dialog.getElementById(dialog.id["height"]).value;
|
||||
if(imageData.src != "")
|
||||
{
|
||||
dialog.getElementById(dialog.id["preview"]).style.display = "block";
|
||||
}
|
||||
};
|
||||
|
||||
OpenCCM.prototype.calcWidth = function()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
|
||||
|
||||
<jsp:directive.page import="com.arsdigita.cms.ui.ImageSelectPage"/>
|
||||
<jsp:directive.page import="com.arsdigita.cms.ContentSectionServlet"/>
|
||||
<jsp:directive.page import="com.arsdigita.cms.ContentSection"/>
|
||||
<jsp:directive.page import="com.arsdigita.cms.dispatcher.Utilities"/>
|
||||
<jsp:directive.page import="com.arsdigita.dispatcher.*"/>
|
||||
<jsp:directive.page import="java.util.Date"/>
|
||||
|
||||
<jsp:declaration>
|
||||
private ImageSelectPage imageSelectPage = new ImageSelectPage();
|
||||
</jsp:declaration>
|
||||
|
||||
<jsp:scriptlet>
|
||||
// Restore the wrapped request
|
||||
request = DispatcherHelper.getRequest();
|
||||
DispatcherHelper.cacheDisable(response);
|
||||
|
||||
ContentSection section =
|
||||
ContentSectionServlet.getContentSection(request);
|
||||
|
||||
if (! ContentSectionServlet.checkAdminAccess(request, section)) {
|
||||
throw new com.arsdigita.cms.dispatcher.AccessDeniedException();
|
||||
}
|
||||
|
||||
RequestContext context = DispatcherHelper.getRequestContext(request);
|
||||
imageSelectPage.init();
|
||||
imageSelectPage.dispatch(request, response, context);
|
||||
</jsp:scriptlet>
|
||||
</jsp:root>
|
||||
Loading…
Reference in New Issue