The caption of an ItemImageAttachment can now be edited (Issue #1575)
git-svn-id: https://svn.libreccm.org/ccm/trunk@2607 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
6fdc39c8d9
commit
e3f40b4e7f
|
|
@ -5,3 +5,5 @@ cms.contentassets.ui.image_step.no_image_attached=This item does not have any as
|
||||||
cms.contentassets.ui.image_step.remove_attached_image=Remove image attachment
|
cms.contentassets.ui.image_step.remove_attached_image=Remove image attachment
|
||||||
cms.contentassets.ui.image_step.move_attached_image_down=Move down
|
cms.contentassets.ui.image_step.move_attached_image_down=Move down
|
||||||
cms.contentassets.ui.image_step.move_attached_image_up=Move up
|
cms.contentassets.ui.image_step.move_attached_image_up=Move up
|
||||||
|
cms.contentassets.ui.image_step.edit_attached_image=Edit caption
|
||||||
|
cms.contentassets.ui.image_step.caption=Caption
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,5 @@ cms.contentassets.ui.image_step.no_image_attached=Diesem Dokument ist noch kein
|
||||||
cms.contentassets.ui.image_step.remove_attached_image=Aus der Liste entfernen
|
cms.contentassets.ui.image_step.remove_attached_image=Aus der Liste entfernen
|
||||||
cms.contentassets.ui.image_step.move_attached_image_down=Nach unten verschieben
|
cms.contentassets.ui.image_step.move_attached_image_down=Nach unten verschieben
|
||||||
cms.contentassets.ui.image_step.move_attached_image_up=Nach oben verschieben
|
cms.contentassets.ui.image_step.move_attached_image_up=Nach oben verschieben
|
||||||
|
cms.contentassets.ui.image_step.edit_attached_image=Bildunterschrift editieren
|
||||||
|
cms.contentassets.ui.image_step.caption=Bildunterschrift
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,5 @@ cms.contentassets.ui.image_step.no_image_attached=This item does not have any as
|
||||||
cms.contentassets.ui.image_step.remove_attached_image=Remove image attachment
|
cms.contentassets.ui.image_step.remove_attached_image=Remove image attachment
|
||||||
cms.contentassets.ui.image_step.move_attached_image_down=Move down
|
cms.contentassets.ui.image_step.move_attached_image_down=Move down
|
||||||
cms.contentassets.ui.image_step.move_attached_image_up=Move up
|
cms.contentassets.ui.image_step.move_attached_image_up=Move up
|
||||||
|
cms.contentassets.ui.image_step.edit_attached_image=Edit caption
|
||||||
|
cms.contentassets.ui.image_step.caption=Caption
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.arsdigita.cms.contentassets.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
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.form.TextField;
|
||||||
|
import com.arsdigita.cms.contentassets.ItemImageAttachment;
|
||||||
|
import com.arsdigita.cms.contentassets.util.ImageStepGlobalizationUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class ImageAttachmentEditForm extends Form
|
||||||
|
implements FormInitListener, FormProcessListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
final ImageStep imageStep;
|
||||||
|
final SaveCancelSection saveCancelSection;
|
||||||
|
|
||||||
|
public ImageAttachmentEditForm(final ImageStep imageStep) {
|
||||||
|
super("ImageAttachmentEditForm");
|
||||||
|
|
||||||
|
this.imageStep = imageStep;
|
||||||
|
|
||||||
|
final Label label = new Label(ImageStepGlobalizationUtil.globalize(
|
||||||
|
"cms.contentassets.ui.image_step.caption"));
|
||||||
|
|
||||||
|
final TextField captionField = new TextField(CAPTION);
|
||||||
|
|
||||||
|
add(label);
|
||||||
|
add(captionField);
|
||||||
|
|
||||||
|
saveCancelSection = new SaveCancelSection();
|
||||||
|
add(saveCancelSection);
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String CAPTION = "caption";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
final ItemImageAttachment attachment = imageStep.getAttachment(event.getPageState());
|
||||||
|
|
||||||
|
event.getFormData().put(CAPTION, attachment.getCaption());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
final ItemImageAttachment attachment = imageStep.getAttachment(event.getPageState());
|
||||||
|
|
||||||
|
attachment.setCaption(event.getFormData().getString(CAPTION));
|
||||||
|
|
||||||
|
attachment.save();
|
||||||
|
|
||||||
|
imageStep.showDisplayPane(event.getPageState());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submitted(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
if (saveCancelSection.getCancelButton().isSelected(event.getPageState())) {
|
||||||
|
imageStep.setAttachment(event.getPageState(), null);
|
||||||
|
|
||||||
|
imageStep.showDisplayPane(event.getPageState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -39,163 +39,171 @@ import java.util.Iterator;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pluggable authoring step as the main entry point to add an ImageAsset to a
|
* Pluggable authoring step as the main entry point to add an ImageAsset to a content item.
|
||||||
* content item.
|
|
||||||
*
|
*
|
||||||
* @author unknown
|
* @author unknown
|
||||||
* @author Sören Bernstein <quasi@quasiweb.de>
|
* @author Sören Bernstein <quasi@quasiweb.de>
|
||||||
*/
|
*/
|
||||||
public class ImageStep extends SecurityPropertyEditor {
|
public class ImageStep extends SecurityPropertyEditor {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(ImageStep.class);
|
private static final Logger s_log = Logger.getLogger(ImageStep.class);
|
||||||
private final ItemSelectionModel m_itemSelection;
|
private final ItemSelectionModel m_itemSelection;
|
||||||
private final AttachmentSelectionModel m_attachmentSelection;
|
private final AttachmentSelectionModel m_attachmentSelection;
|
||||||
private final AuthoringKitWizard m_parent;
|
private final AuthoringKitWizard m_parent;
|
||||||
private final ImageStepDisplay m_display;
|
private final ImageStepDisplay m_display;
|
||||||
private final ImageStepEdit m_add;
|
private final ImageStepEdit m_add;
|
||||||
private final OIDParameter m_attachmentOID;
|
private final OIDParameter m_attachmentOID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param itemModel The {@link ItemSelectionModel} to use with this
|
* @param itemModel The {@link ItemSelectionModel} to use with this instance
|
||||||
* instance
|
* @param parent The parent {@link AuthoringKitWizard}
|
||||||
* @param parent The parent {@link AuthoringKitWizard}
|
*/
|
||||||
*/
|
public ImageStep(ItemSelectionModel itemModel,
|
||||||
public ImageStep(ItemSelectionModel itemModel,
|
AuthoringKitWizard parent) {
|
||||||
AuthoringKitWizard parent) {
|
super();
|
||||||
super();
|
|
||||||
|
|
||||||
m_itemSelection = itemModel;
|
m_itemSelection = itemModel;
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
|
|
||||||
m_attachmentOID = new OIDParameter("attachmentID");
|
m_attachmentOID = new OIDParameter("attachmentID");
|
||||||
m_attachmentSelection = new AttachmentSelectionModel();
|
m_attachmentSelection = new AttachmentSelectionModel();
|
||||||
|
|
||||||
|
|
||||||
/* Create ImageEditStep to add images to the current item */
|
/* Create ImageEditStep to add images to the current item */
|
||||||
m_add = new ImageStepEdit(this);
|
m_add = new ImageStepEdit(this);
|
||||||
WorkflowLockedComponentAccess addCA =
|
WorkflowLockedComponentAccess addCA = new WorkflowLockedComponentAccess(m_add,
|
||||||
new WorkflowLockedComponentAccess(m_add, m_itemSelection);
|
m_itemSelection);
|
||||||
addComponent("add",
|
addComponent("add",
|
||||||
ImageStepGlobalizationUtil.globalize(
|
ImageStepGlobalizationUtil.globalize(
|
||||||
"cms.contentassets.ui.image_step.add_image"),
|
"cms.contentassets.ui.image_step.add_image"),
|
||||||
addCA);
|
addCA);
|
||||||
|
|
||||||
/* ImageDisplayStep to display all already attached images */
|
addComponent("edit",
|
||||||
m_display = new ImageStepDisplay(this); // Component to display
|
new ImageAttachmentEditForm(this));
|
||||||
setDisplayComponent(m_display); // all attached images.
|
|
||||||
|
|
||||||
Iterator imageComponents = m_add.getImageComponents();
|
/* ImageDisplayStep to display all already attached images */
|
||||||
while (imageComponents.hasNext()) {
|
m_display = new ImageStepDisplay(this); // Component to display
|
||||||
ImageComponent component =
|
setDisplayComponent(m_display); // all attached images.
|
||||||
(ImageComponent) imageComponents.next();
|
|
||||||
|
|
||||||
addListeners(component.getForm(),
|
Iterator imageComponents = m_add.getImageComponents();
|
||||||
component.getSaveCancelSection().getCancelButton());
|
while (imageComponents.hasNext()) {
|
||||||
}
|
ImageComponent component = (ImageComponent) imageComponents.next();
|
||||||
|
|
||||||
m_parent.getList().addActionListener(new ActionListener() {
|
addListeners(component.getForm(),
|
||||||
@Override
|
component.getSaveCancelSection().getCancelButton());
|
||||||
public void actionPerformed(ActionEvent event) {
|
}
|
||||||
PageState state = event.getPageState();
|
|
||||||
showDisplayPane(state);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
m_parent.getList().addActionListener(new ActionListener() {
|
||||||
public void register(Page p) {
|
@Override
|
||||||
super.register(p);
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
showDisplayPane(state);
|
||||||
|
}
|
||||||
|
|
||||||
p.addComponentStateParam(this, m_attachmentOID);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return the parent wizard
|
public void register(Page p) {
|
||||||
*/
|
super.register(p);
|
||||||
public AuthoringKitWizard getParentWizard() {
|
|
||||||
return m_parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
p.addComponentStateParam(this, m_attachmentOID);
|
||||||
* @return The item selection model
|
}
|
||||||
*/
|
|
||||||
public ItemSelectionModel getItemSelectionModel() {
|
|
||||||
return m_itemSelection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The currently selected item, null if there isn't one.
|
* @return the parent wizard
|
||||||
*/
|
*/
|
||||||
public ContentItem getItem(PageState ps) {
|
public AuthoringKitWizard getParentWizard() {
|
||||||
return m_itemSelection.getSelectedItem(ps);
|
return m_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The currently selected item, null if there isn't one.
|
* @return The item selection model
|
||||||
*/
|
*/
|
||||||
public ItemImageAttachment getAttachment(PageState ps) {
|
public ItemSelectionModel getItemSelectionModel() {
|
||||||
return (ItemImageAttachment) m_attachmentSelection.getSelectedAttachment(ps);
|
return m_itemSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AttachmentSelectionModel
|
/**
|
||||||
extends AbstractSingleSelectionModel {
|
* @return The currently selected item, null if there isn't one.
|
||||||
|
*/
|
||||||
|
public ContentItem getItem(PageState ps) {
|
||||||
|
return m_itemSelection.getSelectedItem(ps);
|
||||||
|
}
|
||||||
|
|
||||||
private final RequestLocal m_attachment = new RequestLocal() {
|
/**
|
||||||
@Override
|
* @return The currently selected item, null if there isn't one.
|
||||||
protected Object initialValue(PageState ps) {
|
*/
|
||||||
OID oid = (OID) getSelectedKey(ps);
|
public ItemImageAttachment getAttachment(PageState ps) {
|
||||||
if (null == oid) {
|
return m_attachmentSelection.getSelectedAttachment(ps);
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return DomainObjectFactory.newInstance(oid);
|
public void setAttachment(final PageState state, final ItemImageAttachment attachment) {
|
||||||
}
|
m_attachmentSelection.setSelectedAttachment(state, attachment);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
private class AttachmentSelectionModel
|
||||||
|
extends AbstractSingleSelectionModel {
|
||||||
|
|
||||||
@Override
|
private final RequestLocal m_attachment = new RequestLocal() {
|
||||||
public Object getSelectedKey(PageState ps) {
|
@Override
|
||||||
OID oid = (OID) ps.getValue(m_attachmentOID);
|
protected Object initialValue(PageState ps) {
|
||||||
if (null == oid) {
|
OID oid = (OID) getSelectedKey(ps);
|
||||||
return null;
|
if (null == oid) {
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return oid;
|
return DomainObjectFactory.newInstance(oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
};
|
||||||
public void setSelectedKey(PageState ps, Object oid) {
|
|
||||||
m_attachment.set(ps, null);
|
|
||||||
ps.setValue(m_attachmentOID, oid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemImageAttachment getSelectedAttachment(PageState ps) {
|
@Override
|
||||||
return (ItemImageAttachment) m_attachment.get(ps);
|
public Object getSelectedKey(PageState ps) {
|
||||||
}
|
OID oid = (OID) ps.getValue(m_attachmentOID);
|
||||||
|
if (null == oid) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSelectedAttachment(PageState ps,
|
return oid;
|
||||||
ItemImageAttachment attachment) {
|
}
|
||||||
setSelectedKey(ps, attachment);
|
|
||||||
m_attachment.set(ps, attachment);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParameterModel getStateParameter() {
|
public void setSelectedKey(PageState ps, Object oid) {
|
||||||
return m_attachmentOID;
|
m_attachment.set(ps, null);
|
||||||
}
|
ps.setValue(m_attachmentOID, oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemImageAttachment getSelectedAttachment(PageState ps) {
|
||||||
|
return (ItemImageAttachment) m_attachment.get(ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedAttachment(PageState ps,
|
||||||
|
ItemImageAttachment attachment) {
|
||||||
|
setSelectedKey(ps, attachment);
|
||||||
|
m_attachment.set(ps, attachment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ParameterModel getStateParameter() {
|
||||||
|
return m_attachmentOID;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show display pane.
|
||||||
|
*
|
||||||
|
* Also, reset the forms for reuse.
|
||||||
|
*
|
||||||
|
* @param state
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void showDisplayPane(PageState state) {
|
||||||
|
super.showDisplayPane(state);
|
||||||
|
m_add.reset(state);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show display pane.
|
|
||||||
*
|
|
||||||
* Also, reset the forms for reuse.
|
|
||||||
*
|
|
||||||
* @param state
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void showDisplayPane(PageState state) {
|
|
||||||
super.showDisplayPane(state);
|
|
||||||
m_add.reset(state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,404 +50,454 @@ import javax.servlet.ServletException;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component displays the currently attached images for an content item. It is
|
* Component displays the currently attached images for an content item. It is part of the entry
|
||||||
* part of the entry point image authoring step {@see ImageStep}.
|
* point image authoring step {
|
||||||
*
|
*
|
||||||
* It creates a list of images including meta information (name, type, width,
|
* @see ImageStep}.
|
||||||
* etc.), a link to remove from the list for each image and at the bottom a link
|
*
|
||||||
* to add another image.
|
* It creates a list of images including meta information (name, type, width, etc.), a link to
|
||||||
|
* remove from the list for each image and at the bottom a link to add another image.
|
||||||
*
|
*
|
||||||
* @author unknown
|
* @author unknown
|
||||||
* @author Sören Bernstein <quasi@quasiweb.de>
|
* @author Sören Bernstein <quasi@quasiweb.de>
|
||||||
*/
|
*/
|
||||||
public class ImageStepDisplay extends SimpleContainer {
|
public class ImageStepDisplay extends SimpleContainer {
|
||||||
|
|
||||||
private static final Logger S_LOG = Logger.getLogger(ImageStepDisplay.class);
|
private static final Logger S_LOG = Logger.getLogger(ImageStepDisplay.class);
|
||||||
/**
|
/**
|
||||||
* Represents invoking parent component
|
* Represents invoking parent component
|
||||||
*/
|
*/
|
||||||
private final ImageStep m_imageStep;
|
private final ImageStep m_imageStep;
|
||||||
private ImageListModelBuilder m_listModelBuilder;
|
private ImageListModelBuilder m_listModelBuilder;
|
||||||
/**
|
/**
|
||||||
* Name of the delete event
|
* Name of the delete event
|
||||||
*/
|
*/
|
||||||
private final static String DELETE = "deleteAttachment";
|
private final static String DELETE = "deleteAttachment";
|
||||||
private final static String MOVEUP = "moveAttachmentUp";
|
private final static String MOVEUP = "moveAttachmentUp";
|
||||||
private final static String MOVEDOWN = "moveAttachmentDown";
|
private final static String MOVEDOWN = "moveAttachmentDown";
|
||||||
|
private final static String EDIT = "editAttachment";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param step
|
* @param step
|
||||||
*/
|
*/
|
||||||
public ImageStepDisplay(ImageStep step) {
|
public ImageStepDisplay(ImageStep step) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
m_imageStep = step;
|
m_imageStep = step;
|
||||||
|
|
||||||
/* Message to show in case no image has been attached yet. */
|
/* Message to show in case no image has been attached yet. */
|
||||||
Label mainLabel = new Label(ImageStepGlobalizationUtil.globalize(
|
Label mainLabel = new Label(ImageStepGlobalizationUtil.globalize(
|
||||||
"cms.contentassets.ui.image_step.no_image_attached"));
|
"cms.contentassets.ui.image_step.no_image_attached"));
|
||||||
mainLabel.setFontWeight(Label.ITALIC);
|
mainLabel.setFontWeight(Label.ITALIC);
|
||||||
|
|
||||||
m_listModelBuilder = new ImageListModelBuilder();
|
m_listModelBuilder = new ImageListModelBuilder();
|
||||||
List imageList = new List(m_listModelBuilder) {
|
List imageList = new List(m_listModelBuilder) {
|
||||||
@Override
|
@Override
|
||||||
public void respond(PageState ps) throws ServletException {
|
public void respond(PageState ps) throws ServletException {
|
||||||
if (DELETE.equals(ps.getControlEventName())) {
|
if (DELETE.equals(ps.getControlEventName())) {
|
||||||
DomainObjectFactory.newInstance(OID.valueOf(ps.getControlEventValue())).delete();
|
DomainObjectFactory.newInstance(OID.valueOf(ps.getControlEventValue())).delete();
|
||||||
// Regenerate sortkeys
|
// Regenerate sortkeys
|
||||||
m_listModelBuilder.getModel().regenSortKeys(ps);
|
m_listModelBuilder.getModel().regenSortKeys(ps);
|
||||||
} else if (MOVEUP.equals(ps.getControlEventName())) {
|
} else if (EDIT.equals(ps.getControlEventName())) {
|
||||||
m_listModelBuilder.getModel().move(OID.valueOf(ps.getControlEventValue()), -1, ps);
|
m_imageStep.setAttachment(
|
||||||
} else if (MOVEDOWN.equals(ps.getControlEventName())) {
|
ps, ItemImageAttachment.retrieve(OID.valueOf(ps.
|
||||||
m_listModelBuilder.getModel().move(OID.valueOf(ps.getControlEventValue()), 1, ps);
|
getControlEventValue())));
|
||||||
} else {
|
|
||||||
super.respond(ps);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
imageList.setCellRenderer(new ImageListCellRenderer());
|
m_imageStep.showComponent(ps, "edit");
|
||||||
imageList.setEmptyView(mainLabel);
|
} else if (MOVEUP.equals(ps.getControlEventName())) {
|
||||||
|
m_listModelBuilder.getModel().move(OID.valueOf(ps.getControlEventValue()), -1,
|
||||||
|
ps);
|
||||||
|
} else if (MOVEDOWN.equals(ps.getControlEventName())) {
|
||||||
|
m_listModelBuilder.getModel().
|
||||||
|
move(OID.valueOf(ps.getControlEventValue()), 1, ps);
|
||||||
|
} else {
|
||||||
|
super.respond(ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
add(imageList); // finally add the component
|
};
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
imageList.setCellRenderer(new ImageListCellRenderer());
|
||||||
* Inner class
|
imageList.setEmptyView(mainLabel);
|
||||||
*/
|
|
||||||
private class ImageListModelBuilder extends LockableImpl
|
|
||||||
implements ListModelBuilder {
|
|
||||||
|
|
||||||
private ImageListModel m_listModel;
|
add(imageList); // finally add the component
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Inner class
|
||||||
* @param list
|
*/
|
||||||
* @param ps
|
private class ImageListModelBuilder extends LockableImpl
|
||||||
* @return
|
implements ListModelBuilder {
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ListModel makeModel(List list, PageState ps) {
|
|
||||||
ContentItem item = m_imageStep.getItem(ps);
|
|
||||||
|
|
||||||
DataCollection attachments =
|
private ImageListModel m_listModel;
|
||||||
ItemImageAttachment.getImageAttachments(item);
|
|
||||||
attachments.addPath(ItemImageAttachment.IMAGE + "."
|
|
||||||
+ ReusableImageAsset.ID);
|
|
||||||
attachments.addPath(ItemImageAttachment.IMAGE + "."
|
|
||||||
+ ReusableImageAsset.OBJECT_TYPE);
|
|
||||||
attachments.addPath(ItemImageAttachment.IMAGE + "."
|
|
||||||
+ ReusableImageAsset.HEIGHT);
|
|
||||||
attachments.addPath(ItemImageAttachment.IMAGE + "."
|
|
||||||
+ ReusableImageAsset.WIDTH);
|
|
||||||
|
|
||||||
m_listModel = new ImageListModel(attachments);
|
/**
|
||||||
return m_listModel;
|
*
|
||||||
}
|
* @param list
|
||||||
|
* @param ps
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ListModel makeModel(List list, PageState ps) {
|
||||||
|
ContentItem item = m_imageStep.getItem(ps);
|
||||||
|
|
||||||
protected ImageListModel getModel() {
|
DataCollection attachments = ItemImageAttachment.getImageAttachments(item);
|
||||||
return m_listModel;
|
attachments.addPath(ItemImageAttachment.IMAGE + "."
|
||||||
}
|
+ ReusableImageAsset.ID);
|
||||||
}
|
attachments.addPath(ItemImageAttachment.IMAGE + "."
|
||||||
|
+ ReusableImageAsset.OBJECT_TYPE);
|
||||||
|
attachments.addPath(ItemImageAttachment.IMAGE + "."
|
||||||
|
+ ReusableImageAsset.HEIGHT);
|
||||||
|
attachments.addPath(ItemImageAttachment.IMAGE + "."
|
||||||
|
+ ReusableImageAsset.WIDTH);
|
||||||
|
|
||||||
/**
|
m_listModel = new ImageListModel(attachments);
|
||||||
*
|
return m_listModel;
|
||||||
*/
|
}
|
||||||
private class ImageListModel implements ListModel {
|
|
||||||
|
|
||||||
private final DataCollection m_attachments;
|
protected ImageListModel getModel() {
|
||||||
|
return m_listModel;
|
||||||
|
}
|
||||||
|
|
||||||
ImageListModel(DataCollection attachments) {
|
}
|
||||||
m_attachments = attachments;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public Object getElement() {
|
*
|
||||||
return DomainObjectFactory.newInstance(m_attachments.getDataObject());
|
*/
|
||||||
}
|
private class ImageListModel implements ListModel {
|
||||||
|
|
||||||
@Override
|
private final DataCollection m_attachments;
|
||||||
public String getKey() {
|
|
||||||
return m_attachments.getDataObject().getOID().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
ImageListModel(DataCollection attachments) {
|
||||||
public boolean next() {
|
m_attachments = attachments;
|
||||||
return m_attachments.next();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFirst() {
|
@Override
|
||||||
return m_attachments.isFirst();
|
public Object getElement() {
|
||||||
}
|
return DomainObjectFactory.newInstance(m_attachments.getDataObject());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isLast() {
|
@Override
|
||||||
return m_attachments.isLast();
|
public String getKey() {
|
||||||
}
|
return m_attachments.getDataObject().getOID().toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Move an image's position inside the list.
|
public boolean next() {
|
||||||
*
|
return m_attachments.next();
|
||||||
* @param oid {@link OID} of the image to move
|
}
|
||||||
* @param move position steps (positive or negative) to move
|
|
||||||
* @param ps Current {@link PageState}
|
|
||||||
*/
|
|
||||||
protected void move(OID oid, int move, PageState ps) {
|
|
||||||
// Get the current ContentItem
|
|
||||||
ContentItem item = m_imageStep.getItem(ps);
|
|
||||||
// Get the collection of attached images
|
|
||||||
DataCollection attachments = ItemImageAttachment.getImageAttachments(item);
|
|
||||||
|
|
||||||
// Always need an oid of the image to move
|
public boolean isFirst() {
|
||||||
if (oid == null) {
|
return m_attachments.isFirst();
|
||||||
throw new IllegalArgumentException("OID must not be null");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// No move, nothing to do
|
public boolean isLast() {
|
||||||
if (move == 0) {
|
return m_attachments.isLast();
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Find the image in the collection
|
/**
|
||||||
while (attachments.next()) {
|
* Move an image's position inside the list.
|
||||||
if (attachments.getDataObject().getOID().equals(oid)) {
|
*
|
||||||
break;
|
* @param oid {@link OID} of the image to move
|
||||||
}
|
* @param move position steps (positive or negative) to move
|
||||||
}
|
* @param ps Current {@link PageState}
|
||||||
|
*/
|
||||||
|
protected void move(OID oid, int move, PageState ps) {
|
||||||
|
// Get the current ContentItem
|
||||||
|
ContentItem item = m_imageStep.getItem(ps);
|
||||||
|
// Get the collection of attached images
|
||||||
|
DataCollection attachments = ItemImageAttachment.getImageAttachments(item);
|
||||||
|
|
||||||
// Throw an {@link IllegalArgumentxception} if the oid was not found
|
// Always need an oid of the image to move
|
||||||
if (!attachments.getDataObject().getOID().equals(oid)) {
|
if (oid == null) {
|
||||||
throw new IllegalArgumentException("OID " + oid + " is not in collection");
|
throw new IllegalArgumentException("OID must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the image to move and test if it is really an ItemImageAttachment
|
// No move, nothing to do
|
||||||
DomainObject sortDomainObject = DomainObjectFactory.newInstance(attachments.getDataObject());
|
if (move == 0) {
|
||||||
if (sortDomainObject instanceof ItemImageAttachment) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Change the sortKey of the ItemImageAttachment to the desired
|
// Find the image in the collection
|
||||||
// value but respect bounds of the current list
|
while (attachments.next()) {
|
||||||
int newSortKey = Math.max(1,
|
if (attachments.getDataObject().getOID().equals(oid)) {
|
||||||
Math.min((int) attachments.size(),
|
break;
|
||||||
((ItemImageAttachment) sortDomainObject).getSortKey() + move));
|
}
|
||||||
((ItemImageAttachment) sortDomainObject).setSortKey(newSortKey);
|
}
|
||||||
((ItemImageAttachment) sortDomainObject).save();
|
|
||||||
|
|
||||||
// Now, move all the object between the original position and the
|
// Throw an {@link IllegalArgumentxception} if the oid was not found
|
||||||
// new postition one step in the nessecary direction
|
if (!attachments.getDataObject().getOID().equals(oid)) {
|
||||||
if (move < 0) {
|
throw new IllegalArgumentException("OID " + oid + " is not in collection");
|
||||||
while (attachments.previous() && move < 0) {
|
}
|
||||||
DomainObject domainObject = DomainObjectFactory.newInstance(attachments.getDataObject());
|
|
||||||
if (domainObject instanceof ItemImageAttachment) {
|
|
||||||
((ItemImageAttachment) domainObject).setSortKey(
|
|
||||||
((ItemImageAttachment) domainObject).getSortKey() + 1);
|
|
||||||
((ItemImageAttachment) domainObject).save();
|
|
||||||
move++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (move > 0) {
|
|
||||||
while (attachments.next() && move > 0) {
|
|
||||||
DomainObject domainObject = DomainObjectFactory.newInstance(attachments.getDataObject());
|
|
||||||
if (domainObject instanceof ItemImageAttachment) {
|
|
||||||
((ItemImageAttachment) domainObject).setSortKey(
|
|
||||||
((ItemImageAttachment) domainObject).getSortKey() - 1);
|
|
||||||
((ItemImageAttachment) domainObject).save();
|
|
||||||
move--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// close the collection manually to avoid warnings because the list
|
// Get the image to move and test if it is really an ItemImageAttachment
|
||||||
// will not be closed automatically
|
DomainObject sortDomainObject = DomainObjectFactory.newInstance(attachments.
|
||||||
attachments.close();
|
getDataObject());
|
||||||
}
|
if (sortDomainObject instanceof ItemImageAttachment) {
|
||||||
|
|
||||||
/**
|
// Change the sortKey of the ItemImageAttachment to the desired
|
||||||
* Reorganize the sortKeys after removing an item.
|
// value but respect bounds of the current list
|
||||||
*
|
int newSortKey = Math.max(1,
|
||||||
* @param ps The current {@link PageState}
|
Math.min((int) attachments.size(),
|
||||||
*/
|
((ItemImageAttachment) sortDomainObject).
|
||||||
protected void regenSortKeys(PageState ps) {
|
getSortKey() + move));
|
||||||
// Get the current ContentItem
|
((ItemImageAttachment) sortDomainObject).setSortKey(newSortKey);
|
||||||
ContentItem item = m_imageStep.getItem(ps);
|
((ItemImageAttachment) sortDomainObject).save();
|
||||||
// Get the collection of attached images
|
|
||||||
DataCollection attachments = ItemImageAttachment.getImageAttachments(item);
|
|
||||||
|
|
||||||
// Current Position
|
// Now, move all the object between the original position and the
|
||||||
int pos = 0;
|
// new postition one step in the nessecary direction
|
||||||
// Iterate through all items and set item sortKey to pos
|
if (move < 0) {
|
||||||
while (attachments.next()) {
|
while (attachments.previous() && move < 0) {
|
||||||
pos++;
|
DomainObject domainObject = DomainObjectFactory.newInstance(attachments.
|
||||||
DomainObject domainObject = DomainObjectFactory.newInstance(attachments.getDataObject());
|
getDataObject());
|
||||||
if (domainObject instanceof ItemImageAttachment) {
|
if (domainObject instanceof ItemImageAttachment) {
|
||||||
int sortKey = ((ItemImageAttachment) domainObject).getSortKey();
|
((ItemImageAttachment) domainObject).setSortKey(
|
||||||
if (sortKey != pos) {
|
((ItemImageAttachment) domainObject).getSortKey() + 1);
|
||||||
((ItemImageAttachment) domainObject).setSortKey(pos);
|
((ItemImageAttachment) domainObject).save();
|
||||||
domainObject.save();
|
move++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (move > 0) {
|
||||||
}
|
while (attachments.next() && move > 0) {
|
||||||
|
DomainObject domainObject = DomainObjectFactory.newInstance(attachments.
|
||||||
|
getDataObject());
|
||||||
|
if (domainObject instanceof ItemImageAttachment) {
|
||||||
|
((ItemImageAttachment) domainObject).setSortKey(
|
||||||
|
((ItemImageAttachment) domainObject).getSortKey() - 1);
|
||||||
|
((ItemImageAttachment) domainObject).save();
|
||||||
|
move--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
// close the collection manually to avoid warnings because the list
|
||||||
*
|
// will not be closed automatically
|
||||||
*/
|
attachments.close();
|
||||||
private class ImageListCellRenderer implements ListCellRenderer {
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Reorganize the sortKeys after removing an item.
|
||||||
* @param list
|
*
|
||||||
* @param state
|
* @param ps The current {@link PageState}
|
||||||
* @param value
|
*/
|
||||||
* @param key
|
protected void regenSortKeys(PageState ps) {
|
||||||
* @param index
|
// Get the current ContentItem
|
||||||
* @param isSelected
|
ContentItem item = m_imageStep.getItem(ps);
|
||||||
* @return
|
// Get the collection of attached images
|
||||||
*/
|
DataCollection attachments = ItemImageAttachment.getImageAttachments(item);
|
||||||
@Override
|
|
||||||
public Component getComponent(final List list, PageState state,
|
|
||||||
Object value, String key,
|
|
||||||
int index, boolean isSelected) {
|
|
||||||
final ItemImageAttachment attachment = (ItemImageAttachment) value;
|
|
||||||
|
|
||||||
BoxPanel container = new BoxPanel(BoxPanel.VERTICAL);
|
// Current Position
|
||||||
container.setBorder(1);
|
int pos = 0;
|
||||||
|
// Iterate through all items and set item sortKey to pos
|
||||||
|
while (attachments.next()) {
|
||||||
|
pos++;
|
||||||
|
DomainObject domainObject = DomainObjectFactory.newInstance(attachments.
|
||||||
|
getDataObject());
|
||||||
|
if (domainObject instanceof ItemImageAttachment) {
|
||||||
|
int sortKey = ((ItemImageAttachment) domainObject).getSortKey();
|
||||||
|
if (sortKey != pos) {
|
||||||
|
((ItemImageAttachment) domainObject).setSortKey(pos);
|
||||||
|
domainObject.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add CMS ImageDisplay element to BoxPanel container an overwrite
|
}
|
||||||
// generateImagePropertiesXM to add attachment's meta data.
|
|
||||||
container.add(new ImageDisplay(null) {
|
|
||||||
@Override
|
|
||||||
protected void generateImagePropertiesXML(ImageAsset image,
|
|
||||||
PageState state,
|
|
||||||
Element element) {
|
|
||||||
/* Use CMS ImageDisplay to display the image including *
|
|
||||||
* metadata as name, type, widht, height etc. */
|
|
||||||
super.generateImagePropertiesXML(image, state, element);
|
|
||||||
|
|
||||||
// We check config here to see whether additional meta data
|
/**
|
||||||
// as title and description are configured to be displayed.
|
*
|
||||||
// If it is, we display the description and title options
|
*/
|
||||||
// TODO: Currently without Label, labels for each attribut
|
private class ImageListCellRenderer implements ListCellRenderer {
|
||||||
// are provided by the theme. Has to be refactored to
|
|
||||||
// provide labels in Java (including localization).
|
|
||||||
// Title and description - if displayed - have to be
|
|
||||||
// positioned above the image and its metadata.
|
|
||||||
if (ItemImageAttachment.getConfig()
|
|
||||||
.getIsImageStepDescriptionAndTitleShown()) {
|
|
||||||
String description = attachment.getDescription();
|
|
||||||
if (description != null) {
|
|
||||||
element.addAttribute("description", description);
|
|
||||||
}
|
|
||||||
|
|
||||||
String title = attachment.getTitle();
|
/**
|
||||||
if (title != null) {
|
*
|
||||||
element.addAttribute("title", title);
|
* @param list
|
||||||
}
|
* @param state
|
||||||
}
|
* @param value
|
||||||
|
* @param key
|
||||||
|
* @param index
|
||||||
|
* @param isSelected
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Component getComponent(final List list, PageState state,
|
||||||
|
Object value, String key,
|
||||||
|
int index, boolean isSelected) {
|
||||||
|
final ItemImageAttachment attachment = (ItemImageAttachment) value;
|
||||||
|
|
||||||
element.addAttribute("caption_label", (String) GlobalizationUtil.globalize(
|
BoxPanel container = new BoxPanel(BoxPanel.VERTICAL);
|
||||||
"cms.contentasset.image.ui.caption")
|
container.setBorder(1);
|
||||||
.localize());
|
|
||||||
element.addAttribute("caption", attachment.getCaption());
|
|
||||||
|
|
||||||
element.addAttribute("context_label", (String) GlobalizationUtil.globalize(
|
// Add CMS ImageDisplay element to BoxPanel container an overwrite
|
||||||
"cms.contentasset.image.ui.use_context")
|
// generateImagePropertiesXM to add attachment's meta data.
|
||||||
.localize());
|
container.add(new ImageDisplay(null) {
|
||||||
String useContext = attachment.getUseContext();
|
@Override
|
||||||
if (null == useContext) {
|
protected void generateImagePropertiesXML(ImageAsset image,
|
||||||
element.addAttribute("context", (String) GlobalizationUtil.globalize(
|
PageState state,
|
||||||
"cms.ui.unknown")
|
Element element) {
|
||||||
.localize());
|
/* Use CMS ImageDisplay to display the image including *
|
||||||
} else {
|
* metadata as name, type, widht, height etc. */
|
||||||
element.addAttribute("context", useContext);
|
super.generateImagePropertiesXML(image, state, element);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
// We check config here to see whether additional meta data
|
||||||
|
// as title and description are configured to be displayed.
|
||||||
|
// If it is, we display the description and title options
|
||||||
|
// TODO: Currently without Label, labels for each attribut
|
||||||
|
// are provided by the theme. Has to be refactored to
|
||||||
|
// provide labels in Java (including localization).
|
||||||
|
// Title and description - if displayed - have to be
|
||||||
|
// positioned above the image and its metadata.
|
||||||
|
if (ItemImageAttachment.getConfig()
|
||||||
|
.getIsImageStepDescriptionAndTitleShown()) {
|
||||||
|
String description = attachment.getDescription();
|
||||||
|
if (description != null) {
|
||||||
|
element.addAttribute("description", description);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
String title = attachment.getTitle();
|
||||||
protected ImageAsset getImageAsset(PageState ps) {
|
if (title != null) {
|
||||||
return attachment.getImage();
|
element.addAttribute("title", title);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
/* Adds links to move and remove the image in a separate container element */
|
element.addAttribute("caption_label", (String) GlobalizationUtil.globalize(
|
||||||
if (!((ImageListModel) list.getModel(state)).isFirst()) {
|
"cms.contentasset.image.ui.caption")
|
||||||
ControlLink moveUpLink = new ControlLink(new Label(
|
.localize());
|
||||||
ImageStepGlobalizationUtil.globalize(
|
element.addAttribute("caption", attachment.getCaption());
|
||||||
"cms.contentassets.ui.image_step.move_attached_image_up"))) {
|
|
||||||
@Override
|
|
||||||
public void setControlEvent(PageState ps) {
|
|
||||||
String oid = ps.getControlEventValue();
|
|
||||||
ps.setControlEvent(list, MOVEUP, oid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override generateURL to prevent deleting of the page state
|
element.addAttribute("context_label", (String) GlobalizationUtil.globalize(
|
||||||
@Override
|
"cms.contentasset.image.ui.use_context")
|
||||||
protected void generateURL(PageState state, Element parent) {
|
.localize());
|
||||||
setControlEvent(state);
|
String useContext = attachment.getUseContext();
|
||||||
try {
|
if (null == useContext) {
|
||||||
parent.addAttribute("href", state.stateAsURL());
|
element.addAttribute("context", (String) GlobalizationUtil.globalize(
|
||||||
} catch (IOException e) {
|
"cms.ui.unknown")
|
||||||
parent.addAttribute("href", "");
|
.localize());
|
||||||
}
|
} else {
|
||||||
exportAttributes(parent);
|
element.addAttribute("context", useContext);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
container.add(moveUpLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!((ImageListModel) list.getModel(state)).isLast()) {
|
}
|
||||||
ControlLink moveDownLink = new ControlLink(new Label(
|
|
||||||
ImageStepGlobalizationUtil.globalize(
|
|
||||||
"cms.contentassets.ui.image_step.move_attached_image_down"))) {
|
|
||||||
@Override
|
|
||||||
public void setControlEvent(PageState ps) {
|
|
||||||
String oid = ps.getControlEventValue();
|
|
||||||
ps.setControlEvent(list, MOVEDOWN, oid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override generateURL to prevent deleting of the page state
|
@Override
|
||||||
@Override
|
protected ImageAsset getImageAsset(PageState ps) {
|
||||||
protected void generateURL(PageState state, Element parent) {
|
return attachment.getImage();
|
||||||
setControlEvent(state);
|
}
|
||||||
try {
|
|
||||||
parent.addAttribute("href", state.stateAsURL());
|
|
||||||
} catch (IOException e) {
|
|
||||||
parent.addAttribute("href", "");
|
|
||||||
}
|
|
||||||
exportAttributes(parent);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
container.add(moveDownLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
ControlLink deleteLink = new ControlLink(new Label(
|
});
|
||||||
ImageStepGlobalizationUtil.globalize(
|
|
||||||
"cms.contentassets.ui.image_step.remove_attached_image"))) {
|
|
||||||
@Override
|
|
||||||
public void setControlEvent(PageState ps) {
|
|
||||||
String oid = ps.getControlEventValue();
|
|
||||||
ps.setControlEvent(list, DELETE, oid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override generateURL to prevent deleting of the page state
|
/* Adds links to move and remove the image in a separate container element */
|
||||||
@Override
|
if (!((ImageListModel) list.getModel(state)).isFirst()) {
|
||||||
protected void generateURL(PageState state, Element parent) {
|
ControlLink moveUpLink = new ControlLink(new Label(
|
||||||
setControlEvent(state);
|
ImageStepGlobalizationUtil.globalize(
|
||||||
try {
|
"cms.contentassets.ui.image_step.move_attached_image_up"))) {
|
||||||
parent.addAttribute("href", state.stateAsURL());
|
@Override
|
||||||
} catch (IOException e) {
|
public void setControlEvent(PageState ps) {
|
||||||
parent.addAttribute("href", "");
|
String oid = ps.getControlEventValue();
|
||||||
}
|
ps.setControlEvent(list, MOVEUP, oid);
|
||||||
exportAttributes(parent);
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
container.add(deleteLink);
|
|
||||||
|
|
||||||
return container;
|
// Override generateURL to prevent deleting of the page state
|
||||||
}
|
@Override
|
||||||
}
|
protected void generateURL(PageState state, Element parent) {
|
||||||
|
setControlEvent(state);
|
||||||
|
try {
|
||||||
|
parent.addAttribute("href", state.stateAsURL());
|
||||||
|
} catch (IOException e) {
|
||||||
|
parent.addAttribute("href", "");
|
||||||
|
}
|
||||||
|
exportAttributes(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
container.add(moveUpLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!((ImageListModel) list.getModel(state)).isLast()) {
|
||||||
|
ControlLink moveDownLink = new ControlLink(new Label(
|
||||||
|
ImageStepGlobalizationUtil.globalize(
|
||||||
|
"cms.contentassets.ui.image_step.move_attached_image_down"))) {
|
||||||
|
@Override
|
||||||
|
public void setControlEvent(PageState ps) {
|
||||||
|
String oid = ps.getControlEventValue();
|
||||||
|
ps.setControlEvent(list, MOVEDOWN, oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override generateURL to prevent deleting of the page state
|
||||||
|
@Override
|
||||||
|
protected void generateURL(PageState state, Element parent) {
|
||||||
|
setControlEvent(state);
|
||||||
|
try {
|
||||||
|
parent.addAttribute("href", state.stateAsURL());
|
||||||
|
} catch (IOException e) {
|
||||||
|
parent.addAttribute("href", "");
|
||||||
|
}
|
||||||
|
exportAttributes(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
container.add(moveDownLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlLink editLink = new ControlLink(new Label(
|
||||||
|
ImageStepGlobalizationUtil.globalize(
|
||||||
|
"cms.contentassets.ui.image_step.edit_attached_image"))) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setControlEvent(final PageState state) {
|
||||||
|
final String oid = state.getControlEventValue();
|
||||||
|
state.setControlEvent(list, EDIT, oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateURL(final PageState state, Element parent) {
|
||||||
|
setControlEvent(state);
|
||||||
|
try {
|
||||||
|
parent.addAttribute("href", state.stateAsURL());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
parent.addAttribute("href", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
container.add(editLink);
|
||||||
|
|
||||||
|
ControlLink deleteLink = new ControlLink(new Label(
|
||||||
|
ImageStepGlobalizationUtil.globalize(
|
||||||
|
"cms.contentassets.ui.image_step.remove_attached_image"))) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setControlEvent(PageState ps) {
|
||||||
|
String oid = ps.getControlEventValue();
|
||||||
|
ps.setControlEvent(list, DELETE, oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override generateURL to prevent deleting of the page state
|
||||||
|
@Override
|
||||||
|
protected void generateURL(PageState state, Element parent) {
|
||||||
|
setControlEvent(state);
|
||||||
|
try {
|
||||||
|
parent.addAttribute("href", state.stateAsURL());
|
||||||
|
} catch (IOException e) {
|
||||||
|
parent.addAttribute("href", "");
|
||||||
|
}
|
||||||
|
exportAttributes(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
container.add(deleteLink);
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue