Replaced Label widget by setLabel / setHint for CT Event, some reformatting and documentation added.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2735 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2014-07-02 20:42:52 +00:00
parent 740f9b208a
commit 7cdf763aff
10 changed files with 209 additions and 110 deletions

View File

@ -20,7 +20,7 @@
package com.arsdigita.cms.contenttypes; package com.arsdigita.cms.contenttypes;
/** /**
* Loader executes nonrecurring once at install time and loads the e-Form * Loader executes nonrecurring once at install time and loads the Address
* contenttype package persistently into database. * contenttype package persistently into database.
* *
* It uses the base class to create the database schema and the required * It uses the base class to create the database schema and the required
@ -48,6 +48,7 @@ public class AddressLoader extends AbstractContentTypeLoader {
* *
* @return String Atring Array of fully qualified file names * @return String Atring Array of fully qualified file names
*/ */
@Override
public String[] getTypes() { public String[] getTypes() {
return TYPES; return TYPES;
} }

View File

@ -22,3 +22,5 @@ cms.contenttypes.ui.event.cost=Cost:
cms.contenttypes.ui.event.there_are_no_events=There are no events. cms.contenttypes.ui.event.there_are_no_events=There are no events.
cms.contenttypes.event.type_label=Event cms.contenttypes.event.type_label=Event
cms.contenttypes.event_type_not_registered=Type not registered cms.contenttypes.event_type_not_registered=Type not registered
cms.contenttypes.ui.event.lead_hint=A short description of the focus of the event and its main topic. Should be no longer than 2-3 sentences. The lead text will be displayed in the detail view of the event as well as in listings of events.
cms.contenttypes.ui.event.end_date_hint=Optionally enter an end date. It is displayed on the detail view as well as in listings of other short references.

View File

@ -23,3 +23,5 @@ cms.contenttypes.ui.event.cost=Kosten:
cms.contenttypes.ui.event.there_are_no_events=Es sind keine Veranstaltungen vorhanden. cms.contenttypes.ui.event.there_are_no_events=Es sind keine Veranstaltungen vorhanden.
cms.contenttypes.event.type_label=Veranstaltung cms.contenttypes.event.type_label=Veranstaltung
cms.contenttypes.event_type_not_registered=Typ nicht registriert cms.contenttypes.event_type_not_registered=Typ nicht registriert
cms.contenttypes.ui.event.lead_hint=Kurze Beschreibung der Veranstaltung und ihres zentralen Themas. Die L\u00e4nge sollte maximal 2-3 S\u00e4tze betragen. Die Zusammenfassung wird sowohl in der Vollansicht der Veranstaltung als auch in allen Teilsichten und Listen angezeigt.
cms.contenttypes.ui.event.end_date_hint=Ein optionales Enddatum; es wird sowohl in der Vollansicht als auch in allen Listen und sonstigen Referencen angezeigt.

View File

@ -23,3 +23,5 @@ cms.contenttypes.ui.event.link_to_map=Link to Map
cms.contenttypes.ui.event.cost=Cost: cms.contenttypes.ui.event.cost=Cost:
cms.contenttypes.ui.event.there_are_no_events=Il n'y a aucun \u00e9venement cms.contenttypes.ui.event.there_are_no_events=Il n'y a aucun \u00e9venement
cms.contenttypes.event.type_label=Event cms.contenttypes.event.type_label=Event
cms.contenttypes.ui.event.lead_hint=A short description of the focus of the event and its main topic. Should be no longer than 2-3 sentences. The lead text will be displayed in the detail view of the event as well as in listings of events.
cms.contenttypes.ui.event.end_date_hint=Optionally enter an end date. It is displayed on the detail view as well as in listings of other short references.

View File

