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
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.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
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.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
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.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
*/
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;
/**
* 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 Sören Bernstein (quasimodo) <sbernstein@quasiweb.de>
@ -58,6 +59,12 @@ public class ImageStep extends SecurityPropertyEditor {
private final OIDParameter m_attachmentOID;
/**
* Constructor.
*
* @param itemModel
* @param parent
*/
public ImageStep( ItemSelectionModel itemModel,
AuthoringKitWizard parent ) {
super();
@ -69,6 +76,7 @@ public class ImageStep extends SecurityPropertyEditor {
m_attachmentSelection = new AttachmentSelectionModel();
/* Create ImageEditStep to add images to the current item */
m_add = new ImageStepEdit( this );
WorkflowLockedComponentAccess addCA =
new WorkflowLockedComponentAccess( m_add, m_itemSelection );
@ -77,8 +85,9 @@ public class ImageStep extends SecurityPropertyEditor {
"cms.contentassets.ui.image_step.add_image"),
addCA );
m_display = new ImageStepDisplay( this );
setDisplayComponent(m_display);
/* ImageDisplayStep to display all already attached images */
m_display = new ImageStepDisplay( this ); // Component to display
setDisplayComponent(m_display); // all attached images.
Iterator imageComponents = m_add.getImageComponents();
while( imageComponents.hasNext() ) {

View File

@ -45,24 +45,37 @@ import javax.servlet.ServletException;
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 Sören Bernstein (quasimodo) <sbernstein@quasiweb.de>
*/
public class ImageStepDisplay extends SimpleContainer {
private static final Logger S_LOG = Logger.getLogger(ImageStepDisplay.class);
/** Represents invoking parent component */
private final ImageStep m_imageStep;
/** Name of the delete event */
private final static String DELETE = "deleteAttachment";
/**
* Constructor.
*
* @param step
*/
public ImageStepDisplay( ImageStep step ) {
super();
m_imageStep = step;
/* Message to show in case no image has been attached yet. */
Label mainLabel = new Label(ImageStepGlobalizationUtil.globalize(
"cms.contentassets.ui.image_step.no_image_attached"));
mainLabel.setFontWeight(Label.ITALIC);
@ -85,11 +98,20 @@ public class ImageStepDisplay extends SimpleContainer {
imageList.setCellRenderer( new ImageListCellRenderer() );
imageList.setEmptyView( mainLabel );
add( imageList );
add( imageList ); // finally add the component
}
/**
* Inner class
*/
private class ImageListModelBuilder extends LockableImpl
implements ListModelBuilder {
/**
*
* @param list
* @param ps
* @return
*/
public ListModel makeModel( List list, PageState ps ) {
ContentItem item = m_imageStep.getItem( ps );
@ -109,7 +131,11 @@ public class ImageStepDisplay extends SimpleContainer {
}
}
/**
*
*/
private class ImageListModel implements ListModel {
private final DataCollection m_attachments;
ImageListModel( DataCollection attachments ) {
@ -130,7 +156,21 @@ public class ImageStepDisplay extends SimpleContainer {
}
}
/**
*
*/
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,
Object value, String key,
int index, boolean isSelected ) {
@ -139,21 +179,27 @@ public class ImageStepDisplay extends SimpleContainer {
BoxPanel container = new BoxPanel( BoxPanel.VERTICAL );
container.setBorder( 1 );
// 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);
String caption = attachment.getCaption();
if (caption != null) {
element.addAttribute("caption", caption);
}
// We check here to see whether IsImageStepDescriptionAndTitleShown
// is set to true. If it is, we display the description and title options
if(ItemImageAttachment.getConfig().getIsImageStepDescriptionAndTitleShown()) {
// 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);
@ -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 );
useContextPanel.add( new Label( "Use Context: " ) );
useContextPanel.add(new Label( ImageStepGlobalizationUtil.globalize(
"cms.contentasset.image.ui.use_context") ) );
Label useContextLabel = new Label( new PrintListener() {
public void prepare( PrintEvent ev ) {
Label l = (Label) ev.getTarget();
String useContext = attachment.getUseContext();
if( null == useContext ) {
l.setLabel( "<i>Unknown</i>" );
l.setLabel( ImageStepGlobalizationUtil.globalize(
"cms.ui.unknown") );
} else {
l.setLabel( useContext );
}
@ -191,14 +262,17 @@ public class ImageStepDisplay extends SimpleContainer {
useContextPanel.add( useContextLabel );
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
public void setControlEvent( PageState ps ) {
String oid = ps.getControlEventValue();
ps.setControlEvent( list, DELETE, oid );
}
};
container.add( delete );
container.add( deleteLink );
return container;
}

View File

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

View File

@ -17,7 +17,7 @@ mime_type_jsp=JSP
mime_type_xsl=XSL
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.template.body_text.title=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_cancel=Cancel
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.use_context=Use Context
cms.contentasset.image.ui.caption=Caption:
cms.contentasset.image.ui.use_context=Use Context:

View File

@ -17,7 +17,7 @@ mime_type_jsp=JSP
mime_type_xsl=XSL
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.template.body_text.title=Haupttext\:
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_cancel=Abbruch
cms.contenttyes.link.ui.table_no_entries=Es sind noch keine Links zugeordnet.
cms.contentasset.image.ui.caption=Bildunterschrift
cms.contentasset.image.ui.use_context=Kontext
cms.contentasset.image.ui.caption=Bildunterschrift:
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_cancel=Cancel
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.use_context=Use Context
cms.contentasset.image.ui.caption=Caption:
cms.contentasset.image.ui.use_context=Use Context:

View File

@ -16,7 +16,7 @@ cms.templates=Gabarits
# 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.homepage=Accueil
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_cancel=Cancel
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.use_context=Use Context
cms.contentasset.image.ui.caption=Caption:
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})
*/
public ImageBrowser(ImageBrowserModelBuilder b, int mode) {
super(new BuilderAdapter(b), HEADERS);
m_mode = mode;
setThumbnailSize(CMS.getConfig().getImageBrowserThumbnailMaxWidth(),
@ -118,10 +119,18 @@ public class ImageBrowser extends Table {
setClassAttr("imageBrowser");
}
/**
*
* @param renderer
*/
private void addColumn(TableCellRenderer renderer) {
getColumn(++m_numColumns).setCellRenderer(renderer);
}
/**
*
* @return
*/
public int getNumColumns() {
return m_numColumns;
}
@ -159,12 +168,16 @@ public class ImageBrowser extends Table {
}
/**
* An action listener that only gets fired when the "select" link is
* clicked. Child classes should override the linkClicked method.
* Inner class action listener that only gets fired when the "select" link
* is clicked. Child classes should override the linkClicked method.
*/
public static abstract class LinkActionListener
extends TableActionAdapter {
extends TableActionAdapter {
/**
*
* @param e
*/
@Override
public void cellSelected(TableActionEvent e) {
int c = e.getColumn().intValue();
@ -180,7 +193,9 @@ public class ImageBrowser extends Table {
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 {
@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 {
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 {
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
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 ImageBrowserModel m_model;

View File

@ -34,6 +34,10 @@ import java.math.BigDecimal;
/**
* Displays a single ImageAsset, showing its image, width, height,
* 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 Stanislav Freidin (sfreidin@arsdigita.com)
@ -51,7 +55,6 @@ public class ImageDisplay extends SimpleComponent {
*/
public ImageDisplay(ItemSelectionModel m) {
super();
m_item = m;
}
@ -63,6 +66,11 @@ public class ImageDisplay extends SimpleComponent {
return m_item;
}
/**
*
* @param state
* @param parent
*/
@Override
public void generateXML(PageState state, Element parent) {
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,
PageState state,
Element element) {
@ -91,6 +108,11 @@ public class ImageDisplay extends SimpleComponent {
element.addAttribute("src", URL.getDispatcherPath() +
Service.getImageURL(image));
MimeType mimeType = image.getMimeType();
if ( mimeType != null ) {
element.addAttribute("mime_type", mimeType.getLabel());
}
BigDecimal width = image.getWidth();
if ( width != null ) {
element.addAttribute("width", width.toString());
@ -100,13 +122,13 @@ public class ImageDisplay extends SimpleComponent {
if ( height != null ) {
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) {
ImageAsset image = (ImageAsset) m_item.getSelectedObject(state);
Assert.exists(image, "Image asset");

View File

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