Weitere Verbesserungen Multilanguage Support.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2205 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2013-06-14 07:18:04 +00:00
parent 114dab54a3
commit 09ee19c021
24 changed files with 563 additions and 264 deletions

View File

@ -55,7 +55,7 @@ public class ArticlePropertiesStep extends GenericArticlePropertiesStep {
BasicPageForm editSheet; BasicPageForm editSheet;
editSheet = new ArticlePropertyForm(itemModel, this); editSheet = new ArticlePropertyForm(itemModel, this);
add(EDIT_SHEET_NAME, add(EDIT_SHEET_NAME,
"Edit", "Edit", // curently add accepts just a String, not a Label
new WorkflowLockedComponentAccess(editSheet, itemModel), new WorkflowLockedComponentAccess(editSheet, itemModel),
editSheet.getSaveCancelSection().getCancelButton()); editSheet.getSaveCancelSection().getCancelButton());
} }

View File

@ -20,6 +20,8 @@ package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.contenttypes.Bookmark; import com.arsdigita.cms.contenttypes.Bookmark;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
@ -35,8 +37,7 @@ import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
* Authoring step to edit the simple attributes of the Bookmark content * Authoring step to edit the simple attributes of the Bookmark content
* type (and its subclasses). * type (and its subclasses).
*/ */
public class BookmarkPropertiesStep public class BookmarkPropertiesStep extends SimpleEditStep {
extends SimpleEditStep {
/** The name of the editing sheet added to this step */ /** The name of the editing sheet added to this step */
public static final String EDIT_SHEET_NAME = "edit"; public static final String EDIT_SHEET_NAME = "edit";
@ -67,16 +68,18 @@ public class BookmarkPropertiesStep
itemModel ) { itemModel ) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( itemModel ); DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( itemModel );
// sheet.add( "Page Title:", Bookmark.TITLE );
sheet.add(GlobalizationUtil sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.title"), Bookmark.TITLE ); .globalize("cms.contenttypes.ui.title"), Bookmark.TITLE );
// sheet.add( "Name (URL):", Bookmark.NAME );
sheet.add(GlobalizationUtil sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.name"), Bookmark.NAME ); .globalize("cms.contenttypes.ui.name"), Bookmark.NAME );
// sheet.add( "Description:", Bookmark.DESCRIPTION ); if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.launch_date"),
ContentPage.LAUNCH_DATE,
new LaunchDateAttributeFormatter() );
}
sheet.add(GlobalizationUtil sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.summary"), Bookmark.DESCRIPTION ); .globalize("cms.contenttypes.ui.summary"), Bookmark.DESCRIPTION );
// sheet.add( "URL:", Bookmark.URL );
sheet.add(new GlobalizedMessage sheet.add(new GlobalizedMessage
("cms.contenttypes.ui.bookmark.url",Bookmark.RESOURCES), ("cms.contenttypes.ui.bookmark.url",Bookmark.RESOURCES),
Bookmark.URL ); Bookmark.URL );

View File

@ -29,6 +29,7 @@ import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep; import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.domain.DomainObject; import com.arsdigita.domain.DomainObject;
import com.arsdigita.globalization.GlobalizationHelper; import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
@ -67,9 +68,10 @@ public class EventPropertiesStep extends SimpleEditStep {
BasicPageForm editSheet; BasicPageForm editSheet;
editSheet = new EventPropertyForm(itemModel, this); editSheet = new EventPropertyForm(itemModel, this);
add(EDIT_SHEET_NAME, "Edit", add(EDIT_SHEET_NAME,
new WorkflowLockedComponentAccess(editSheet, itemModel), "Edit",
editSheet.getSaveCancelSection().getCancelButton()); new WorkflowLockedComponentAccess(editSheet, itemModel),
editSheet.getSaveCancelSection().getCancelButton());
setDisplayComponent(getEventPropertySheet(itemModel)); setDisplayComponent(getEventPropertySheet(itemModel));
} }
@ -93,81 +95,20 @@ public class EventPropertiesStep extends SimpleEditStep {
.globalize("cms.contenttypes.ui.name"), Event.NAME); .globalize("cms.contenttypes.ui.name"), Event.NAME);
sheet.add( EventGlobalizationUtil sheet.add( EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.lead"), Event.LEAD); .globalize("cms.contenttypes.ui.event.lead"), Event.LEAD);
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(EventGlobalizationUtil sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.launch_date"), .globalize("cms.contenttypes.ui.launch_date"),
ContentPage.LAUNCH_DATE, ContentPage.LAUNCH_DATE,
new DomainObjectPropertySheet.AttributeFormatter() { new LaunchDateAttributeFormatter() );
public String format(DomainObject item,
String attribute,
PageState state) {
ContentPage page = (ContentPage) item;
if (page.getLaunchDate() != null) {
return DateFormat
.getDateInstance(DateFormat.LONG,
GlobalizationHelper
.getNegotiatedLocale())
.format(page
.getLaunchDate());
} else {
return (String) EventGlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
});
} }
sheet.add( EventGlobalizationUtil sheet.add( EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.start_time"), Event.START_DATE, .globalize("cms.contenttypes.ui.event.start_time"), Event.START_DATE,
new DomainObjectPropertySheet.AttributeFormatter() { new DateTimeAttributeFormatter() );
public String format(DomainObject item, sheet.add( EventGlobalizationUtil
String attribute, .globalize("cms.contenttypes.ui.event.end_time"), Event.END_DATE,
PageState state) { new DateTimeAttributeFormatter() );
Event e = (Event) item;
if (e.getStartDate() != null) {
if (e.getStartTime() == null) {
return DateFormat.getDateInstance(DateFormat.LONG, GlobalizationHelper.getNegotiatedLocale()).format(e.getStartDate());
} else {
int timezoneOffset = Calendar.getInstance().get(Calendar.ZONE_OFFSET) + Calendar.getInstance().get(Calendar.DST_OFFSET) / (60 * 1000);
Date startDateTime = new Date(e.getStartDate().getTime() + e.getStartTime().getTime() + timezoneOffset);
return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, GlobalizationHelper.getNegotiatedLocale()).format(startDateTime);
}
} else {
return (String) EventGlobalizationUtil.globalize("cms.ui.unknown").localize();
}
}
});
sheet.add( EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.end_time"), Event.END_DATE,
new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject item,
String attribute,
PageState state) {
Event e = (Event) item;
if (e.getEndDate() != null) {
if (e.getEndTime() == null) {
return DateFormat.getDateInstance(DateFormat.LONG, GlobalizationHelper.getNegotiatedLocale()).format(e.getEndDate());
} else {
int timezoneOffset = Calendar.getInstance().get(Calendar.ZONE_OFFSET) + Calendar.getInstance().get(Calendar.DST_OFFSET) / (60 * 1000);
Date endDateTime = new Date(e.getEndDate().getTime() + e.getEndTime().getTime() + timezoneOffset);
return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, GlobalizationHelper.getNegotiatedLocale()).format(endDateTime);
}
} else {
return (String) EventGlobalizationUtil.globalize("cms.ui.unknown").localize();
}
}
});
if (!Event.getConfig().getHideDateDescription()) { if (!Event.getConfig().getHideDateDescription()) {
sheet.add( EventGlobalizationUtil sheet.add( EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.date_description"), .globalize("cms.contenttypes.ui.event.date_description"),
@ -199,4 +140,63 @@ public class EventPropertiesStep extends SimpleEditStep {
} }
return sheet; return sheet;
} }
/**
* Private class which implements an AttributeFormatter interface for
* date values.
* Its format(...) class returns a string representation for either a
* false or a true value.
*/
private static class DateTimeAttributeFormatter
implements DomainObjectPropertySheet.AttributeFormatter {
/**
* Constructor, does nothing.
*/
public DateTimeAttributeFormatter() {
}
/**
* Formatter for the value of an attribute.
*
* It currently relays on the prerequisite that the passed in property
* attribute is in fact a date property. No type checking yet!
*
* Note: the format method has to be executed at each page request. Take
* care to properly adjust globalization and localization here!
*
* @param obj Object containing the attribute to format.
* @param attribute Name of the attribute to retrieve and format
* @param state PageState of the request
* @return A String representation of the retrieved boolean
* attribute of the domain object.
*/
public String format(DomainObject obj, String attribute, PageState state) {
if ( obj != null && obj instanceof Event) {
Event event = (Event) obj;
Object field = event.get(attribute);
if( field != null ) {
// Note: No type safety here! We relay that it is
// attached to a date property!
return DateFormat.getDateTimeInstance(
DateFormat.LONG,
DateFormat.SHORT,
GlobalizationHelper.getNegotiatedLocale()
)
.format(field);
} else {
return (String)GlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
return (String) GlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
} }

View File

@ -84,16 +84,24 @@ public class ImagePropertiesStep extends SimpleEditStep {
BasicPageForm editSheet; BasicPageForm editSheet;
m_imageComponentKey = new StringParameter("imageComponent"); m_imageComponentKey = new StringParameter("imageComponent");
ParameterSingleSelectionModel componentModel = new ParameterSingleSelectionModel(m_imageComponentKey); ParameterSingleSelectionModel componentModel =
m_imageComponent = new MapComponentSelectionModel(componentModel, new HashMap()); new ParameterSingleSelectionModel(m_imageComponentKey);
m_imageComponent = new MapComponentSelectionModel(componentModel,
new HashMap());
Map selectors = m_imageComponent.getComponentsMap(); Map selectors = m_imageComponent.getComponentsMap();
uploadSheet = new ImageUploadComponent(); uploadSheet = new ImageUploadComponent();
uploadSheet.getForm().addProcessListener(new ImageUploadListerner()); uploadSheet.getForm().addProcessListener(new ImageUploadListerner());
selectors.put(UPLOAD, uploadSheet); selectors.put(UPLOAD, uploadSheet);
editSheet = new ImagePropertyForm(itemModel, this); editSheet = new ImagePropertyForm(itemModel, this);
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel), editSheet.getSaveCancelSection().getCancelButton()); add(EDIT_SHEET_NAME,
add(UPLOAD_SHEET_NAME, "Upload", new WorkflowLockedComponentAccess(uploadSheet, itemModel), uploadSheet.getSaveCancelSection().getCancelButton()); "Edit",
new WorkflowLockedComponentAccess(editSheet, itemModel),
editSheet.getSaveCancelSection().getCancelButton());
add(UPLOAD_SHEET_NAME,
"Upload",
new WorkflowLockedComponentAccess(uploadSheet, itemModel),
uploadSheet.getSaveCancelSection().getCancelButton());
setDisplayComponent(getImagePropertySheet(itemModel)); setDisplayComponent(getImagePropertySheet(itemModel));
} }
@ -114,7 +122,12 @@ public class ImagePropertiesStep extends SimpleEditStep {
@Override @Override
protected ImageAsset getImageAsset(PageState state) { protected ImageAsset getImageAsset(PageState state) {
try { try {
ImageAsset image = ((Image) itemModel.getSelectedItem(state)).getImage().proportionalResizeToWidth(Image.getConfig().getMaxImageWidth()); ImageAsset image = ((Image)
itemModel
.getSelectedItem(state))
.getImage()
.proportionalResizeToWidth(Image.getConfig()
.getMaxImageWidth());
return image; return image;
} catch (NullPointerException ex) { } catch (NullPointerException ex) {
return null; return null;
@ -124,74 +137,40 @@ public class ImagePropertiesStep extends SimpleEditStep {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"), Image.TITLE); sheet.add(GlobalizationUtil
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"), .globalize("cms.contenttypes.ui.title"),
Image.TITLE);
sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.name"),
Image.NAME); Image.NAME);
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"), sheet.add(GlobalizationUtil
ContentPage.LAUNCH_DATE, .globalize("cms.contenttypes.ui.launch_date"),
new DomainObjectPropertySheet.AttributeFormatter() { ContentPage.LAUNCH_DATE,
new LaunchDateAttributeFormatter() );
@Override
public String format(DomainObject item,
String attribute,
PageState state) {
ContentPage page = (ContentPage) item;
if (page.getLaunchDate() != null) {
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
} else {
return (String) GlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
});
} }
sheet.add(ImageGlobalizationUtil sheet.add(ImageGlobalizationUtil
.globalize("cms.contenttypes.ui.image.width"), Image.WIDTH); .globalize("cms.contenttypes.ui.image.width"),
Image.WIDTH);
sheet.add(ImageGlobalizationUtil sheet.add(ImageGlobalizationUtil
.globalize("cms.contenttypes.ui.image.height"), Image.HEIGHT); .globalize("cms.contenttypes.ui.image.height"),
Image.HEIGHT);
sheet.add(ImageGlobalizationUtil sheet.add(ImageGlobalizationUtil
.globalize("cms.contenttypes.ui.image.caption"), Image.CAPTION); .globalize("cms.contenttypes.ui.image.caption"),
Image.CAPTION);
sheet.add(GlobalizationUtil sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.description"), Image.DESCRIPTION); .globalize("cms.contenttypes.ui.description"),
Image.DESCRIPTION);
sheet.add(ImageGlobalizationUtil sheet.add(ImageGlobalizationUtil
.globalize("cms.contenttypes.ui.image.artist"), Image.ARTIST); .globalize("cms.contenttypes.ui.image.artist"),
Image.ARTIST);
sheet.add(ImageGlobalizationUtil sheet.add(ImageGlobalizationUtil
.globalize("cms.contenttypes.ui.image.publishDate"), .globalize("cms.contenttypes.ui.image.publishDate"),
Image.PUBLISHDATE, Image.PUBLISHDATE,
new DomainObjectPropertySheet.AttributeFormatter() { new ImageDateAttributeFormatter()
);
@Override
public String format(DomainObject item, String attribute, PageState state) {
Image image = (Image) item;
if ((image.getPublishDate()) != null) {
if (image.getSkipDay().booleanValue() == true || image.getSkipMonth().booleanValue() == true) {
String month = "";
if (image.getSkipMonth().booleanValue() == false) {
Locale locale = GlobalizationHelper.getNegotiatedLocale();
if (locale != null) {
DateFormatSymbols dfs = new DateFormatSymbols(locale);
String[] months = dfs.getMonths();
month = months[image.getPublishDate().getMonth()] + " ";
}
}
String year = Integer.toString(image.getPublishDate().getYear() + 1900);
return month + year;
} else {
return DateFormat.getDateInstance(DateFormat.LONG).format(image.getPublishDate());
}
} else {
return (String) GlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
});
sheet.add(ImageGlobalizationUtil.globalize( sheet.add(ImageGlobalizationUtil.globalize(
"cms.contenttypes.ui.image.source"), "cms.contenttypes.ui.image.source"),
Image.SOURCE); Image.SOURCE);
@ -331,4 +310,78 @@ public class ImagePropertiesStep extends SimpleEditStep {
return this; return this;
} }
} }
/**
* Private class which implements an AttributeFormatter interface for
* boolean values.
* Its format(...) class returns a string representation for either a
* false or a true value.
*/
private static class ImageDateAttributeFormatter
implements DomainObjectPropertySheet.AttributeFormatter {
/**
* Constructor, does nothing.
*/
public ImageDateAttributeFormatter() {
}
/**
* Formatter for the value of an attribute.
*
* It currently relays on the prerequisite that the passed in property
* attribute is in fact a date property. No type checking yet!
*
* Note: the format method has to be executed at each page request. Take
* care to properly adjust globalization and localization here!
*
* @param obj Object containing the attribute to format.
* @param attribute Name of the attribute to retrieve and format
* @param state PageState of the request
* @return A String representation of the retrieved boolean
* attribute of the domain object.
*/
public String format(DomainObject obj, String attribute, PageState state) {
if ( obj != null && obj instanceof Image) {
Image image = (Image) obj;
if ((image.getPublishDate()) != null) {
if (image.getSkipDay().booleanValue() == true
|| image.getSkipMonth().booleanValue() == true) {
String month = "";
if (image.getSkipMonth().booleanValue() == false) {
Locale locale = GlobalizationHelper.getNegotiatedLocale();
if (locale != null) {
DateFormatSymbols dfs = new DateFormatSymbols(locale);
String[] months = dfs.getMonths();
month = months[image.getPublishDate().getMonth()]
+ " ";
}
}
String year = Integer
.toString(image.getPublishDate().getYear()
+ 1900);
return month + year;
} else {
return DateFormat.getDateInstance(DateFormat.LONG)
.format(image.getPublishDate());
}
} else {
return (String)GlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
return (String) GlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
} }

View File

@ -86,19 +86,7 @@ public class MultiPartArticleEdit extends SimpleEditStep {
sheet.add(GlobalizationUtil sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.launch_date"), .globalize("cms.contenttypes.ui.launch_date"),
ContentPage.LAUNCH_DATE, ContentPage.LAUNCH_DATE,
new DomainObjectPropertySheet.AttributeFormatter() { new LaunchDateAttributeFormatter() );
public String format(DomainObject item,
String attribute,
PageState state) {
ContentPage page = (ContentPage) item;
if (page.getLaunchDate() != null) {
return DateFormat.getDateInstance(DateFormat.LONG)
.format(page.getLaunchDate());
} else {
return "unknown";
}
}
});
} }
sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.summary"), sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.summary"),
MultiPartArticle.SUMMARY ); MultiPartArticle.SUMMARY );

