diff --git a/ccm-cms-types-article/src/com/arsdigita/cms/contenttypes/ui/ArticlePropertiesStep.java b/ccm-cms-types-article/src/com/arsdigita/cms/contenttypes/ui/ArticlePropertiesStep.java
index 8e0c5f0f0..681ef5b2b 100755
--- a/ccm-cms-types-article/src/com/arsdigita/cms/contenttypes/ui/ArticlePropertiesStep.java
+++ b/ccm-cms-types-article/src/com/arsdigita/cms/contenttypes/ui/ArticlePropertiesStep.java
@@ -55,7 +55,7 @@ public class ArticlePropertiesStep extends GenericArticlePropertiesStep {
BasicPageForm editSheet;
editSheet = new ArticlePropertyForm(itemModel, this);
add(EDIT_SHEET_NAME,
- "Edit",
+ "Edit", // curently add accepts just a String, not a Label
new WorkflowLockedComponentAccess(editSheet, itemModel),
editSheet.getSaveCancelSection().getCancelButton());
}
diff --git a/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertiesStep.java b/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertiesStep.java
index 4c943e7f6..5a09497d8 100755
--- a/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertiesStep.java
+++ b/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertiesStep.java
@@ -20,6 +20,8 @@ package com.arsdigita.cms.contenttypes.ui;
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.ItemSelectionModel;
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
* type (and its subclasses).
*/
-public class BookmarkPropertiesStep
- extends SimpleEditStep {
+public class BookmarkPropertiesStep extends SimpleEditStep {
/** The name of the editing sheet added to this step */
public static final String EDIT_SHEET_NAME = "edit";
@@ -67,16 +68,18 @@ public class BookmarkPropertiesStep
itemModel ) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( itemModel );
- // sheet.add( "Page Title:", Bookmark.TITLE );
sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.title"), Bookmark.TITLE );
- // sheet.add( "Name (URL):", Bookmark.NAME );
sheet.add(GlobalizationUtil
.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
.globalize("cms.contenttypes.ui.summary"), Bookmark.DESCRIPTION );
- // sheet.add( "URL:", Bookmark.URL );
sheet.add(new GlobalizedMessage
("cms.contenttypes.ui.bookmark.url",Bookmark.RESOURCES),
Bookmark.URL );
diff --git a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/ui/EventPropertiesStep.java b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/ui/EventPropertiesStep.java
index de314e630..5f0b5558f 100755
--- a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/ui/EventPropertiesStep.java
+++ b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/ui/EventPropertiesStep.java
@@ -29,6 +29,7 @@ import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
+import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
@@ -67,9 +68,10 @@ public class EventPropertiesStep extends SimpleEditStep {
BasicPageForm editSheet;
editSheet = new EventPropertyForm(itemModel, this);
- add(EDIT_SHEET_NAME, "Edit",
- new WorkflowLockedComponentAccess(editSheet, itemModel),
- editSheet.getSaveCancelSection().getCancelButton());
+ add(EDIT_SHEET_NAME,
+ "Edit",
+ new WorkflowLockedComponentAccess(editSheet, itemModel),
+ editSheet.getSaveCancelSection().getCancelButton());
setDisplayComponent(getEventPropertySheet(itemModel));
}
@@ -93,81 +95,20 @@ public class EventPropertiesStep extends SimpleEditStep {
.globalize("cms.contenttypes.ui.name"), Event.NAME);
sheet.add( EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.lead"), Event.LEAD);
- if (!ContentSection.getConfig().getHideLaunchDate()) {
- sheet.add(EventGlobalizationUtil
+ if (!ContentSection.getConfig().getHideLaunchDate()) {
+ sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.launch_date"),
- ContentPage.LAUNCH_DATE,
- new DomainObjectPropertySheet.AttributeFormatter() {
-
- 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();
- }
- }
- });
+ ContentPage.LAUNCH_DATE,
+ new LaunchDateAttributeFormatter() );
}
sheet.add( EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.start_time"), Event.START_DATE,
- new DomainObjectPropertySheet.AttributeFormatter() {
+ new DateTimeAttributeFormatter() );
- public String format(DomainObject item,
- String attribute,
- PageState state) {
- 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();
- }
- }
- });
+ sheet.add( EventGlobalizationUtil
+ .globalize("cms.contenttypes.ui.event.end_time"), Event.END_DATE,
+ new DateTimeAttributeFormatter() );
if (!Event.getConfig().getHideDateDescription()) {
sheet.add( EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.date_description"),
@@ -199,4 +140,63 @@ public class EventPropertiesStep extends SimpleEditStep {
}
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();
+ }
+ }
}
diff --git a/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertiesStep.java b/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertiesStep.java
index 6ff93777b..bbb293e5a 100755
--- a/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertiesStep.java
+++ b/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertiesStep.java
@@ -84,16 +84,24 @@ public class ImagePropertiesStep extends SimpleEditStep {
BasicPageForm editSheet;
m_imageComponentKey = new StringParameter("imageComponent");
- ParameterSingleSelectionModel componentModel = new ParameterSingleSelectionModel(m_imageComponentKey);
- m_imageComponent = new MapComponentSelectionModel(componentModel, new HashMap());
+ ParameterSingleSelectionModel componentModel =
+ new ParameterSingleSelectionModel(m_imageComponentKey);
+ m_imageComponent = new MapComponentSelectionModel(componentModel,
+ new HashMap());
Map selectors = m_imageComponent.getComponentsMap();
uploadSheet = new ImageUploadComponent();
uploadSheet.getForm().addProcessListener(new ImageUploadListerner());
selectors.put(UPLOAD, uploadSheet);
editSheet = new ImagePropertyForm(itemModel, this);
- add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel), editSheet.getSaveCancelSection().getCancelButton());
- add(UPLOAD_SHEET_NAME, "Upload", new WorkflowLockedComponentAccess(uploadSheet, itemModel), uploadSheet.getSaveCancelSection().getCancelButton());
+ add(EDIT_SHEET_NAME,
+ "Edit",
+ new WorkflowLockedComponentAccess(editSheet, itemModel),
+ editSheet.getSaveCancelSection().getCancelButton());
+ add(UPLOAD_SHEET_NAME,
+ "Upload",
+ new WorkflowLockedComponentAccess(uploadSheet, itemModel),
+ uploadSheet.getSaveCancelSection().getCancelButton());
setDisplayComponent(getImagePropertySheet(itemModel));
}
@@ -114,7 +122,12 @@ public class ImagePropertiesStep extends SimpleEditStep {
@Override
protected ImageAsset getImageAsset(PageState state) {
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;
} catch (NullPointerException ex) {
return null;
@@ -124,74 +137,40 @@ public class ImagePropertiesStep extends SimpleEditStep {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
- sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"), Image.TITLE);
- sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"),
+ sheet.add(GlobalizationUtil
+ .globalize("cms.contenttypes.ui.title"),
+ Image.TITLE);
+ sheet.add(GlobalizationUtil
+ .globalize("cms.contenttypes.ui.name"),
Image.NAME);
if (!ContentSection.getConfig().getHideLaunchDate()) {
- sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"),
- ContentPage.LAUNCH_DATE,
- new DomainObjectPropertySheet.AttributeFormatter() {
-
- @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(GlobalizationUtil
+ .globalize("cms.contenttypes.ui.launch_date"),
+ ContentPage.LAUNCH_DATE,
+ new LaunchDateAttributeFormatter() );
}
sheet.add(ImageGlobalizationUtil
- .globalize("cms.contenttypes.ui.image.width"), Image.WIDTH);
+ .globalize("cms.contenttypes.ui.image.width"),
+ Image.WIDTH);
sheet.add(ImageGlobalizationUtil
- .globalize("cms.contenttypes.ui.image.height"), Image.HEIGHT);
+ .globalize("cms.contenttypes.ui.image.height"),
+ Image.HEIGHT);
sheet.add(ImageGlobalizationUtil
- .globalize("cms.contenttypes.ui.image.caption"), Image.CAPTION);
+ .globalize("cms.contenttypes.ui.image.caption"),
+ Image.CAPTION);
sheet.add(GlobalizationUtil
- .globalize("cms.contenttypes.ui.description"), Image.DESCRIPTION);
+ .globalize("cms.contenttypes.ui.description"),
+ Image.DESCRIPTION);
sheet.add(ImageGlobalizationUtil
- .globalize("cms.contenttypes.ui.image.artist"), Image.ARTIST);
+ .globalize("cms.contenttypes.ui.image.artist"),
+ Image.ARTIST);
sheet.add(ImageGlobalizationUtil
.globalize("cms.contenttypes.ui.image.publishDate"),
Image.PUBLISHDATE,
- new DomainObjectPropertySheet.AttributeFormatter() {
-
- @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();
- }
- }
- });
+ new ImageDateAttributeFormatter()
+ );
sheet.add(ImageGlobalizationUtil.globalize(
"cms.contenttypes.ui.image.source"),
Image.SOURCE);
@@ -331,4 +310,78 @@ public class ImagePropertiesStep extends SimpleEditStep {
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();
+
+ }
+ }
}
diff --git a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEdit.java b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEdit.java
index 7a00c0381..a9a8cc2e1 100755
--- a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEdit.java
+++ b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEdit.java
@@ -86,19 +86,7 @@ public class MultiPartArticleEdit extends SimpleEditStep {
sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.launch_date"),
ContentPage.LAUNCH_DATE,
- new DomainObjectPropertySheet.AttributeFormatter() {
- 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";
- }
- }
- });
+ new LaunchDateAttributeFormatter() );
}
sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.summary"),
MultiPartArticle.SUMMARY );
diff --git a/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/Organization.java b/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/Organization.java
index 751da22e7..6a78bc244 100755
--- a/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/Organization.java
+++ b/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/Organization.java
@@ -43,8 +43,8 @@ public class Organization extends ContentPage {
public static final String IMAGE_ID = "imageID";
/** Data object type for tihs domain object */
- public static final String BASE_DATA_OBJECT_TYPE
- = "com.arsdigita.cms.contenttypes.Organization";
+ public static final String BASE_DATA_OBJECT_TYPE =
+ "com.arsdigita.cms.contenttypes.Organization";
public Organization () {
super(BASE_DATA_OBJECT_TYPE);
diff --git a/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/ui/OrganizationImageStep.java b/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/ui/OrganizationImageStep.java
index ff07640bf..196769cd2 100755
--- a/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/ui/OrganizationImageStep.java
+++ b/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/ui/OrganizationImageStep.java
@@ -64,7 +64,7 @@ public class OrganizationImageStep extends SimpleEditStep {
add( IMAGE_SHEET_NAME,
"Change (OrgImageStep)",
new WorkflowLockedComponentAccess(new OrganizationImageForm(
- "OrganizationImageForm", itemModel, this),
+ "OrganizationImageForm", itemModel, this),
itemModel));
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel, false);
diff --git a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressRelease.java b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressRelease.java
index 99d6a81fa..e73abcfbe 100755
--- a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressRelease.java
+++ b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressRelease.java
@@ -32,8 +32,8 @@ import java.math.BigDecimal;
* reference purposes. Reference code is an arbitrary string that is used for
* out-of-system reference. The type inherits name (filename), title, body
* (TextAsset), and metadata from
- * com.arsdigita.cms.contenttypes.Genericrticle, and also provides the
- * capability to associate contact information with this press release.
+ * com.arsdigita.cms.contenttypes.Genericrticle, and also provides
+ * the capability to associate contact information with this press release.
*
* @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?
// implements ContactSupport {
- /** PDL property name for contact info */
- public static final String CONTACT_INFO = "contactInfo";
/** PDL property name for 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 */
public static final String REFERENCE_CODE = "referenceCode";
/** 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() {
this(BASE_DATA_OBJECT_TYPE);
@@ -77,14 +78,6 @@ public class PressRelease extends GenericArticle {
}
/* accessors *****************************************************/
- public String getContactInfo() {
- return (String) get(CONTACT_INFO);
- }
-
- public void setContactInfo(String contactInfo) {
- set(CONTACT_INFO, contactInfo);
- }
-
public String getSummary() {
return (String) get(SUMMARY);
}
@@ -93,6 +86,14 @@ public class PressRelease extends GenericArticle {
set(SUMMARY, summary);
}
+ public String getContactInfo() {
+ return (String) get(CONTACT_INFO);
+ }
+
+ public void setContactInfo(String contactInfo) {
+ set(CONTACT_INFO, contactInfo);
+ }
+
public String getReferenceCode() {
return (String) get(REFERENCE_CODE);
}
diff --git a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources.properties b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources.properties
index dfa1073a0..586e9873a 100755
--- a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources.properties
+++ b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources.properties
@@ -1 +1,3 @@
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:
diff --git a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources_de.properties b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources_de.properties
index d266b095c..7a001d5c0 100644
--- a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources_de.properties
+++ b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources_de.properties
@@ -1 +1,3 @@
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:
diff --git a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources_fr.properties b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources_fr.properties
index dfa1073a0..92050c470 100644
--- a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources_fr.properties
+++ b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/PressReleaseResources_fr.properties
@@ -1 +1,3 @@
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:
diff --git a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/ui/PressReleasePropertiesStep.java b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/ui/PressReleasePropertiesStep.java
index b6af39e9b..7adc2d5aa 100755
--- a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/ui/PressReleasePropertiesStep.java
+++ b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/ui/PressReleasePropertiesStep.java
@@ -24,13 +24,14 @@ import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.PressRelease;
-import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
-import com.arsdigita.domain.DomainObject;
+import com.arsdigita.cms.contenttypes.util.PressReleaseGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.cms.util.GlobalizationUtil;
+import com.arsdigita.domain.DomainObject;
+import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import java.text.DateFormat;
@@ -39,13 +40,18 @@ import java.text.DateFormat;
* (and its subclasses). The attributes edited are 'name', 'title', 'release
* date' and 'reference code'. This authoring step replaces the
* com.arsdigita.ui.authoring.PageEdit step for this type.
- **/
-public class PressReleasePropertiesStep
- extends SimpleEditStep {
+ */
+public class PressReleasePropertiesStep extends SimpleEditStep {
/** The name of the editing sheet added to this step */
public static String EDIT_SHEET_NAME = "edit";
+ /**
+ * Constructor.
+ *
+ * @param itemModel
+ * @param parent
+ */
public PressReleasePropertiesStep( ItemSelectionModel itemModel,
AuthoringKitWizard parent ) {
super( itemModel, parent );
@@ -54,7 +60,12 @@ public class PressReleasePropertiesStep
BasicPageForm editSheet;
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() );
setDisplayComponent( getPressReleasePropertySheet( itemModel ) );
@@ -73,28 +84,27 @@ public class PressReleasePropertiesStep
itemModel ) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( itemModel );
- sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.name"), PressRelease.NAME);
- sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.contact_info"), PressRelease.CONTACT_INFO );
- sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.summary"), PressRelease.SUMMARY );
- sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"), 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()) {
- sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"),
+ sheet.add(GlobalizationUtil
+ .globalize("cms.contenttypes.ui.launch_date"),
ContentPage.LAUNCH_DATE,
- new DomainObjectPropertySheet.AttributeFormatter() {
- 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();
- }
- }
- });
+ new LaunchDateAttributeFormatter() );
}
- 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;
}
diff --git a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/ui/PressReleasePropertyForm.java b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/ui/PressReleasePropertyForm.java
index 2d2128330..a9a04b26b 100755
--- a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/ui/PressReleasePropertyForm.java
+++ b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/ui/PressReleasePropertyForm.java
@@ -32,6 +32,7 @@ import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.PressRelease;
+import com.arsdigita.cms.contenttypes.util.PressReleaseGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
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,
* release date and reference code. This form can be extended to create forms
* for PressRelease subclasses.
- **/
+ */
public class PressReleasePropertyForm extends BasicPageForm
- implements FormProcessListener, FormInitListener, FormSubmissionListener {
+ implements FormProcessListener,
+ FormInitListener,
+ FormSubmissionListener {
private PressReleasePropertiesStep m_step;
- /** contact info parameter name */
- public static final String CONTACT_INFO = "contactInfo";
/** summary parameter name */
public static final String SUMMARY = "summary";
+ /** contact info parameter name */
+ public static final String CONTACT_INFO = "contactInfo";
/** Reference code parameter name */
public static final String REF_CODE = "ref_code";
/** Release date parameter name */
@@ -73,7 +76,8 @@ public class PressReleasePropertyForm extends BasicPageForm
* PressRelease to work on
* @param step The PressReleasePropertiesStep which controls this form.
*/
- public PressReleasePropertyForm( ItemSelectionModel itemModel, PressReleasePropertiesStep step ) {
+ public PressReleasePropertyForm( ItemSelectionModel itemModel,
+ PressReleasePropertiesStep step ) {
super( ID, itemModel );
m_step = step;
addSubmissionListener(this);
@@ -85,21 +89,24 @@ public class PressReleasePropertyForm extends BasicPageForm
protected void addWidgets() {
super.addWidgets();
- add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.contact_info")));
- ParameterModel contactInfoParam = new StringParameter(CONTACT_INFO);
- CMSDHTMLEditor contactInfo = new CMSDHTMLEditor(contactInfoParam);
- contactInfo.setCols(40);
- contactInfo.setRows(10);
- add(contactInfo);
-
- add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.summary")));
+ add(new Label(GlobalizationUtil
+ .globalize("cms.contenttypes.ui.summary")));
ParameterModel summaryParam = new StringParameter(SUMMARY);
TextArea summary = new TextArea(summaryParam);
summary.setCols(40);
summary.setRows(7);
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);
TextField refCode = new TextField(refCodeParam);
refCode.setSize(30);
@@ -107,18 +114,22 @@ public class PressReleasePropertyForm extends BasicPageForm
add(refCode);
}
- /** Form initialisation hook. Fills widgets with data. */
+ /**
+ * Form initialisation hook. Fills widgets with data.
+ */
public void init(FormSectionEvent fse) {
FormData data = fse.getFormData();
PressRelease release
= (PressRelease) super.initBasicWidgets(fse);
- data.put(CONTACT_INFO, release.getContactInfo());
data.put(SUMMARY, release.getSummary());
+ data.put(CONTACT_INFO, release.getContactInfo());
data.put(REF_CODE, release.getReferenceCode());
}
- /** Cancels streamlined editing. */
+ /**
+ * Cancels streamlined editing.
+ */
public void submitted( FormSectionEvent fse ) {
if (m_step != null &&
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) {
FormData data = fse.getFormData();
@@ -138,9 +151,9 @@ public class PressReleasePropertyForm extends BasicPageForm
&& getSaveCancelSection().getSaveButton()
.isSelected(fse.getPageState())) {
- release.setReferenceCode((String) data.get(REF_CODE));
- release.setContactInfo((String) data.get(CONTACT_INFO));
release.setSummary((String) data.get(SUMMARY));
+ release.setContactInfo((String) data.get(CONTACT_INFO));
+ release.setReferenceCode((String) data.get(REF_CODE));
release.save();
}
if (m_step != null) {
diff --git a/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/util/PressReleaseGlobalizationUtil.java b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/util/PressReleaseGlobalizationUtil.java
new file mode 100644
index 000000000..ede720431
--- /dev/null
+++ b/ccm-cms-types-pressrelease/src/com/arsdigita/cms/contenttypes/util/PressReleaseGlobalizationUtil.java
@@ -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);
+ }
+}
\ No newline at end of file
diff --git a/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources.properties b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources.properties
index b10f15e72..8eeaa0675 100755
--- a/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources.properties
+++ b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources.properties
@@ -1 +1,5 @@
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:
diff --git a/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources_de.properties b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources_de.properties
index bc82bace3..d8af9fe4a 100644
--- a/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources_de.properties
+++ b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources_de.properties
@@ -1 +1,5 @@
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:
diff --git a/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources_fr.properties b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources_fr.properties
index b10f15e72..1735868eb 100644
--- a/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources_fr.properties
+++ b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ServiceResources_fr.properties
@@ -1 +1,5 @@
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:
diff --git a/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ui/ServicePropertiesStep.java b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ui/ServicePropertiesStep.java
index be61e784c..a4ae58b46 100755
--- a/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ui/ServicePropertiesStep.java
+++ b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ui/ServicePropertiesStep.java
@@ -25,6 +25,7 @@ import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.Service;
+import com.arsdigita.cms.contenttypes.util.ServiceGlobalizationUtil;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
@@ -56,7 +57,9 @@ public class ServicePropertiesStep extends SimpleEditStep {
BasicPageForm editSheet;
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());
setDisplayComponent(getServicePropertySheet(itemModel));
@@ -76,29 +79,33 @@ public class ServicePropertiesStep extends SimpleEditStep {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
- sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.name"), Service.NAME);
- sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.title"), Service.TITLE);
+ sheet.add( GlobalizationUtil
+ .globalize("cms.contenttypes.ui.title"),
+ Service.TITLE);
+ sheet.add( GlobalizationUtil
+ .globalize("cms.contenttypes.ui.name"),
+ Service.NAME);
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,
- new DomainObjectPropertySheet.AttributeFormatter() {
- 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();
- }
- }
- });
+ new LaunchDateAttributeFormatter() );
}
- sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.summary"), Service.SUMMARY);
- sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.services_provided"), Service.SERVICES_PROVIDED);
- sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.opening_times"), Service.OPENING_TIMES);
- sheet.add( GlobalizationUtil.globalize("cms.contenttypes.ui.contacts"), Service.CONTACTS);
+ sheet.add( GlobalizationUtil
+ .globalize("cms.contenttypes.ui.summary"),
+ Service.SUMMARY);
+ 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;
}
diff --git a/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ui/ServicePropertyForm.java b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ui/ServicePropertyForm.java
index e4f5260d6..a7dca50c4 100755
--- a/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ui/ServicePropertyForm.java
+++ b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/ui/ServicePropertyForm.java
@@ -30,15 +30,18 @@ import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.Service;
+import com.arsdigita.cms.contenttypes.util.ServiceGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.util.GlobalizationUtil;
/**
* Form to edit the basic properties of an service. This form can be extended to
* create forms for Service subclasses.
- **/
+ */
public class ServicePropertyForm extends BasicPageForm
- implements FormProcessListener, FormInitListener, FormSubmissionListener {
+ implements FormProcessListener,
+ FormInitListener,
+ FormSubmissionListener {
private ServicePropertiesStep m_step;
@@ -73,7 +76,8 @@ public class ServicePropertyForm extends BasicPageForm
* Service to work on
* @param step The ServicePropertiesStep which controls this form.
*/
- public ServicePropertyForm( ItemSelectionModel itemModel, ServicePropertiesStep step ) {
+ public ServicePropertyForm( ItemSelectionModel itemModel,
+ ServicePropertiesStep step ) {
super( ID, itemModel );
m_step = step;
addSubmissionListener(this);
@@ -85,14 +89,16 @@ public class ServicePropertyForm extends BasicPageForm
protected void 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);
TextArea summary = new TextArea(summaryParam);
summary.setCols(40);
summary.setRows(5);
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 =
new StringParameter(SERVICES_PROVIDED);
TextArea servicesProvided = new TextArea(servicesProvidedParam);
@@ -100,14 +106,16 @@ public class ServicePropertyForm extends BasicPageForm
servicesProvided.setRows(5);
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);
TextArea openingTimes = new TextArea(openingTimesParam);
openingTimes.setCols(40);
openingTimes.setRows(5);
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);
TextArea address = new TextArea(addressParam);
address.setCols(40);
@@ -115,7 +123,8 @@ public class ServicePropertyForm extends BasicPageForm
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);
TextArea contacts = new TextArea(contactsParam);
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) {
FormData data = fse.getFormData();
Service service = (Service) super.initBasicWidgets(fse);
@@ -136,7 +147,9 @@ public class ServicePropertyForm extends BasicPageForm
data.put(CONTACTS, service.getContacts());
}
- /** Cancels streamlined editing. */
+ /**
+ * Cancels streamlined editing.
+ */
public void submitted( FormSectionEvent fse ) {
if (m_step != null &&
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) {
FormData data = fse.getFormData();
diff --git a/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/util/ServiceGlobalizationUtil.java b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/util/ServiceGlobalizationUtil.java
new file mode 100644
index 000000000..a36eabd7e
--- /dev/null
+++ b/ccm-cms-types-service/src/com/arsdigita/cms/contenttypes/util/ServiceGlobalizationUtil.java
@@ -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);
+ }
+}
\ No newline at end of file
diff --git a/ccm-cms/src/com/arsdigita/cms/ui/DefaultImageBrowserModelBuilder.java b/ccm-cms/src/com/arsdigita/cms/ui/DefaultImageBrowserModelBuilder.java
index 482fb2e36..b136a2e23 100755
--- a/ccm-cms/src/com/arsdigita/cms/ui/DefaultImageBrowserModelBuilder.java
+++ b/ccm-cms/src/com/arsdigita/cms/ui/DefaultImageBrowserModelBuilder.java
@@ -45,8 +45,7 @@ public class DefaultImageBrowserModelBuilder extends LockableImpl
implements ImageBrowserModelBuilder, PaginationModelBuilder {
private SingleSelectionModel m_keywordModel;
- private static ImageBrowserModel EMPTY_MODEL =
- new EmptyImageBrowserModel();
+ private static ImageBrowserModel EMPTY_MODEL = new EmptyImageBrowserModel();
private ImageBrowser m_imageBrowser;
private RequestLocal m_size;
private String m_key;
diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/SimpleEditStep.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/SimpleEditStep.java
index 3e2185bd2..366495ddc 100755
--- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/SimpleEditStep.java
+++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/SimpleEditStep.java
@@ -25,11 +25,17 @@ import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.RequestEvent;
import com.arsdigita.bebop.event.RequestListener;
import com.arsdigita.bebop.parameters.StringParameter;
+import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.cms.ui.ContentItemPage;
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.DomainObjectPropertySheet;
+import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Iterator;
@@ -98,14 +104,14 @@ public class SimpleEditStep extends SecurityPropertyEditor
* Construct a new SimpleEditStep component
*
* @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.
- * The component may use the wizard's methods, such as stepForward
- * and stepBack, in its process listener.
+ * @param parent The parent wizard which contains the form. The component
+ * may use the wizard's methods, such as stepForward
+ * and stepBack, in its process listener.
*
- * @param paramSuffix Additional global parameter name suffix if
- * there are multiple SimpleEditStep instances in an authoring kit.
+ * @param paramSuffix Additional global parameter name suffix if there are
+ * multiple SimpleEditStep instances in an authoring kit.
*/
public SimpleEditStep(ItemSelectionModel itemModel,
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();
+ }
+ }
+
}
diff --git a/ccm-core/src/com/arsdigita/bebop/form/OptionGroup.java b/ccm-core/src/com/arsdigita/bebop/form/OptionGroup.java
index 6fb24abc9..c22b82750 100755
--- a/ccm-core/src/com/arsdigita/bebop/form/OptionGroup.java
+++ b/ccm-core/src/com/arsdigita/bebop/form/OptionGroup.java
@@ -45,7 +45,7 @@ import org.apache.log4j.Logger;
* @author Michael Pih
* @version $Id: OptionGroup.java 738 2005-09-01 12:36:52Z sskracic $ */
public abstract class OptionGroup extends Widget
- implements BebopConstants {
+ implements BebopConstants {
private static final Logger s_log = Logger.getLogger( OptionGroup.class );
diff --git a/ccm-core/src/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java b/ccm-core/src/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java
index 6abfa9cb3..6cd7b08ef 100755
--- a/ccm-core/src/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java
+++ b/ccm-core/src/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java
@@ -121,7 +121,8 @@ public class DomainObjectPropertySheet extends PropertySheet {
*
* @param label The label for the attribute
* @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
*/
public void add(String label, String attribute) {
@@ -134,7 +135,8 @@ public class DomainObjectPropertySheet extends PropertySheet {
*
* @param label The label for the attribute
* @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) {
// Determine if we are dealing with a simple string or a complex
@@ -152,8 +154,11 @@ public class DomainObjectPropertySheet extends PropertySheet {
* to a String.
*
* @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
+ *
* @deprecated Use add(GlobalizedMessage label, String attribute,
* AttributeFormatter f) instead
*/
@@ -167,7 +172,9 @@ public class DomainObjectPropertySheet extends PropertySheet {
* to a String.
*
* @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
*/
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
* return object.get(attribute).toString()
*
In case of associations, however, more complicated processing @@ -199,16 +208,26 @@ public class DomainObjectPropertySheet extends PropertySheet { public interface AttributeFormatter { /** - * Retrieve the string value for the specified attribute - * of the object. + * Formatter for the value of an attribute. It has to retrieve the value + * 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 attribute The name of the attribute to get + * @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 attribute + * of the domain object. */ 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 { private GlobalizedMessage m_label;