@ -35,8 +35,6 @@ import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
/** /**
* Authoring step to view/edit the simple attributes of the Event content type (and * Authoring step to view/edit the simple attributes of the Event content type (and

View File

@ -117,69 +117,93 @@ public class EventPropertyForm extends BasicPageForm
super.addWidgets(); super.addWidgets();
/* Summary (lead) */ /* Summary (lead) */
add(new Label(EventGlobalizationUtil // add(new Label(EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.lead")) ); // .globalize("cms.contenttypes.ui.event.lead")) );
ParameterModel leadParam = new StringParameter(LEAD); ParameterModel leadParam = new StringParameter(LEAD);
if(Event.getConfig().isLeadTextOptional()) { if(Event.getConfig().isLeadTextOptional()) {
leadParam.addParameterListener(new NotNullValidationListener()); leadParam.addParameterListener(new NotNullValidationListener());
} }
TextArea lead = new TextArea(leadParam); TextArea lead = new TextArea(leadParam);
lead.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.lead"));
lead.setCols(50); lead.setCols(50);
lead.setRows(5); lead.setRows(5);
add(lead); add(lead);
/* Start date and time */ /* Start date and time */
// add(new Label(EventGlobalizationUtil
// .globalize("cms.contenttypes.ui.event.start_date")) );
ParameterModel eventStartDateParam = new DateParameter(START_DATE); ParameterModel eventStartDateParam = new DateParameter(START_DATE);
add(new Label(EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.start_date")) );
eventStartDateParam.addParameterListener(new NotNullValidationListener()); eventStartDateParam.addParameterListener(new NotNullValidationListener());
// Use bebop date instead of java.util.date // Use bebop date instead of java.util.date
m_startDate = new com.arsdigita.bebop.form.Date(eventStartDateParam); m_startDate = new com.arsdigita.bebop.form.Date(eventStartDateParam);
m_startDate.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.start_date"));
// Set the upper und lower boundary of the year select box // Set the upper und lower boundary of the year select box
m_startDate.setYearRange(Event.getConfig().getStartYear(), m_startDate.setYearRange(Event.getConfig().getStartYear(),
GregorianCalendar.getInstance().get(Calendar.YEAR) + Event.getConfig().getEndYearDelta()); GregorianCalendar.getInstance().get(Calendar.YEAR)
+ Event.getConfig().getEndYearDelta());
add(m_startDate); add(m_startDate);
// add(new Label(EventGlobalizationUtil
// .globalize("cms.contenttypes.ui.event.start_time")) );
ParameterModel eventStartTimeParam = new TimeParameter(START_TIME); ParameterModel eventStartTimeParam = new TimeParameter(START_TIME);
add(new Label(EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.start_time")) );
if(Event.getConfig().isStartTimeOptional()) { if(Event.getConfig().isStartTimeOptional()) {
eventStartTimeParam.addParameterListener(new NotNullValidationListener()); eventStartTimeParam.addParameterListener(new NotNullValidationListener());
} }
Time startTime = new Time(eventStartTimeParam); Time startTime = new Time(eventStartTimeParam);
startTime.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.start_time"));
add(startTime); add(startTime);
/* End date and time */ /* End date and time */
ParameterModel eventEndDateParam = new DateParameter(END_DATE); ParameterModel eventEndDateParam = new DateParameter(END_DATE);
add(new Label(EventGlobalizationUtil // add(new Label(EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.end_date"))); // .globalize("cms.contenttypes.ui.event.end_date")));
// Use bebop date instead of java.util.date // Use bebop date instead of java.util.date
m_endDate = new com.arsdigita.bebop.form.Date(eventEndDateParam); m_endDate = new com.arsdigita.bebop.form.Date(eventEndDateParam);
m_endDate.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.end_date"));
m_endDate.setHint(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.end_date_hint"));
m_endDate.setYearRange(Event.getConfig().getStartYear(), m_endDate.setYearRange(Event.getConfig().getStartYear(),
GregorianCalendar.getInstance().get(Calendar.YEAR) + Event.getConfig().getEndYearDelta()); GregorianCalendar.getInstance().get(Calendar.YEAR) + Event.getConfig().getEndYearDelta());
add(m_endDate); add(m_endDate);
ParameterModel eventEndTimeParam = new TimeParameter(END_TIME); ParameterModel eventEndTimeParam = new TimeParameter(END_TIME);
add(new Label(EventGlobalizationUtil // add(new Label(EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.end_time"))); // .globalize("cms.contenttypes.ui.event.end_time")));
Time endTime = new Time(eventEndTimeParam); Time endTime = new Time(eventEndTimeParam);
endTime.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.end_time"));
endTime.setHint(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.end_time_hint"));
add(endTime); add(endTime);
/* optional additional / literal date description */ /* optional additional / literal date description */
if (!Event.getConfig().getHideDateDescription()) { if (!Event.getConfig().getHideDateDescription()) {
add(new Label(EventGlobalizationUtil //add(new Label(EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.date_description"))); // .globalize("cms.contenttypes.ui.event.date_description")));
ParameterModel eventDateParam = new StringParameter(EVENT_DATE); ParameterModel eventDateParam = new StringParameter(EVENT_DATE);
//eventDateParam //eventDateParam
// .addParameterListener(new NotNullValidationListener()); // .addParameterListener(new NotNullValidationListener());
if (Event.getConfig().getUseHtmlDateDescription()) { if (Event.getConfig().getUseHtmlDateDescription()) {
CMSDHTMLEditor eventDate = new CMSDHTMLEditor(eventDateParam); CMSDHTMLEditor eventDate = new CMSDHTMLEditor(eventDateParam);
eventDate.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.date_description"));
eventDate.setHint(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.date_description_hint"));
eventDate.setCols(40); eventDate.setCols(40);
eventDate.setRows(8); eventDate.setRows(8);
add(eventDate); add(eventDate);
} else { } else {
eventDateParam.addParameterListener(new StringInRangeValidationListener(0, 100)); eventDateParam.addParameterListener(new StringInRangeValidationListener(0, 100));
TextArea eventDate = new TextArea(eventDateParam); TextArea eventDate = new TextArea(eventDateParam);
eventDate.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.date_description"));
eventDate.setHint(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.date_description_hint"));
eventDate.setCols(50); eventDate.setCols(50);
eventDate.setRows(2); eventDate.setRows(2);
add(eventDate); add(eventDate);
@ -188,12 +212,16 @@ public class EventPropertyForm extends BasicPageForm
/* extensive description of location */ /* extensive description of location */
add(new Label(EventGlobalizationUtil // add(new Label(EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.location"))); // .globalize("cms.contenttypes.ui.event.location")));
ParameterModel locationParam = new StringParameter(LOCATION); ParameterModel locationParam = new StringParameter(LOCATION);
//locationParam //locationParam
// .addParameterListener(new NotNullValidationListener()); // .addParameterListener(new NotNullValidationListener());
CMSDHTMLEditor location = new CMSDHTMLEditor(locationParam); CMSDHTMLEditor location = new CMSDHTMLEditor(locationParam);
location.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.location"));
location.setHint(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.location_hint"));
location.setCols(40); location.setCols(40);
location.setRows(8); location.setRows(8);
add(location); add(location);
@ -201,13 +229,17 @@ public class EventPropertyForm extends BasicPageForm
/* optional: main contributor */ /* optional: main contributor */
if (!Event.getConfig().getHideMainContributor()) { if (!Event.getConfig().getHideMainContributor()) {
add(new Label(EventGlobalizationUtil // add(new Label(EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.main_contributor"))); // .globalize("cms.contenttypes.ui.event.main_contributor")));
ParameterModel mainContributorParam = ParameterModel mainContributorParam =
new StringParameter(MAIN_CONTRIBUTOR); new StringParameter(MAIN_CONTRIBUTOR);
//mainContributorParam //mainContributorParam.addParameterListener(
// .addParameterListener(new NotNullValidationListener()); // new NotNullValidationListener());
CMSDHTMLEditor mainContributor = new CMSDHTMLEditor(mainContributorParam); CMSDHTMLEditor mainContributor = new CMSDHTMLEditor(mainContributorParam);
mainContributor.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.main_contributor"));
mainContributor.setHint(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.main_contributor_hint"));
mainContributor.setCols(40); mainContributor.setCols(40);
mainContributor.setRows(10); mainContributor.setRows(10);
add(mainContributor); add(mainContributor);
@ -216,12 +248,16 @@ public class EventPropertyForm extends BasicPageForm
/* optional: event type */ /* optional: event type */
if (!Event.getConfig().getHideEventType()) { if (!Event.getConfig().getHideEventType()) {
add(new Label(EventGlobalizationUtil // add(new Label(EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.event_type"))); // .globalize("cms.contenttypes.ui.event.event_type")));
ParameterModel eventTypeParam = new StringParameter(EVENT_TYPE); ParameterModel eventTypeParam = new StringParameter(EVENT_TYPE);
//eventTypeParam //eventTypeParam
// .addParameterListener(new NotNullValidationListener()); // .addParameterListener(new NotNullValidationListener());
TextField eventType = new TextField(eventTypeParam); TextField eventType = new TextField(eventTypeParam);
eventType.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.event_type"));
eventType.setHint(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.event_type_hint"));
eventType.setSize(30); eventType.setSize(30);
eventType.setMaxLength(30); eventType.setMaxLength(30);
add(eventType); add(eventType);
@ -230,12 +266,16 @@ public class EventPropertyForm extends BasicPageForm
/* optional: link to map */ /* optional: link to map */
if (!Event.getConfig().getHideLinkToMap()) { if (!Event.getConfig().getHideLinkToMap()) {
add(new Label(EventGlobalizationUtil // add(new Label(EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.link_to_map"))); // .globalize("cms.contenttypes.ui.event.link_to_map")));
ParameterModel mapLinkParam = new StringParameter(MAP_LINK); ParameterModel mapLinkParam = new StringParameter(MAP_LINK);
//mapLinkParam //mapLinkParam
// .addParameterListener(new NotNullValidationListener()); // .addParameterListener(new NotNullValidationListener());
TextArea mapLink = new TextArea(mapLinkParam); TextArea mapLink = new TextArea(mapLinkParam);
mapLink.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.link_to_map"));
mapLink.setHint(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.link_to_map_hint"));
mapLink.setCols(40); mapLink.setCols(40);
mapLink.setRows(2); mapLink.setRows(2);
add(mapLink); add(mapLink);
@ -244,10 +284,14 @@ public class EventPropertyForm extends BasicPageForm
/* optional: costs */ /* optional: costs */
if (!Event.getConfig().getHideCost()) { if (!Event.getConfig().getHideCost()) {
add(new Label(EventGlobalizationUtil // add(new Label(EventGlobalizationUtil
.globalize("cms.contenttypes.ui.event.cost"))); // .globalize("cms.contenttypes.ui.event.cost")));
ParameterModel costParam = new TrimmedStringParameter(COST); ParameterModel costParam = new TrimmedStringParameter(COST);
TextField cost = new TextField(costParam); TextField cost = new TextField(costParam);
cost.setLabel(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.cost"));
cost.setHint(EventGlobalizationUtil.globalize(
"cms.contenttypes.ui.event.cost_hint"));
cost.setSize(30); cost.setSize(30);
cost.setMaxLength(30); cost.setMaxLength(30);
add(cost); add(cost);
@ -327,7 +371,11 @@ public class EventPropertyForm extends BasicPageForm
} }
} }
/** Cancels streamlined editing. */ /**
* Cancels streamlined editing.
* @param fse
*/
@Override
public void submitted(FormSectionEvent fse) { public void submitted(FormSectionEvent fse) {
if (m_step != null if (m_step != null
&& getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) { && getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {

View File

@ -45,11 +45,10 @@ import java.util.StringTokenizer;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* <p>A Content Type defines the characteristics of a content * <p>A Content Type defines the characteristics of a content item. Content
* item. Content management resources are registered to a content * management resources are registered to a content type, including
* type, including the {@link com.arsdigita.cms.AuthoringKit * the {@link com.arsdigita.cms.AuthoringKit Authoring Kit}, and
* Authoring Kit}, and {@link com.arsdigita.cms.Template * {@link com.arsdigita.cms.Template templates}.</p>
* templates}.</p>
* *
* <p>Each content type is associated with a {@link * <p>Each content type is associated with a {@link
* com.arsdigita.domain.DomainObject domain object} and a {@link * com.arsdigita.domain.DomainObject domain object} and a {@link
@ -424,7 +423,8 @@ public class ContentType extends ACSObject {
} }
/** /**
* Add an ancestor to the list of descendants, if not already in the list * Add an ancestor to the list of descendants, if not already in the list.
*
* @param newAncestor ID of the ancestor to add * @param newAncestor ID of the ancestor to add
*/ */
public void addAncestor(BigDecimal newAncestor) { public void addAncestor(BigDecimal newAncestor) {
@ -449,7 +449,8 @@ public class ContentType extends ACSObject {
} }
/** /**
* Remove an ancestor id from the list of descendants * Remove an ancestor id from the list of descendants.
*
* @param ancestor ID to be removed * @param ancestor ID to be removed
*/ */
public void delAncestor(BigDecimal ancestor) { public void delAncestor(BigDecimal ancestor) {
@ -464,8 +465,8 @@ public class ContentType extends ACSObject {
// Delete the additional slash // Delete the additional slash
ancestors.replace("//", "/"); ancestors.replace("//", "/");
// If the list only contains a single slash, // If the list only contains a single slash, we have just removed
// we have just removed the last list entry, so the list is empty // the last list entry, so the list is empty
if (ancestors.equals("/")) { if (ancestors.equals("/")) {
ancestors = ""; ancestors = "";
} }
@ -476,7 +477,8 @@ public class ContentType extends ACSObject {
} }
/** /**
* Get the list of ancestors * Get the list of ancestors.
*
* @return * @return
*/ */
public String getAncestors() { public String getAncestors() {
@ -484,7 +486,8 @@ public class ContentType extends ACSObject {
} }
/** /**
* Add a descendant to the list of descendants, if not already in list * Add a descendant to the list of descendants, if not already in list.
*
* @param newDescendant ID of the descendant to add * @param newDescendant ID of the descendant to add
*/ */
public void addDescendants(BigDecimal newDescendant) { public void addDescendants(BigDecimal newDescendant) {
@ -645,6 +648,11 @@ public class ContentType extends ACSObject {
return new ContentTypeCollection(dc); return new ContentTypeCollection(dc);
} }
/**
*
* @param ct
* @return
*/
public static ContentTypeCollection getDescendantsOf(ContentType ct) { public static ContentTypeCollection getDescendantsOf(ContentType ct) {
ContentTypeCollection ctc = ContentType.getRegisteredContentTypes(); ContentTypeCollection ctc = ContentType.getRegisteredContentTypes();
@ -674,9 +682,9 @@ public class ContentType extends ACSObject {
private static List s_xsl = new ArrayList(); private static List s_xsl = new ArrayList();
/** /**
* Registers an XSL file against a content type.
* NB this interface is liable to change. * NB this interface is liable to change.
* *
* Registers an XSL file against a content type.
* @param type the content type * @param type the content type
* @param path the path relative to the server root * @param path the path relative to the server root
*/ */
@ -685,9 +693,9 @@ public class ContentType extends ACSObject {
} }
/** /**
* Unregisters an XSL file against a content type.
* NB this interface is liable to change. * NB this interface is liable to change.
* *
* Unregisters an XSL file against a content type.
* @param type the content type * @param type the content type
* @param path the path relative to the server root * @param path the path relative to the server root
*/ */
@ -698,24 +706,31 @@ public class ContentType extends ACSObject {
/** /**
* Gets an iterator of java.net.URL objects for * Gets an iterator of java.net.URL objects for
* all registered XSL files * all registered XSL files.
*
* @return
*/ */
public static Iterator getXSLFileURLs() { public static Iterator getXSLFileURLs() {
return new EntryIterator(s_xsl.iterator()); return new EntryIterator(s_xsl.iterator());
} }
/**
*
*/
private static class EntryIterator implements Iterator { private static class EntryIterator implements Iterator {
private Iterator m_inner; private final Iterator m_inner;
public EntryIterator(Iterator inner) { public EntryIterator(Iterator inner) {
m_inner = inner; m_inner = inner;
} }
@Override
public boolean hasNext() { public boolean hasNext() {
return m_inner.hasNext(); return m_inner.hasNext();
} }
@Override
public Object next() { public Object next() {
XSLEntry entry = (XSLEntry) m_inner.next(); XSLEntry entry = (XSLEntry) m_inner.next();
String path = entry.getPath(); String path = entry.getPath();
@ -730,15 +745,19 @@ public class ContentType extends ACSObject {
} }
} }
@Override
public void remove() { public void remove() {
m_inner.remove(); m_inner.remove();
} }
} }
/**
*
*/
private static class XSLEntry { private static class XSLEntry {
private ContentType m_type; private final ContentType m_type;
private String m_path; private final String m_path;
public XSLEntry(ContentType type, public XSLEntry(ContentType type,
String path) { String path) {

View File

@ -66,7 +66,10 @@ import org.apache.log4j.Logger;
**/ **/
public abstract class AbstractContentTypeLoader extends PackageLoader { public abstract class AbstractContentTypeLoader extends PackageLoader {
/** Logger instance for debugging */ /** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
* and set com.arsdigita.cms.contenttypes.AbstractContentTypeLoader=DEBUG
* by uncommenting or adding the line. */
private static final Logger s_log = Logger.getLogger( private static final Logger s_log = Logger.getLogger(
AbstractContentTypeLoader.class); AbstractContentTypeLoader.class);
@ -74,9 +77,11 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
* *
* @param ctx * @param ctx
*/ */
@Override
public void run(final ScriptContext ctx) { public void run(final ScriptContext ctx) {
new KernelExcursion() { new KernelExcursion() {
@Override
protected void excurse() { protected void excurse() {
setEffectiveParty(Kernel.getSystemParty()); setEffectiveParty(Kernel.getSystemParty());
@ -93,8 +98,8 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
private void createTypes(ScriptContext ctx) { private void createTypes(ScriptContext ctx) {
XMLContentTypeHandler handler = new XMLContentTypeHandler(); XMLContentTypeHandler handler = new XMLContentTypeHandler();
String[] contentTypes = getTypes(); String[] contentTypes = getTypes();
for (int i = 0; i < contentTypes.length; i++) { for (String contentType : contentTypes) {
XML.parseResource(contentTypes[i], handler); XML.parseResource(contentType, handler);
} }
List types = handler.getContentTypes(); List types = handler.getContentTypes();
@ -110,8 +115,7 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
continue; continue;
} }
LifecycleDefinitionCollection ldc = LifecycleDefinitionCollection ldc = section.getLifecycleDefinitions();
section.getLifecycleDefinitions();
LifecycleDefinition ld = null; LifecycleDefinition ld = null;
if (ldc.next()) { if (ldc.next()) {
ld = ldc.getLifecycleDefinition(); ld = ldc.getLifecycleDefinition();
@ -130,6 +134,13 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
} }
} }
/**
*
* @param section
* @param type
* @param ld
* @param wf
*/
protected void prepareSection(final ContentSection section, protected void prepareSection(final ContentSection section,
final ContentType type, final ContentType type,
final LifecycleDefinition ld, final LifecycleDefinition ld,
@ -152,7 +163,7 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
*/ */
protected abstract String[] getTypes(); protected abstract String[] getTypes();
/* /**
* *
*/ */
private boolean isLoadableInto(ContentSection section) { private boolean isLoadableInto(ContentSection section) {
@ -185,9 +196,18 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
} }
/** /**
* This provides an easy way to subtypes to register default * This provides an easy way to subtypes to register default templates
* templates during the loading. When this is used, it should * during the loading. When this is used, it should be called by the
* be called by the loader class by overriding prepareSection * loader class by overriding prepareSection.
*
* @param name
* @param label
* @param templateIs
* @param section
* @param type
* @param ld
* @param wf
* @return
*/ */
protected Template setDefaultTemplate(final String name, protected Template setDefaultTemplate(final String name,
final String label, final String label,
@ -196,6 +216,7 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
final ContentType type, final ContentType type,
final LifecycleDefinition ld, final LifecycleDefinition ld,
final WorkflowTemplate wf) { final WorkflowTemplate wf) {
final Template template = new Template(); final Template template = new Template();
template.setName(name); template.setName(name);
template.setLabel(label); template.setLabel(label);

View File

@ -49,9 +49,9 @@ import java.math.BigDecimal;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* A form which displays a select box of all content types available under the * A form element which displays a select box of all content types available
* given content section, and forwards to the item creation UI when the user * under the given content section, and forwards to the item creation UI when
* selects a content type to instantiate. * the user selects a content type to instantiate.
* *
* @author Stanislav Freidin (sfreidin@arsdigtia.com) * @author Stanislav Freidin (sfreidin@arsdigtia.com)
* @version $Revision: #12 $ $DateTime: 2004/08/17 23:15:09 $ * @version $Revision: #12 $ $DateTime: 2004/08/17 23:15:09 $

View File

@ -43,15 +43,15 @@ import com.arsdigita.xml.Element;
*/ */
public class Label extends DescriptiveComponent implements Cloneable { public class Label extends DescriptiveComponent implements Cloneable {
private static final String NO_LABEL = "";
public static final String BOLD = "b"; public static final String BOLD = "b";
public static final String ITALIC = "i"; public static final String ITALIC = "i";
// the default label // the default label
private GlobalizedMessage m_label; private GlobalizedMessage m_label;
// a requestlocal set of labels (to avoid printlisteners) // a requestlocal set of labels (to avoid printlisteners)
private RequestLocal m_requestLabel = new RequestLocal(); private final RequestLocal m_requestLabel = new RequestLocal();
private String m_fontWeight; private String m_fontWeight;
/** The setting for output escaping affects how markup in the /** The setting for output escaping affects how markup in the
* <code>content</code> is handled. * <code>content</code> is handled.
* <UL><LI>If output escaping is in effect (true), &lt;b>example&lt;/b> * <UL><LI>If output escaping is in effect (true), &lt;b>example&lt;/b>
@ -59,21 +59,25 @@ public class Label extends DescriptiveComponent implements Cloneable {
* <LI>If output escaping is disabled, &lt;b>example&lt;/b> appears as the * <LI>If output escaping is disabled, &lt;b>example&lt;/b> appears as the
* String "example" in bold (i.e. retaining the markup.</LI></UL> * String "example" in bold (i.e. retaining the markup.</LI></UL>
* Default is false. */ * Default is false. */
private boolean m_escaping = false; // default for a primitive private boolean m_escaping = false; // default for a primitive anyway
private PrintListener m_printListener; private PrintListener m_printListener;
/** /**
* Constructor creates a new <code>Label</code> with empty text. * Constructor creates a new <code>Label</code> with empty text.
*/ */
public Label() { public Label() {
this(NO_LABEL); // A kind of fallback (or a hack) here. Parameter label is taken as
// a key for some (unknown) Resource bundle. Because GlobalizedMessage
// will not find a corrresponding message it will display the key
// itself, 'faking' a globalized message.
m_label = new GlobalizedMessage(" ");
} }
/** /**
* Creates a new <code>Label</code> with the specified (fixed) text. * Creates a new <code>Label</code> with the specified (fixed) text.
* *
* @param label the text to display * @param label the text to display
* @deprecated refactor to use Label(GlobalizedMessage label) instad * @deprecated refactor to use Label(GlobalizedMessage label) instead
*/ */
public Label(String label) { public Label(String label) {
this(label, true); this(label, true);
@ -81,15 +85,14 @@ public class Label extends DescriptiveComponent implements Cloneable {
/** /**
* Creates a new <code>Label</code> with the specified text and * Creates a new <code>Label</code> with the specified text and
* output escaping turned on if * output escaping turned on if <code>escaping</code> is <code>true</code>.
* <code>escaping</code> is
* <code>true</code>.
* *
* The setting for output escaping affects how markup in the * The setting for output escaping affects how markup in the
* <code>label</code> is handled. For example: <UL><LI>If output escaping is * <code>label</code> is handled. For example:
* in effect, &lt;b>text&lt;/b> will appear literally.</LI> <LI>If output * <UL><LI>If output escaping is in effect, &lt;b>text&lt;/b> will appear
* escaping is disabled, &lt;b>text&lt;/b> appears as the word "text" in * literally.</LI>
* bold.</LI></UL> * <LI>If output escaping is disabled, &lt;b>text&lt;/b> appears as the
* word "text" in bold.</LI></UL>
* *
* @param label the text to display * @param label the text to display
* @param escaping <code>true</code> if output escaping will be in effect; * @param escaping <code>true</code> if output escaping will be in effect;
@ -127,8 +130,7 @@ public class Label extends DescriptiveComponent implements Cloneable {
/** /**
* <p> Creates a new label with the specified text as GlobalizedMessage * <p> Creates a new label with the specified text as GlobalizedMessage
* and output escaping turned on if * and output escaping turned on if <code>escaping</code> is
* <code>escaping</code> is
* <code>true</code>. </p> * <code>true</code>. </p>
* *
* @param label the text to display as GlobalizedMessage * @param label the text to display as GlobalizedMessage
@ -166,15 +168,18 @@ public class Label extends DescriptiveComponent implements Cloneable {
} }
/** /**
* . * Provides the Label as Text, localized for the current request.
*
* Although it is not recommended, this method may be overridden to * Although it is not recommended, this method may be overridden to
* dynamically generate the text of the label. Overriding code may need the * dynamically generate the text of the label. Overriding code may need
* page state. <p>If possible, derived classes should override * the page state.
* {@link #getLabel()} instead, which is called from this method. As long as * <p>
* we don't have a static method to obtain ApplicationContext, this is a way * If possible, derived classes should override {@link #getLabel()} instead,
* to get the RequestContext (that is, to determine the locale). When * which is called from this method. As long as we don't have a static
* ApplicationContext gets available, that will become the suggested way for * method to obtain ApplicationContext, this is a way to get the
* overriding code to get context. * RequestContext (to determine the locale). When ApplicationContext gets
* available, that will become the suggested way for overriding code to get
* context.
* *
* @param state the current page state * @param state the current page state
* @return the string produced for this label * @return the string produced for this label
@ -183,16 +188,16 @@ public class Label extends DescriptiveComponent implements Cloneable {
return (String) getGlobalizedMessage(state).localize(state.getRequest()); return (String) getGlobalizedMessage(state).localize(state.getRequest());
} }
/** // /**
* . // * .
* // *
* This method may be overridden to dynamically generate the default text of // * This method may be overridden to dynamically generate the default text of
* the label. // * the label.
* // *
* @return the string produced for this label. // * @return the string produced for this label.
* // *
* @deprecated Use {@link #getGlobalizedMessage()} // * @deprecated Use {@link #getGlobalizedMessage()}
*/ // */
// Conflicts with Super's getLabel message of type GlobalizedMessage. But isn't // Conflicts with Super's getLabel message of type GlobalizedMessage. But isn't
// needed anyway. Should deleted as soon as the refactoring of Label is // needed anyway. Should deleted as soon as the refactoring of Label is
// completed (i.e. any string Label ironed out). // completed (i.e. any string Label ironed out).
@ -256,8 +261,10 @@ public class Label extends DescriptiveComponent implements Cloneable {
if (label == null || label.length() == 0) { if (label == null || label.length() == 0) {
label = " "; label = " ";
} }
// Seems to be quite useless. label is taken as a key for some (unknown) // A kind of fallback (or a hack) here. Parameter label is taken as
// Resource bundle. // a key for some (unknown) Resource bundle. Because GlobalizedMessage
// will not find a corrresponding message it will display the key
// itself, 'faking' a globalized message.
setLabel(new GlobalizedMessage(label), state); setLabel(new GlobalizedMessage(label), state);
} }
@ -319,9 +326,8 @@ public class Label extends DescriptiveComponent implements Cloneable {
/** /**
* Adds a print listener. Only one print listener can be set for a label, * Adds a print listener. Only one print listener can be set for a label,
* since the * since the <code>PrintListener</code> is expected to modify the target
* <code>PrintListener</code> is expected to modify the target of the * of the <code>PrintEvent</code>.
* <code>PrintEvent</code>.
* *
* @param listener the print listener * @param listener the print listener
* @throws IllegalArgumentException if <code>listener</code> is null. * @throws IllegalArgumentException if <code>listener</code> is null.
@ -341,8 +347,8 @@ public class Label extends DescriptiveComponent implements Cloneable {
} }
/** /**
* Removes a previously added print listener. If * Removes a previously added print listener. If <code>listener</code> is
* <code>listener</code> is not the listener that was added with {@link #addPrintListener * not the listener that was added with {@link #addPrintListener
* addPrintListener}, an IllegalArgumentException will be thrown. * addPrintListener}, an IllegalArgumentException will be thrown.
* *
* @param listener the listener that was added with * @param listener the listener that was added with
@ -408,10 +414,10 @@ public class Label extends DescriptiveComponent implements Cloneable {
} }
/* /*
* This may break with normal JDOM. We may need to have a node * This may break with normal JDOM. We may need to have a node for
* for the case where there is no weight. The problem comes in that * the case where there is no weight. The problem comes in that
* setText *may* kill the other content in the node. It will kill the * setText *may* kill the other content in the node. It will kill
* other text, so it may be a good idea anyways. * the other text, so it may be a good idea anyways.
*/ */
label.setText(target.getLabel(state)); label.setText(target.getLabel(state));
} }