View File

@ -43,8 +43,8 @@ public class Organization extends ContentPage {
public static final String IMAGE_ID = "imageID"; public static final String IMAGE_ID = "imageID";
/** Data object type for tihs domain object */ /** Data object type for tihs domain object */
public static final String BASE_DATA_OBJECT_TYPE public static final String BASE_DATA_OBJECT_TYPE =
= "com.arsdigita.cms.contenttypes.Organization"; "com.arsdigita.cms.contenttypes.Organization";
public Organization () { public Organization () {
super(BASE_DATA_OBJECT_TYPE); super(BASE_DATA_OBJECT_TYPE);

View File

@ -64,7 +64,7 @@ public class OrganizationImageStep extends SimpleEditStep {
add( IMAGE_SHEET_NAME, add( IMAGE_SHEET_NAME,
"Change (OrgImageStep)", "Change (OrgImageStep)",
new WorkflowLockedComponentAccess(new OrganizationImageForm( new WorkflowLockedComponentAccess(new OrganizationImageForm(
"OrganizationImageForm", itemModel, this), "OrganizationImageForm", itemModel, this),
itemModel)); itemModel));
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel, false); DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel, false);

View File

@ -32,8 +32,8 @@ import java.math.BigDecimal;
* reference purposes. Reference code is an arbitrary string that is used for * reference purposes. Reference code is an arbitrary string that is used for
* out-of-system reference. The type inherits name (filename), title, body * out-of-system reference. The type inherits name (filename), title, body
* (TextAsset), and metadata from * (TextAsset), and metadata from
* <code>com.arsdigita.cms.contenttypes.Genericrticle</code>, and also provides the * <code>com.arsdigita.cms.contenttypes.Genericrticle</code>, and also provides
* capability to associate contact information with this press release. * the capability to associate contact information with this press release.
* *
* @version $Revision: #6 $ $Date: 2004/08/17 $ * @version $Revision: #6 $ $Date: 2004/08/17 $
**/ **/
@ -41,14 +41,15 @@ public class PressRelease extends GenericArticle {
// is the CardBin sort of contact support needed here? // is the CardBin sort of contact support needed here?
// implements ContactSupport { // implements ContactSupport {
/** PDL property name for contact info */
public static final String CONTACT_INFO = "contactInfo";
/** PDL property name for summary */ /** PDL property name for summary */
public static final String SUMMARY = "summary"; public static final String SUMMARY = "summary";
/** PDL property name for contact info */
public static final String CONTACT_INFO = "contactInfo";
/** PDL property name for reference code */ /** PDL property name for reference code */
public static final String REFERENCE_CODE = "referenceCode"; public static final String REFERENCE_CODE = "referenceCode";
/** Data object type for this domain object */ /** Data object type for this domain object */
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.PressRelease"; public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.contenttypes.PressRelease";
public PressRelease() { public PressRelease() {
this(BASE_DATA_OBJECT_TYPE); this(BASE_DATA_OBJECT_TYPE);
@ -77,14 +78,6 @@ public class PressRelease extends GenericArticle {
} }
/* accessors *****************************************************/ /* accessors *****************************************************/
public String getContactInfo() {
return (String) get(CONTACT_INFO);
}
public void setContactInfo(String contactInfo) {
set(CONTACT_INFO, contactInfo);
}
public String getSummary() { public String getSummary() {
return (String) get(SUMMARY); return (String) get(SUMMARY);
} }
@ -93,6 +86,14 @@ public class PressRelease extends GenericArticle {
set(SUMMARY, summary); set(SUMMARY, summary);
} }
public String getContactInfo() {
return (String) get(CONTACT_INFO);
}
public void setContactInfo(String contactInfo) {
set(CONTACT_INFO, contactInfo);
}
public String getReferenceCode() { public String getReferenceCode() {
return (String) get(REFERENCE_CODE); return (String) get(REFERENCE_CODE);
} }

View File

@ -1 +1,3 @@
press_release.authoring.basic_properties.description=Edit the title, name, contact info, summary, ref. code and release date press_release.authoring.basic_properties.description=Edit the title, name, contact info, summary, ref. code and release date
cms.contenttypes.ui.pressrelease.contact_info=Contact Info:
cms.contenttypes.ui.pressrelease.ref_code=Ref. Code:

View File

@ -1 +1,3 @@
press_release.authoring.basic_properties.description=Editieren von Titel, Name, Kontakt Information, Zusammenfassung, Ref. Id und Erscheinungsdatum press_release.authoring.basic_properties.description=Editieren von Titel, Name, Kontakt Information, Zusammenfassung, Ref. Id und Erscheinungsdatum
cms.contenttypes.ui.pressrelease.contact_info=Kontaktinformation:
cms.contenttypes.ui.pressrelease.ref_code=Referenz:

View File

@ -1 +1,3 @@
press_release.authoring.basic_properties.description=Edit the title, name, contact info, summary, ref. code and release date press_release.authoring.basic_properties.description=Edit the title, name, contact info, summary, ref. code and release date
cms.contenttypes.ui.pressrelease.contact_info=Contact:
cms.contenttypes.ui.pressrelease.ref_code=Code de r\u00e9f\u00e9rence:

View File

@ -24,13 +24,14 @@ import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.PressRelease; import com.arsdigita.cms.contenttypes.PressRelease;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.cms.contenttypes.util.PressReleaseGlobalizationUtil;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep; import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import java.text.DateFormat; import java.text.DateFormat;
@ -39,13 +40,18 @@ import java.text.DateFormat;
* (and its subclasses). The attributes edited are 'name', 'title', 'release * (and its subclasses). The attributes edited are 'name', 'title', 'release
* date' and 'reference code'. This authoring step replaces the * date' and 'reference code'. This authoring step replaces the
* <code>com.arsdigita.ui.authoring.PageEdit</code> step for this type. * <code>com.arsdigita.ui.authoring.PageEdit</code> step for this type.
**/ */
public class PressReleasePropertiesStep public class PressReleasePropertiesStep extends SimpleEditStep {
extends SimpleEditStep {
/** The name of the editing sheet added to this step */ /** The name of the editing sheet added to this step */
public static String EDIT_SHEET_NAME = "edit"; public static String EDIT_SHEET_NAME = "edit";
/**
* Constructor.
*
* @param itemModel
* @param parent
*/
public PressReleasePropertiesStep( ItemSelectionModel itemModel, public PressReleasePropertiesStep( ItemSelectionModel itemModel,
AuthoringKitWizard parent ) { AuthoringKitWizard parent ) {
super( itemModel, parent ); super( itemModel, parent );
@ -54,7 +60,12 @@ public class PressReleasePropertiesStep
BasicPageForm editSheet; BasicPageForm editSheet;
editSheet = new PressReleasePropertyForm( itemModel, this); editSheet = new PressReleasePropertyForm( itemModel, this);
add( EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel), // SecurityPropertyEditor#add currently accepts just a String as label
// parameter. As soon as it is refactored, a GlobalizedMessage or a
// Label should be used.
add( EDIT_SHEET_NAME,
"Edit",
new WorkflowLockedComponentAccess(editSheet, itemModel),
editSheet.getSaveCancelSection().getCancelButton() ); editSheet.getSaveCancelSection().getCancelButton() );
setDisplayComponent( getPressReleasePropertySheet( itemModel ) ); setDisplayComponent( getPressReleasePropertySheet( itemModel ) );
@ -73,28 +84,27 @@ public class PressReleasePropertiesStep
itemModel ) { itemModel ) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( itemModel ); DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( itemModel );
sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.name"), PressRelease.NAME); sheet.add(GlobalizationUtil
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.contact_info"), PressRelease.CONTACT_INFO ); .globalize("cms.contenttypes.ui.title"),
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.summary"), PressRelease.SUMMARY ); PressRelease.TITLE);
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"), PressRelease.TITLE); sheet.add( GlobalizationUtil
.globalize("cms.contenttypes.ui.name"),
PressRelease.NAME);
sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.summary"),
PressRelease.SUMMARY );
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"), sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.launch_date"),
ContentPage.LAUNCH_DATE, ContentPage.LAUNCH_DATE,
new DomainObjectPropertySheet.AttributeFormatter() { new LaunchDateAttributeFormatter() );
public String format(DomainObject item,
String attribute,
PageState state) {
ContentPage page = (ContentPage) item;
if(page.getLaunchDate() != null) {
return DateFormat.getDateInstance(DateFormat.LONG)
.format(page.getLaunchDate());
} else {
return (String)GlobalizationUtil.globalize("cms.ui.unknown").localize();
}
}
});
} }
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.ref_code"), PressRelease.REFERENCE_CODE ); sheet.add(PressReleaseGlobalizationUtil
.globalize("cms.contenttypes.ui.pressrelease.contact_info"),
PressRelease.CONTACT_INFO );
sheet.add(PressReleaseGlobalizationUtil
.globalize("cms.contenttypes.ui.pressrelease.ref_code"),
PressRelease.REFERENCE_CODE );
return sheet; return sheet;
} }

