ImageSelectPage und ImagePane (1/2)
Weitere Änderungen. Restrukturierung, unter anderem interne Klassen aus ImageStepEdit zu normalen Klassen in cms.ui gemacht. git-svn-id: https://svn.libreccm.org/ccm/trunk@1766 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
29eaf69880
commit
7749c376a5
|
|
@ -34,6 +34,7 @@ import com.arsdigita.cms.CMS;
|
||||||
import com.arsdigita.cms.ImageAsset;
|
import com.arsdigita.cms.ImageAsset;
|
||||||
import com.arsdigita.cms.SecurityManager;
|
import com.arsdigita.cms.SecurityManager;
|
||||||
import com.arsdigita.cms.Service;
|
import com.arsdigita.cms.Service;
|
||||||
|
import com.arsdigita.cms.ui.ImageComponent;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.mimetypes.MimeType;
|
import com.arsdigita.mimetypes.MimeType;
|
||||||
|
|
@ -65,9 +66,6 @@ import org.apache.log4j.Logger;
|
||||||
*/
|
*/
|
||||||
public class ImageBrowser extends Table {
|
public class ImageBrowser extends Table {
|
||||||
|
|
||||||
public static final int DISPLAY_ONLY = 0;
|
|
||||||
public static final int SELECT_IMAGE = 1;
|
|
||||||
public static final int ADMIN_IMAGES = 2;
|
|
||||||
private ImageBrowserModelBuilder m_builder;
|
private ImageBrowserModelBuilder m_builder;
|
||||||
private static final String[] HEADERS = {"Thumbnail", "Name", "Size", "Type", "Action", ""};
|
private static final String[] HEADERS = {"Thumbnail", "Name", "Size", "Type", "Action", ""};
|
||||||
private static final int THUMB = 0;
|
private static final int THUMB = 0;
|
||||||
|
|
@ -76,8 +74,8 @@ public class ImageBrowser extends Table {
|
||||||
private static final int TYPE = 3;
|
private static final int TYPE = 3;
|
||||||
private static final int LINK = 4;
|
private static final int LINK = 4;
|
||||||
private static final int DELETE = 5;
|
private static final int DELETE = 5;
|
||||||
private static int s_numColumns = -1;
|
private int m_numColumns = -1;
|
||||||
private int m_mode = DISPLAY_ONLY;
|
private int m_mode;
|
||||||
private Dimension m_thumbSize;
|
private Dimension m_thumbSize;
|
||||||
private static final Logger s_log = Logger.getLogger(ImageBrowser.class);
|
private static final Logger s_log = Logger.getLogger(ImageBrowser.class);
|
||||||
|
|
||||||
|
|
@ -89,7 +87,7 @@ public class ImageBrowser extends Table {
|
||||||
*/
|
*/
|
||||||
public ImageBrowser(ImageBrowserModelBuilder b) {
|
public ImageBrowser(ImageBrowserModelBuilder b) {
|
||||||
|
|
||||||
this(b, ImageBrowser.SELECT_IMAGE);
|
this(b, ImageComponent.ATTACH_IMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageBrowser(ImageBrowserModelBuilder b, int mode) {
|
public ImageBrowser(ImageBrowserModelBuilder b, int mode) {
|
||||||
|
|
@ -114,9 +112,13 @@ public class ImageBrowser extends Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addColumn(TableCellRenderer renderer) {
|
private void addColumn(TableCellRenderer renderer) {
|
||||||
getColumn(++s_numColumns).setCellRenderer(renderer);
|
getColumn(++m_numColumns).setCellRenderer(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNumColumns() {
|
||||||
|
return m_numColumns;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the size, in pixels, of the thumbnail images
|
* @return the size, in pixels, of the thumbnail images
|
||||||
*/
|
*/
|
||||||
|
|
@ -217,7 +219,7 @@ public class ImageBrowser extends Table {
|
||||||
boolean isSelected, Object key,
|
boolean isSelected, Object key,
|
||||||
int row, int column) {
|
int row, int column) {
|
||||||
|
|
||||||
if (m_mode == ImageBrowser.SELECT_IMAGE) {
|
if (m_mode == ImageComponent.SELECT_IMAGE) {
|
||||||
return super.getComponent(table, state, value, isSelected, key, row, column);
|
return super.getComponent(table, state, value, isSelected, key, row, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,7 +241,7 @@ public class ImageBrowser extends Table {
|
||||||
int row, int column) {
|
int row, int column) {
|
||||||
|
|
||||||
// Only show delete link in admin mode
|
// Only show delete link in admin mode
|
||||||
if (m_mode == ADMIN_IMAGES) {
|
if (m_mode == ImageComponent.ADMIN_IMAGES) {
|
||||||
|
|
||||||
boolean canDelete = false;
|
boolean canDelete = false;
|
||||||
// SecurityManager sm = Utilities.getSecurityManager(state);
|
// SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
|
@ -300,7 +302,8 @@ public class ImageBrowser extends Table {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
return ImageBrowser.s_numColumns;
|
return ((ImageBrowser)m_model).getNumColumns();
|
||||||
|
// return ImageBrowser.s_numColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -95,14 +95,18 @@ public class ImageChooser extends BoxPanel {
|
||||||
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
|
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
|
||||||
*/
|
*/
|
||||||
public ImageChooser(String context) {
|
public ImageChooser(String context) {
|
||||||
this(context, ImageBrowser.SELECT_IMAGE);
|
this(context, ImageComponent.ATTACH_IMAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageChooser(int mode) {
|
||||||
|
this(ContentItem.DRAFT, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new ImageChooser
|
* Construct a new ImageChooser
|
||||||
*/
|
*/
|
||||||
public ImageChooser() {
|
public ImageChooser() {
|
||||||
this(ContentItem.DRAFT, ImageBrowser.SELECT_IMAGE);
|
this(ContentItem.DRAFT, ImageComponent.ATTACH_IMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,14 @@ import com.arsdigita.cms.ReusableImageAsset;
|
||||||
*/
|
*/
|
||||||
public interface ImageComponent {
|
public interface ImageComponent {
|
||||||
|
|
||||||
|
public static final int DISPLAY_ONLY = 0;
|
||||||
|
public static final int SELECT_IMAGE = 1;
|
||||||
|
public static final int ATTACH_IMAGE = 2;
|
||||||
|
public static final int ADMIN_IMAGES = 3;
|
||||||
|
|
||||||
|
public static final String UPLOAD = "upload";
|
||||||
|
public static final String LIBRARY = "library";
|
||||||
|
|
||||||
ReusableImageAsset getImage(FormSectionEvent event) throws FormProcessException;
|
ReusableImageAsset getImage(FormSectionEvent event) throws FormProcessException;
|
||||||
|
|
||||||
String getCaption(FormSectionEvent event);
|
String getCaption(FormSectionEvent event);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import java.math.BigDecimal;
|
||||||
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
||||||
*/
|
*/
|
||||||
public class ImageLibraryComponent extends SimpleContainer implements ImageComponent {
|
public class ImageLibraryComponent extends SimpleContainer implements ImageComponent {
|
||||||
|
|
||||||
private final ImageChooser m_chooser;
|
private final ImageChooser m_chooser;
|
||||||
private final ItemSelectionModel m_imageModel;
|
private final ItemSelectionModel m_imageModel;
|
||||||
private final BigDecimalParameter m_imageID;
|
private final BigDecimalParameter m_imageID;
|
||||||
|
|
@ -38,11 +39,17 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
|
||||||
private final TextField m_title;
|
private final TextField m_title;
|
||||||
private final TextField m_useContext;
|
private final TextField m_useContext;
|
||||||
private final SaveCancelSection m_saveCancel;
|
private final SaveCancelSection m_saveCancel;
|
||||||
|
private int m_mode;
|
||||||
|
|
||||||
public ImageLibraryComponent() {
|
public ImageLibraryComponent() {
|
||||||
|
this(ImageComponent.SELECT_IMAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageLibraryComponent(int 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);
|
||||||
m_chooser = new ImageChooser(ContentItem.DRAFT, ImageBrowser.ADMIN_IMAGES);
|
m_chooser = new ImageChooser(ContentItem.DRAFT, m_mode);
|
||||||
m_chooser.addImageActionListener(new ImageBrowser.LinkActionListener() {
|
m_chooser.addImageActionListener(new ImageBrowser.LinkActionListener() {
|
||||||
|
|
||||||
public void deleteClicked(PageState ps, BigDecimal imageID) {
|
public void deleteClicked(PageState ps, BigDecimal imageID) {
|
||||||
|
|
@ -62,42 +69,46 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(m_chooser);
|
add(m_chooser);
|
||||||
m_form = new Form("imageStepEditLibrary", new ColumnPanel(2));
|
|
||||||
|
// Form for additional fields and submit
|
||||||
|
m_form = new Form("imageLibraryComponent", new ColumnPanel(2));
|
||||||
add(m_form);
|
add(m_form);
|
||||||
m_form.add(new Label("Caption"));
|
|
||||||
|
// Initialize all wisgets
|
||||||
m_caption = new TextField("caption");
|
m_caption = new TextField("caption");
|
||||||
m_caption.addValidationListener(new NotNullValidationListener());
|
|
||||||
m_caption.setSize(40);
|
|
||||||
m_form.add(m_caption);
|
|
||||||
m_description = new TextField("description");
|
m_description = new TextField("description");
|
||||||
m_description.addValidationListener(new NotNullValidationListener());
|
|
||||||
m_description.setSize(40);
|
|
||||||
m_title = new TextField("title");
|
m_title = new TextField("title");
|
||||||
m_title.addValidationListener(new NotNullValidationListener());
|
|
||||||
m_title.setSize(40);
|
|
||||||
// Only show the title and description fields where these have
|
|
||||||
// been explicitly requested.
|
|
||||||
/*
|
|
||||||
* if
|
|
||||||
* (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown())
|
|
||||||
* { m_form.add(new Label("Description"));
|
|
||||||
* m_form.add(m_description); m_form.add(new Label("Title"));
|
|
||||||
* m_form.add(m_title); }
|
|
||||||
*/
|
|
||||||
m_form.add(new Label("Use Context"));
|
|
||||||
m_useContext = new TextField("useContext");
|
m_useContext = new TextField("useContext");
|
||||||
m_useContext.setSize(40);
|
|
||||||
m_form.add(m_useContext);
|
// Show additional fields only in default mode a.k.a. ATTACH_IMAGE like
|
||||||
|
// in image-step
|
||||||
|
if (m_mode == ImageComponent.ATTACH_IMAGE) {
|
||||||
|
m_form.add(new Label("Caption"));
|
||||||
|
m_caption.addValidationListener(new NotNullValidationListener());
|
||||||
|
m_caption.setSize(40);
|
||||||
|
m_form.add(m_caption);
|
||||||
|
m_description.addValidationListener(new NotNullValidationListener());
|
||||||
|
m_description.setSize(40);
|
||||||
|
m_title.addValidationListener(new NotNullValidationListener());
|
||||||
|
m_title.setSize(40);
|
||||||
|
// Only show the title and description fields where these have
|
||||||
|
// been explicitly requested.
|
||||||
|
/*
|
||||||
|
* if
|
||||||
|
* (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown())
|
||||||
|
* { m_form.add(new Label("Description"));
|
||||||
|
* m_form.add(m_description); m_form.add(new Label("Title"));
|
||||||
|
* m_form.add(m_title); }
|
||||||
|
*/
|
||||||
|
m_form.add(new Label("Use Context"));
|
||||||
|
m_useContext.setSize(40);
|
||||||
|
m_form.add(m_useContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
// save and cancel buttons
|
||||||
m_saveCancel = new SaveCancelSection();
|
m_saveCancel = new SaveCancelSection();
|
||||||
m_form.add(m_saveCancel);
|
m_form.add(m_saveCancel);
|
||||||
ActionLink upload = new ActionLink("Upload a new image");
|
|
||||||
upload.addActionListener(new ActionListener() {
|
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent ev) {
|
|
||||||
// setImageComponent(ev.getPageState(), UPLOAD);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
add(upload, ColumnPanel.FULL_WIDTH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReusableImageAsset getImage(FormSectionEvent event) {
|
public ReusableImageAsset getImage(FormSectionEvent event) {
|
||||||
|
|
@ -138,5 +149,13 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
|
||||||
public SaveCancelSection getSaveCancelSection() {
|
public SaveCancelSection getSaveCancelSection() {
|
||||||
return m_saveCancel;
|
return m_saveCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addUploadLink(ActionListener actionListener) {
|
||||||
|
// Add action link to image upload component
|
||||||
|
if (m_mode != ImageComponent.DISPLAY_ONLY) {
|
||||||
|
ActionLink upload = new ActionLink("Upload new image");
|
||||||
|
upload.addActionListener(actionListener);
|
||||||
|
add(upload, ColumnPanel.FULL_WIDTH);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.ui;
|
package com.arsdigita.cms.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.SimpleContainer;
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
import com.arsdigita.bebop.TabbedPane;
|
import com.arsdigita.bebop.TabbedPane;
|
||||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
|
@ -19,7 +20,8 @@ public class ImageSelectPage extends CMSPage {
|
||||||
|
|
||||||
private final static String XSL_CLASS = "CMS Admin";
|
private final static String XSL_CLASS = "CMS Admin";
|
||||||
private TabbedPane m_tabbedPane;
|
private TabbedPane m_tabbedPane;
|
||||||
private ImagesPane m_imagePane;
|
private ImageLibraryComponent m_imageLibrary;
|
||||||
|
private ImageUploadComponent m_imageUpload;
|
||||||
private BigDecimalParameter m_sectionId;
|
private BigDecimalParameter m_sectionId;
|
||||||
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;
|
private static final boolean LIMIT_TO_CONTENT_SECTION = false;
|
||||||
|
|
@ -33,6 +35,70 @@ public class ImageSelectPage extends CMSPage {
|
||||||
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
||||||
addGlobalStateParam(m_sectionId);
|
addGlobalStateParam(m_sectionId);
|
||||||
|
|
||||||
// m_imagePane = new ImagesPane();
|
m_tabbedPane = createTabbedPane();
|
||||||
|
m_tabbedPane.setIdAttr("page-body");
|
||||||
|
add(m_tabbedPane);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ImageLibraryComponent getImageLibraryPane() {
|
||||||
|
if (m_imageLibrary == null) {
|
||||||
|
m_imageLibrary = new ImageLibraryComponent(ImageComponent.SELECT_IMAGE);
|
||||||
|
// library.getForm().addInitListener(this);
|
||||||
|
// library.getForm().addProcessListener(this);
|
||||||
|
}
|
||||||
|
return m_imageLibrary;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ImageUploadComponent getImageUploadPane() {
|
||||||
|
|
||||||
|
if (m_imageUpload == null) {
|
||||||
|
m_imageUpload = new ImageUploadComponent(ImageComponent.SELECT_IMAGE);
|
||||||
|
// upload.getForm().addInitListener(this);
|
||||||
|
// upload.getForm().addProcessListener(this);
|
||||||
|
}
|
||||||
|
return m_imageUpload;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TabbedPane createTabbedPane() {
|
||||||
|
TabbedPane pane = new TabbedPane();
|
||||||
|
pane.setClassAttr(XSL_CLASS);
|
||||||
|
|
||||||
|
addToPane(pane, "library", getImageLibraryPane());
|
||||||
|
addToPane(pane, "upload", getImageUploadPane());
|
||||||
|
pane.setDefaultPane(m_imageLibrary);
|
||||||
|
|
||||||
|
return pane;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the specified component, with the specified tab name, to the tabbed
|
||||||
|
* pane only if it is not null.
|
||||||
|
*
|
||||||
|
* @param pane The pane to which to add the tab
|
||||||
|
* @param tabName The name of the tab if it's added
|
||||||
|
* @param comp The component to add to the pane
|
||||||
|
*/
|
||||||
|
protected void addToPane(TabbedPane pane, String tabName, Component comp) {
|
||||||
|
if (comp != null) {
|
||||||
|
pane.addTab(GlobalizationUtil.globalize("cms.ui.item_search." + tabName).localize().toString(), comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Listeners */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InitListener
|
||||||
|
*
|
||||||
|
* this init listener selects the object with the submitted oid
|
||||||
|
*/
|
||||||
|
// private init() {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProcessListener
|
||||||
|
*
|
||||||
|
* this process listener
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,62 +25,76 @@ import java.io.IOException;
|
||||||
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
||||||
*/
|
*/
|
||||||
public class ImageUploadComponent extends Form implements ImageComponent {
|
public class ImageUploadComponent extends Form implements ImageComponent {
|
||||||
|
|
||||||
private final FileUploadSection m_imageFile;
|
private final FileUploadSection m_imageFile;
|
||||||
private final TextField m_caption;
|
private final TextField m_caption;
|
||||||
private final TextField m_title;
|
private final TextField m_title;
|
||||||
private final TextArea m_description;
|
private final TextArea m_description;
|
||||||
private final TextField m_useContext;
|
private final TextField m_useContext;
|
||||||
private final SaveCancelSection m_saveCancel;
|
private final SaveCancelSection m_saveCancel;
|
||||||
|
private int m_mode;
|
||||||
|
|
||||||
public ImageUploadComponent() {
|
public ImageUploadComponent() {
|
||||||
|
this(ImageComponent.ATTACH_IMAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageUploadComponent(int mode) {
|
||||||
super("imageUploadComponent", new ColumnPanel(2));
|
super("imageUploadComponent", new ColumnPanel(2));
|
||||||
|
m_mode = mode;
|
||||||
setEncType("multipart/form-data");
|
setEncType("multipart/form-data");
|
||||||
// Ignoring deprecated constructor.
|
// Ignoring deprecated constructor.
|
||||||
m_imageFile = new FileUploadSection("Image Type", "image", ImageAsset.MIME_JPEG);
|
m_imageFile = new FileUploadSection("Image Type", "image", ImageAsset.MIME_JPEG);
|
||||||
m_imageFile.getFileUploadWidget().addValidationListener(new NotNullValidationListener());
|
m_imageFile.getFileUploadWidget().addValidationListener(new NotNullValidationListener());
|
||||||
add(m_imageFile, ColumnPanel.FULL_WIDTH);
|
add(m_imageFile, ColumnPanel.FULL_WIDTH);
|
||||||
add(new Label("Caption"));
|
|
||||||
|
// Initialize all widgets
|
||||||
m_caption = new TextField("caption");
|
m_caption = new TextField("caption");
|
||||||
m_caption.addValidationListener(new NotNullValidationListener());
|
|
||||||
m_caption.addValidationListener(new StringLengthValidationListener(40));
|
|
||||||
m_caption.setSize(40);
|
|
||||||
add(m_caption);
|
|
||||||
m_title = new TextField("title");
|
m_title = new TextField("title");
|
||||||
m_description = new TextArea("description");
|
m_description = new TextArea("description");
|
||||||
// We only show the title and description fields in the case where
|
|
||||||
// getIsImageStepDescriptionAndTitleShown is false.
|
|
||||||
/*
|
|
||||||
* if
|
|
||||||
* (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown())
|
|
||||||
* { add(new Label("Title")); m_title.addValidationListener(new
|
|
||||||
* NotNullValidationListener()); m_title.setSize(40);
|
|
||||||
* m_title.addValidationListener(new
|
|
||||||
* StringLengthValidationListener(40)); add(m_title);
|
|
||||||
*
|
|
||||||
* add(new Label("Description"));
|
|
||||||
* m_description.addValidationListener(new
|
|
||||||
* NotNullValidationListener());
|
|
||||||
* m_description.addValidationListener(new
|
|
||||||
* StringLengthValidationListener(600)); m_description.setCols(30);
|
|
||||||
* m_description.setRows(5); add(m_description);
|
|
||||||
*
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
add(new Label("Use Context"));
|
|
||||||
m_useContext = new TextField("useContext");
|
m_useContext = new TextField("useContext");
|
||||||
m_useContext.setSize(40);
|
|
||||||
add(m_useContext);
|
// add widget only if we are in attach mode
|
||||||
|
if (m_mode == ImageComponent.ATTACH_IMAGE) {
|
||||||
|
add(new Label("Caption"));
|
||||||
|
m_caption.addValidationListener(new NotNullValidationListener());
|
||||||
|
m_caption.addValidationListener(new StringLengthValidationListener(40));
|
||||||
|
m_caption.setSize(40);
|
||||||
|
add(m_caption);
|
||||||
|
|
||||||
|
// We only show the title and description fields in the case where
|
||||||
|
// getIsImageStepDescriptionAndTitleShown is false.
|
||||||
|
|
||||||
|
// if (ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown()) {
|
||||||
|
// add(new Label("Title"));
|
||||||
|
// m_title.addValidationListener(new NotNullValidationListener());
|
||||||
|
// m_title.setSize(40);
|
||||||
|
// m_title.addValidationListener(new StringLengthValidationListener(40));
|
||||||
|
// add(m_title);
|
||||||
|
//
|
||||||
|
// add(new Label("Description"));
|
||||||
|
// m_description.addValidationListener(new NotNullValidationListener());
|
||||||
|
// m_description.addValidationListener(new StringLengthValidationListener(600));
|
||||||
|
// m_description.setCols(30);
|
||||||
|
// m_description.setRows(5);
|
||||||
|
// add(m_description);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
add(new Label("Use Context"));
|
||||||
|
m_useContext.setSize(40);
|
||||||
|
add(m_useContext);
|
||||||
|
}
|
||||||
m_saveCancel = new SaveCancelSection();
|
m_saveCancel = new SaveCancelSection();
|
||||||
add(m_saveCancel);
|
add(m_saveCancel);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Removed by Quasimodo: Changed editing workflow, so that library
|
* Removed by Quasimodo: Changed editing workflow, so that library comes
|
||||||
* comes first Also, library mode has now a link to upload images
|
* first Also, library mode has now a link to upload images which will
|
||||||
* whixh will link to this form. Consequently, this link will create
|
* link to this form. Consequently, this link will create a loop, which
|
||||||
* a loop, which isn't fatal but confusing ActionLink library = new
|
* isn't fatal but confusing. ActionLink library = new ActionLink(
|
||||||
* ActionLink( "Select an existing image" );
|
* "Select an existing image" ); library.addActionListener( new
|
||||||
* library.addActionListener( new ActionListener() { public void
|
* ActionListener() { public void actionPerformed( ActionEvent ev ) {
|
||||||
* actionPerformed( ActionEvent ev ) { setImageComponent(
|
* setImageComponent( ev.getPageState(), LIBRARY ); } } ); add( library,
|
||||||
* ev.getPageState(), LIBRARY ); } } ); add( library,
|
|
||||||
* ColumnPanel.FULL_WIDTH );
|
* ColumnPanel.FULL_WIDTH );
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
@ -127,5 +141,4 @@ public class ImageUploadComponent extends Form implements ImageComponent {
|
||||||
public Form getForm() {
|
public Form getForm() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.ui;
|
package com.arsdigita.cms.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.ActionLink;
|
import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.ColumnPanel;
|
|
||||||
import com.arsdigita.bebop.Form;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.MapComponentSelectionModel;
|
import com.arsdigita.bebop.MapComponentSelectionModel;
|
||||||
|
|
@ -14,30 +12,21 @@ import com.arsdigita.bebop.Page;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
import com.arsdigita.bebop.Resettable;
|
import com.arsdigita.bebop.Resettable;
|
||||||
import com.arsdigita.bebop.SaveCancelSection;
|
|
||||||
import com.arsdigita.bebop.SegmentedPanel;
|
import com.arsdigita.bebop.SegmentedPanel;
|
||||||
import com.arsdigita.bebop.SimpleComponent;
|
import com.arsdigita.bebop.SimpleComponent;
|
||||||
import com.arsdigita.bebop.SimpleContainer;
|
|
||||||
import com.arsdigita.bebop.event.ActionEvent;
|
import com.arsdigita.bebop.event.ActionEvent;
|
||||||
import com.arsdigita.bebop.event.ActionListener;
|
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.FormSectionEvent;
|
||||||
import com.arsdigita.bebop.form.TextArea;
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringLengthValidationListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.ImageAsset;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ReusableImageAsset;
|
import com.arsdigita.cms.ReusableImageAsset;
|
||||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
|
||||||
import com.arsdigita.toolbox.ui.LayoutPanel;
|
import com.arsdigita.toolbox.ui.LayoutPanel;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
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;
|
||||||
|
|
||||||
|
|
@ -46,14 +35,12 @@ import org.apache.log4j.Logger;
|
||||||
*
|
*
|
||||||
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
||||||
*/
|
*/
|
||||||
public class ImagesPane extends LayoutPanel implements Resettable {
|
public class ImagesPane extends LayoutPanel implements Resettable, FormProcessListener, FormInitListener {
|
||||||
|
|
||||||
public static final Logger s_log = Logger.getLogger(BrowsePane.class);
|
public static final Logger s_log = Logger.getLogger(BrowsePane.class);
|
||||||
//private ImageChooser imageChooser;
|
//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 String UPLOAD = "upload";
|
|
||||||
private final String LIBRARY = "library";
|
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -61,12 +48,8 @@ public class ImagesPane extends LayoutPanel implements Resettable {
|
||||||
setLeft(new SimpleComponent());
|
setLeft(new SimpleComponent());
|
||||||
|
|
||||||
SegmentedPanel body = new SegmentedPanel();
|
SegmentedPanel body = new SegmentedPanel();
|
||||||
body.addSegment(
|
|
||||||
new Label(GlobalizationUtil.globalize("cms.ui.image_browser")),
|
|
||||||
new ImageChooser(ContentItem.DRAFT, ImageBrowser.ADMIN_IMAGES));
|
|
||||||
|
|
||||||
setBody(body);
|
setBody(body);
|
||||||
|
|
||||||
m_imageComponentKey = new StringParameter("imageComponent");
|
m_imageComponentKey = new StringParameter("imageComponent");
|
||||||
|
|
||||||
ParameterSingleSelectionModel componentModel = new ParameterSingleSelectionModel(m_imageComponentKey);
|
ParameterSingleSelectionModel componentModel = new ParameterSingleSelectionModel(m_imageComponentKey);
|
||||||
|
|
@ -74,24 +57,36 @@ public class ImagesPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
Map selectors = m_imageComponent.getComponentsMap();
|
Map selectors = m_imageComponent.getComponentsMap();
|
||||||
|
|
||||||
// ImageUploadComponent upload = new ImageUploadComponent();
|
ImageUploadComponent upload = new ImageUploadComponent(ImageComponent.ADMIN_IMAGES);
|
||||||
// upload.getForm().addInitListener(this);
|
upload.getForm().addInitListener(this);
|
||||||
// upload.getForm().addProcessListener(this);
|
upload.getForm().addProcessListener(this);
|
||||||
// selectors.put(UPLOAD, upload);
|
selectors.put(ImageComponent.UPLOAD, upload);
|
||||||
// add(upload);
|
body.addSegment(
|
||||||
//
|
new Label(GlobalizationUtil.globalize("cms.ui.image_upload")),
|
||||||
// ImageLibraryComponent library = new ImageLibraryComponent();
|
upload);
|
||||||
// library.getForm().addInitListener(this);
|
|
||||||
// library.getForm().addProcessListener(this);
|
ImageLibraryComponent library = new ImageLibraryComponent(ImageComponent.ADMIN_IMAGES);
|
||||||
// selectors.put(LIBRARY,
|
library.getForm().addInitListener(this);
|
||||||
// library);
|
library.getForm().addProcessListener(this);
|
||||||
// add(library);
|
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")),
|
||||||
|
library);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final void register(Page page) {
|
public final void register(Page page) {
|
||||||
super.register(page);
|
super.register(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final void reset(PageState state) {
|
public final void reset(PageState state) {
|
||||||
super.reset(state);
|
super.reset(state);
|
||||||
}
|
}
|
||||||
|
|
@ -99,43 +94,73 @@ public class ImagesPane extends LayoutPanel implements Resettable {
|
||||||
/*
|
/*
|
||||||
* // Private classes and methods private final class ProcessListener
|
* // Private classes and methods private final class ProcessListener
|
||||||
* implements FormProcessListener {
|
* 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) { final PageState s
|
|
||||||
* = e.getPageState();
|
|
||||||
*
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*/
|
*/
|
||||||
|
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) {
|
||||||
|
final PageState s = e.getPageState();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
public void init(FormSectionEvent event)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
PageState ps = event.getPageState();
|
PageState ps = event.getPageState();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue