Weitere Verbesserung Lokalisierung ImageSte.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2244 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2013-07-03 23:59:44 +00:00
parent 5ccdb3bab5
commit d03a076b08
15 changed files with 191 additions and 49 deletions

View File

@ -2,3 +2,4 @@ com.arsdigita.cms.contentassets.image_step_label=Add Images
com.arsdigita.cms.contentassets.image_step_description=Add Images com.arsdigita.cms.contentassets.image_step_description=Add Images
cms.contentassets.ui.image_step.add_image=Add Image cms.contentassets.ui.image_step.add_image=Add Image
cms.contentassets.ui.image_step.no_image_attached=This item does not have any associated images. cms.contentassets.ui.image_step.no_image_attached=This item does not have any associated images.
cms.contentassets.ui.image_step.remove_attached_image=Remove image attachment

View File

@ -2,3 +2,4 @@ com.arsdigita.cms.contentassets.image_step_label=Bild hinzuf\u00fcgen
com.arsdigita.cms.contentassets.image_step_description=Bild hinzuf\u00fcgen com.arsdigita.cms.contentassets.image_step_description=Bild hinzuf\u00fcgen
cms.contentassets.ui.image_step.add_image=Bild hinzuf\u00fcgen cms.contentassets.ui.image_step.add_image=Bild hinzuf\u00fcgen
cms.contentassets.ui.image_step.no_image_attached=Diesem Dokument ist noch kein Bild zugeordnet. cms.contentassets.ui.image_step.no_image_attached=Diesem Dokument ist noch kein Bild zugeordnet.
cms.contentassets.ui.image_step.remove_attached_image=Aus der Liste entfernen

View File

@ -2,3 +2,4 @@ com.arsdigita.cms.contentassets.image_step_label=Add Images
com.arsdigita.cms.contentassets.image_step_description=Add Images com.arsdigita.cms.contentassets.image_step_description=Add Images
cms.contentassets.ui.image_step.add_image=Add Image cms.contentassets.ui.image_step.add_image=Add Image
cms.contentassets.ui.image_step.no_image_attached=This item does not have any associated images. cms.contentassets.ui.image_step.no_image_attached=This item does not have any associated images.
cms.contentassets.ui.image_step.remove_attached_image=Remove image attachment

View File