View File

@ -32,6 +32,7 @@ import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.PressRelease; import com.arsdigita.cms.contenttypes.PressRelease;
import com.arsdigita.cms.contenttypes.util.PressReleaseGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.util.GlobalizationUtil;
@ -39,16 +40,18 @@ import com.arsdigita.cms.util.GlobalizationUtil;
* Form to edit the basic properties of a press release. These are name, title, * Form to edit the basic properties of a press release. These are name, title,
* release date and reference code. This form can be extended to create forms * release date and reference code. This form can be extended to create forms
* for PressRelease subclasses. * for PressRelease subclasses.
**/ */
public class PressReleasePropertyForm extends BasicPageForm public class PressReleasePropertyForm extends BasicPageForm
implements FormProcessListener, FormInitListener, FormSubmissionListener { implements FormProcessListener,
FormInitListener,
FormSubmissionListener {
private PressReleasePropertiesStep m_step; private PressReleasePropertiesStep m_step;
/** contact info parameter name */
public static final String CONTACT_INFO = "contactInfo";
/** summary parameter name */ /** summary parameter name */
public static final String SUMMARY = "summary"; public static final String SUMMARY = "summary";
/** contact info parameter name */
public static final String CONTACT_INFO = "contactInfo";
/** Reference code parameter name */ /** Reference code parameter name */
public static final String REF_CODE = "ref_code"; public static final String REF_CODE = "ref_code";
/** Release date parameter name */ /** Release date parameter name */
@ -73,7 +76,8 @@ public class PressReleasePropertyForm extends BasicPageForm
* PressRelease to work on * PressRelease to work on
* @param step The PressReleasePropertiesStep which controls this form. * @param step The PressReleasePropertiesStep which controls this form.
*/ */
public PressReleasePropertyForm( ItemSelectionModel itemModel, PressReleasePropertiesStep step ) { public PressReleasePropertyForm( ItemSelectionModel itemModel,
PressReleasePropertiesStep step ) {
super( ID, itemModel ); super( ID, itemModel );
m_step = step; m_step = step;
addSubmissionListener(this); addSubmissionListener(this);
@ -85,21 +89,24 @@ public class PressReleasePropertyForm extends BasicPageForm
protected void addWidgets() { protected void addWidgets() {
super.addWidgets(); super.addWidgets();
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.contact_info"))); add(new Label(GlobalizationUtil
ParameterModel contactInfoParam = new StringParameter(CONTACT_INFO); .globalize("cms.contenttypes.ui.summary")));
CMSDHTMLEditor contactInfo = new CMSDHTMLEditor(contactInfoParam);
contactInfo.setCols(40);
contactInfo.setRows(10);
add(contactInfo);
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.summary")));
ParameterModel summaryParam = new StringParameter(SUMMARY); ParameterModel summaryParam = new StringParameter(SUMMARY);
TextArea summary = new TextArea(summaryParam); TextArea summary = new TextArea(summaryParam);
summary.setCols(40); summary.setCols(40);
summary.setRows(7); summary.setRows(7);
add(summary); add(summary);
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.reference_code"))); add(new Label(PressReleaseGlobalizationUtil
.globalize("cms.contenttypes.ui.pressrelease.contact_info")));
ParameterModel contactInfoParam = new StringParameter(CONTACT_INFO);
CMSDHTMLEditor contactInfo = new CMSDHTMLEditor(contactInfoParam);
contactInfo.setCols(40);
contactInfo.setRows(10);
add(contactInfo);
add(new Label(PressReleaseGlobalizationUtil
.globalize("cms.contenttypes.ui.pressrelease.ref_code")));
ParameterModel refCodeParam = new StringParameter(REF_CODE); ParameterModel refCodeParam = new StringParameter(REF_CODE);
TextField refCode = new TextField(refCodeParam); TextField refCode = new TextField(refCodeParam);
refCode.setSize(30); refCode.setSize(30);
@ -107,18 +114,22 @@ public class PressReleasePropertyForm extends BasicPageForm
add(refCode); add(refCode);
} }
/** Form initialisation hook. Fills widgets with data. */ /**
* Form initialisation hook. Fills widgets with data.
*/
public void init(FormSectionEvent fse) { public void init(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PressRelease release PressRelease release
= (PressRelease) super.initBasicWidgets(fse); = (PressRelease) super.initBasicWidgets(fse);
data.put(CONTACT_INFO, release.getContactInfo());
data.put(SUMMARY, release.getSummary()); data.put(SUMMARY, release.getSummary());
data.put(CONTACT_INFO, release.getContactInfo());
data.put(REF_CODE, release.getReferenceCode()); data.put(REF_CODE, release.getReferenceCode());
} }
/** Cancels streamlined editing. */ /**
* Cancels streamlined editing.
*/
public void submitted( FormSectionEvent fse ) { public void submitted( FormSectionEvent fse ) {
if (m_step != null && if (m_step != null &&
getSaveCancelSection().getCancelButton() getSaveCancelSection().getCancelButton()
@ -127,7 +138,9 @@ public class PressReleasePropertyForm extends BasicPageForm
} }
} }
/** Form processing hook. Saves PressRelease object. */ /**
* Form processing hook. Saves PressRelease object.
*/
public void process(FormSectionEvent fse) { public void process(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
@ -138,9 +151,9 @@ public class PressReleasePropertyForm extends BasicPageForm
&& getSaveCancelSection().getSaveButton() && getSaveCancelSection().getSaveButton()
.isSelected(fse.getPageState())) { .isSelected(fse.getPageState())) {
release.setReferenceCode((String) data.get(REF_CODE));
release.setContactInfo((String) data.get(CONTACT_INFO));
release.setSummary((String) data.get(SUMMARY)); release.setSummary((String) data.get(SUMMARY));
release.setContactInfo((String) data.get(CONTACT_INFO));
release.setReferenceCode((String) data.get(REF_CODE));
release.save(); release.save();
} }
if (m_step != null) { if (m_step != null) {

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2009 Jens Pelzetter, Center of Social Politic Research, University of Bremen
*
* 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.contenttypes.util;
import com.arsdigita.cms.contenttypes.util.*;
import com.arsdigita.globalization.Globalized;
import com.arsdigita.globalization.GlobalizedMessage;
/**
* Compilation of methods to simplify the handling of globalizing keys.
* Basically it adds the name of package's resource bundle files to the
* globalize methods and forwards to GlobalizedMessage, shortening the
* method invocation in the various application classes.
*
*/
public class PressReleaseGlobalizationUtil implements Globalized {
/** Name of Java resource files to handle PressRelease's globalisation. */
final public static String BUNDLE_NAME =
"com.arsdigita.cms.contenttypes.PressReleaseResources";
/**
* Returns a globalized message using the package specific bundle,
* provided by BUNDLE_NAME.
*/
public static GlobalizedMessage globalize (String key) {
return new GlobalizedMessage(key, BUNDLE_NAME);
}
/**
* Returns a globalized message object, using the package specific bundle,
* as specified by BUNDLE_NAME. Also takes in an Object[] of arguments to
* interpolate into the retrieved message using the MessageFormat class.
*/
public static GlobalizedMessage globalize (String key, Object[] args) {
return new GlobalizedMessage(key, BUNDLE_NAME, args);
}
}

View File

@ -1 +1,5 @@
service.authoring.basic_properties.description=Edit the title, name, contact info, summary, ref. code and release date service.authoring.basic_properties.description=Edit the title, name, contact info, summary, ref. code and release date
cms.contenttypes.ui.service.services_provided=Services Provided:
cms.contenttypes.ui.service.opening_times=Opening Times:
cms.contenttypes.ui.service.contacts=Contacts:
cms.contenttypes.ui.service.address=Address:

View File

@ -1 +1,5 @@
service.authoring.basic_properties.description=Editieren von Titel, Name, etc. service.authoring.basic_properties.description=Editieren von Titel, Name, etc.
cms.contenttypes.ui.service.services_provided=Verf\u00fcgbarer Service:
cms.contenttypes.ui.service.opening_times=\u00d6ffnungszeiten:
cms.contenttypes.ui.service.contacts=Kontakte:
cms.contenttypes.ui.service.address=Adresse:

View File

@ -1 +1,5 @@
service.authoring.basic_properties.description=Edit the title, name, contact info, summary, ref. code and release date service.authoring.basic_properties.description=Edit the title, name, contact info, summary, ref. code and release date
cms.contenttypes.ui.service.services_provided=Services propos\u00e9s:
cms.contenttypes.ui.service.opening_times=Heures d'ouverture:
cms.contenttypes.ui.service.contacts=Contacts:
cms.contenttypes.ui.service.address=Addresse:

View File

@ -25,6 +25,7 @@ import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.Service; import com.arsdigita.cms.contenttypes.Service;
import com.arsdigita.cms.contenttypes.util.ServiceGlobalizationUtil;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.domain.DomainObject; import com.arsdigita.domain.DomainObject;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
@ -56,7 +57,9 @@ public class ServicePropertiesStep extends SimpleEditStep {
BasicPageForm editSheet; BasicPageForm editSheet;
editSheet = new ServicePropertyForm(itemModel,this); editSheet = new ServicePropertyForm(itemModel,this);
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel), add(EDIT_SHEET_NAME,
"Edit", // currently just a String is acepted!
new WorkflowLockedComponentAccess(editSheet, itemModel),
editSheet.getSaveCancelSection().getCancelButton()); editSheet.getSaveCancelSection().getCancelButton());
setDisplayComponent(getServicePropertySheet(itemModel)); setDisplayComponent(getServicePropertySheet(itemModel));
@ -76,29 +79,33 @@ public class ServicePropertiesStep extends SimpleEditStep {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.name"), Service.NAME); sheet.add( GlobalizationUtil
sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.title"), Service.TITLE); .globalize("cms.contenttypes.ui.title"),
Service.TITLE);
sheet.add( GlobalizationUtil
.globalize("cms.contenttypes.ui.name"),
Service.NAME);
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"), sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.launch_date"),
ContentPage.LAUNCH_DATE, ContentPage.LAUNCH_DATE,
new DomainObjectPropertySheet.AttributeFormatter() { new LaunchDateAttributeFormatter() );
public String format(DomainObject item,
String attribute,
PageState state) {
ContentPage page = (ContentPage) item;
if(page.getLaunchDate() != null) {
return DateFormat.getDateInstance(DateFormat.LONG)
.format(page.getLaunchDate());
} else {
return (String)GlobalizationUtil.globalize("cms.ui.unknown").localize();
}
}
});
} }
sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.summary"), Service.SUMMARY); sheet.add( GlobalizationUtil
sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.services_provided"), Service.SERVICES_PROVIDED); .globalize("cms.contenttypes.ui.summary"),
sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.opening_times"), Service.OPENING_TIMES); Service.SUMMARY);
sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.contacts"), Service.CONTACTS); sheet.add( ServiceGlobalizationUtil
.globalize("cms.contenttypes.ui.service.services_provided"),
Service.SERVICES_PROVIDED);
sheet.add( ServiceGlobalizationUtil
.globalize("cms.contenttypes.ui.service.opening_times"),
Service.OPENING_TIMES);
sheet.add( ServiceGlobalizationUtil
.globalize("cms.contenttypes.ui.service.address"),
Service.ADDRESS);
sheet.add( ServiceGlobalizationUtil
.globalize("cms.contenttypes.ui.service.contacts"),
Service.CONTACTS);
return sheet; return sheet;
} }

