The images attached to a ContentItem are now shown in a table.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2696 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
03f920d8c6
commit
ba8419d8b2
|
|
@ -7,3 +7,5 @@ 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.edit_attached_image=Edit caption
|
||||
cms.contentassets.ui.image_step.caption=Caption
|
||||
cms.contentassets.ui.image_step.image_table.thumbnail=Thumbnail
|
||||
cms.contentassets.ui.image_step.remove_attached_image.confirm=Are you sure to remove this attached image?
|
||||
|
|
|
|||
|
|
@ -7,3 +7,5 @@ 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.edit_attached_image=Bildunterschrift editieren
|
||||
cms.contentassets.ui.image_step.caption=Bildunterschrift
|
||||
cms.contentassets.ui.image_step.image_table.thumbnail=Vorschau
|
||||
cms.contentassets.ui.image_step.remove_attached_image.confirm=Sind Sie sicher das Sie die Zuordnung dieses Bildes entfernen m\u00f6chten?
|
||||
|
|
|
|||
|
|
@ -7,3 +7,5 @@ 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.edit_attached_image=Edit caption
|
||||
cms.contentassets.ui.image_step.caption=Caption
|
||||
cms.contentassets.ui.image_step.image_table.thumbnail=Thumbnail
|
||||
cms.contentassets.ui.image_step.remove_attached_image.confirm=cms.contentassets.ui.image_step.remove_attached_image.confirm
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ public class ImageStep extends SecurityPropertyEditor {
|
|||
private final ItemSelectionModel m_itemSelection;
|
||||
private final AttachmentSelectionModel m_attachmentSelection;
|
||||
private final AuthoringKitWizard m_parent;
|
||||
private final ImageStepDisplay m_display;
|
||||
//private final ImageStepDisplay m_display;
|
||||
private final ImageStepDisplayTable m_display;
|
||||
private final ImageStepEdit m_add;
|
||||
private final OIDParameter m_attachmentOID;
|
||||
|
||||
|
|
@ -84,7 +85,8 @@ public class ImageStep extends SecurityPropertyEditor {
|
|||
new ImageAttachmentEditForm(this));
|
||||
|
||||
/* ImageDisplayStep to display all already attached images */
|
||||
m_display = new ImageStepDisplay(this); // Component to display
|
||||
//m_display = new ImageStepDisplay(this); // Component to display
|
||||
m_display = new ImageStepDisplayTable(this);
|
||||
setDisplayComponent(m_display); // all attached images.
|
||||
|
||||
Iterator imageComponents = m_add.getImageComponents();
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ public class ImageStepDisplay extends SimpleContainer {
|
|||
|
||||
m_listModelBuilder = new ImageListModelBuilder();
|
||||
List imageList = new List(m_listModelBuilder) {
|
||||
|
||||
@Override
|
||||
public void respond(PageState ps) throws ServletException {
|
||||
if (DELETE.equals(ps.getControlEventName())) {
|
||||
|
|
@ -338,6 +339,7 @@ public class ImageStepDisplay extends SimpleContainer {
|
|||
// 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,
|
||||
|
|
@ -398,6 +400,7 @@ public class ImageStepDisplay extends SimpleContainer {
|
|||
ControlLink moveUpLink = new ControlLink(new Label(
|
||||
ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.move_attached_image_up"))) {
|
||||
|
||||
@Override
|
||||
public void setControlEvent(PageState ps) {
|
||||
String oid = ps.getControlEventValue();
|
||||
|
|
@ -424,6 +427,7 @@ public class ImageStepDisplay extends SimpleContainer {
|
|||
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();
|
||||
|
|
@ -500,4 +504,5 @@ public class ImageStepDisplay extends SimpleContainer {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,571 @@
|
|||
/*
|
||||
* Copyright (c) 2010 Jens Pelzetter
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.contentassets.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ImageAsset;
|
||||
import com.arsdigita.cms.Service;
|
||||
import com.arsdigita.cms.contentassets.ItemImageAttachment;
|
||||
import com.arsdigita.cms.contentassets.util.ImageStepGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.ImageDisplay;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import com.arsdigita.web.URL;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
*/
|
||||
public class ImageStepDisplayTable extends Table {
|
||||
|
||||
private final static String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final static String TABLE_COL_DEL = "table_col_del";
|
||||
private final static String TABLE_COL_UP = "table_col_up";
|
||||
private final static String TABLE_COL_DOWN = "table_col_down";
|
||||
private final static int TABLE_COL_INDEX_THUMBNAIL = 0;
|
||||
private final static int TABLE_COL_INDEX_NAME = 1;
|
||||
private final static int TABLE_COL_INDEX_DIMENSIONS = 2;
|
||||
private final static int TABLE_COL_INDEX_TYPE = 3;
|
||||
private final static int TABLE_COL_INDEX_CAPTION = 4;
|
||||
private final static int TABLE_COL_INDEX_EDIT = 5;
|
||||
private final static int TABLE_COL_INDEX_UP = 6;
|
||||
private final static int TABLE_COL_INDEX_DOWN = 7;
|
||||
private final static int TABLE_COL_INDEX_DEL = 8;
|
||||
private final static int UP = -1;
|
||||
private final static int DOWN = 1;
|
||||
|
||||
private final ImageStep imageStep;
|
||||
|
||||
public ImageStepDisplayTable(final ImageStep imageStep) {
|
||||
super();
|
||||
this.imageStep = imageStep;
|
||||
setEmptyView(new Label(ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.no_image_attached")));
|
||||
|
||||
final TableColumnModel columnModel = getColumnModel();
|
||||
columnModel.add(new TableColumn(
|
||||
TABLE_COL_INDEX_THUMBNAIL,
|
||||
ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.image_table.thumbnail")));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
TABLE_COL_INDEX_NAME,
|
||||
GlobalizationUtil.globalize(
|
||||
"cms.contentasset.image.ui.display.name")));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
TABLE_COL_INDEX_DIMENSIONS,
|
||||
GlobalizationUtil.globalize("cms.contentasset.image.ui.display.dimensions")));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
TABLE_COL_INDEX_TYPE,
|
||||
GlobalizationUtil.globalize(
|
||||
"cms.contentasset.image.ui.display.type")));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
TABLE_COL_INDEX_CAPTION,
|
||||
GlobalizationUtil.globalize("cms.contentasset.image.ui.caption")));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
TABLE_COL_INDEX_EDIT,
|
||||
ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.edit_attached_image"),
|
||||
TABLE_COL_EDIT));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
TABLE_COL_INDEX_UP,
|
||||
ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.move_attached_image_up"),
|
||||
TABLE_COL_UP));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
TABLE_COL_INDEX_DOWN,
|
||||
ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.move_attached_image_down"),
|
||||
TABLE_COL_DOWN));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
TABLE_COL_INDEX_DEL,
|
||||
ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.remove_attached_image"),
|
||||
TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(new ImageTableModelBuilder(imageStep));
|
||||
|
||||
columnModel.get(0).setCellRenderer(new ThumbnailCellRenderer());
|
||||
columnModel.get(1).setCellRenderer(new NameCellRenderer());
|
||||
columnModel.get(2).setCellRenderer(new DimensionsCellRenderer());
|
||||
columnModel.get(3).setCellRenderer(new TypeCellRenderer());
|
||||
columnModel.get(4).setCellRenderer(new CaptionCellRenderer());
|
||||
columnModel.get(5).setCellRenderer(new EditCellRenderer());
|
||||
columnModel.get(6).setCellRenderer(new UpCellRenderer());
|
||||
columnModel.get(7).setCellRenderer(new DownCellRenderer());
|
||||
columnModel.get(8).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
addTableActionListener(new ImageStepTableActionListener());
|
||||
|
||||
}
|
||||
|
||||
private class ImageTableModelBuilder extends LockableImpl implements TableModelBuilder {
|
||||
|
||||
private final ImageStep imageStep;
|
||||
|
||||
public ImageTableModelBuilder(final ImageStep imageStep) {
|
||||
this.imageStep = imageStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table,
|
||||
final PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
return new ImageTableModel(table, state, imageStep.getItem(state));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ImageTableModel implements TableModel {
|
||||
|
||||
private final Table table;
|
||||
private final ContentItem item;
|
||||
private final DataCollection images;
|
||||
|
||||
public ImageTableModel(final Table table,
|
||||
final PageState state,
|
||||
final ContentItem item) {
|
||||
this.table = table;
|
||||
this.item = item;
|
||||
images = ItemImageAttachment.getImageAttachments(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return table.getColumnModel().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
if (images == null) {
|
||||
return false;
|
||||
} else {
|
||||
return images.next();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(final int columnIndex) {
|
||||
final ItemImageAttachment image = (ItemImageAttachment) DomainObjectFactory.newInstance(
|
||||
images.getDataObject());
|
||||
|
||||
switch (columnIndex) {
|
||||
case TABLE_COL_INDEX_THUMBNAIL:
|
||||
return image;
|
||||
case TABLE_COL_INDEX_NAME:
|
||||
return image.getImage().getName();
|
||||
case TABLE_COL_INDEX_DIMENSIONS:
|
||||
return String.format("%sx%s px", image.getImage().getWidth().toString(),
|
||||
image.getImage().getHeight().toString());
|
||||
case TABLE_COL_INDEX_TYPE:
|
||||
return image.getImage().getMimeType().getLabel();
|
||||
case TABLE_COL_INDEX_CAPTION:
|
||||
return image.getCaption();
|
||||
case TABLE_COL_INDEX_EDIT:
|
||||
return ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.edit_attached_image");
|
||||
case TABLE_COL_INDEX_UP:
|
||||
return ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.move_attached_image_up");
|
||||
case TABLE_COL_INDEX_DOWN:
|
||||
return ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.move_attached_image_down");
|
||||
case TABLE_COL_INDEX_DEL:
|
||||
return ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.remove_attached_image");
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return images.getDataObject().getOID().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ThumbnailCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
final ItemImageAttachment image = (ItemImageAttachment) value;
|
||||
|
||||
return new ImageStepImageDisplay(image.getImage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ImageStepImageDisplay extends ImageDisplay {
|
||||
|
||||
private final ImageAsset image;
|
||||
|
||||
public ImageStepImageDisplay(final ImageAsset image) {
|
||||
super(null);
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImageAsset getImageAsset(final PageState state) {
|
||||
return image;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateImagePropertiesXML(final ImageAsset image,
|
||||
final PageState state,
|
||||
final Element element) {
|
||||
element.addAttribute("name", image.getName());
|
||||
element.addAttribute("src", URL.getDispatcherPath()
|
||||
+ Service.getImageURL(image));
|
||||
final BigDecimal width = image.getWidth();
|
||||
if (width != null) {
|
||||
element.addAttribute("width", width.toString());
|
||||
}
|
||||
final BigDecimal height = image.getHeight();
|
||||
if (height != null) {
|
||||
element.addAttribute("height", height.toString());
|
||||
}
|
||||
element.addAttribute("plain", "true");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class NameCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
return new Label((String) value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DimensionsCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
return new Label((String) value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class TypeCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
return new Label((String) value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class CaptionCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
return new Label((String) value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
|
||||
final ContentItem item = imageStep.getItem(state);
|
||||
|
||||
final boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
|
||||
item);
|
||||
|
||||
if (canEdit) {
|
||||
return new ControlLink(new Label((GlobalizedMessage) value));
|
||||
} else {
|
||||
return new Label("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class UpCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
if (0 == row) {
|
||||
//First row, don't show up link
|
||||
return new Label("");
|
||||
} else {
|
||||
return new ControlLink(new Label((GlobalizedMessage) value));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DownCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
final ContentItem item = imageStep.getItem(state);
|
||||
final DataCollection images = ItemImageAttachment.getImageAttachments(item);
|
||||
|
||||
if ((images.size() - 1) == row) {
|
||||
//Last row in table, don't show down link
|
||||
return new Label("");
|
||||
} else {
|
||||
return new ControlLink(new Label((GlobalizedMessage) value));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
|
||||
final ContentItem item = imageStep.getItem(state);
|
||||
|
||||
final boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
|
||||
item);
|
||||
|
||||
if (canEdit) {
|
||||
final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value));
|
||||
link.setConfirmation(ImageStepGlobalizationUtil.globalize(
|
||||
"cms.contentassets.ui.image_step.remove_attached_image.confirm"));
|
||||
|
||||
return link;
|
||||
} else {
|
||||
return new Label("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ImageStepTableActionListener implements TableActionListener {
|
||||
|
||||
public ImageStepTableActionListener() {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
final TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
||||
imageStep.setAttachment(state, ItemImageAttachment.retrieve(OID.valueOf(event
|
||||
.getRowKey().toString())));
|
||||
imageStep.showComponent(state, "edit");
|
||||
} else if (TABLE_COL_UP.equals(column.getHeaderKey().toString())) {
|
||||
move(OID.valueOf(event.getRowKey().toString()), UP, state);
|
||||
} else if (TABLE_COL_DOWN.equals(column.getHeaderKey().toString())) {
|
||||
move(OID.valueOf(event.getRowKey().toString()), DOWN, state);
|
||||
} else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
|
||||
DomainObjectFactory.newInstance(OID.valueOf(event.getRowKey().toString())).delete();
|
||||
regenSortKeys(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
//Nothing to do here.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void regenSortKeys(final PageState state) {
|
||||
final ContentItem item = imageStep.getItem(state);
|
||||
final DataCollection images = ItemImageAttachment.getImageAttachments(item);
|
||||
|
||||
int pos = 0;
|
||||
while (images.next()) {
|
||||
pos++;
|
||||
final DomainObject domainObject = DomainObjectFactory
|
||||
.newInstance(images.getDataObject());
|
||||
|
||||
if (domainObject instanceof ItemImageAttachment) {
|
||||
final ItemImageAttachment image = (ItemImageAttachment) domainObject;
|
||||
if (image.getSortKey() != pos) {
|
||||
image.setSortKey(pos);
|
||||
image.save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void move(final OID imageOid, final int direction, final PageState state) {
|
||||
final ContentItem item = imageStep.getItem(state);
|
||||
final DataCollection images = ItemImageAttachment.getImageAttachments(item);
|
||||
|
||||
if (imageOid == null) {
|
||||
throw new IllegalArgumentException("OID of ImageAttachment must not be null.");
|
||||
}
|
||||
|
||||
// No move, nothing to do
|
||||
if (direction == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the image in the collection
|
||||
while (images.next()) {
|
||||
if (images.getDataObject().getOID().equals(imageOid)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Throw an {@link IllegalArgumentxception} if the imageOid was not found
|
||||
if (!images.getDataObject().getOID().equals(imageOid)) {
|
||||
throw new IllegalArgumentException("OID " + imageOid + " is not in collection");
|
||||
}
|
||||
|
||||
// Get the image to move and test if it is really an ItemImageAttachment
|
||||
final DomainObject sortDomainObject = DomainObjectFactory
|
||||
.newInstance(images.getDataObject());
|
||||
int move = direction;
|
||||
if (sortDomainObject instanceof ItemImageAttachment) {
|
||||
|
||||
// Change the sortKey of the ItemImageAttachment to the desired
|
||||
// value but respect bounds of the current list
|
||||
final int newSortKey = Math.max(1,
|
||||
Math.min((int) images.size(),
|
||||
((ItemImageAttachment) sortDomainObject).
|
||||
getSortKey() + move));
|
||||
((ItemImageAttachment) sortDomainObject).setSortKey(newSortKey);
|
||||
sortDomainObject.save();
|
||||
|
||||
// Now, move all the object between the original position and the
|
||||
// new postition one step in the nessecary direction
|
||||
if (move < 0) {
|
||||
while (images.previous() && move < 0) {
|
||||
final DomainObject domainObject = DomainObjectFactory.newInstance(images.
|
||||
getDataObject());
|
||||
if (domainObject instanceof ItemImageAttachment) {
|
||||
((ItemImageAttachment) domainObject).setSortKey(
|
||||
((ItemImageAttachment) domainObject).getSortKey() + 1);
|
||||
domainObject.save();
|
||||
move++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (move > 0) {
|
||||
while (images.next() && move > 0) {
|
||||
final DomainObject domainObject = DomainObjectFactory.newInstance(images.
|
||||
getDataObject());
|
||||
if (domainObject instanceof ItemImageAttachment) {
|
||||
((ItemImageAttachment) domainObject).setSortKey(
|
||||
((ItemImageAttachment) domainObject).getSortKey() - 1);
|
||||
domainObject.save();
|
||||
move--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// close the collection manually to avimageOid warnings because the list
|
||||
// will not be closed automatically
|
||||
images.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -32,8 +32,7 @@ import com.arsdigita.xml.Element;
|
|||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* Displays a single ImageAsset, showing its image, width, height, name and
|
||||
* mime-type.
|
||||
* Displays a single ImageAsset, showing its image, width, height, name and mime-type.
|
||||
*
|
||||
* @author Michael Pih (pihman@arsdigita.com)
|
||||
* @author Stanislav Freidin (sfreidin@arsdigita.com)
|
||||
|
|
@ -46,8 +45,8 @@ public class ImageDisplay extends SimpleComponent {
|
|||
/**
|
||||
* Construct a new ImageDisplay
|
||||
*
|
||||
* @param m The {@link ItemSelectionModel} which will supply this component
|
||||
* with the {@link ImageAsset}
|
||||
* @param m The {@link ItemSelectionModel} which will supply this component with the
|
||||
* {@link ImageAsset}
|
||||
*/
|
||||
public ImageDisplay(ItemSelectionModel m) {
|
||||
super();
|
||||
|
|
@ -55,8 +54,8 @@ public class ImageDisplay extends SimpleComponent {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the {@link ItemSelectionModel} which supplies this component with
|
||||
* the {@link ImageAsset}
|
||||
* @return the {@link ItemSelectionModel} which supplies this component with the
|
||||
* {@link ImageAsset}
|
||||
*/
|
||||
public final ItemSelectionModel getImageSelectionModel() {
|
||||
return m_item;
|
||||
|
|
@ -147,6 +146,7 @@ public class ImageDisplay extends SimpleComponent {
|
|||
/**
|
||||
*
|
||||
* @param state
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected ImageAsset getImageAsset(PageState state) {
|
||||
|
|
@ -154,4 +154,5 @@ public class ImageDisplay extends SimpleComponent {
|
|||
Assert.exists(image, "Image asset");
|
||||
return image;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ import java.io.IOException;
|
|||
/**
|
||||
* An image upload component.
|
||||
*
|
||||
* This component can be used in different places to add image upload
|
||||
* capabilities in a convinient way. This class uses a listener class which
|
||||
* should be extended from {@link ImageComponentAbstractListener}.
|
||||
* This component can be used in different places to add image upload capabilities in a convinient
|
||||
* way. This class uses a listener class which should be extended from
|
||||
* {@link ImageComponentAbstractListener}.
|
||||
*
|
||||
* @author unknown
|
||||
* @author Sören Bernstein <quasi@quasiweb.de>
|
||||
|
|
@ -83,7 +83,6 @@ public class ImageUploadComponent extends Form implements ImageComponent {
|
|||
|
||||
// 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());
|
||||
|
|
@ -99,7 +98,6 @@ public class ImageUploadComponent extends Form implements ImageComponent {
|
|||
// add(m_description);
|
||||
//
|
||||
// }
|
||||
|
||||
add(new Label(GlobalizationUtil
|
||||
.globalize("cms.contentasset.image.ui.use_context")));
|
||||
m_useContext.setSize(40);
|
||||
|
|
@ -174,4 +172,5 @@ public class ImageUploadComponent extends Form implements ImageComponent {
|
|||
public Form getForm() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
name="ScientificCMS"
|
||||
prettyName="Scientific CMS"
|
||||
version="2.3.0"
|
||||
release="devel-SNAPSHOT-r2664"
|
||||
release="devel-SNAPSHOT-r2691"
|
||||
webxml="sci-web.xml"
|
||||
portletxml="sci-portlet.xml"
|
||||
webapp="libreccm"
|
||||
|
|
|
|||
|
|
@ -93,12 +93,15 @@
|
|||
<xsl:value-of select="@height"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:if test="@plain != 'true'">
|
||||
<div class="cmsImageInfoOverlay">
|
||||
<xsl:if test="$setImageName = 'true'">
|
||||
<span class="key">
|
||||
<xsl:value-of select="@name_label"/>
|
||||
</span>
|
||||
<span class="value"><xsl:value-of select="@name"/></span>
|
||||
<span class="value">
|
||||
<xsl:value-of select="@name"/>
|
||||
</span>
|
||||
<br/>
|
||||
</xsl:if>
|
||||
<xsl:if test="$setMimeType = 'true'">
|
||||
|
|
@ -126,14 +129,18 @@
|
|||
<span class="key">
|
||||
<xsl:value-of select="@dimension_label"/>
|
||||
</span>
|
||||
<span class="value"><xsl:value-of select="@width"/> x <xsl:value-of select="@height"/></span>
|
||||
<span class="value">
|
||||
<xsl:value-of select="@width"/> x <xsl:value-of select="@height"/>
|
||||
</span>
|
||||
<br/>
|
||||
</xsl:if>
|
||||
<xsl:if test="$setContext = 'true'">
|
||||
<span class="key">
|
||||
<xsl:value-of select="@context_label"/>
|
||||
</span>
|
||||
<span class="value"><xsl:value-of select="@context"/></span>
|
||||
<span class="value">
|
||||
<xsl:value-of select="@context"/>
|
||||
</span>
|
||||
<br/>
|
||||
</xsl:if>
|
||||
<xsl:if test="$setCaption = 'true'">
|
||||
|
|
@ -145,6 +152,7 @@
|
|||
</span>
|
||||
</xsl:if>
|
||||
</div>
|
||||
</xsl:if>
|
||||
</img>
|
||||
</xsl:template>
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
<!--
|
||||
<xsl:if test="count($resultTree//cms:item/image | $resultTree//cms:item/imageAttachments/image) > 1">
|
||||
-->
|
||||
<script type="text/javascript" src="/assets/fancybox2/source/jquery.fancybox.pack.js"/>
|
||||
<!--<script type="text/javascript" src="/assets/fancybox2/source/jquery.fancybox.pack.js"/>-->
|
||||
<!--script type="text/javascript" src="/assets/fancybox/jquery.easing.pack.js"/-->
|
||||
|
||||
<!-- Add mousewheel plugin (this is optional) -->
|
||||
|
|
@ -68,16 +68,17 @@
|
|||
<!-- Add Media helper (this is optional) -->
|
||||
<script type="text/javascript" src="/assets/fancybox2/source/helpers/jquery.fancybox-media.js"></script>
|
||||
|
||||
<script type="text/javascript">$(document).ready(function() {$("a.imageZoom").fancybox({'type':'image'}); $("a.imageGallery").fancybox({'type':'image'});});</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("a.imageZoom").fancybox({'type':'image'});
|
||||
$("a.imageGallery").fancybox({
|
||||
'type': 'image',
|
||||
'helpers': {
|
||||
'buttons': {
|
||||
'position': 'bottom',
|
||||
type: 'image',
|
||||
helpers: {
|
||||
title: {
|
||||
type: 'inside',
|
||||
},
|
||||
buttons: {
|
||||
position: 'bottom',
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -120,7 +121,7 @@
|
|||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:if test="../id = $firstMatch">
|
||||
<!--<xsl:if test="../id = $firstMatch">
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("a.<xsl:value-of select="$imageGallery"/>").fancybox({
|
||||
|
|
@ -140,16 +141,16 @@
|
|||
<xsl:with-param name="settingName" select="@id"/>
|
||||
<xsl:with-param name="value" select="."/>
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>-->
|
||||
|
||||
<!-- DE Hack, um ein korrektes Array zu erzeugen. Es gibt leider keine Möglichkeit
|
||||
das Komma hinter den letzten Eintrag wegzulassen, daher wird hier ein "leerer"
|
||||
Eintrag angelegt, den fancybox ignoriert. -->
|
||||
<xsl:text>'dummyEntry' : 'ignoreMe'</xsl:text>
|
||||
<!--<xsl:text>'dummyEntry' : 'ignoreMe'</xsl:text>
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</xsl:if>
|
||||
</xsl:if>-->
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="mandalay:setImageGalleryConfigParam">
|
||||
|
|
|
|||
|
|
@ -19,6 +19,16 @@
|
|||
along with Mandalay. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<!--
|
||||
_
|
||||
| | Currently not used due to compatibility problems between FancyBox 2 and the code in
|
||||
| | imageGallery.js which interprets the settings!
|
||||
|_|
|
||||
(_)
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<settings>
|
||||
<setting id="padding">10</setting>
|
||||
<setting id="margin">20</setting>
|
||||
|
|
|
|||
Loading…
Reference in New Issue