@ -79,7 +79,8 @@ public class ItemImageAttachmentInitializer extends ContentAssetInitializer {
* /WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/FileAttachments.xml * /WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/FileAttachments.xml
*/ */
public String getTraversalXML() { public String getTraversalXML() {
return "/WEB-INF/traversal-adapters/com/arsdigita/" + "cms/contentassets/ItemImageAttachment.xml"; return "/WEB-INF/traversal-adapters/com/arsdigita/" +
"cms/contentassets/ItemImageAttachment.xml";
} }
/** /**

View File

@ -40,7 +40,8 @@ import java.util.Iterator;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Pluggable authoring step to add an ImageAsset to a content item. * Pluggable authoring step as the main entry point to add an ImageAsset to a
* content item.
* *
* @author unknown * @author unknown
* @author Sören Bernstein (quasimodo) <sbernstein@quasiweb.de> * @author Sören Bernstein (quasimodo) <sbernstein@quasiweb.de>
@ -58,6 +59,12 @@ public class ImageStep extends SecurityPropertyEditor {
private final OIDParameter m_attachmentOID; private final OIDParameter m_attachmentOID;
/**
* Constructor.
*
* @param itemModel
* @param parent
*/
public ImageStep( ItemSelectionModel itemModel, public ImageStep( ItemSelectionModel itemModel,
AuthoringKitWizard parent ) { AuthoringKitWizard parent ) {
super(); super();
@ -69,6 +76,7 @@ public class ImageStep extends SecurityPropertyEditor {
m_attachmentSelection = new AttachmentSelectionModel(); m_attachmentSelection = new AttachmentSelectionModel();
/* 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, m_itemSelection ); new WorkflowLockedComponentAccess( m_add, m_itemSelection );
@ -77,8 +85,9 @@ public class ImageStep extends SecurityPropertyEditor {
"cms.contentassets.ui.image_step.add_image"), "cms.contentassets.ui.image_step.add_image"),
addCA ); addCA );
m_display = new ImageStepDisplay( this ); /* ImageDisplayStep to display all already attached images */
setDisplayComponent(m_display); m_display = new ImageStepDisplay( this ); // Component to display
setDisplayComponent(m_display); // all attached images.
Iterator imageComponents = m_add.getImageComponents(); Iterator imageComponents = m_add.getImageComponents();
while( imageComponents.hasNext() ) { while( imageComponents.hasNext() ) {

View File

@ -45,24 +45,37 @@ import javax.servlet.ServletException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Pluggable authoring step to add an ImageAsset to a content item. * Component displays the currently attached images for an content item. It is
* part of the entry point image authoring step {@see ImageStep}.
*
* 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 (quasimodo) <sbernstein@quasiweb.de> * @author Sören Bernstein (quasimodo) <sbernstein@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 */
private final ImageStep m_imageStep; private final ImageStep m_imageStep;
/** Name of the delete event */
private final static String DELETE = "deleteAttachment"; private final static String DELETE = "deleteAttachment";
/**
* Constructor.
*
* @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. */
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);
@ -85,11 +98,20 @@ public class ImageStepDisplay extends SimpleContainer {
imageList.setCellRenderer( new ImageListCellRenderer() ); imageList.setCellRenderer( new ImageListCellRenderer() );
imageList.setEmptyView( mainLabel ); imageList.setEmptyView( mainLabel );
add( imageList ); add( imageList ); // finally add the component
} }
/**
* Inner class
*/
private class ImageListModelBuilder extends LockableImpl private class ImageListModelBuilder extends LockableImpl
implements ListModelBuilder { implements ListModelBuilder {
/**
*
* @param list
* @param ps
* @return
*/
public ListModel makeModel( List list, PageState ps ) { public ListModel makeModel( List list, PageState ps ) {
ContentItem item = m_imageStep.getItem( ps ); ContentItem item = m_imageStep.getItem( ps );
@ -109,7 +131,11 @@ public class ImageStepDisplay extends SimpleContainer {
} }
} }
/**
*
*/
private class ImageListModel implements ListModel { private class ImageListModel implements ListModel {
private final DataCollection m_attachments; private final DataCollection m_attachments;
ImageListModel( DataCollection attachments ) { ImageListModel( DataCollection attachments ) {
@ -130,7 +156,21 @@ public class ImageStepDisplay extends SimpleContainer {
} }
} }
/**
*
*/
private class ImageListCellRenderer implements ListCellRenderer { private class ImageListCellRenderer implements ListCellRenderer {
/**
*
* @param list
* @param state
* @param value
* @param key
* @param index
* @param isSelected
* @return
*/
public Component getComponent( final List list, PageState state, public Component getComponent( final List list, PageState state,
Object value, String key, Object value, String key,
int index, boolean isSelected ) { int index, boolean isSelected ) {
@ -139,21 +179,27 @@ public class ImageStepDisplay extends SimpleContainer {
BoxPanel container = new BoxPanel( BoxPanel.VERTICAL ); BoxPanel container = new BoxPanel( BoxPanel.VERTICAL );
container.setBorder( 1 ); container.setBorder( 1 );
// Add CMS ImageDisplay element to BoxPanel container an overwrite
// generateImagePropertiesXM to add attachment's meta data.
container.add( new ImageDisplay(null) { container.add( new ImageDisplay(null) {
@Override @Override
protected void generateImagePropertiesXML( ImageAsset image, protected void generateImagePropertiesXML( ImageAsset image,
PageState state, PageState state,
Element element ) { Element element ) {
/* Use CMS ImageDisplay to display the image including *
* metadata as name, type, widht, height etc. */
super.generateImagePropertiesXML(image, state, element); super.generateImagePropertiesXML(image, state, element);
String caption = attachment.getCaption(); // We check config here to see whether additional meta data
if (caption != null) { // as title and description are configured to be displayed.
element.addAttribute("caption", caption); // 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
// We check here to see whether IsImageStepDescriptionAndTitleShown // provide labels in Java (including localization).
// is set to true. If it is, we display the description and title options // Title and description - if displayed - have to be
if(ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown()) { // positioned above the image and its metadata.
if(ItemImageAttachment.getConfig()
.getIsImageStepDescriptionAndTitleShown()) {
String description = attachment.getDescription(); String description = attachment.getDescription();
if (description != null) { if (description != null) {
element.addAttribute("description", description); element.addAttribute("description", description);
@ -174,14 +220,39 @@ public class ImageStepDisplay extends SimpleContainer {
} }
} ); } );
/* Create a box panel beloy the image to display the caption */
BoxPanel captionPanel = new BoxPanel( BoxPanel.HORIZONTAL );
captionPanel.add(new Label(ImageStepGlobalizationUtil.globalize(
"cms.contentasset.image.ui.caption")));
Label captionText = new Label( new PrintListener() {
public void prepare( PrintEvent ev ) {
Label l = (Label) ev.getTarget();
String caption = attachment.getCaption();
if( null == caption ) {
l.setLabel( ImageStepGlobalizationUtil.globalize(
"cms.ui.unknown") );
} else {
l.setLabel( caption );
}
}
} );
captionText.setOutputEscaping( false );
captionPanel.add( captionText );
container.add( captionPanel );
/* Create a box panel beloy the image to display use context*/
BoxPanel useContextPanel = new BoxPanel( BoxPanel.HORIZONTAL ); BoxPanel useContextPanel = new BoxPanel( BoxPanel.HORIZONTAL );
useContextPanel.add( new Label( "Use Context: " ) );
useContextPanel.add(new Label( ImageStepGlobalizationUtil.globalize(
"cms.contentasset.image.ui.use_context") ) );
Label useContextLabel = new Label( new PrintListener() { Label useContextLabel = new Label( new PrintListener() {
public void prepare( PrintEvent ev ) { public void prepare( PrintEvent ev ) {
Label l = (Label) ev.getTarget(); Label l = (Label) ev.getTarget();
String useContext = attachment.getUseContext(); String useContext = attachment.getUseContext();
if( null == useContext ) { if( null == useContext ) {
l.setLabel( "<i>Unknown</i>" ); l.setLabel( ImageStepGlobalizationUtil.globalize(
"cms.ui.unknown") );
} else { } else {
l.setLabel( useContext ); l.setLabel( useContext );
} }
@ -191,14 +262,17 @@ public class ImageStepDisplay extends SimpleContainer {
useContextPanel.add( useContextLabel ); useContextPanel.add( useContextLabel );
container.add( useContextPanel ); container.add( useContextPanel );
ControlLink delete = new ControlLink( "Delete" ) { /* Add a link to remove the image in a separate container elemet */
ControlLink deleteLink = new ControlLink(new Label(
ImageStepGlobalizationUtil.globalize(
"cms.contentassets.ui.image_step.remove_attached_image") )) {
@Override @Override
public void setControlEvent( PageState ps ) { public void setControlEvent( PageState ps ) {
String oid = ps.getControlEventValue(); String oid = ps.getControlEventValue();
ps.setControlEvent( list, DELETE, oid ); ps.setControlEvent( list, DELETE, oid );
} }
}; };
container.add( delete ); container.add( deleteLink );
return container; return container;
} }

View File

@ -46,13 +46,13 @@ import java.util.Map;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Pluggable authoring step to add an ImageAsset to a content item. *
* *
* @author unknown * @author unknown
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de> * @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/ */
public class ImageStepEdit extends SimpleContainer public class ImageStepEdit extends SimpleContainer
implements Resettable { implements Resettable {
private static final Logger S_LOG = Logger.getLogger(ImageStepEdit.class); private static final Logger S_LOG = Logger.getLogger(ImageStepEdit.class);
private final ImageStep m_imageStep; private final ImageStep m_imageStep;
@ -61,7 +61,7 @@ public class ImageStepEdit extends SimpleContainer
private final ImageComponentAttachListener m_attachListener; private final ImageComponentAttachListener m_attachListener;
/** /**
* Creates a new ImageStepEidt form. * Creates a new ImageStepEdit form.
* *
* @param step the parent {@link ImageStep} form * @param step the parent {@link ImageStep} form
*/ */
@ -76,8 +76,10 @@ public class ImageStepEdit extends SimpleContainer
new MapComponentSelectionModel(componentModel, new HashMap()); new MapComponentSelectionModel(componentModel, new HashMap());
Map selectors = m_imageComponent.getComponentsMap(); Map selectors = m_imageComponent.getComponentsMap();
m_attachListener = new ImageComponentAttachListener(m_imageComponent, m_imageStep); m_attachListener = new ImageComponentAttachListener(m_imageComponent,
m_imageStep);
/* Include CMS ImageLibrary to display existing images too select from*/
ImageLibraryComponent library = new ImageLibraryComponent(); ImageLibraryComponent library = new ImageLibraryComponent();
library.getForm().addInitListener(m_attachListener); library.getForm().addInitListener(m_attachListener);
library.getForm().addProcessListener(m_attachListener); library.getForm().addProcessListener(m_attachListener);
@ -89,6 +91,7 @@ public class ImageStepEdit extends SimpleContainer
selectors.put(ImageComponent.LIBRARY, library); selectors.put(ImageComponent.LIBRARY, library);
add(library); add(library);
/* Include CMS Image Upload component to enable uploading new img */
ImageUploadComponent upload = new ImageUploadComponent(); ImageUploadComponent upload = new ImageUploadComponent();
upload.getForm().addInitListener(m_attachListener); upload.getForm().addInitListener(m_attachListener);
upload.getForm().addProcessListener(m_attachListener); upload.getForm().addProcessListener(m_attachListener);
@ -113,6 +116,10 @@ public class ImageStepEdit extends SimpleContainer
p.addComponentStateParam(this, m_imageComponentKey); p.addComponentStateParam(this, m_imageComponentKey);
} }
/**
*
* @return
*/
protected Iterator getImageComponents() { protected Iterator getImageComponents() {
return m_imageComponent.getComponentsMap().values().iterator(); return m_imageComponent.getComponentsMap().values().iterator();
} }

View File

@ -17,7 +17,7 @@ mime_type_jsp=JSP
mime_type_xsl=XSL mime_type_xsl=XSL
cms.contentassets.ui.description=Description cms.contentassets.ui.description=Description
cms.contenttypes.coudlnt_retrieve_text=Coudln't retrieve text cms.contenttypes.couldnt_retrieve_text=Coudln't retrieve text
cms.contenttypes.event_type_not_registered=Event type not registered cms.contenttypes.event_type_not_registered=Event type not registered
cms.contenttypes.template.body_text.title=Body text cms.contenttypes.template.body_text.title=Body text
cms.contenttypes.template.body_text.description=Edit the body text cms.contenttypes.template.body_text.description=Edit the body text
@ -1035,5 +1035,5 @@ cms.contenttyes.link.ui.button_save=Save
cms.contenttyes.link.ui.button_reset=Reset cms.contenttyes.link.ui.button_reset=Reset
cms.contenttyes.link.ui.button_cancel=Cancel cms.contenttyes.link.ui.button_cancel=Cancel
cms.contenttyes.link.ui.table_no_entries=There are no links for this content item cms.contenttyes.link.ui.table_no_entries=There are no links for this content item
cms.contentasset.image.ui.caption=Caption cms.contentasset.image.ui.caption=Caption:
cms.contentasset.image.ui.use_context=Use Context cms.contentasset.image.ui.use_context=Use Context:

View File

@ -17,7 +17,7 @@ mime_type_jsp=JSP
mime_type_xsl=XSL mime_type_xsl=XSL
cms.contentassets.ui.description=Beschreibung cms.contentassets.ui.description=Beschreibung
cms.contenttypes.coudlnt_retrieve_text=Text konnte nicht gefunden werden cms.contenttypes.couldnt_retrieve_text=Text konnte nicht gefunden werden
cms.contenttypes.event_type_not_registered=Veranstaltungs-Typ nicht registriert cms.contenttypes.event_type_not_registered=Veranstaltungs-Typ nicht registriert
cms.contenttypes.template.body_text.title=Haupttext\: cms.contenttypes.template.body_text.title=Haupttext\:
cms.contenttypes.template.body_text.description=Haupttext bearbeiten cms.contenttypes.template.body_text.description=Haupttext bearbeiten
@ -1030,5 +1030,5 @@ cms.contenttyes.link.ui.button_save=Sichern
cms.contenttyes.link.ui.button_reset=Zur\u00fccksetzen cms.contenttyes.link.ui.button_reset=Zur\u00fccksetzen
cms.contenttyes.link.ui.button_cancel=Abbruch cms.contenttyes.link.ui.button_cancel=Abbruch
cms.contenttyes.link.ui.table_no_entries=Es sind noch keine Links zugeordnet. cms.contenttyes.link.ui.table_no_entries=Es sind noch keine Links zugeordnet.
cms.contentasset.image.ui.caption=Bildunterschrift cms.contentasset.image.ui.caption=Bildunterschrift:
cms.contentasset.image.ui.use_context=Kontext cms.contentasset.image.ui.use_context=Kontext:

View File

@ -83,5 +83,5 @@ cms.contenttyes.link.ui.button_save=Save
cms.contenttyes.link.ui.button_reset=Reset cms.contenttyes.link.ui.button_reset=Reset
cms.contenttyes.link.ui.button_cancel=Cancel cms.contenttyes.link.ui.button_cancel=Cancel
cms.contenttyes.link.ui.table_no_entries=There are no links for this content item cms.contenttyes.link.ui.table_no_entries=There are no links for this content item
cms.contentasset.image.ui.caption=Caption cms.contentasset.image.ui.caption=Caption:
cms.contentasset.image.ui.use_context=Use Context cms.contentasset.image.ui.use_context=Use Context:

View File

@ -16,7 +16,7 @@ cms.templates=Gabarits
# Package com.arsdigita.cms.contenttypes # Package com.arsdigita.cms.contenttypes
# ====================================== # ======================================
cms.contenttypes.coudlnt_retrieve_text=Impossible d'afficher le texte cms.contenttypes.couldnt_retrieve_text=Impossible d'afficher le texte
cms.contenttypes.ui.description=Description cms.contenttypes.ui.description=Description
cms.contenttypes.ui.homepage=Accueil cms.contenttypes.ui.homepage=Accueil
cms.contenttypes.ui.lead=Fil conducteur cms.contenttypes.ui.lead=Fil conducteur
@ -557,5 +557,5 @@ cms.contenttyes.link.ui.button_save=Save
cms.contenttyes.link.ui.button_reset=Reset cms.contenttyes.link.ui.button_reset=Reset
cms.contenttyes.link.ui.button_cancel=Cancel cms.contenttyes.link.ui.button_cancel=Cancel
cms.contenttyes.link.ui.table_no_entries=There are no links for this content item cms.contenttyes.link.ui.table_no_entries=There are no links for this content item
cms.contentasset.image.ui.caption=Caption cms.contentasset.image.ui.caption=Caption:
cms.contentasset.image.ui.use_context=Use Context cms.contentasset.image.ui.use_context=Use Context:

View File

@ -98,6 +98,7 @@ public class ImageBrowser extends Table {
* @param mode the component mode (see {@link ImageComponent}) * @param mode the component mode (see {@link ImageComponent})
*/ */
public ImageBrowser(ImageBrowserModelBuilder b, int mode) { public ImageBrowser(ImageBrowserModelBuilder b, int mode) {
super(new BuilderAdapter(b), HEADERS); super(new BuilderAdapter(b), HEADERS);
m_mode = mode; m_mode = mode;
setThumbnailSize(CMS.getConfig().getImageBrowserThumbnailMaxWidth(), setThumbnailSize(CMS.getConfig().getImageBrowserThumbnailMaxWidth(),
@ -118,10 +119,18 @@ public class ImageBrowser extends Table {
setClassAttr("imageBrowser"); setClassAttr("imageBrowser");
} }
/**
*
* @param renderer
*/
private void addColumn(TableCellRenderer renderer) { private void addColumn(TableCellRenderer renderer) {
getColumn(++m_numColumns).setCellRenderer(renderer); getColumn(++m_numColumns).setCellRenderer(renderer);
} }
/**
*
* @return
*/
public int getNumColumns() { public int getNumColumns() {
return m_numColumns; return m_numColumns;
} }
@ -159,12 +168,16 @@ public class ImageBrowser extends Table {
} }
/** /**
* An action listener that only gets fired when the "select" link is * Inner class action listener that only gets fired when the "select" link
* clicked. Child classes should override the linkClicked method. * is clicked. Child classes should override the linkClicked method.
*/ */
public static abstract class LinkActionListener public static abstract class LinkActionListener
extends TableActionAdapter { extends TableActionAdapter {
/**
*
* @param e
*/
@Override @Override
public void cellSelected(TableActionEvent e) { public void cellSelected(TableActionEvent e) {
int c = e.getColumn().intValue(); int c = e.getColumn().intValue();
@ -180,7 +193,9 @@ public class ImageBrowser extends Table {
public abstract void deleteClicked(PageState state, BigDecimal imageId); public abstract void deleteClicked(PageState state, BigDecimal imageId);
} }
// Renders a static image for the current asset /**
* Inner private class renders a static image for the current asset.
*/
private class ThumbnailCellRenderer implements TableCellRenderer { private class ThumbnailCellRenderer implements TableCellRenderer {
@Override @Override
@ -200,7 +215,9 @@ public class ImageBrowser extends Table {
} }
} }
// Renders the select link if the mode needs one /**
* Inner private class renders the select link if the mode needs one
*/
private class SelectCellRenderer extends DefaultTableCellRenderer { private class SelectCellRenderer extends DefaultTableCellRenderer {
public SelectCellRenderer() { public SelectCellRenderer() {
@ -220,8 +237,10 @@ public class ImageBrowser extends Table {
} }
} }
// Renders the delete link if the user has permission to delete /**
// the asset and it's not used in an article. * Inner private class renders the delete link if the user has permission
* to deletethe asset and it's not used in an article.
*/
private class DeleteCellRenderer extends DefaultTableCellRenderer { private class DeleteCellRenderer extends DefaultTableCellRenderer {
public DeleteCellRenderer() { public DeleteCellRenderer() {
@ -271,7 +290,10 @@ public class ImageBrowser extends Table {
} }
} }
// Converts an ImageBrowserModelBuilder to a TableModelBuilder /**
* Inner private class converts an ImageBrowserModelBuilder to a
* TableModelBuilder
*/
private static class BuilderAdapter extends LockableImpl private static class BuilderAdapter extends LockableImpl
implements TableModelBuilder { implements TableModelBuilder {
@ -294,7 +316,9 @@ public class ImageBrowser extends Table {
} }
} }
// Converts an ImageBrowserModel to a TableModel /**
* Inner private class converts an ImageBrowserModel to a TableModel.
*/
private static class ImageModelAdapter implements TableModel { private static class ImageModelAdapter implements TableModel {
private ImageBrowserModel m_model; private ImageBrowserModel m_model;

View File

@ -35,6 +35,10 @@ import java.math.BigDecimal;
* Displays a single ImageAsset, showing its image, width, height, * Displays a single ImageAsset, showing its image, width, height,
* name and mime-type. * name and mime-type.
* *
* TODO: Method generateImagePropertiesXML currently just generates the
* property values. The labels (including localization) are handled by the
* theme. Has to be refactord to provide labels including localization as well.
*
* @author Michael Pih (pihman@arsdigita.com) * @author Michael Pih (pihman@arsdigita.com)
* @author Stanislav Freidin (sfreidin@arsdigita.com) * @author Stanislav Freidin (sfreidin@arsdigita.com)
* @version $Id: ImageDisplay.java 287 2005-02-22 00:29:02Z sskracic $ * @version $Id: ImageDisplay.java 287 2005-02-22 00:29:02Z sskracic $
@ -51,7 +55,6 @@ public class ImageDisplay extends SimpleComponent {
*/ */
public ImageDisplay(ItemSelectionModel m) { public ImageDisplay(ItemSelectionModel m) {
super(); super();
m_item = m; m_item = m;
} }
@ -63,6 +66,11 @@ public class ImageDisplay extends SimpleComponent {
return m_item; return m_item;
} }
/**
*
* @param state
* @param parent
*/
@Override @Override
public void generateXML(PageState state, Element parent) { public void generateXML(PageState state, Element parent) {
if ( isVisible(state) ) { if ( isVisible(state) ) {
@ -84,6 +92,15 @@ public class ImageDisplay extends SimpleComponent {
} }
} }
/**
* Generates the property xml. The xml contains no labels for meta date as
* name, type, width, and height. Labels are currently handled by theme!
* A proper localization has to be done in theme as well!
*
* @param image
* @param state
* @param element
*/
protected void generateImagePropertiesXML(ImageAsset image, protected void generateImagePropertiesXML(ImageAsset image,
PageState state, PageState state,
Element element) { Element element) {
@ -91,6 +108,11 @@ public class ImageDisplay extends SimpleComponent {
element.addAttribute("src", URL.getDispatcherPath() + element.addAttribute("src", URL.getDispatcherPath() +
Service.getImageURL(image)); Service.getImageURL(image));
MimeType mimeType = image.getMimeType();
if ( mimeType != null ) {
element.addAttribute("mime_type", mimeType.getLabel());
}
BigDecimal width = image.getWidth(); BigDecimal width = image.getWidth();
if ( width != null ) { if ( width != null ) {
element.addAttribute("width", width.toString()); element.addAttribute("width", width.toString());
@ -100,13 +122,13 @@ public class ImageDisplay extends SimpleComponent {
if ( height != null ) { if ( height != null ) {
element.addAttribute("height", height.toString()); element.addAttribute("height", height.toString());
} }
MimeType mimeType = image.getMimeType();
if ( mimeType != null ) {
element.addAttribute("mime_type", mimeType.getLabel());
}
} }
/**
*
* @param state
* @return
*/
protected ImageAsset getImageAsset(PageState state) { protected ImageAsset getImageAsset(PageState state) {
ImageAsset image = (ImageAsset) m_item.getSelectedObject(state); ImageAsset image = (ImageAsset) m_item.getSelectedObject(state);
Assert.exists(image, "Image asset"); Assert.exists(image, "Image asset");

View File

@ -54,6 +54,7 @@
</xsl:choose> </xsl:choose>
</td> </td>
</tr> </tr>
<!-- Caption is now provided by ImageStepDisplay in Java
<tr> <tr>
<td class="form_label" valign="top">Caption:</td> <td class="form_label" valign="top">Caption:</td>
<td class="form_value" valign="top"> <td class="form_value" valign="top">
@ -67,6 +68,7 @@
</xsl:choose> </xsl:choose>
</td> </td>
</tr> </tr>
-->
<tr> <tr>
<td colspan="2" valign="top"> <td colspan="2" valign="top">
<img src="{@src}" alt="{@name}"> <img src="{@src}" alt="{@name}">