ImageSelectPage

Kommunikation zwischen ISP und Xinha-Plugin fertiggestellt

git-svn-id: https://svn.libreccm.org/ccm/trunk@1783 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2012-07-26 05:26:52 +00:00
parent a8cd3bac81
commit f0b01cda4c
5 changed files with 50 additions and 42 deletions

View File

@ -4,11 +4,11 @@
*/ */
package com.arsdigita.cms.ui; package com.arsdigita.cms.ui;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.MapComponentSelectionModel; import com.arsdigita.bebop.MapComponentSelectionModel;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.cms.ReusableImageAsset; import com.arsdigita.cms.ReusableImageAsset;
import java.math.BigDecimal;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@ -25,9 +25,14 @@ public class ImageComponentSelectListener extends ImageComponentAbstractListener
m_resultPane = resultPane; m_resultPane = resultPane;
} }
@Override
protected void cancelled(PageState ps) {
super.cancelled(ps);
m_resultPane.reset(ps);
}
protected void processImage(FormSectionEvent event, PageState ps, ImageComponent component, ReusableImageAsset image) { protected void processImage(FormSectionEvent event, PageState ps, ImageComponent component, ReusableImageAsset image) {
m_resultPane.setResult(image.getDisplayName(), image.getID(), image.getWidth(), image.getHeight());
m_imageComponent.setSelectedKey(ps, ImageSelectPage.RESULT); m_imageComponent.setSelectedKey(ps, ImageSelectPage.RESULT);
m_resultPane.reset(ps);
} }
} }

View File

@ -42,10 +42,10 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
private int m_mode; private int m_mode;
public ImageLibraryComponent() { public ImageLibraryComponent() {
this(ImageComponent.ATTACH_IMAGE); this(ImageComponent.ATTACH_IMAGE, null);
} }
public ImageLibraryComponent(final int mode) { public ImageLibraryComponent(final int mode, final ImageSelectPage parent) {
m_mode = mode; m_mode = mode;
m_imageID = new BigDecimalParameter("imageID"); m_imageID = new BigDecimalParameter("imageID");
m_imageModel = new ItemSelectionModel(m_imageID); m_imageModel = new ItemSelectionModel(m_imageID);
@ -62,6 +62,9 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
ImagesPane.S_LOG.debug("Clicked select"); ImagesPane.S_LOG.debug("Clicked select");
try { try {
final ReusableImageAsset image = new ReusableImageAsset(imageID); final ReusableImageAsset image = new ReusableImageAsset(imageID);
if(m_mode == ImageComponent.SELECT_IMAGE) {
parent.getResultPane().setResult(image.getDisplayName(), image.getID(), image.getWidth(), image.getHeight());
}
m_imageModel.setSelectedObject(state, image); m_imageModel.setSelectedObject(state, image);
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
ImagesPane.S_LOG.error("Selected non-existant image: " + imageID, ex); ImagesPane.S_LOG.error("Selected non-existant image: " + imageID, ex);
@ -105,8 +108,14 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
m_form.add(m_useContext); m_form.add(m_useContext);
} }
// if (m_mode == ImageComponent.SELECT_IMAGE) {
// m_form.setOnSubmit("selectImage();");
// }
// save and cancel buttons // save and cancel buttons
m_saveCancel = new SaveCancelSection(); m_saveCancel = new SaveCancelSection();
m_saveCancel.getSaveButton().setOnClick("selectImage(this)");
m_saveCancel.getCancelButton().setOnClick("selectImage(this)");
if (m_mode == ImageComponent.SELECT_IMAGE || m_mode == ImageComponent.ATTACH_IMAGE) { if (m_mode == ImageComponent.SELECT_IMAGE || m_mode == ImageComponent.ATTACH_IMAGE) {
m_form.add(m_saveCancel); m_form.add(m_saveCancel);
} }

View File

@ -38,7 +38,6 @@ public class ImageSelectPage extends CMSPage {
private final MapComponentSelectionModel m_imageComponent; private final MapComponentSelectionModel m_imageComponent;
private final ImageComponentSelectListener m_selectListener; private final ImageComponentSelectListener m_selectListener;
private static final CMSConfig s_conf = CMSConfig.getInstance(); 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 static final String CONTENT_SECTION = "section_id";
public static final String RESULT = "result"; public static final String RESULT = "result";
@ -85,7 +84,7 @@ public class ImageSelectPage extends CMSPage {
protected ImageLibraryComponent getImageLibraryPane() { protected ImageLibraryComponent getImageLibraryPane() {
if (m_imageLibrary == null) { if (m_imageLibrary == null) {
m_imageLibrary = new ImageLibraryComponent(ImageComponent.SELECT_IMAGE); m_imageLibrary = new ImageLibraryComponent(ImageComponent.SELECT_IMAGE, this);
m_imageLibrary.getForm().addInitListener(m_selectListener); m_imageLibrary.getForm().addInitListener(m_selectListener);
m_imageLibrary.getForm().addProcessListener(m_selectListener); m_imageLibrary.getForm().addProcessListener(m_selectListener);
m_imageComponent.getComponentsMap().put(ImageComponent.LIBRARY, m_imageLibrary); m_imageComponent.getComponentsMap().put(ImageComponent.LIBRARY, m_imageLibrary);

View File

@ -16,10 +16,7 @@ import java.math.BigDecimal;
*/ */
public class ImageSelectResultPane extends SimpleContainer implements Resettable { public class ImageSelectResultPane extends SimpleContainer implements Resettable {
public static final int UNSET = 0; boolean m_valid = false;
public static final int CANCEL = 1;
public static final int SELECT = 2;
int m_state = UNSET;
String m_name; String m_name;
BigDecimal m_id; BigDecimal m_id;
BigDecimal m_width; BigDecimal m_width;
@ -34,46 +31,44 @@ public class ImageSelectResultPane extends SimpleContainer implements Resettable
m_id = id; m_id = id;
m_width = width; m_width = width;
m_height = height; m_height = height;
m_state = SELECT; m_valid = true;
} }
@Override @Override
public void generateXML(PageState state, Element parent) { public void generateXML(PageState state, Element parent) {
if (m_state != UNSET) { Element scriptElem = parent.newChildElement("script");
scriptElem.addAttribute("type", "text/javascript");
Element scriptElem = parent.newChildElement("script"); StringBuilder script = new StringBuilder(1000);
scriptElem.addAttribute("type", "text/javascript");
scriptElem.addAttribute("eventHandler", "onload");
StringBuilder script = new StringBuilder(1000); script.append("function selectImage(button) {");
if (m_valid) {
script.append("alert(\"SCRIPT\");"); script.append("if(button.id == \"save\" ) {");
if (m_state == SELECT) { script.append("window.opener.openCCM.imageSet({");
// script.append("window.opener.document.OpenCCM.imageSet("); script.append(" src : \"/ccm/cms-service/stream/image/?image_id=");
script.append("window.openCCM.imageSet("); script.append(m_id);
script.append("{"); script.append("\", ");
script.append(" src : \"/theme/mandalay/ccm/cms-service/stream/image/?image_id="); script.append(" name : \"");
script.append(m_id); script.append(m_name);
script.append("\", "); script.append("\", ");
script.append(" name : \""); script.append(" width : \"");
script.append(m_name); script.append(m_width);
script.append("\", "); script.append("\", ");
script.append(" width : \""); script.append(" height : \"");
script.append(m_width); script.append(m_height);
script.append("\", "); script.append("\"");
script.append(" height : \""); script.append("});");
script.append(m_height); script.append("}");
script.append("\"");
script.append(" });");
}
script.append("self.close();"); script.append("self.close();");
script.append("return false;");
scriptElem.setText(script.toString());
} }
script.append("return false;");
script.append("}");
scriptElem.setText(script.toString());
} }
public void reset(PageState state) { public void reset(PageState state) {
@ -81,6 +76,6 @@ public class ImageSelectResultPane extends SimpleContainer implements Resettable
m_id = null; m_id = null;
m_width = null; m_width = null;
m_height = null; m_height = null;
m_state = UNSET; m_valid = false;
} }
} }

View File

@ -293,8 +293,8 @@ OpenCCM.prototype.imageBrowse = function(window)
// var searchDialog = new Xinha.Dialog(this.editor, destURL, '');//,{width:800, height:600}, {'closable':true}); // var searchDialog = new Xinha.Dialog(this.editor, destURL, '');//,{width:800, height:600}, {'closable':true});
// searchDialog.show(); // searchDialog.show();
var selectWindow = window.open(destURL, "_blank", "scrollbars=yes,directories=no,toolbar=no,width=800,height=600,status=no,menubar=no"); var selectWindow = window.open(destURL, "_blank", "scrollbars=yes,directories=no,toolbar=no,width=800,height=600,status=no,menubar=no");
selectWindow.openCCM = this; window.openCCM = this;
// return false; return false;
}; };
OpenCCM.prototype.imageSet = function(imageData) OpenCCM.prototype.imageSet = function(imageData)