View File

@ -30,15 +30,18 @@ import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.Service; import com.arsdigita.cms.contenttypes.Service;
import com.arsdigita.cms.contenttypes.util.ServiceGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.util.GlobalizationUtil;
/** /**
* Form to edit the basic properties of an service. This form can be extended to * Form to edit the basic properties of an service. This form can be extended to
* create forms for Service subclasses. * create forms for Service subclasses.
**/ */
public class ServicePropertyForm extends BasicPageForm public class ServicePropertyForm extends BasicPageForm
implements FormProcessListener, FormInitListener, FormSubmissionListener { implements FormProcessListener,
FormInitListener,
FormSubmissionListener {
private ServicePropertiesStep m_step; private ServicePropertiesStep m_step;
@ -73,7 +76,8 @@ public class ServicePropertyForm extends BasicPageForm
* Service to work on * Service to work on
* @param step The ServicePropertiesStep which controls this form. * @param step The ServicePropertiesStep which controls this form.
*/ */
public ServicePropertyForm( ItemSelectionModel itemModel, ServicePropertiesStep step ) { public ServicePropertyForm( ItemSelectionModel itemModel,
ServicePropertiesStep step ) {
super( ID, itemModel ); super( ID, itemModel );
m_step = step; m_step = step;
addSubmissionListener(this); addSubmissionListener(this);
@ -85,14 +89,16 @@ public class ServicePropertyForm extends BasicPageForm
protected void addWidgets() { protected void addWidgets() {
super.addWidgets(); super.addWidgets();
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.summary"))); add(new Label(GlobalizationUtil
.globalize("cms.contenttypes.ui.summary")));
ParameterModel summaryParam = new StringParameter(SUMMARY); ParameterModel summaryParam = new StringParameter(SUMMARY);
TextArea summary = new TextArea(summaryParam); TextArea summary = new TextArea(summaryParam);
summary.setCols(40); summary.setCols(40);
summary.setRows(5); summary.setRows(5);
add(summary); add(summary);
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.services_provided"))); add(new Label(ServiceGlobalizationUtil
.globalize("cms.contenttypes.ui.service.services_provided")));
ParameterModel servicesProvidedParam = ParameterModel servicesProvidedParam =
new StringParameter(SERVICES_PROVIDED); new StringParameter(SERVICES_PROVIDED);
TextArea servicesProvided = new TextArea(servicesProvidedParam); TextArea servicesProvided = new TextArea(servicesProvidedParam);
@ -100,14 +106,16 @@ public class ServicePropertyForm extends BasicPageForm
servicesProvided.setRows(5); servicesProvided.setRows(5);
add(servicesProvided); add(servicesProvided);
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.opening_times"))); add(new Label(ServiceGlobalizationUtil
.globalize("cms.contenttypes.ui.service.opening_times")));
ParameterModel openingTimesParam = new StringParameter(OPENING_TIMES); ParameterModel openingTimesParam = new StringParameter(OPENING_TIMES);
TextArea openingTimes = new TextArea(openingTimesParam); TextArea openingTimes = new TextArea(openingTimesParam);
openingTimes.setCols(40); openingTimes.setCols(40);
openingTimes.setRows(5); openingTimes.setRows(5);
add(openingTimes); add(openingTimes);
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.address"))); add(new Label(ServiceGlobalizationUtil
.globalize("cms.contenttypes.ui.service.address")));
ParameterModel addressParam = new StringParameter(ADDRESS); ParameterModel addressParam = new StringParameter(ADDRESS);
TextArea address = new TextArea(addressParam); TextArea address = new TextArea(addressParam);
address.setCols(40); address.setCols(40);
@ -115,7 +123,8 @@ public class ServicePropertyForm extends BasicPageForm
add(address); add(address);
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.contacts"))); add(new Label(ServiceGlobalizationUtil
.globalize("cms.contenttypes.ui.service.contacts")));
ParameterModel contactsParam = new StringParameter(CONTACTS); ParameterModel contactsParam = new StringParameter(CONTACTS);
TextArea contacts = new TextArea(contactsParam); TextArea contacts = new TextArea(contactsParam);
contacts.setCols(40); contacts.setCols(40);
@ -124,7 +133,9 @@ public class ServicePropertyForm extends BasicPageForm
} }
/** Form initialisation hook. Fills widgets with data. */ /**
* Form initialisation hook. Fills widgets with data.
*/
public void init(FormSectionEvent fse) { public void init(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
Service service = (Service) super.initBasicWidgets(fse); Service service = (Service) super.initBasicWidgets(fse);
@ -136,7 +147,9 @@ public class ServicePropertyForm extends BasicPageForm
data.put(CONTACTS, service.getContacts()); data.put(CONTACTS, service.getContacts());
} }
/** Cancels streamlined editing. */ /**
* Cancels streamlined editing.
*/
public void submitted( FormSectionEvent fse ) { public void submitted( FormSectionEvent fse ) {
if (m_step != null && if (m_step != null &&
getSaveCancelSection().getCancelButton() getSaveCancelSection().getCancelButton()
@ -145,7 +158,9 @@ public class ServicePropertyForm extends BasicPageForm
} }
} }
/** Form processing hook. Saves Service object. */ /**
* Form processing hook. Saves Service object.
*/
public void process(FormSectionEvent fse) { public void process(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();

View File

@ -0,0 +1,54 @@
/*
* Copyright (C) 2009 Jens Pelzetter, University of Bremen
*
* 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.contenttypes.util;
import com.arsdigita.globalization.Globalized;
import com.arsdigita.globalization.GlobalizedMessage;
/**
* Compilation of methods to simplify the handling of globalizing keys.
* Basically it adds the name of package's resource bundle files to the
* globalize methods and forwards to GlobalizedMessage, shortening the
* method invocation in the various application classes.
*
*/
public class ServiceGlobalizationUtil implements Globalized {
/** Name of Java resource files to handle PressRelease's globalisation. */
final public static String BUNDLE_NAME =
"com.arsdigita.cms.contenttypes.ServiceResources";
/**
* Returns a globalized message using the package specific bundle,
* provided by BUNDLE_NAME.
*/
public static GlobalizedMessage globalize (String key) {
return new GlobalizedMessage(key, BUNDLE_NAME);
}
/**
* Returns a globalized message object, using the package specific bundle,
* as specified by BUNDLE_NAME. Also takes in an Object[] of arguments to
* interpolate into the retrieved message using the MessageFormat class.
*/
public static GlobalizedMessage globalize (String key, Object[] args) {
return new GlobalizedMessage(key, BUNDLE_NAME, args);
}
}

View File

@ -45,8 +45,7 @@ public class DefaultImageBrowserModelBuilder extends LockableImpl
implements ImageBrowserModelBuilder, PaginationModelBuilder { implements ImageBrowserModelBuilder, PaginationModelBuilder {
private SingleSelectionModel m_keywordModel; private SingleSelectionModel m_keywordModel;
private static ImageBrowserModel EMPTY_MODEL = private static ImageBrowserModel EMPTY_MODEL = new EmptyImageBrowserModel();
new EmptyImageBrowserModel();
private ImageBrowser m_imageBrowser; private ImageBrowser m_imageBrowser;
private RequestLocal m_size; private RequestLocal m_size;
private String m_key; private String m_key;

View File

@ -25,11 +25,17 @@ import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.RequestEvent; import com.arsdigita.bebop.event.RequestEvent;
import com.arsdigita.bebop.event.RequestListener; import com.arsdigita.bebop.event.RequestListener;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.cms.ui.ContentItemPage; import com.arsdigita.cms.ui.ContentItemPage;
import com.arsdigita.cms.ui.SecurityPropertyEditor; import com.arsdigita.cms.ui.SecurityPropertyEditor;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.toolbox.ui.ComponentAccess; import com.arsdigita.toolbox.ui.ComponentAccess;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import java.text.DateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -98,14 +104,14 @@ public class SimpleEditStep extends SecurityPropertyEditor
* Construct a new SimpleEditStep component * Construct a new SimpleEditStep component
* *
* @param itemModel The {@link ItemSelectionModel} which will * @param itemModel The {@link ItemSelectionModel} which will
* be responsible for loading the current item * be responsible for loading the current item
* *
* @param parent The parent wizard which contains the form. * @param parent The parent wizard which contains the form. The component
* The component may use the wizard's methods, such as stepForward * may use the wizard's methods, such as stepForward
* and stepBack, in its process listener. * and stepBack, in its process listener.
* *
* @param paramSuffix Additional global parameter name suffix if * @param paramSuffix Additional global parameter name suffix if there are
* there are multiple SimpleEditStep instances in an authoring kit. * multiple SimpleEditStep instances in an authoring kit.
*/ */
public SimpleEditStep(ItemSelectionModel itemModel, public SimpleEditStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent, AuthoringKitWizard parent,
@ -229,4 +235,62 @@ public class SimpleEditStep extends SecurityPropertyEditor
} }
} }
/**
* Public class which implements an AttributeFormatter interface for
* boolean values.
* Its format(...) class returns a string representation for either a
* false or a true value.
*/
protected static class LaunchDateAttributeFormatter
implements DomainObjectPropertySheet.AttributeFormatter {
/**
* Constructor, does nothing.
*/
public LaunchDateAttributeFormatter() {
}
/**
* Formatter for the value of a (LaunchDate) attribute.
*
* It currently relays on the prerequisite that the passed in property
* attribute is in fact a date property. No type checking yet!
*
* Note: the format method has to be executed at each page request. Take
* care to properly adjust globalization and localization here!
*
* @param obj Object containing the attribute to format.
* @param attribute Name of the attribute to retrieve and format
* @param state PageState of the request
* @return A String representation of the retrieved boolean
* attribute of the domain object.
*/
public String format(DomainObject obj, String attribute, PageState state) {
if ( obj != null && obj instanceof ContentPage) {
ContentPage page = (ContentPage) obj;
Object field = page.get(attribute);
if( field != null ) {
// Note: No type safety here! We relay that it is
// attached to a date property!
return DateFormat.getDateInstance(
DateFormat.LONG,
GlobalizationHelper.getNegotiatedLocale()
)
.format(field);
} else {
return (String)GlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
return (String) GlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
} }

View File

@ -45,7 +45,7 @@ import org.apache.log4j.Logger;
* @author Michael Pih * @author Michael Pih
* @version $Id: OptionGroup.java 738 2005-09-01 12:36:52Z sskracic $ */ * @version $Id: OptionGroup.java 738 2005-09-01 12:36:52Z sskracic $ */
public abstract class OptionGroup extends Widget public abstract class OptionGroup extends Widget
implements BebopConstants { implements BebopConstants {
private static final Logger s_log = Logger.getLogger( OptionGroup.class ); private static final Logger s_log = Logger.getLogger( OptionGroup.class );

View File

@ -121,7 +121,8 @@ public class DomainObjectPropertySheet extends PropertySheet {
* *
* @param label The label for the attribute * @param label The label for the attribute
* @param attribute The name for the attribute. Could be a simple name * @param attribute The name for the attribute. Could be a simple name
* or a compound path, such as "foo.bar.baz" * or a compound path, such as "foo.bar.baz" (usually a
* PDL property)
* @deprecated use add(GlobalizedMessage label, String attribute) instead * @deprecated use add(GlobalizedMessage label, String attribute) instead
*/ */
public void add(String label, String attribute) { public void add(String label, String attribute) {
@ -134,7 +135,8 @@ public class DomainObjectPropertySheet extends PropertySheet {
* *
* @param label The label for the attribute * @param label The label for the attribute
* @param attribute The name for the attribute. Could be a simple name * @param attribute The name for the attribute. Could be a simple name
* or a compound path, such as "foo.bar.baz" * or a compound path, such as "foo.bar.baz" (usually a
* PDL property)
*/ */
public void add(GlobalizedMessage label, String attribute) { public void add(GlobalizedMessage label, String attribute) {
// Determine if we are dealing with a simple string or a complex // Determine if we are dealing with a simple string or a complex
@ -152,8 +154,11 @@ public class DomainObjectPropertySheet extends PropertySheet {
* to a String. * to a String.
* *
* @param label The label for the attribute * @param label The label for the attribute
* @param attribute The name for the attribute * @param attribute The name for the attribute. Could be a simple name
* or a compound path, such as "foo.bar.baz" (usually a
* PDL property)
* @param formatter An instance of AttributeFormatter * @param formatter An instance of AttributeFormatter
*
* @deprecated Use add(GlobalizedMessage label, String attribute, * @deprecated Use add(GlobalizedMessage label, String attribute,
* AttributeFormatter f) instead * AttributeFormatter f) instead
*/ */
@ -167,7 +172,9 @@ public class DomainObjectPropertySheet extends PropertySheet {
* to a String. * to a String.
* *
* @param label The label for the attribute * @param label The label for the attribute
* @param attribute The name for the attribute * @param attribute The name for the attribute. Could be a simple name
* or a compound path, such as "foo.bar.baz" (usually a
* PDL property)
* @param formatter An instance of AttributeFormatter * @param formatter An instance of AttributeFormatter
*/ */
public void add(GlobalizedMessage label, String attribute, public void add(GlobalizedMessage label, String attribute,
@ -190,7 +197,9 @@ public class DomainObjectPropertySheet extends PropertySheet {
} }
/** /**
* An interface which can transform some property to a string. * An interface which can transform the value of a (domain) property to a
* string.
*
* Most of the time, classes which implement this interface will just * Most of the time, classes which implement this interface will just
* return <code>object.get(attribute).toString()</code> * return <code>object.get(attribute).toString()</code>
* <p>In case of associations, however, more complicated processing * <p>In case of associations, however, more complicated processing
@ -199,16 +208,26 @@ public class DomainObjectPropertySheet extends PropertySheet {
public interface AttributeFormatter { public interface AttributeFormatter {
/** /**
* Retrieve the string value for the specified attribute * Formatter for the value of an attribute. It has to retrieve the value
* of the object. * for the specified attribute of the object and format it as an string
* if it is one already.
*
* Note: the format method has to be executed at each page request. Take
* care to properly adjust globalization and localization inside thes
* method and not earlier in one of the classes using it!
* *
* @param obj The domain object * @param obj Object containing the attribute to format.
* @param attribute The name of the attribute to get * @param attribute Name of the attribute to retrieve and format
* @param state PageState of the request
* @return A String representation of the retrieved attribute
* of the domain object.
*/ */
String format(DomainObject obj, String attribute, PageState state); String format(DomainObject obj, String attribute, PageState state);
} }
// Associates a label with the attribute and the formatter /**
* Associates a label with the attribute and the formatter.
*/
protected static class Property { protected static class Property {
private GlobalizedMessage m_label; private GlobalizedMessage m_label;