ImageSelectPage
Kommunikation zwischen ISP und Xinha-Plugin fertiggestellt git-svn-id: https://svn.libreccm.org/ccm/trunk@1783 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
a8cd3bac81
commit
f0b01cda4c
|
|
@ -4,11 +4,11 @@
|
|||
*/
|
||||
package com.arsdigita.cms.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.MapComponentSelectionModel;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.cms.ReusableImageAsset;
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -25,9 +25,14 @@ public class ImageComponentSelectListener extends ImageComponentAbstractListener
|
|||
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) {
|
||||
m_resultPane.setResult(image.getDisplayName(), image.getID(), image.getWidth(), image.getHeight());
|
||||
|
||||
m_imageComponent.setSelectedKey(ps, ImageSelectPage.RESULT);
|
||||
m_resultPane.reset(ps);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
|
|||
private int m_mode;
|
||||
|
||||
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_imageID = new BigDecimalParameter("imageID");
|
||||
m_imageModel = new ItemSelectionModel(m_imageID);
|
||||
|
|
@ -62,6 +62,9 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
|
|||
ImagesPane.S_LOG.debug("Clicked select");
|
||||
try {
|
||||
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);
|
||||
} catch (DataObjectNotFoundException 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);
|
||||
}
|
||||
|
||||
// if (m_mode == ImageComponent.SELECT_IMAGE) {
|
||||
// m_form.setOnSubmit("selectImage();");
|
||||
// }
|
||||
|
||||
// save and cancel buttons
|
||||
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) {
|
||||
m_form.add(m_saveCancel);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ public class ImageSelectPage extends CMSPage {
|
|||
private final MapComponentSelectionModel m_imageComponent;
|
||||
private final ImageComponentSelectListener m_selectListener;
|
||||
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 RESULT = "result";
|
||||
|
||||
|
|
@ -85,7 +84,7 @@ public class ImageSelectPage extends CMSPage {
|
|||
|
||||
protected ImageLibraryComponent getImageLibraryPane() {
|
||||
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().addProcessListener(m_selectListener);
|
||||
m_imageComponent.getComponentsMap().put(ImageComponent.LIBRARY, m_imageLibrary);
|
||||
|
|
|
|||
|
|
@ -16,10 +16,7 @@ import java.math.BigDecimal;
|
|||
*/
|
||||
public class ImageSelectResultPane extends SimpleContainer implements Resettable {
|
||||
|
||||
public static final int UNSET = 0;
|
||||
public static final int CANCEL = 1;
|
||||
public static final int SELECT = 2;
|
||||
int m_state = UNSET;
|
||||
boolean m_valid = false;
|
||||
String m_name;
|
||||
BigDecimal m_id;
|
||||
BigDecimal m_width;
|
||||
|
|
@ -34,46 +31,44 @@ public class ImageSelectResultPane extends SimpleContainer implements Resettable
|
|||
m_id = id;
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
m_state = SELECT;
|
||||
m_valid = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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");
|
||||
scriptElem.addAttribute("type", "text/javascript");
|
||||
scriptElem.addAttribute("eventHandler", "onload");
|
||||
StringBuilder script = new StringBuilder(1000);
|
||||
|
||||
StringBuilder script = new StringBuilder(1000);
|
||||
script.append("function selectImage(button) {");
|
||||
if (m_valid) {
|
||||
|
||||
script.append("alert(\"SCRIPT\");");
|
||||
|
||||
if (m_state == SELECT) {
|
||||
// script.append("window.opener.document.OpenCCM.imageSet(");
|
||||
script.append("window.openCCM.imageSet(");
|
||||
script.append("{");
|
||||
script.append(" src : \"/theme/mandalay/ccm/cms-service/stream/image/?image_id=");
|
||||
script.append(m_id);
|
||||
script.append("\", ");
|
||||
script.append(" name : \"");
|
||||
script.append(m_name);
|
||||
script.append("\", ");
|
||||
script.append(" width : \"");
|
||||
script.append(m_width);
|
||||
script.append("\", ");
|
||||
script.append(" height : \"");
|
||||
script.append(m_height);
|
||||
script.append("\"");
|
||||
script.append(" });");
|
||||
}
|
||||
script.append("if(button.id == \"save\" ) {");
|
||||
|
||||
script.append("window.opener.openCCM.imageSet({");
|
||||
script.append(" src : \"/ccm/cms-service/stream/image/?image_id=");
|
||||
script.append(m_id);
|
||||
script.append("\", ");
|
||||
script.append(" name : \"");
|
||||
script.append(m_name);
|
||||
script.append("\", ");
|
||||
script.append(" width : \"");
|
||||
script.append(m_width);
|
||||
script.append("\", ");
|
||||
script.append(" height : \"");
|
||||
script.append(m_height);
|
||||
script.append("\"");
|
||||
script.append("});");
|
||||
script.append("}");
|
||||
|
||||
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) {
|
||||
|
|
@ -81,6 +76,6 @@ public class ImageSelectResultPane extends SimpleContainer implements Resettable
|
|||
m_id = null;
|
||||
m_width = null;
|
||||
m_height = null;
|
||||
m_state = UNSET;
|
||||
m_valid = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,8 +293,8 @@ OpenCCM.prototype.imageBrowse = function(window)
|
|||
// var searchDialog = new Xinha.Dialog(this.editor, destURL, '');//,{width:800, height:600}, {'closable':true});
|
||||
// searchDialog.show();
|
||||
var selectWindow = window.open(destURL, "_blank", "scrollbars=yes,directories=no,toolbar=no,width=800,height=600,status=no,menubar=no");
|
||||
selectWindow.openCCM = this;
|
||||
// return false;
|
||||
window.openCCM = this;
|
||||
return false;
|
||||
};
|
||||
|
||||
OpenCCM.prototype.imageSet = function(imageData)
|
||||
|
|
|
|||
Loading…
Reference in New Issue