Weitere Verbesserungen Multilanguage Support.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2206 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2013-06-14 07:34:04 +00:00
parent 09ee19c021
commit 972b8dd775
20 changed files with 430 additions and 280 deletions

View File

@ -52,6 +52,10 @@ import java.util.Date;
**/
public class Agenda extends GenericArticle {
/** Data object type for this domain object (for CMS compatibility) */
private static final Logger s_log = Logger.getLogger(Logger.class);
// PDL stuff *************************************************************
/** PDL property name for summary */
public static final String SUMMARY = "summary";
/** PDL property name for agenda date */
@ -67,9 +71,8 @@ public class Agenda extends GenericArticle {
/** PDL property name for creation date */
public static final String CREATION_DATE = "creationDate";
/** Data object type for this domain object */
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Agenda";
/** Data object type for this domain object (for CMS compatibility) */
private static final Logger s_log = Logger.getLogger(Logger.class);
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.contenttypes.Agenda";
/**
* Default constructor. This creates a new (empty) Agenda.

View File

@ -21,10 +21,11 @@ package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.contenttypes.util.AgendaGlobalizationUtil;
import com.arsdigita.cms.contenttypes.Agenda;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.cms.contenttypes.Agenda;
import com.arsdigita.cms.contenttypes.util.AgendaGlobalizationUtil;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
@ -36,6 +37,7 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.globalization.GlobalizationHelper;
import java.text.DateFormat;
import java.util.Date;
/**
* Authoring step to edit the simple attributes of the Agenda content type (and
@ -62,7 +64,8 @@ public class AgendaPropertiesStep extends SimpleEditStep {
BasicPageForm editSheet;
editSheet = new AgendaPropertyForm(itemModel, this);
add(EDIT_SHEET_NAME, "Edit",
add(EDIT_SHEET_NAME,
"Edit",
new WorkflowLockedComponentAccess(editSheet, itemModel),
editSheet.getSaveCancelSection().getCancelButton() );
@ -88,57 +91,153 @@ public class AgendaPropertiesStep extends SimpleEditStep {
.globalize("cms.contenttypes.ui.name"), Agenda.NAME );
if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(AgendaGlobalizationUtil
.globalize("cms.ui.authoring.page_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,
GlobalizationHelper.getNegotiatedLocale())
.format(page.getLaunchDate());
} else {
return (String)AgendaGlobalizationUtil.globalize("cms.ui.unknown").localize();
}
}
});
new LaunchDateAttributeFormatter() );
}
sheet.add(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.summary"), Agenda.SUMMARY);
.globalize("cms.contenttypes.ui.summary"),
Agenda.SUMMARY);
sheet.add(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.agenda_date"), Agenda.AGENDA_DATE);
.globalize("cms.contenttypes.ui.agenda.agenda_date"),
Agenda.AGENDA_DATE,
new DateTimeAttributeFormatter());
sheet.add(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.location"), Agenda.LOCATION);
.globalize("cms.contenttypes.ui.agenda.location"),
Agenda.LOCATION);
sheet.add(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.attendees"), Agenda.ATTENDEES);
.globalize("cms.contenttypes.ui.agenda.attendees"),
Agenda.ATTENDEES);
sheet.add(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.subject_items"), Agenda.SUBJECT_ITEMS);
.globalize("cms.contenttypes.ui.agenda.subject_items"),
Agenda.SUBJECT_ITEMS);
sheet.add(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.contact_info"), Agenda.CONTACT_INFO);
.globalize("cms.contenttypes.ui.agenda.contact_info"),
Agenda.CONTACT_INFO);
sheet.add(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.creation_date"),
Agenda.AGENDA_DATE,
new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject item,
String attribute,
PageState state) {
Agenda agenda = (Agenda) item;
if(agenda.getCreationDate() != null) {
return DateFormat.getDateInstance(
DateFormat.LONG,
GlobalizationHelper.getNegotiatedLocale())
.format(agenda.getCreationDate());
} else {
return (String)AgendaGlobalizationUtil
.globalize("cms.ui.unknown").localize();
}
}
});
Agenda.CREATION_DATE,
new DateAttributeFormatter() );
return sheet;
}
/**
* Private class which implements an AttributeFormatter interface for
* Agenda's date values.
* Its format(...) class returns a string representation for either a
* false or a true value.
*/
private static class DateAttributeFormatter
implements DomainObjectPropertySheet.AttributeFormatter {
/**
* Constructor, does nothing.
*/
public DateAttributeFormatter() {
}
/**
* 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 Agenda) {
Agenda agenda = (Agenda) obj;
Object field = agenda.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();
}
}
/**
* 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 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 Agenda) {
Agenda agenda = (Agenda) obj;
Object field = agenda.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

@ -99,7 +99,8 @@ public class AgendaPropertyForm extends BasicPageForm
protected void addWidgets() {
super.addWidgets();
add(new Label(AgendaGlobalizationUtil.globalize("cms.contenttypes.ui.summary")));
add(new Label(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.summary")));
ParameterModel summaryParam = new StringParameter(SUMMARY);
//summaryParam
// .addParameterListener(new NotNullValidationListener());
@ -109,14 +110,16 @@ public class AgendaPropertyForm extends BasicPageForm
summary.setRows(5);
add(summary);
add(new Label(AgendaGlobalizationUtil.globalize("cms.contenttypes.ui.agenda.agenda_date")));
add(new Label(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.agenda_date")));
ParameterModel agendaDateParam = new DateTimeParameter(AGENDA_DATE);
agendaDateParam
.addParameterListener(new NotNullValidationListener());
DateTime agendaDate = new DateTime(agendaDateParam);
add(agendaDate);
add(new Label(AgendaGlobalizationUtil.globalize("cms.contenttypes.ui.agenda.location")));
add(new Label(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.location")));
ParameterModel locationParam = new StringParameter(LOCATION);
//locationParam
// .addParameterListener(new NotNullValidationListener());
@ -126,7 +129,8 @@ public class AgendaPropertyForm extends BasicPageForm
location.setRows(3);
add(location);
add(new Label(AgendaGlobalizationUtil.globalize("cms.contenttypes.ui.agenda.attendees")));
add(new Label(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.attendees")));
ParameterModel attendeesParam = new StringParameter(ATTENDEES);
//attendeesParam
// .addParameterListener(new NotNullValidationListener());
@ -136,7 +140,8 @@ public class AgendaPropertyForm extends BasicPageForm
attendees.setRows(3);
add(attendees);
add(new Label(AgendaGlobalizationUtil.globalize("cms.contenttypes.ui.agenda.subject_items")));
add(new Label(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.subject_items")));
ParameterModel subjectItemsParam = new StringParameter(SUBJECT_ITEMS);
//subjectItemsParam
// .addParameterListener(new NotNullValidationListener());
@ -146,7 +151,8 @@ public class AgendaPropertyForm extends BasicPageForm
subjectItems.setRows(3);
add(subjectItems);
add(new Label(AgendaGlobalizationUtil.globalize("cms.contenttypes.ui.agenda.contact_info")));
add(new Label(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.contact_info")));
ParameterModel contactInfoParam = new StringParameter(CONTACT_INFO);
//contactInfoParam
// .addParameterListener(new NotNullValidationListener());
@ -156,7 +162,8 @@ public class AgendaPropertyForm extends BasicPageForm
contactInfo.setRows(3);
add(contactInfo);
add(new Label(AgendaGlobalizationUtil.globalize("cms.contenttypes.ui.agenda.creation_date")));
add(new Label(AgendaGlobalizationUtil
.globalize("cms.contenttypes.ui.agenda.creation_date")));
ParameterModel creationDateParam = new DateParameter(CREATION_DATE);
creationDateParam
.addParameterListener(new NotNullValidationListener());
@ -201,12 +208,11 @@ public class AgendaPropertyForm extends BasicPageForm
/**
* Form processing hook. Saves Agenda object.
**/
*/
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
Agenda agenda
= (Agenda) super.processBasicWidgets(fse);
Agenda agenda = (Agenda) super.processBasicWidgets(fse);
// save only if save button was pressed
if (agenda != null

View File

@ -21,6 +21,8 @@ package com.arsdigita.cms.contenttypes.ui.authoring;
import com.arsdigita.cms.contenttypes.FileStorageItem;
import com.arsdigita.cms.contenttypes.ui.FileStorageItemPropertyForm;
import com.arsdigita.bebop.Component;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
@ -70,12 +72,18 @@ public class FileStorageItemPropertiesStep
itemModel ) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( itemModel );
sheet.add( GlobalizationUtil
.globalize("cms.ui.authoring.title"), FileStorageItem.TITLE );
sheet.add(GlobalizationUtil
.globalize("cms.ui.authoring.name"), FileStorageItem.NAME );
sheet.add( GlobalizationUtil
.globalize("cms.ui.authoring.title"), FileStorageItem.TITLE );
sheet.add( GlobalizationUtil
.globalize("cms.contenttypes.ui.summary"), FileStorageItem.DESCRIPTION );
if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.launch_date"),
ContentPage.LAUNCH_DATE,
new LaunchDateAttributeFormatter() );
}
return sheet;
}

View File

@ -36,7 +36,8 @@ import com.arsdigita.domain.DomainObject;
import java.text.DateFormat;
/**
* Authoring step to edit the simple attributes of the InlineSite content type (and its subclasses).
* Authoring step to edit the simple attributes of the InlineSite content type
* (and its subclasses).
*/
public class InlineSitePropertiesStep extends SimpleEditStep {
@ -75,25 +76,9 @@ public class InlineSitePropertiesStep extends SimpleEditStep {
if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(GlobalizationUtil
.globalize("cms.contenttypes.ui.launch_date"),
.globalize("cms.contenttypes.ui.launch_date"),
ContentPage.LAUNCH_DATE,
new DomainObjectPropertySheet.AttributeFormatter() {
@Override
public String format(final DomainObject item,
final String attribute,
final 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"),

View File

@ -26,13 +26,14 @@ import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.Job;
import com.arsdigita.cms.contenttypes.util.JobGlobalizationUtil;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
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;
import java.text.DateFormat;
@ -89,27 +90,14 @@ public class JobPropertiesStep extends SimpleEditStep {
Job.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() );
}
// Job content type currently does not use the default
// basic descriuption properties (as persisted in cms-pages and by
// basic description properties (as persisted in cms-pages and by
// default part of the object list). Would be convenient to move the
// ct specific overview property to basic description.
sheet.add( JobGlobalizationUtil
@ -122,22 +110,7 @@ public class JobPropertiesStep extends SimpleEditStep {
sheet.add( JobGlobalizationUtil
.globalize("cms.contenttypes.ui.job.closing_date"),
Job.CLOSING_DATE,
new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject item,
String attribute,
PageState state) {
Job job = (Job) item;
if(job.getClosingDate() != null) {
return DateFormat.getDateInstance(DateFormat.LONG)
.format(job.getClosingDate());
} else {
return (String)GlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
});
new JobDateAttributeFormatter() );
sheet.add( JobGlobalizationUtil
.globalize("cms.contenttypes.ui.job.salary"),
Job.SALARY);
@ -159,4 +132,62 @@ public class JobPropertiesStep extends SimpleEditStep {
return sheet;
}
/**
* 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 JobDateAttributeFormatter
implements DomainObjectPropertySheet.AttributeFormatter {
/**
* Constructor, does nothing.
*/
public JobDateAttributeFormatter() {
}
/**
* 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 Job) {
Job job = (Job) obj;
Object field = job.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

@ -86,21 +86,7 @@ public class LegalNoticePropertiesStep 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 (String)GlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
});
new LaunchDateAttributeFormatter() );
}
sheet.add( LegalNoticeGlobalizationUtil
.globalize("cms.contenttypes.ui.legal_notice.government_uid"),

View File

@ -56,7 +56,9 @@ public class MinutesPropertiesStep extends SimpleEditStep {
BasicPageForm editSheet;
editSheet = new MinutesPropertyForm(itemModel,this);
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel),
add(EDIT_SHEET_NAME,
"Edit",
new WorkflowLockedComponentAccess(editSheet, itemModel),
editSheet.getSaveCancelSection().getCancelButton());
setDisplayComponent(getMinutesPropertySheet(itemModel));
@ -86,21 +88,7 @@ public class MinutesPropertiesStep 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 (String)GlobalizationUtil
.globalize("cms.ui.unknown")
.localize();
}
}
});
new LaunchDateAttributeFormatter() );
}
sheet.add( MinutesGlobalizationUtil
.globalize("cms.contenttypes.ui.minutes.reference"),

View File

@ -31,6 +31,7 @@ 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.contenttypes.util.NewsItemGlobalizationUtil;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.globalization.GlobalizationHelper;
@ -57,9 +58,10 @@ public class NewsItemPropertiesStep extends SimpleEditStep {
BasicPageForm editSheet;
editSheet = new NewsItemPropertyForm(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(getNewsDomainObjectPropertySheet(itemModel));
}
@ -84,27 +86,10 @@ public class NewsItemPropertiesStep extends SimpleEditStep {
.globalize("cms.contenttypes.ui.newsitem.lead"), NewsItem.LEAD);
if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(NewsItemGlobalizationUtil.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,
GlobalizationHelper.getNegotiatedLocale())
.format(page.getLaunchDate());
} else {
return (String) NewsItemGlobalizationUtil
.globalize("cms.contenttypes.ui.newsitem.unknown")
.localize();
}
}
});
new LaunchDateAttributeFormatter() );
}
// Show news item on homepage?
@ -135,25 +120,66 @@ public class NewsItemPropertiesStep extends SimpleEditStep {
sheet.add(NewsItemGlobalizationUtil.globalize(
"cms.contenttypes.ui.newsitem.news_date"),
NewsItem.NEWS_DATE,
new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject item,
String attribute,
PageState state) {
NewsItem pr = (NewsItem) item;
if (pr.getNewsDate() != null) {
return DateFormat.getDateInstance(
DateFormat.LONG,
GlobalizationHelper.getNegotiatedLocale())
.format(pr.getNewsDate());
} else {
return (String) NewsItemGlobalizationUtil
.globalize("cms.contenttypes.ui.newsitem.unknown")
.localize();
}
}
});
new NewsItemDateAttributeFormatter() );
return sheet;
}
/**
* Private class which implements an AttributeFormatter interface for
* NewsItem's date values.
* Its format(...) class returns a string representation for either a
* false or a true value.
*/
private static class NewsItemDateAttributeFormatter
implements DomainObjectPropertySheet.AttributeFormatter {
/**
* Constructor, does nothing.
*/
public NewsItemDateAttributeFormatter() {
}
/**
* 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 NewsItem) {
NewsItem newsItem = (NewsItem) obj;
Object field = newsItem.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

@ -48,11 +48,15 @@ public class SiteProxy extends ContentPage {
public static final String USED_IN_ATOZ = "usedInAtoZ";
/** Data object type for this domain object */
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.SiteProxy";
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.contenttypes.SiteProxy";
/** Data object type for this domain object (for CMS compatibility) */
public static final String TYPE = BASE_DATA_OBJECT_TYPE;
/**
* Default Constructor.
*/
public SiteProxy() {
this(BASE_DATA_OBJECT_TYPE);
try {

View File

@ -10,3 +10,5 @@ cms.contenttypes.ui.siteproxy.label.usedinatoz=Used in AtoZ
cms.contenttypes.ui.siteproxy.option.usedinatoz.yes=Yes
cms.contenttypes.ui.siteproxy.option.usedinatoz.no=No
cms.contenttypes.ui.siteproxy.link.editatoz=Edit
#URL:
cms.contenttypes.ui.siteproxy.url=URL:

View File

@ -9,4 +9,6 @@ cms.contenttypes.ui.siteproxy.label.atoztitle=AtoZ Titel
cms.contenttypes.ui.siteproxy.label.usedinatoz=In AtoZ benutzen
cms.contenttypes.ui.siteproxy.option.usedinatoz.yes=Ja
cms.contenttypes.ui.siteproxy.option.usedinatoz.no=Nein
cms.contenttypes.ui.siteproxy.link.editatoz=Editieren
cms.contenttypes.ui.siteproxy.link.editatoz=Bearbeiten
#URL:
cms.contenttypes.ui.siteproxy.url=URL:

View File

@ -10,3 +10,5 @@ cms.contenttypes.ui.siteproxy.label.usedinatoz=Used in AtoZ
cms.contenttypes.ui.siteproxy.option.usedinatoz.yes=Yes
cms.contenttypes.ui.siteproxy.option.usedinatoz.no=No
cms.contenttypes.ui.siteproxy.link.editatoz=Edit
#URL:
cms.contenttypes.ui.siteproxy.url=URL:

View File

@ -1,29 +0,0 @@
/*
* Copyright (C) 2004 Red Hat Inc. All Rights Reserved.
*
* 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.ui;
interface Constants {
/* Globalization constants */
static final String LABEL_TITLE_ATOZ = "cms.contenttypes.ui.siteproxy.label.atoztitle";
static final String LABEL_USED_IN_ATOZ = "cms.contenttypes.ui.siteproxy.label.usedinatoz";
static final String OPTION_USED_IN_ATOZ_YES = "cms.contenttypes.ui.siteproxy.option.usedinatoz.yes";
static final String OPTION_USED_IN_ATOZ_NO = "cms.contenttypes.ui.siteproxy.option.usedinatoz.no";
}

View File

@ -33,29 +33,31 @@ import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
/**
* Authoring step to edit the simple attributes for the SiteProxy content
* connection to new AtoZ
* connection to new AtoZ.
*/
public class SiteProxyAtoZPropertiesStep extends SimpleEditStep {
/** The name of the editing sheet added to this step */
public static final String EDIT_ATOZ_SHEET_NAME = "editAtoZ";
public static final String LINK_EDIT = "cms.contenttypes.ui.siteproxy.link.editatoz";
/**
* @param itemModel
* @param parent
*/
public SiteProxyAtoZPropertiesStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
super(itemModel, parent);
* Constructor.
*
* @param itemModel
* @param parent
*/
public SiteProxyAtoZPropertiesStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
BasicItemForm form;
super(itemModel, parent);
form = new SiteProxyAtoZPropertyForm(itemModel);
add(EDIT_ATOZ_SHEET_NAME, SiteProxyGlobalizationUtil.globalize(
LINK_EDIT).localize().toString(),
new WorkflowLockedComponentAccess(form, itemModel), form
BasicItemForm form;
form = new SiteProxyAtoZPropertyForm(itemModel);
add(EDIT_ATOZ_SHEET_NAME,
SiteProxyGlobalizationUtil.globalize(
"cms.contenttypes.ui.siteproxy.link.editatoz").localize().toString(),
new WorkflowLockedComponentAccess(form, itemModel), form
.getSaveCancelSection().getCancelButton());
setDisplayComponent(getSiteProxyAtoZPropertySheet(itemModel));
@ -72,40 +74,55 @@ public class SiteProxyAtoZPropertiesStep extends SimpleEditStep {
* properties of the release
*/
public static Component getSiteProxyAtoZPropertySheet(
ItemSelectionModel itemModel) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
ItemSelectionModel itemModel) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
itemModel);
sheet.add(SiteProxyGlobalizationUtil
.globalize(Constants.LABEL_TITLE_ATOZ), SiteProxy.TITLE_ATOZ);
.globalize("cms.contenttypes.ui.siteproxy.label.atoztitle"),
SiteProxy.TITLE_ATOZ);
sheet.add(SiteProxyGlobalizationUtil
.globalize(Constants.LABEL_USED_IN_ATOZ),
SiteProxy.USED_IN_ATOZ, new BooleanAttributeFormater(
(String) SiteProxyGlobalizationUtil.globalize(
Constants.OPTION_USED_IN_ATOZ_YES).localize(),
(String) SiteProxyGlobalizationUtil.globalize(
Constants.OPTION_USED_IN_ATOZ_NO).localize()));
.globalize("cms.contenttypes.ui.siteproxy.label.usedinatoz"),
SiteProxy.USED_IN_ATOZ,
new BooleanAttributeFormater());
return sheet;
}
private static class BooleanAttributeFormater implements
DomainObjectPropertySheet.AttributeFormatter {
/**
* 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 BooleanAttributeFormater
implements DomainObjectPropertySheet.AttributeFormatter {
private static final String DEFAULT = "-";
/** Default value just in case there is no value at all. */
private static final String DEFAULT = "-";
private String trueValue;
/**
* Constructor, does nothing.
*/
public BooleanAttributeFormater() {
}
private String falseValue;
public BooleanAttributeFormater(String trueValue, String falseValue) {
this.trueValue = trueValue;
this.falseValue = falseValue;
}
public String format(DomainObject obj, String attribute, PageState state) {
if (obj == null)
/**
* Formatter for the value of an attribute.
*
* 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)
return BooleanAttributeFormater.DEFAULT;
if ((obj instanceof ContentItem)) {
@ -116,10 +133,19 @@ public class SiteProxyAtoZPropertiesStep extends SimpleEditStep {
if (field instanceof Boolean) {
Boolean value = (Boolean) contentItem.get(attribute);
if (value.booleanValue())
return trueValue;
else
return falseValue;
if (value.booleanValue()) {
return (String) SiteProxyGlobalizationUtil.globalize(
"cms.contenttypes.ui.siteproxy.option.usedinatoz.yes")
.localize();
} else {
return (String) SiteProxyGlobalizationUtil.globalize(
"cms.contenttypes.ui.siteproxy.option.usedinatoz.no")
.localize();
}
}
}
return BooleanAttributeFormater.DEFAULT;

View File

@ -59,24 +59,28 @@ public class SiteProxyAtoZPropertyForm extends BasicItemForm {
/**
* Adds widgets to the form.
*/
@Override
protected void addWidgets() {
add(new Label(SiteProxyGlobalizationUtil
.globalize(Constants.LABEL_TITLE_ATOZ)));
add(new Label(SiteProxyGlobalizationUtil
.globalize("cms.contenttypes.ui.siteproxy.label.atoztitle")));
m_title_atoz = new TextField(SiteProxy.TITLE_ATOZ);
m_title_atoz.setSize(50);
add(m_title_atoz);
add(new Label(SiteProxyGlobalizationUtil
.globalize(Constants.LABEL_USED_IN_ATOZ)));
add(new Label(SiteProxyGlobalizationUtil
.globalize("cms.contenttypes.ui.siteproxy.label.usedinatoz")));
m_radiogroupUsedInAtoZ = new RadioGroup(SiteProxy.USED_IN_ATOZ);
m_radiogroupUsedInAtoZ.addOption(new Option(Boolean.TRUE.toString(),
SiteProxyGlobalizationUtil.globalize(
Constants.OPTION_USED_IN_ATOZ_YES).localize()
.toString()));
m_radiogroupUsedInAtoZ
.addOption(new Option(Boolean.FALSE.toString(),
SiteProxyGlobalizationUtil.globalize(
Constants.OPTION_USED_IN_ATOZ_NO).localize()
.toString()));
m_radiogroupUsedInAtoZ.addOption(new
Option(Boolean.TRUE.toString(),
new Label( SiteProxyGlobalizationUtil.globalize(
"cms.contenttypes.ui.siteproxy.option.usedinatoz.yes"))
));
m_radiogroupUsedInAtoZ.addOption(new
Option(Boolean.FALSE.toString(),
new Label( SiteProxyGlobalizationUtil.globalize(
"cms.contenttypes.ui.siteproxy.option.usedinatoz.no"))
));
add(m_radiogroupUsedInAtoZ);
}

View File

@ -26,6 +26,7 @@ import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.util.SiteProxyGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
@ -62,8 +63,9 @@ public class SiteProxyPropertiesStep extends SimpleEditStep {
}
/**
* Returns a component that displays the properties of the
* SiteProxy specified by the ItemSelectionModel passed in.
* Returns a component that displays the properties of the SiteProxy
* specified by the ItemSelectionModel passed in.
*
* @param itemModel The ItemSelectionModel to use
* @pre itemModel != null
* @return A component to display the state of the basic properties
@ -73,14 +75,14 @@ public class SiteProxyPropertiesStep extends SimpleEditStep {
itemModel ) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( itemModel );
sheet.add( SiteProxyGlobalizationUtil
sheet.add( GlobalizationUtil
.globalize("cms.contenttypes.ui.title"),
SiteProxy.TITLE );
sheet.add( SiteProxyGlobalizationUtil
sheet.add( GlobalizationUtil
.globalize("cms.contenttypes.ui.name"),
SiteProxy.NAME );
sheet.add( SiteProxyGlobalizationUtil
.globalize("cms.contenttypes.ui.url"),
.globalize("cms.contenttypes.ui.siteproxy.url"),
SiteProxy.URL );
return sheet;

View File

@ -39,10 +39,12 @@ public class XMLFeedProperties extends FormProperties {
super(model, parent);
}
@Override
protected BasicPageForm buildEditForm(ItemSelectionModel model) {
return new XMLFeedPropertyEditForm(model);
}
@Override
protected Component buildDisplayComponent(ItemSelectionModel model) {
return new XMLFeedPropertySheet(model);
}
@ -55,6 +57,7 @@ public class XMLFeedProperties extends FormProperties {
super(model);
}
@Override
protected void addWidgets() {
super.addWidgets();
@ -66,6 +69,7 @@ public class XMLFeedProperties extends FormProperties {
add(m_url);
}
@Override
public ContentPage initBasicWidgets(FormSectionEvent e) {
XMLFeed item = (XMLFeed)super.initBasicWidgets(e);
@ -74,6 +78,7 @@ public class XMLFeedProperties extends FormProperties {
}
@Override
public ContentPage processBasicWidgets(FormSectionEvent e) {
XMLFeed item = (XMLFeed)super.processBasicWidgets(e);

View File

@ -68,9 +68,9 @@ import org.apache.log4j.Logger;
/**
* <p>
* This class represents the authoring step for the
* {@link XmlFeed XmlFeed} that allows you to associate the correct XSL file to
* allow the feed to be transformed into HTML.
* This class represents the authoring step for the {@link XmlFeed XmlFeed}
* that allows you to associate the correct XSL file to allow the feed to
* be transformed into HTML.
* </p>
*
* <p>

View File

@ -71,14 +71,14 @@ public class ContactPropertiesStep extends SimpleEditStep {
public static Component getContactPropertySheet(ItemSelectionModel itemModel) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
sheet.add(
GlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.name"),
Contact.NAME);
sheet.add(
GlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.title"),
Contact.TITLE);
sheet.add(
GlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.name"),
Contact.NAME);
sheet.add(
ContactGlobalizationUtil.globalize(
"com.arsdigita.london.contenttypes.ui.contact_givenname"),