diff --git a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/ui/EventPropertyForm.java b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/ui/EventPropertyForm.java index 5f00d8384..851a0bbf2 100755 --- a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/ui/EventPropertyForm.java +++ b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/ui/EventPropertyForm.java @@ -271,10 +271,10 @@ public class EventPropertyForm extends BasicPageForm if (endDate != null) { if (startDate == null || startDate.compareTo(endDate) > 0) { - throw new FormProcessException((String) + throw new FormProcessException("End date must be after start date", EventGlobalizationUtil.globalize( "cms.contenttypes.ui.event.end_date_after_start_date") - .localize()); + ); } } } diff --git a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleCreate.java b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleCreate.java index 8e5bef988..8d5275b73 100755 --- a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleCreate.java +++ b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleCreate.java @@ -55,7 +55,7 @@ public class MultiPartArticleCreate extends MultiPartArticleForm FormSubmissionListener, FormValidationListener, CreationComponent { - private CreationSelector m_parent; + private final CreationSelector m_parent; private ApplyWorkflowFormSection m_workflowSection; public MultiPartArticleCreate(ItemSelectionModel itemModel, @@ -84,38 +84,45 @@ public class MultiPartArticleCreate extends MultiPartArticleForm * * @return the ApplyWorkflowFormSection associated with this CreationComponent. */ + @Override public ApplyWorkflowFormSection getWorkflowSection() { return m_workflowSection; } + @Override public void init(FormSectionEvent event) throws FormProcessException { // this is currently a no-op } + @Override public void submitted(FormSectionEvent event) throws FormProcessException { PageState state = event.getPageState(); if (getSaveCancelSection().getCancelButton().isSelected(state)) { m_parent.redirectBack(state); throw new FormProcessException( - (String)MPArticleGlobalizationUtil - .globalize("cms.contenttypes.ui.mparticle.submission_cancelled") - .localize()); + "Submission cancelled", + MPArticleGlobalizationUtil.globalize( + "cms.contenttypes.ui.mparticle.submission_cancelled") + ); } } + @Override public void validate(FormSectionEvent event) throws FormProcessException { Folder f = m_parent.getFolder(event.getPageState()); Assert.exists(f, Folder.class); if (!validateNameUniqueness(f, event)) { throw new FormProcessException( - (String)MPArticleGlobalizationUtil - .globalize("cms.contenttypes.ui.mparticle." + - "an_item_with_this_name_already_exists") - .localize()); + "An item with this name already exists", + MPArticleGlobalizationUtil.globalize( + "cms.contenttypes.ui.mparticle." + + "an_item_with_this_name_already_exists") + ); } } + @Override public void process(final FormSectionEvent e) throws FormProcessException { final FormData data = e.getFormData(); final PageState state = e.getPageState(); diff --git a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEditForm.java b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEditForm.java index ab9929176..89ff9f6ac 100755 --- a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEditForm.java +++ b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEditForm.java @@ -37,7 +37,7 @@ import com.arsdigita.util.Assert; public class MultiPartArticleEditForm extends MultiPartArticleForm implements FormSubmissionListener { - private SimpleEditStep m_step; + private final SimpleEditStep m_step; public MultiPartArticleEditForm(ItemSelectionModel itemModel, SimpleEditStep step) { @@ -46,11 +46,15 @@ public class MultiPartArticleEditForm extends MultiPartArticleForm m_step = step; } + @Override public void init(FormSectionEvent e) throws FormProcessException { super.initBasicWidgets(e); } - /** Cancels streamlined editing. */ + /** + * Cancels streamlined editing. + * @param fse */ + @Override public void submitted( FormSectionEvent fse ) { if (getSaveCancelSection().getCancelButton() .isSelected( fse.getPageState())) { @@ -58,12 +62,14 @@ public class MultiPartArticleEditForm extends MultiPartArticleForm } } + @Override public void process(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); MultiPartArticle article = processBasicWidgets(e); m_step.maybeForwardToNextStep(e.getPageState()); } + @Override public void validate(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); FormData data = e.getFormData(); @@ -83,9 +89,10 @@ public class MultiPartArticleEditForm extends MultiPartArticleForm if ( !valid ) { throw new FormProcessException - ((String)MPArticleGlobalizationUtil - .globalize("cms.contenttypes.ui.mparticle." + - "an_item_with_name_already_exists").localize()); + ("An item with name already exists", + MPArticleGlobalizationUtil.globalize( + "cms.contenttypes.ui.mparticle." + + "an_item_with_name_already_exists")); } } diff --git a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionDeleteForm.java b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionDeleteForm.java index fd2daa45f..5ec6f5868 100755 --- a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionDeleteForm.java +++ b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionDeleteForm.java @@ -85,6 +85,7 @@ public class SectionDeleteForm extends Form return m_saveCancelSection; } + @Override public void init ( FormSectionEvent event ) throws FormProcessException { PageState state = event.getPageState(); @@ -97,14 +98,20 @@ public class SectionDeleteForm extends Form } } + @Override public void submitted ( FormSectionEvent event ) throws FormProcessException { PageState state = event.getPageState(); if ( m_saveCancelSection.getCancelButton().isSelected(state) ) { - throw new FormProcessException( (String) MPArticleGlobalizationUtil.globalize("cms.contenttypes.ui.mparticle.submission_cancelled").localize()); + throw new FormProcessException( + "Submission cancelled", + MPArticleGlobalizationUtil.globalize( + "cms.contenttypes.ui.mparticle.submission_cancelled") + ); } } + @Override public void process ( FormSectionEvent event ) throws FormProcessException { PageState state = event.getPageState(); diff --git a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionEditForm.java b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionEditForm.java index 4ef52ca95..5d549e3ab 100755 --- a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionEditForm.java +++ b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionEditForm.java @@ -190,12 +190,48 @@ public class SectionEditForm extends Form { add(pageBreak); } + /** + * Utility method to create a Section from the form data supplied. + * + * @param event + * @param article + * @return + */ + protected ArticleSection createSection(FormSectionEvent event, + MultiPartArticle article) { + + PageState state = event.getPageState(); + FormData data = event.getFormData(); + + ArticleSection section = new ArticleSection(); + + section.setTitle((String)data.get(TITLE)); + section.setName(article.getName() + ": " + (String)data.get(TITLE)); + section.setContentSection(article.getContentSection()); + + return section; + } + + /** + * + * @param p + */ + @Override + public void register(Page p) { + super.register(p); + p.addGlobalStateParam(m_imageParam); + p.addGlobalStateParam(m_textParam); + } + + /** * Initialize the form. If there is a selected section, ie. this * is an 'edit' step rather than a 'create new' step, load the data * into the form fields. */ private class SectionInitListener implements FormInitListener { + + @Override public void init( FormSectionEvent event ) throws FormProcessException { PageState state = event.getPageState(); @@ -245,6 +281,8 @@ public class SectionEditForm extends Form { * cancel button. If they did, don't continue with the form. */ private class SectionSubmissionListener implements FormSubmissionListener { + + @Override public void submitted( FormSectionEvent event ) throws FormProcessException { PageState state = event.getPageState(); @@ -255,9 +293,10 @@ public class SectionEditForm extends Form { state, MultiPartArticleViewSections.SECTION_TABLE+ m_container.getTypeIDStr()); throw new FormProcessException( - (String)MPArticleGlobalizationUtil - .globalize("cms.contenttypes.ui.mparticle.submission_cancelled") - .localize()); + "Submission cancelled", + MPArticleGlobalizationUtil.globalize( + "cms.contenttypes.ui.mparticle.submission_cancelled") + ); } else if ( m_imageUpload.getDeleteImageButton().isSelected(state) ) { BigDecimal id = new BigDecimal(m_selSection .getSelectedKey(state).toString()); @@ -278,6 +317,8 @@ public class SectionEditForm extends Form { * assign it to the current MultiPartArticle. */ private class SectionProcessListener implements FormProcessListener { + + @Override public void process( FormSectionEvent event ) throws FormProcessException { PageState state = event.getPageState(); @@ -294,7 +335,6 @@ public class SectionEditForm extends Form { throw new UncheckedWrapperException(ex); } - // get the selected section to update or create a new one ArticleSection section = (ArticleSection) m_selSection.getSelectedObject(state); @@ -349,28 +389,4 @@ public class SectionEditForm extends Form { } } - - /** - * Utility method to create a Section from the form data supplied. - */ - protected ArticleSection createSection(FormSectionEvent event, - MultiPartArticle article) { - - PageState state = event.getPageState(); - FormData data = event.getFormData(); - - ArticleSection section = new ArticleSection(); - - section.setTitle((String)data.get(TITLE)); - section.setName(article.getName() + ": " + (String)data.get(TITLE)); - section.setContentSection(article.getContentSection()); - - return section; - } - - public void register(Page p) { - super.register(p); - p.addGlobalStateParam(m_imageParam); - p.addGlobalStateParam(m_textParam); - } } diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties index ab9529b03..f3e0f0322 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties @@ -263,7 +263,7 @@ cms.ui.item_search.search=Search # Package com.arsdigita.cms.ui.authoring # ====================================== -cms.ui.authoring.an_item_with_this_name_already_exists=An item with this name already exists +cms.ui.authoring.an_item_with_this_name_already_exists=An item with this name already exists! cms.ui.authoring.bad_getblob_datatype=Bad getBlob datatype cms.ui.authoring.bad_getclob_datatype=Bad getClob datatype cms.ui.authoring.body=Body: @@ -1074,3 +1074,7 @@ cms.ui.change_password=Change password cms.ui.image_select.page_title=Select or upload image cms.ui.image_library=Image library cms.ui.image_upload=Upload image +cms.ui.authoring.items_with_this_name_already_exist=Items with whit name already exist. (Id: {0}) +cms.ui.authoring.parameter_not_empty=This parameter may not be empty. +cms.ui.authoring.parameter_should_be_a_valid_filename=This parameter should be a valid filename. +cms.ui.authoring.parameter_may_not_contain_periods=This parameter may not contain periods diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties index 31faae807..b11cd3604 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties @@ -261,7 +261,7 @@ cms.ui.item_search.search=Suchen # Package com.arsdigita.cms.ui.authoring # ====================================== -cms.ui.authoring.an_item_with_this_name_already_exists=Ein Dokument mit diesem Namen existiert bereits +cms.ui.authoring.an_item_with_this_name_already_exists=Ein Dokument mit diesem Namen existiert bereits! cms.ui.authoring.bad_getblob_datatype=Ung\u00fcltiger Datentyp getBlob cms.ui.authoring.bad_getclob_datatype=Ung\u00fcltiger Datentyp getClob cms.ui.authoring.body=Textbereich: @@ -1068,3 +1068,7 @@ cms.ui.change_password=Passwort \u00e4ndern cms.ui.image_select.page_title=Bild ausw\u00e4hlen oder hochladen cms.ui.image_library=Bildersammlung cms.ui.image_upload=Bild hochladen +cms.ui.authoring.items_with_this_name_already_exist=Dokumentemitdiesem Namen existieren bereits. (ID: {0}) +cms.ui.authoring.parameter_not_empty=Dieser Parameter darf nicht leer sein. +cms.ui.authoring.parameter_should_be_a_valid_filename=Dieser Parameter muss einem g\u00fcltigen Dateinamen entsprechen. +cms.ui.authoring.parameter_may_not_contain_periods=This parameter may not contain periods diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties index d023c668b..1be2f8612 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties @@ -122,3 +122,7 @@ cms.ui.change_password= cms.ui.image_select.page_title= cms.ui.image_library= cms.ui.image_upload= +cms.ui.authoring.items_with_this_name_already_exist=Items with whit name already exist. (Id: {0}) +cms.ui.authoring.parameter_not_empty=This parameter may not be empty. +cms.ui.authoring.parameter_should_be_a_valid_filename=This parameter should be a valid filename. +cms.ui.authoring.parameter_may_not_contain_periods=This parameter may not contain periods diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties index 5440f86d5..823319681 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties @@ -157,7 +157,7 @@ cms.ui.no_items_matched_the_search=Pas d'\u00e9l\u00e9ment trouv\u00e9 dans la r # Package com.arsdigita.cms.ui.authoring # ====================================== -cms.ui.authoring.an_item_with_this_name_already_exists=Un \u00e9l\u00e9ment de ce nom existe d\u00e9j\u00e0 +cms.ui.authoring.an_item_with_this_name_already_exists=Un \u00e9l\u00e9ment de ce nom existe d\u00e9j\u00e0! cms.ui.authoring.bad_getblob_datatype=TRANSLATE THIS: Bad getBlob datatype (cms.ui.authoring.bad_getblob_datatype) cms.ui.authoring.bad_getclob_datatype=TRANSLATE THIS: Bad getClob datatype (cms.ui.authoring.bad_getclob_datatype) cms.ui.authoring.body=Corsp de la page @@ -596,3 +596,7 @@ cms.ui.change_password= cms.ui.image_select.page_title= cms.ui.image_library= cms.ui.image_upload= +cms.ui.authoring.items_with_this_name_already_exist=Items with whit name already exist. (Id: {0}) +cms.ui.authoring.parameter_not_empty=This parameter may not be empty. +cms.ui.authoring.parameter_should_be_a_valid_filename=This parameter should be a valid filename. +cms.ui.authoring.parameter_may_not_contain_periods=This parameter may not contain periods diff --git a/ccm-cms/src/com/arsdigita/cms/DataQueryExistsListener.java b/ccm-cms/src/com/arsdigita/cms/DataQueryExistsListener.java index 1339d0337..a81627dbb 100755 --- a/ccm-cms/src/com/arsdigita/cms/DataQueryExistsListener.java +++ b/ccm-cms/src/com/arsdigita/cms/DataQueryExistsListener.java @@ -25,13 +25,12 @@ import com.arsdigita.persistence.DataQuery; /** - *

Verifies that a specified {@link - * com.arsdigita.persistence.DataQuery data query} has no results. - * This is useful for making sure emails are unique in the - * database.

+ *

Verifies that a specified + * {@link com.arsdigita.persistence.DataQuery data query} has no results. + * This is useful for making sure emails are unique in the database.

* - *

Users of this class must override the method {@link - * #getDataQuery} which specifies the data query to check.

+ *

Users of this class must override the method {@link #getDataQuery} which + * specifies the data query to check.

* * @author Uday Mathur (umathur@arsdigita.com) * @author Michael Pih (pihman@arsdigita.com) @@ -40,6 +39,7 @@ import com.arsdigita.persistence.DataQuery; public abstract class DataQueryExistsListener implements FormValidationListener { + /** */ protected String m_errorMsg; @@ -50,8 +50,19 @@ public abstract class DataQueryExistsListener m_errorMsg = msg; } + /** + * + * @param event + * @return + */ public abstract DataQuery getDataQuery(FormSectionEvent event); + /** + * + * @param event + * @throws FormProcessException + */ + @Override public void validate(FormSectionEvent event) throws FormProcessException { DataQuery dq = getDataQuery(event); if ( dq.next() ) { diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/ContentGroupPropertyForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/ContentGroupPropertyForm.java index 5ff2067d4..9187d8a36 100755 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/ContentGroupPropertyForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/ContentGroupPropertyForm.java @@ -50,6 +50,11 @@ import java.util.Iterator; * extended to create forms for Brand subclasses. */ public class ContentGroupPropertyForm extends BasicItemForm { + + /** 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.ui.ContentGroupPropertyForm=DEBUG + * by uncommenting or adding the line. */ private final static org.apache.log4j.Logger s_log = org.apache.log4j.Logger.getLogger(ContentGroupPropertyForm.class); @@ -77,6 +82,7 @@ public class ContentGroupPropertyForm extends BasicItemForm { /** * Adds widgets to the form. */ + @Override protected void addWidgets() { add(new Label(GlobalizationUtil .globalize("cms.contenttypes.ui.content_group_name"))); @@ -87,6 +93,7 @@ public class ContentGroupPropertyForm extends BasicItemForm { add(new Label(GlobalizationUtil .globalize("cms.contenttypes.ui.content_group_current_items")) { + @Override public boolean isVisible(PageState state) { ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel() @@ -97,6 +104,7 @@ public class ContentGroupPropertyForm extends BasicItemForm { } }); m_checkboxGroup = new CheckboxGroup(ASSOCIATED_ITEMS) { + @Override public boolean isVisible(PageState state) { ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel() @@ -122,7 +130,10 @@ public class ContentGroupPropertyForm extends BasicItemForm { * Perform form initialization. Children should override this * this method to pre-fill the widgets with data, instantiate * the content item, etc. + * + * @throws com.arsdigita.bebop.FormProcessException */ + @Override public void init(FormSectionEvent e) throws FormProcessException { s_log.debug("here in init"); FormData data = e.getFormData(); @@ -154,7 +165,10 @@ public class ContentGroupPropertyForm extends BasicItemForm { /** * Process the form. Children should override this method to save * the user's changes to the database. + * + * @throws com.arsdigita.bebop.FormProcessException */ + @Override public void process(FormSectionEvent e) throws FormProcessException { s_log.debug("here in process"); ContentGroupContainer item = @@ -190,9 +204,9 @@ public class ContentGroupPropertyForm extends BasicItemForm { String[] values = (String[])m_checkboxGroup.getValue(e.getPageState()); if (values != null) { - for (int i = 0; i < values.length; i++) { - ids.remove(values[i]); - s_log.debug("marking " + values[i] + " for keeping"); + for (String value : values) { + ids.remove(value); + s_log.debug("marking " + value + " for keeping"); } } // now, we remove the itmes that were unselected @@ -234,7 +248,9 @@ public class ContentGroupPropertyForm extends BasicItemForm { * The name of the Content Type to restrict the ItemSearchWidget to. * To allow the user to search for any content type, this should * return null. - **/ + * + * @return + */ protected String getSearchContentType() { return null; } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericArticlePropertyForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericArticlePropertyForm.java index 057b56614..492a37da1 100755 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericArticlePropertyForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericArticlePropertyForm.java @@ -42,8 +42,9 @@ public class GenericArticlePropertyForm extends BasicPageForm /** * Creates a new form to edit the Article object specified * by the item selection model passed in. + * * @param itemModel The ItemSelectionModel to use to obtain the - * Article to work on + * Article to work on */ public GenericArticlePropertyForm(ItemSelectionModel itemModel) { this(itemModel, null); @@ -52,8 +53,9 @@ public class GenericArticlePropertyForm extends BasicPageForm /** * Creates a new form to edit the GenericArticle object specified * by the item selection model passed in. + * * @param itemModel The ItemSelectionModel to use to obtain the - * GenericArticle to work on + * GenericArticle to work on * @param step The GenericArticlePropertiesStep which controls this form. */ public GenericArticlePropertyForm(ItemSelectionModel itemModel, @@ -76,14 +78,24 @@ public class GenericArticlePropertyForm extends BasicPageForm super.validate(e); } - /** Form initialisation hook. Fills widgets with data. */ + /** + * Form initialisation hook. Fills widgets with data. + * + * @param fse + */ + @Override public void init(FormSectionEvent fse) { // Do some initialization hook stuff FormData data = fse.getFormData(); GenericArticle article = (GenericArticle) super.initBasicWidgets(fse); } - /** Cancels streamlined editing. */ + /** + * Cancels streamlined editing. + * + * @param fse + */ + @Override public void submitted(FormSectionEvent fse) { if (m_step != null && getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) { @@ -91,7 +103,12 @@ public class GenericArticlePropertyForm extends BasicPageForm } } - /** Form processing hook. Saves Event object. */ + /** + * Form processing hook. Saves Event object. + * + * @param fse + */ + @Override public void process(FormSectionEvent fse) { FormData data = fse.getFormData(); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/BaseForm.java b/ccm-cms/src/com/arsdigita/cms/ui/BaseForm.java index f9cd07ef3..64c0b9cf6 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/BaseForm.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/BaseForm.java @@ -127,6 +127,7 @@ public abstract class BaseForm extends Form addSubmissionListener(new FormSecurityListener(action, item)); } + @Override public boolean isCancelled(final PageState state) { return m_cancel != null && m_cancel.isSelected(state); } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/UniqueItemNameValidationListener.java b/ccm-cms/src/com/arsdigita/cms/ui/UniqueItemNameValidationListener.java index 4a67e5474..934d3dacc 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/UniqueItemNameValidationListener.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/UniqueItemNameValidationListener.java @@ -28,9 +28,9 @@ import com.arsdigita.cms.ui.util.UniqueStringValidationListener; /** - * Ensures that the name of the item is unique by resolving the - * would-be URL of the item. If an item already "exists" at the URL in the - * current context, then the name is invalid. + * Ensures that the name of the item is unique by resolving the would-be URL + * of the item. If an item already "exists" at the URL in the current context, + * then the name is invalid. * * * @author Michael Pih (pihman@arsdigita.com) @@ -71,6 +71,7 @@ public class UniqueItemNameValidationListener * @param value The submitted string value * @return true if the string value is unique, false otherwise */ + @Override protected boolean isUnique(PageState state, String value) { // Fetch the current content section. diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java index e8d5786cf..0dc274c00 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java @@ -40,6 +40,7 @@ import com.arsdigita.cms.Folder; import com.arsdigita.cms.ItemCollection; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.util.GlobalizationUtil; +import static com.arsdigita.cms.util.GlobalizationUtil.globalize; import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.SessionManager; @@ -55,17 +56,21 @@ import java.util.Collection; * * @author Stanislav Freidin (stas@arsdigita.com) * @version $Revision: #13 $ $DateTime: 2004/08/17 23:15:09 $ - * */ public abstract class BasicItemForm extends FormSection - implements FormInitListener, - FormProcessListener, - FormValidationListener { + implements FormInitListener, + FormProcessListener, + FormValidationListener { + /** 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.ui.BasicItemForm=DEBUG + * by uncommenting or adding the line. */ private static final Logger s_log = Logger.getLogger(BasicItemForm.class); + private final ItemSelectionModel m_itemModel; private SaveCancelSection m_saveCancelSection; - private FormSection m_widgetSection; + private final FormSection m_widgetSection; public static final String CONTENT_ITEM_ID = ContentItem.ID; public static final String NAME = ContentItem.NAME; public static final String TITLE = ContentPage.TITLE; @@ -73,14 +78,11 @@ public abstract class BasicItemForm extends FormSection /** * Construct a new BasicItemForm with 2 ColumnPanels and add basic content. - * * The left Panel is used for Labels, the right Panel for values. * - * - * * @param formName the name of this form - * @param itemModel The {@link ItemSelectionModel} which will be responsible for loading the - * current item + * @param itemModel The {@link ItemSelectionModel} which will be responsible + * for loading the current item */ public BasicItemForm(String formName, ItemSelectionModel itemModel) { super(new ColumnPanel(2)); @@ -110,12 +112,13 @@ public abstract class BasicItemForm extends FormSection } /** - * Construct a new BasicItemForm with a specified number of ColumnPanels and without any content + * Construct a new BasicItemForm with a specified number of ColumnPanels + * and without any content. * * @param formName the name of this form * @param columnPanel the columnpanel of the form - * @param itemModel The {@link ItemSelectionModel} which will be responsible for loading the - * current item + * @param itemModel The {@link ItemSelectionModel} which will be + * responsible for loading the current item */ public BasicItemForm(String formName, ColumnPanel columnPanel, @@ -139,23 +142,22 @@ public abstract class BasicItemForm extends FormSection /** * Currently, to insert javascript code the Label Widget is "abused". */ - private Label m_script = new Label( + private final Label m_script = new Label( "", false); /** * Add basic widgets to the form. * - * Widgets added are 'title' and 'name (url)' which are part of any content item. Child classes - * will override this method to perform all their widget-adding needs but may use super() to add - * the basic widgets. + * Widgets added are 'title' and 'name (url)' which are part of any + * content item. Child classes will override this method to perform all + * their widget-adding needs but are supposed to use super() to add the + * basic widgets. */ protected void addWidgets() { //add(new FormErrorDisplay(this), ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT); - //add(new Label("id")); final Hidden id = new Hidden(CONTENT_ITEM_ID); - //final TextField id = new TextField(CONTENT_ITEM_ID); add(id); // JavaScript auto-name generation is off by default. @@ -175,6 +177,8 @@ public abstract class BasicItemForm extends FormSection // (jensp 2011-01-28) add(new Label(getTitleLabel())); final TextField titleWidget = new TextField(new TrimmedStringParameter(TITLE)); + titleWidget.setLabel(getTitleLabel()); + titleWidget.setHint(getTitleHint()); titleWidget.addValidationListener(new NotNullValidationListener()); titleWidget.setOnFocus("if (this.form." + NAME + ".value == '') { " + " defaulting = true; this.form." + NAME @@ -182,8 +186,6 @@ public abstract class BasicItemForm extends FormSection titleWidget.setOnKeyUp( "if (defaulting) { this.form." + NAME + ".value = urlize(this.value) }"); - titleWidget.setLabel(getTitleLabel()); - titleWidget.setHint(getTitleHint()); add(titleWidget); // For some content types it may be useful to change the label of @@ -192,6 +194,9 @@ public abstract class BasicItemForm extends FormSection // (jensp 2011-01-28) add(new Label(getNameLabel())); final TextField nameWidget = new TextField(new TrimmedStringParameter(NAME)); + nameWidget.setLabel(getNameLabel()); + nameWidget.setHint(getNameHint()); + nameWidget.addValidationListener(new NotNullValidationListener()); nameWidget.addValidationListener(new NameValidationListener()); nameWidget.setMaxLength(190); nameWidget.setOnFocus("defaulting = false"); @@ -199,8 +204,6 @@ public abstract class BasicItemForm extends FormSection "if (this.value == '') " + "{ defaulting = true; this.value = urlize(this.form." + TITLE + ".value) } " + " else { this.value = urlize(this.value); }"); - nameWidget.addValidationListener(new NotNullValidationListener()); - nameWidget.setHint(getNameHint()); add(nameWidget); } @@ -226,46 +229,51 @@ public abstract class BasicItemForm extends FormSection } /** - * Perform form initialization. Children should override this this method to pre-fill the - * widgets with data, instantiate the content item, etc. + * Perform form initialization. Children should override this this method + * to pre-fill the widgets with data, instantiate the content item, etc. * * @param e - * * @throws FormProcessException */ + @Override public abstract void init(FormSectionEvent e) throws FormProcessException; /** - * Process the form. Children should override this method to save the user's changes to the - * database. + * Process the form. Children have to override this method to save the + * user's changes to the database. * * @param e - * * @throws FormProcessException */ + @Override public abstract void process(FormSectionEvent e) throws FormProcessException; /** - * Validate the form. Children should override this method to provide custom form validation. + * Validate the form. Children should override this method to provide + * custom form validation. * * @param e + * @throws com.arsdigita.bebop.FormProcessException */ + @Override public void validate(FormSectionEvent e) throws FormProcessException { // do nothing } + /** - * Ensure that the name of an item is unique within a folder. A "New item" form should call this - * method in the validation listener. + * Ensure that the name of an item is unique within a folder. + * A "New item" form should call this method in the validation listener. * * @param parent the folder in which to check - * @param event the {@link FormSectionEvent} which was passed to the validation listener + * @param event the {@link FormSectionEvent} which was passed to the + * validation listener * - * @throws FormProcessException if the folder already contains an item with the name the user - * provided on the input form. + * @throws FormProcessException if the folder already contains an item + * with the name the use provided on the input form. */ public void validateNameUniqueness(Folder parent, FormSectionEvent event) - throws FormProcessException { + throws FormProcessException { FormData data = event.getFormData(); String newName = (String) data.get(NAME); @@ -281,14 +289,18 @@ public abstract class BasicItemForm extends FormSection * * @throws FormProcessException */ - public void validateNameUniqueness(Folder parent, FormSectionEvent event, + public void validateNameUniqueness(Folder parent, + FormSectionEvent event, String newName) - throws FormProcessException { + throws FormProcessException { + if (newName != null) { final String query = "com.arsdigita.cms.validateUniqueItemName"; DataQuery dq = SessionManager.getSession().retrieveQuery(query); dq.setParameter("parentId", parent.getID()); dq.setParameter("name", newName.toUpperCase()); + FormData data = event.getFormData(); + if (dq.size() > 0) { // we need to add all of the items that are @@ -299,25 +311,34 @@ public abstract class BasicItemForm extends FormSection ContentItem item = null; if (getItemSelectionModel() != null) { - item = (ContentItem) getItemSelectionModel(). - getSelectedObject(event.getPageState()); + item = (ContentItem) getItemSelectionModel() + .getSelectedObject(event.getPageState()); } if (item == null) { // this means it is a creation form -// throw new FormProcessException( -// "An item with this name already exists"); + data.addError(globalize( + "cms.ui.authoring.an_item_with_this_name_already_exists")); throw new FormProcessException( - "cms.ui.authoring.an_item_with_this_name_already_exists"); + "An item with this name already exists", + globalize("cms.ui.authoring.an_item_with_this_name_already_exists" + ) + ); } Collection list = getAllVersionIDs(item); while (dq.next()) { itemID = (BigDecimal) dq.get("itemID"); if (!list.contains(itemID)) { + String[] itemObj=new String[1]; + itemObj[0]=itemID.toString(); dq.close(); -// throw new FormProcessException( -// "An item with this name already exists"); - throw new FormProcessException( - "cms.ui.authoring.an_item_with_this_name_already_exists"); + data.addError(globalize( + "cms.ui.authoring.an_item_with_this_name_already_exists")); + throw new FormProcessException( + "An item with this name already exists", + globalize( + "cms.ui.authoring.items_with_this_name_already_exist", + itemObj) + ); } } } @@ -325,14 +346,15 @@ public abstract class BasicItemForm extends FormSection } /** - * Ensure that the name of an item is unique within a category. This should only be called from - * the validation listener of an "edit" form. + * Ensure that the name of an item is unique within a category. This should + * only be called from the validation listener of an "edit" form. * - * @param event the {@link FormSectionEvent} which was passed to the validation listener + * @param event the {@link FormSectionEvent} which was passed to the + * validation listener * @param id The id of the item that is being checked. This must no be null. * - * @throws FormProcessException if the folder already contains an item with the name the user - * provided on the input form. + * @throws FormProcessException if the folder already contains an item with + * the name the user provided on the input form. */ public void validateNameUniquenessWithinCategory(FormSectionEvent event, BigDecimal id) @@ -361,18 +383,25 @@ public abstract class BasicItemForm extends FormSection // pending or live version of the same item BigDecimal itemID = null; - ContentItem item = (ContentItem) getItemSelectionModel().getSelectedObject(event. - getPageState()); + ContentItem item = (ContentItem)getItemSelectionModel() + .getSelectedObject(event.getPageState()); Collection list = getAllVersionIDs(item); try { while (query.next()) { itemID = (BigDecimal) query.get("itemID"); if (!list.contains(itemID)) { - StringBuffer buffer = new StringBuffer((String) GlobalizationUtil - .globalize("cms.ui.authoring.error_conflicts_with_this_url") - .localize()); - buffer.append(url); - throw new FormProcessException(buffer.toString()); + // StringBuffer buffer = new StringBuffer((String) GlobalizationUtil + // .globalize("cms.ui.authoring.error_conflicts_with_this_url") + // .localize()); + // buffer.append(url); + String[] urlObj=new String[1]; + urlObj[0]=url; + throw new FormProcessException( + "Error: Conflict with url: "+url, + globalize( + "cms.ui.authoring.error_conflicts_with_this_url", + urlObj) + ); } } @@ -411,14 +440,13 @@ public abstract class BasicItemForm extends FormSection } /** - * Adds a component with the specified layout constraints to this container. Layout constraints - * are defined in each layout container as static ints. Use a bitwise OR to specify multiple - * constraints. + * Adds a component with the specified layout constraints to this container. + * Layout constraints are defined in each layout container as static ints. + * Use a bitwise OR to specify multiple constraints. * * @param pc the component to add to this container - * - * @param constraints layout constraints (a bitwise OR of static ints in the particular layout) - * + * @param constraints layout constraints (a bitwise OR of static ints in + * the particular layout) */ @Override public void add(Component pc, int constraints) { @@ -426,10 +454,11 @@ public abstract class BasicItemForm extends FormSection } /** - * jensp, 2011-01-28 This method can be overridden to change the label of the title field. To - * change to label of the title field can be useful for some content types. For example, for an - * organization the label "Title" for the field is may confusing for the normal user. For such a - * content type, the label would be changed to something like "Name of the organization". + * This method can be overridden to change the label of the title field. To + * change to label of the title field can be useful for some content types. + * For example, for an organization the label "Title" for the field may be + * confusing for the normal user. For such a content type, the label would + * be changed to something like "Name of the organization". * * @return (Content for the) Label for the title field as string */ @@ -438,9 +467,8 @@ public abstract class BasicItemForm extends FormSection } /** - * Provides the text for the user hint providing some detailed information how to use this - * widget. - * + * Provides the text for the user hint providing some detailed information + * how to use this widget. * This method can be overwritten to adjust the text for some content types. * {@link #getTitleLabel()} * @@ -451,8 +479,8 @@ public abstract class BasicItemForm extends FormSection } /** - * jensp, 2011-01-28 This method does the same as {@link #getTitleLabel() } for the label of the - * name (URL) field. + * This method does the same as {@link #getTitleLabel() } for the labe + *l of the name (URL) field. * * @return (Content for the) Label for the name field as string */ @@ -461,9 +489,8 @@ public abstract class BasicItemForm extends FormSection } /** - * Provides the text for the unser hint providing some detailed information how to use this - * widget. - * + * Provides the text for the unser hint providing some detailed information + * how to use this widget. * This method can be overwritten to adjust the text for some content types. * {@link #getNameLabel()} * diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicPageForm.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicPageForm.java index 965c86bd3..6062c16c6 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicPageForm.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicPageForm.java @@ -206,7 +206,9 @@ public abstract class BasicPageForm extends BasicItemForm { * form. See {@link PageCreate} for an example. * * @param state the current page state - * @return the new content item (or a proper subclass thereof) @pre state != null @post return != null + * @return the new content item (or a proper subclass thereof) + * @throws com.arsdigita.bebop.FormProcessException + * @pre state != null @post return != null */ public ContentPage createContentPage(PageState state) throws FormProcessException { @@ -220,8 +222,12 @@ public abstract class BasicPageForm extends BasicItemForm { try { item = (ContentPage) m.createItem(); } catch (ServletException ex) { - throw new FormProcessException((String) GlobalizationUtil.globalize( - "cms.ui.authoring.couldnt_create_contentpage").localize(), ex); + throw new FormProcessException( + "Couldn't create contentpage", + GlobalizationUtil.globalize( + "cms.ui.authoring.couldnt_create_contentpage"), + ex + ); } // Make sure the item will be remembered across requests diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/ItemCategoryStep.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/ItemCategoryStep.java index 9eed99aa7..a3a1017cf 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/ItemCategoryStep.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/ItemCategoryStep.java @@ -98,6 +98,7 @@ public class ItemCategoryStep extends SimpleContainer add(m_add); } + @Override public void register(Page p) { super.register(p); @@ -109,6 +110,7 @@ public class ItemCategoryStep extends SimpleContainer p.addGlobalStateParam(m_mode); } + @Override public void reset(PageState state) { state.setValue(m_root, null); state.setValue(m_mode, null); @@ -128,6 +130,7 @@ public class ItemCategoryStep extends SimpleContainer m_mode = mode; } + @Override public void actionPerformed(ActionEvent e) { PageState state = e.getPageState(); @@ -147,6 +150,7 @@ public class ItemCategoryStep extends SimpleContainer } private class ResetListener implements ActionListener { + @Override public void actionPerformed(ActionEvent e) { PageState state = e.getPageState(); reset(state); @@ -159,6 +163,7 @@ public class ItemCategoryStep extends SimpleContainer public ExtensionListener(int i) { extensionIndex = i; } + @Override public void actionPerformed(ActionEvent e) { PageState state = e.getPageState(); m_summary.setVisible(state, false); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/NameValidationListener.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/NameValidationListener.java index edb90e6f9..dc8d94248 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/NameValidationListener.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/NameValidationListener.java @@ -21,49 +21,60 @@ package com.arsdigita.cms.ui.authoring; import com.arsdigita.bebop.event.ParameterEvent; import com.arsdigita.bebop.event.ParameterListener; import com.arsdigita.bebop.parameters.ParameterData; -import org.apache.log4j.Logger; +import com.arsdigita.cms.util.GlobalizationUtil; import java.util.StringTokenizer; +import org.apache.log4j.Logger; + /** - * Verifies that the parameter is a valid filename, is not null, and - * contains no reserved characters. + * Verifies that the parameter is a valid filenamersp. URL stub, is not null, + * and contains no reserved characters. * * @author Justin Ross <jross@redhat.com> + * @author Peter Boy <pb@zes.uni-bremen.de> * @version $Id: NameValidationListener.java 2090 2010-04-17 08:04:14Z pboy $ */ public class NameValidationListener implements ParameterListener { + + /** 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.ui.authoring.NameValidationListener=DEBUG + * by uncommenting or adding the line. */ private static final Logger s_log = Logger.getLogger - (NameValidationListener.class); + (NameValidationListener.class); - // Why is this protected? XXX - protected String label; + /** + * Default Constructor, creates a new NameValidationListener. + */ + public NameValidationListener() { - // XXX this stuff needs globalization + } /** * Constructs a new NameValidationListener. * * @param label the label for the error message + * @deprecated with no replacement. Does nothing anymore. */ public NameValidationListener(final String label) { - this.label = label; + // Do nothing } /** - * Constructs a new NameValidationListener. + * Validate the input field as passed in by ParameterEvent. + * + * @param e ParameterEvent containing input data. */ - public NameValidationListener() { - this("This parameter"); - } - + @Override public void validate(final ParameterEvent e) { final ParameterData data = e.getParameterData(); final Object value = data.getValue(); if (value == null || value.toString().length() < 1) { - data.addError(label + " may not be null"); + data.addError(GlobalizationUtil + .globalize("cms.ui.authoring.parameter_not_empty")); return; } @@ -76,12 +87,14 @@ public class NameValidationListener implements ParameterListener { final String token = tok.nextToken(); if (!token.equals(text)) { - data.addError(label + " should be a valid filename"); + data.addError(GlobalizationUtil.globalize( + "cms.ui.authoring.parameter_should_be_a_valid_filename")); } } if (text.indexOf(".") != -1) { - data.addError(label + " may not contain periods"); + data.addError(GlobalizationUtil.globalize( + "cms.ui.authoring.parameter_should_be_a_valid_filename")); } } } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageCreate.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageCreate.java index ca285ffc5..f43b3921f 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageCreate.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageCreate.java @@ -34,6 +34,7 @@ import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.util.Assert; import java.util.Date; + import org.apache.log4j.Logger; /** @@ -65,13 +66,12 @@ public class PageCreate extends BasicPageForm * Construct a new PageCreationForm * * @param itemModel The {@link ItemSelectionModel} which will be - * responsible for loading the current item - * - * @param parent The {@link CreationSelector} parent. This class - * should call either the {@link - * CreationSelector#redirectBack(PageState)} or {@link - * CreationSelector#editItem(PageState, ContentItem)} methods on - * the parent eventually + * responsible for loading the current item + * @param parent The {@link CreationSelector} parent. This class + * should call either the {@link + * CreationSelector#redirectBack(PageState)} or {@link + * CreationSelector#editItem(PageState, ContentItem)} + * methods on the parent eventually */ public PageCreate(final ItemSelectionModel itemModel, final CreationSelector parent) { @@ -114,21 +114,27 @@ public class PageCreate extends BasicPageForm * * @return the ApplyWorkflowFormSection associated with this CreationComponent. */ + @Override public ApplyWorkflowFormSection getWorkflowSection() { return m_workflowSection; } /** * Create a new item id. + * @throws com.arsdigita.bebop.FormProcessException */ + @Override public void init(FormSectionEvent e) throws FormProcessException { // this is currently a no-op } /** - * If the Cancel button was pressed, hide self and - * show the display component + * If the Cancel button was pressed, hide self and show the display + * component. + * + * @throws com.arsdigita.bebop.FormProcessException */ + @Override public void submitted(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageCreateDynamic.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageCreateDynamic.java index 8ff7f8f13..cea8160aa 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageCreateDynamic.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageCreateDynamic.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.ui.authoring; -import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.Component; import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; @@ -33,10 +32,8 @@ import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.event.FormValidationListener; import com.arsdigita.bebop.event.PrintEvent; import com.arsdigita.bebop.event.PrintListener; -import com.arsdigita.bebop.form.Hidden; import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.SingleSelect; -import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.AuthoringKit; import com.arsdigita.cms.CMS; import com.arsdigita.cms.ContentBundle; @@ -56,11 +53,7 @@ import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.dispatcher.MultipartHttpServletRequest; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DomainObjectFactory; -import com.arsdigita.formbuilder.PersistentComponent; -import com.arsdigita.formbuilder.PersistentForm; import com.arsdigita.metadata.DynamicObjectType; -import com.arsdigita.mimetypes.ImageMimeType; -import com.arsdigita.persistence.DataAssociationCursor; import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; @@ -70,7 +63,7 @@ import com.arsdigita.persistence.metadata.MetadataRoot; import com.arsdigita.persistence.metadata.ObjectType; import com.arsdigita.persistence.metadata.Property; import com.arsdigita.util.Assert; -import com.arsdigita.util.UncheckedWrapperException; + import java.io.File; import java.io.IOException; import java.lang.reflect.Constructor; @@ -80,14 +73,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.Iterator; -import java.util.TooManyListenersException; import javax.servlet.ServletException; import org.apache.log4j.Logger; /** - * The creation component for user-defined content items + * The creation component for user-defined content items. * * TODO: subclass PageCreate now that this no longer extends MetaForm? */ @@ -343,6 +335,7 @@ public class PageCreateDynamic extends FormSection /** * instanciate and add the save/cancel section for this form */ + @Override public void addSaveCancelSection() { if (m_parentComponent != null) { m_parentComponent.addSaveCancelSection(); @@ -352,6 +345,7 @@ public class PageCreateDynamic extends FormSection /** * @return the save/cancel section for this form */ + @Override public SaveCancelSection getSaveCancelSection() { if (m_parentComponent != null) { return m_parentComponent.getSaveCancelSection(); @@ -365,6 +359,7 @@ public class PageCreateDynamic extends FormSection * * @return the ApplyWorkflowFormSection associated with this CreationComponent. */ + @Override public ApplyWorkflowFormSection getWorkflowSection() { if (m_parentComponent != null) { return m_parentComponent.getWorkflowSection(); @@ -373,14 +368,18 @@ public class PageCreateDynamic extends FormSection } } + @Override public void init(FormSectionEvent e) throws FormProcessException { // this is currently a no-op } /** * Submission: If the Cancel button was pressed, hide self and - * show the display component + * show the display component. + * + * @throws com.arsdigita.bebop.FormProcessException */ + @Override public void submitted(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); @@ -393,8 +392,12 @@ public class PageCreateDynamic extends FormSection } /** - * Validate: ensure name uniqueness + * Validate: ensure name uniqueness. + * + * @param e + * @throws com.arsdigita.bebop.FormProcessException */ + @Override public void validate(FormSectionEvent e) throws FormProcessException { Folder f = m_parent.getFolder(e.getPageState()); Assert.exists(f); @@ -402,8 +405,12 @@ public class PageCreateDynamic extends FormSection } /** - * Process: save fields to the database + * Process: save fields to the database. + * + * @param e + * @throws com.arsdigita.bebop.FormProcessException */ + @Override public void process(FormSectionEvent e) throws FormProcessException { FormData data = e.getFormData(); PageState state = e.getPageState(); @@ -590,11 +597,16 @@ public class PageCreateDynamic extends FormSection * @throws FormProcessException if the folder already contains an item * with the name the user provided on the input form. */ - public void validateNameUniqueness(Folder parent, FormSectionEvent e) throws FormProcessException { + public void validateNameUniqueness(Folder parent, FormSectionEvent e) + throws FormProcessException { FormData data = e.getFormData(); if ( parent.getItem((String) data.get(NAME), false) != null ) { - throw new FormProcessException( (String) GlobalizationUtil.globalize("cms.ui.authoring.an_item_with_this_name_already_exists").localize()); + throw new FormProcessException( + "An Item with his name already exists", + GlobalizationUtil.globalize( + "cms.ui.authoring.an_item_with_this_name_already_exists") + ); } } @@ -605,6 +617,7 @@ public class PageCreateDynamic extends FormSection * * @param state the current page state * @return the new content item (or a proper subclass thereof) + * @throws com.arsdigita.bebop.FormProcessException * @pre state != null * @post return != null */ @@ -718,6 +731,7 @@ public class PageCreateDynamic extends FormSection * * @param pc the component to add to this BasicPageForm * */ + @Override public void add(Component pc) { if (m_parentComponent != null) { m_parentComponent.add(pc); @@ -732,10 +746,10 @@ public class PageCreateDynamic extends FormSection * static ints. Use a bitwise OR to specify multiple constraints. * * @param pc the component to add to this container - * - * @param constraints layout constraints (a - * bitwise OR of static ints in the particular layout) - * */ + * @param constraints layout constraints (a bitwise OR of static ints + * in the particular layout) + */ + @Override public void add(Component pc, int constraints) { if (m_parentComponent != null) { m_parentComponent.add(pc, constraints); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageEdit.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageEdit.java index 54d65043d..7e6f3cfbd 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageEdit.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/PageEdit.java @@ -120,12 +120,24 @@ public class PageEdit extends SimpleEditStep { super("PageEditForm", itemModel); } - // Init: load the item and preset the widgets + /** + * Load the item and preset the widgets. + * + * @param e + * @throws FormProcessException + */ + @Override public void init(FormSectionEvent e) throws FormProcessException { super.initBasicWidgets(e); } - // Process: save fields to the database + /** + * Process the entry data, specifically save fields to the database. + * + * @param e + * @throws FormProcessException + */ + @Override public void process(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); ContentPage item = (ContentPage)super.processBasicWidgets(e); @@ -134,6 +146,7 @@ public class PageEdit extends SimpleEditStep { } } + @Override public void validate(FormSectionEvent event) throws FormProcessException { super.validate(event); 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 366495ddc..8d108e320 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/SimpleEditStep.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/SimpleEditStep.java @@ -202,11 +202,10 @@ public class SimpleEditStep extends SecurityPropertyEditor } /** - * Open the edit component if the streamlined - * creation parameter is turned on _and_ the streamlined_creation - * global state param is set to 'active' + * Open the edit component if the streamlined creation parameter is turned + * on _and_ the streamlined_creation global state param is set to 'active' * - * @param state the PageState + * @param e */ @Override public void pageRequested(RequestEvent e) { @@ -265,6 +264,7 @@ public class SimpleEditStep extends SecurityPropertyEditor * @return A String representation of the retrieved boolean * attribute of the domain object. */ + @Override public String format(DomainObject obj, String attribute, PageState state) { if ( obj != null && obj instanceof ContentPage) { diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoringkit/EditKit.java b/ccm-cms/src/com/arsdigita/cms/ui/authoringkit/EditKit.java index 3c619907c..e7f04f841 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoringkit/EditKit.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoringkit/EditKit.java @@ -63,7 +63,7 @@ public class EditKit extends Form protected SaveCancelSection m_saveCancelSection; /** - * @param types The content type selection model. This is to tell the form + * @param type The content type selection model. This is to tell the form * which content type is selected. */ public EditKit(ContentTypeRequestLocal type) { @@ -87,6 +87,7 @@ public class EditKit extends Form addProcessListener(this); addInitListener(this); addSubmissionListener(new FormSubmissionListener() { + @Override public void submitted(FormSectionEvent event) throws FormProcessException { PageState state = event.getPageState(); @@ -134,7 +135,9 @@ public class EditKit extends Form /** * Form init listener which initializes form values. + * @param e */ + @Override public void init(FormSectionEvent e) { FormData data = e.getFormData(); PageState state = e.getPageState(); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/util/UniqueStringValidationListener.java b/ccm-cms/src/com/arsdigita/cms/ui/util/UniqueStringValidationListener.java index 860732796..78c00594d 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/util/UniqueStringValidationListener.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/util/UniqueStringValidationListener.java @@ -48,6 +48,8 @@ public abstract class UniqueStringValidationListener /** * Constructor. + * + * @param widget */ public UniqueStringValidationListener(Widget widget) { this(widget, null); @@ -76,10 +78,12 @@ public abstract class UniqueStringValidationListener * then the name is invalid. * * @param event The form section event + * @throws com.arsdigita.bebop.FormProcessException * @pre ( event != null ) */ + @Override public final void validate(FormSectionEvent event) - throws FormProcessException { + throws FormProcessException { PageState state = event.getPageState(); diff --git a/ccm-cms/src/com/arsdigita/cms/util/GlobalizationUtil.java b/ccm-cms/src/com/arsdigita/cms/util/GlobalizationUtil.java index 35c30fac9..02e5b58e7 100755 --- a/ccm-cms/src/com/arsdigita/cms/util/GlobalizationUtil.java +++ b/ccm-cms/src/com/arsdigita/cms/util/GlobalizationUtil.java @@ -39,6 +39,8 @@ public class GlobalizationUtil implements Globalized { /** * Returns a globalized message using the package specific bundle, * provided by BUNDLE_NAME. + * @param key + * @return */ public static GlobalizedMessage globalize(String key) { return new GlobalizedMessage(key, BUNDLE_NAME); @@ -48,6 +50,9 @@ public class GlobalizationUtil implements Globalized { * 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. + * @param key + * @param args + * @return */ public static GlobalizedMessage globalize(String key, Object[] args) { return new GlobalizedMessage(key, BUNDLE_NAME, args); diff --git a/ccm-core/src/com/arsdigita/bebop/ui/BebopResources.properties b/ccm-core/src/com/arsdigita/bebop/BebopResources.properties similarity index 97% rename from ccm-core/src/com/arsdigita/bebop/ui/BebopResources.properties rename to ccm-core/src/com/arsdigita/bebop/BebopResources.properties index 7ea97a111..ceef11533 100755 --- a/ccm-core/src/com/arsdigita/bebop/ui/BebopResources.properties +++ b/ccm-core/src/com/arsdigita/bebop/BebopResources.properties @@ -93,3 +93,5 @@ bebop.are_you_sure=Are you sure? bebop.the_model_is_empty=The Model is Empty bebop.save=Save bebop.cancel=Cancel +bebop.cancel.msg=Submission Cancelled +bebop.parameter.unexpected_value_type=Unexpected value type: {0} diff --git a/ccm-core/src/com/arsdigita/bebop/ui/BebopResources_de.properties b/ccm-core/src/com/arsdigita/bebop/BebopResources_de.properties similarity index 97% rename from ccm-core/src/com/arsdigita/bebop/ui/BebopResources_de.properties rename to ccm-core/src/com/arsdigita/bebop/BebopResources_de.properties index 9a999e91c..b14131e83 100644 --- a/ccm-core/src/com/arsdigita/bebop/ui/BebopResources_de.properties +++ b/ccm-core/src/com/arsdigita/bebop/BebopResources_de.properties @@ -93,3 +93,5 @@ bebop.are_you_sure=Sind Sie sicher? bebop.the_model_is_empty=The Model is Empty bebop.save=Speichern bebop.cancel=Abbrechen +bebop.cancel.msg=Bearbeitung abgebrochen +bebop.parameter.unexpected_value_type=Unerwarteter Typ des Wertes: {0} diff --git a/ccm-core/src/com/arsdigita/bebop/ui/BebopResources_fr.properties b/ccm-core/src/com/arsdigita/bebop/BebopResources_fr.properties similarity index 98% rename from ccm-core/src/com/arsdigita/bebop/ui/BebopResources_fr.properties rename to ccm-core/src/com/arsdigita/bebop/BebopResources_fr.properties index 483d8fc4d..ebf898037 100755 --- a/ccm-core/src/com/arsdigita/bebop/ui/BebopResources_fr.properties +++ b/ccm-core/src/com/arsdigita/bebop/BebopResources_fr.properties @@ -93,3 +93,5 @@ bebop.are_you_sure=TRANSLATE THIS: Are you sure? (bebop.are_you_sure) bebop.the_model_is_empty=TRANSLATE THIS: The Model is Empty (bebop.the_model_is_empty) bebop.save=TRANSLATE THIS: Previous (bebop.save) bebop.cancel=TRANSLATE THIS: Previous (bebop.cancel) +bebop.cancel.msg=TRANSLATE THIS: Previous (bebop.cancel.submission.msg) +bebop.parameter.unexpected_value_type=Unexpected value type: {0} diff --git a/ccm-core/src/com/arsdigita/bebop/FormData.java b/ccm-core/src/com/arsdigita/bebop/FormData.java index 2b4e2fb56..20489a6f5 100755 --- a/ccm-core/src/com/arsdigita/bebop/FormData.java +++ b/ccm-core/src/com/arsdigita/bebop/FormData.java @@ -344,12 +344,13 @@ public class FormData implements Map, Cloneable { * the parameter model identified by name. * * @param name the name of the parameter model to whose - * ParameterData the error message will be added + * ParameterData the error message will be added * * @param message the text of the error message to add * * @pre name != null * @pre message != null + * @deprecated use addError(String name, GlobalizedMessage message) instead */ public void addError(String name, String message) { @@ -459,11 +460,13 @@ public class FormData implements Map, Cloneable { } } + @Override public boolean hasNext() { seekToNextError(); return paramErrors.hasNext() || formErrors.hasNext(); } + @Override public Object next() throws NoSuchElementException { seekToNextError(); @@ -475,6 +478,7 @@ public class FormData implements Map, Cloneable { return formErrors.next(); } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -493,9 +497,11 @@ public class FormData implements Map, Cloneable { } /** - * Sets the ParameterData object identified by the name in this FormData Object. + * Sets the ParameterData object identified by the name in this FormData + * Object. * * @param name the name of the parameterModel + * @param value */ public void setParameter(String name, ParameterData value) { m_parameterDataValues.put(name,value); @@ -512,9 +518,9 @@ public class FormData implements Map, Cloneable { /** * Determines whether this request represents a submission event. + * * @return true if this request represents a submission event; * false if it represents an initialization event. - * */ public final boolean isSubmission() { return m_isSubmission; @@ -523,9 +529,10 @@ public class FormData implements Map, Cloneable { /** * Determines whether the key-value string pairs in the * request have been transformed into Java data objects. - * @return true if the key-value string pairs - * have been transformed into Java data objects; - * false otherwise. + * + * @return true if the key-value string pairs have been + * transformed into Java data objects; + * false otherwise. * */ public final boolean isTransformed() { @@ -630,14 +637,17 @@ public class FormData implements Map, Cloneable { // --- Public methods to satisfy Map interface --- + @Override public void clear() { throw new UnsupportedOperationException(); } + @Override public boolean containsKey(Object key) { return m_parameterDataValues.containsKey(key); } + @Override public boolean containsValue(Object value) { // this is very expensive with ParameterData throw new UnsupportedOperationException(); @@ -647,6 +657,7 @@ public class FormData implements Map, Cloneable { * This is just plain wrong. Either you pretend to be a Map of * things, or you are a Map of ParameterData-s. */ + @Override public Set entrySet() { return m_parameterDataValues.entrySet(); } @@ -660,6 +671,7 @@ public class FormData implements Map, Cloneable { * @throws java.lang.IllegalArgumentException thrown when the key * is not a valid parameter. */ + @Override public Object get(Object key) throws IllegalArgumentException { ParameterData p = getParameter((String)key); @@ -671,8 +683,10 @@ public class FormData implements Map, Cloneable { } /** + * @param m + * @return * @deprecated Use get(m.getName()) instead, and then manually check - * for model identity + * for model identity */ public Object get(ParameterModel m) { ParameterData p = getParameter(m.getName()); @@ -712,14 +726,17 @@ public class FormData implements Map, Cloneable { } + @Override public boolean isEmpty() { return m_parameterDataValues.isEmpty(); } + @Override public Set keySet() { return m_parameterDataValues.keySet(); } + @Override public Object put(Object key, Object value) { Object previousValue = get(key); setParameterValue((String)key, value); @@ -727,6 +744,7 @@ public class FormData implements Map, Cloneable { return previousValue; } + @Override public void putAll(Map t) { for (Iterator i = t.keySet().iterator(); i.hasNext(); ) { String key = (String) i.next(); @@ -735,18 +753,32 @@ public class FormData implements Map, Cloneable { m_isValid = false; } + /** + * + * @param key + * @return + */ + @Override public Object remove(Object key) { throw new UnsupportedOperationException(); } + @Override public int size() { return m_parameterDataValues.size(); } + @Override public Collection values() { throw new UnsupportedOperationException(); } + /** + * + * @return + * @throws CloneNotSupportedException + */ + @Override public Object clone() throws CloneNotSupportedException { FormData result = (FormData) super.clone(); result.m_parameterDataValues = new HashMap(); @@ -764,8 +796,9 @@ public class FormData implements Map, Cloneable { } + @Override public String toString() { - StringBuffer s = new StringBuffer(); + StringBuilder s = new StringBuilder(); for (Iterator i = getAllErrors(); i.hasNext();) { s.append(i.next()).append(System.getProperty("line.separator")); @@ -775,13 +808,14 @@ public class FormData implements Map, Cloneable { } /** - * Converts to a String. + * Converts to a String. * The method {@link #toString()} returns all errors. + * * @return a human-readable representation of this. */ public String asString() { String newLine = System.getProperty("line.separator"); - StringBuffer to = new StringBuffer(); + StringBuilder to = new StringBuilder(); to.append(super.toString() + " = {" + newLine); //Map to.append("m_parameterDataValues = ") diff --git a/ccm-core/src/com/arsdigita/bebop/FormProcessException.java b/ccm-core/src/com/arsdigita/bebop/FormProcessException.java index 55ab60270..a3b3e8fec 100755 --- a/ccm-core/src/com/arsdigita/bebop/FormProcessException.java +++ b/ccm-core/src/com/arsdigita/bebop/FormProcessException.java @@ -18,39 +18,88 @@ */ package com.arsdigita.bebop; +import com.arsdigita.globalization.GlobalizedMessage; import javax.servlet.ServletException; /** - * This class represents exceptions that occur within the processing - * methods of any of the form event listeners. Typically the code - * will catch specific exceptions such as SQLException - * and rethrow them as instances of this class to pass the message to - * the controller in a standard fashion. + * This class represents exceptions that occur within the processing methods + * of any of the form event listeners. Typically the code will catch specific + * exceptions such as SQLException and rethrow them as instances + * of this class to pass the message to the controller in a standard fashion. * - *

Since this class is a subclass of ServletException, - * servlets that do form processing within a doPost or - * doGet methods do not need to explicitly catch - * instances of this class. However, they may wish to do so for - * special error reporting to the user, or to notify the webmaster via - * e-mail of the problem. + *

Since this class is a subclass of ServletException, servlets + * that do form processing within a doPost or doGet + * methods do not need to explicitly catch instances of this class. However, + * they may wish to do so for special error reporting to the user, or to notify + * the webmaster via e-mail of the problem. * * @version $Id: FormProcessException.java 287 2005-02-22 00:29:02Z sskracic $ */ public class FormProcessException extends ServletException { + /** Globalized version of the exception message, intended for output in the UI */ + private GlobalizedMessage m_globalizedMessage; + public FormProcessException(String message) { super(message); } + + public FormProcessException(String message, + GlobalizedMessage globalizedMessage) { + super(message); + m_globalizedMessage = globalizedMessage; + } + + public FormProcessException(GlobalizedMessage globalizedMessage) { + super(); + m_globalizedMessage = globalizedMessage; + } - public FormProcessException(String message, Throwable rootCause) { + /** + * + * @param message + * @param rootCause + * @deprecated use FormProcessException(String,GlobalizedMessage,Throwable) + * instead + */ + public FormProcessException(String message, + Throwable rootCause) { super(message, rootCause); } + public FormProcessException(String message, + GlobalizedMessage globalizedMessage, + Throwable rootCause) { + super(message, rootCause); + m_globalizedMessage = globalizedMessage; + } + public FormProcessException(Throwable rootCause) { super(rootCause); } + /** + * Add a globalized version of the exception message just in case a non- + * globalized message enabled constructor has been used. + * + * @param globalizedMessage the globalized message intended for output in UI + */ + public void setGlobalizedMessage(GlobalizedMessage globalizedMessage) { + m_globalizedMessage = globalizedMessage; + } + + /** + * Retrieve the globalized version of the exception message, intended for + * use in the UI widgets. + * The standard non-globalizatin enabled exception message is for use in + * log entries only! + * + * @return the globalized message intended for output in UI + */ + GlobalizedMessage getGlobalizedMessage() { + return m_globalizedMessage; + } /** * In addition to printing the stack trace for this exception, also prints * the stack trace for the root cause, if any. This is a workaround for @@ -70,6 +119,7 @@ public class FormProcessException extends ServletException { } /** + * @param s * @see #printStackTrace() */ @Override @@ -82,6 +132,7 @@ public class FormProcessException extends ServletException { } /** + * @param s * @see #printStackTrace() */ @Override @@ -96,6 +147,7 @@ public class FormProcessException extends ServletException { /** *

Returns the concatenation of {@link #getMessage()} and {@link * #getRootCause()}.getMessage().

+ * @return **/ public String getMessages() { StringBuilder result = new StringBuilder(getMessage()); diff --git a/ccm-core/src/com/arsdigita/bebop/FormSection.java b/ccm-core/src/com/arsdigita/bebop/FormSection.java index bbd61ef14..a60d8d924 100755 --- a/ccm-core/src/com/arsdigita/bebop/FormSection.java +++ b/ccm-core/src/com/arsdigita/bebop/FormSection.java @@ -27,18 +27,20 @@ import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.event.FormValidationListener; import com.arsdigita.util.Assert; import com.arsdigita.xml.Element; + import java.util.Iterator; + import org.apache.log4j.Logger; /** * A standalone section of a Form. A FormSection * contains other Bebop components, most importantly * Widgets and associated listeners. It serves two purposes: - * + * *

Since a FormSection has its own init, validation, and * process listeners, it can do all of its processing without any intervention * from the enclosing form. @@ -62,29 +64,31 @@ import org.apache.log4j.Logger; */ public class FormSection extends SimpleComponent implements Container { + /** Internal logger instance to faciliate debugging. Enable logging output + * by editing /WEB-INF/conf/log4j.properties int the runtime environment + * and set com.arsdigita.subsite.FormSection=DEBUG + * by uncommenting or adding the line. */ private static final Logger s_log = Logger.getLogger(FormSection.class); - /** - * Underlying FormModel that stores - * the parameter models for all the widgets in this form section. - */ + + /** Underlying FormModel that stores + * the parameter models for all the widgets in this form section. */ protected FormModel m_formModel; - /** - * The container to which all children are added. A - * ColumnPanel by default. - */ + + /** The container to which all children are added. A + * ColumnPanel by default. */ protected Container m_panel; - /** - * Contains all the listeners that were added with the various - * addXXXListener methods. - * - * We maintain our own list of listeners, so that we can re-send the - * events the FormModel generates, but with us as the source, not the - * FormModel. - */ + + /** Contains all the listeners that were added with the various + * addXXXListener methods. + * We maintain our own list of listeners, so that we can re-send the + * events the FormModel generates, but with us as the source, not the + * FormModel. */ private EventListenerList m_listeners; - // Listeners we attach to the FormModel to forward - // form model events to our listeners with the right source + + /** Listeners we attach to the FormModel to forward + * form model events to our listeners with the right source */ private FormSubmissionListener m_forwardSubmission; + private FormInitListener m_forwardInit; private FormValidationListener m_forwardValidation; private FormProcessListener m_forwardProcess; @@ -101,6 +105,8 @@ public class FormSection extends SimpleComponent implements Container { /** * Constructs a new form section. Sets the form model of this * FormSection to a new, anonymous FormModel. + * + * @param panel **/ public FormSection(Container panel) { this(panel, new FormModel("anonymous")); @@ -200,6 +206,9 @@ public class FormSection extends SimpleComponent implements Container { } } + /** + * + */ protected void forwardSubmission() { if (m_forwardSubmission == null) { m_forwardSubmission = createSubmissionListener(); @@ -217,6 +226,7 @@ public class FormSection extends SimpleComponent implements Container { protected FormSubmissionListener createSubmissionListener() { return new FormSubmissionListener() { + @Override public void submitted(FormSectionEvent e) throws FormProcessException { fireSubmitted(new FormSectionEvent(FormSection.this, @@ -287,6 +297,9 @@ public class FormSection extends SimpleComponent implements Container { } } + /** + * + */ protected void forwardInit() { if (m_forwardInit == null) { m_forwardInit = createInitListener(); @@ -304,6 +317,7 @@ public class FormSection extends SimpleComponent implements Container { protected FormInitListener createInitListener() { return new FormInitListener() { + @Override public void init(FormSectionEvent e) throws FormProcessException { fireInit(new FormSectionEvent(FormSection.this, @@ -322,6 +336,7 @@ public class FormSection extends SimpleComponent implements Container { protected FormCancelListener createCancelListener() { return new FormCancelListener() { + @Override public void cancel(FormSectionEvent e) throws FormProcessException { fireCancel(new FormSectionEvent(FormSection.this, e.getPageState(), @@ -389,7 +404,7 @@ public class FormSection extends SimpleComponent implements Container { listener.validate(e); } catch (FormProcessException fpe) { s_log.debug(fpe); - data.addError(fpe.getMessage()); + data.addError(fpe.getGlobalizedMessage()); } } } @@ -411,6 +426,7 @@ public class FormSection extends SimpleComponent implements Container { protected FormValidationListener createValidationListener() { return new FormValidationListener() { + @Override public void validate(FormSectionEvent e) { fireValidate(new FormSectionEvent(FormSection.this, e.getPageState(), @@ -470,6 +486,7 @@ public class FormSection extends SimpleComponent implements Container { protected FormProcessListener createProcessListener() { return new FormProcessListener() { + @Override public void process(FormSectionEvent e) throws FormProcessException { fireProcess(new FormSectionEvent(FormSection.this, @@ -507,8 +524,10 @@ public class FormSection extends SimpleComponent implements Container { * (Processing of form sections is done by the form in which the * section is contained.) * - * @throws javax.servlet.ServletException because processing a form section is - * not meaningful. + * @param data + * @return + * @throws javax.servlet.ServletException because processing a form section + * is not meaningful. */ public FormData process(PageState data) throws javax.servlet.ServletException { @@ -578,11 +597,11 @@ public class FormSection extends SimpleComponent implements Container { * of widgets in this FormSection to the supplied Form. * * @param f pointer to the form that is set inside Widgets within this - * FormSection - * + * FormSection * @param m the FormModel in which to merge ParameterModels and - * Listeners + * Listeners * */ + @Override public void register(Form f, FormModel m) { m.mergeModel(getModel()); } @@ -599,12 +618,14 @@ public class FormSection extends SimpleComponent implements Container { /** * Locks this FormSection, its FormModel, and the implicit Container. * */ + @Override public void lock() { m_formModel.lock(); m_panel.lock(); super.lock(); } + @Override public void respond(PageState state) throws javax.servlet.ServletException { //call listeners here. throw new UnsupportedOperationException(); @@ -614,7 +635,9 @@ public class FormSection extends SimpleComponent implements Container { * Returns the implicit Container of this FormSection. * * This must not be final, because MetaFrom needs to override it. - * */ + * + * @return + */ public Container getPanel() { return m_panel; } @@ -626,6 +649,7 @@ public class FormSection extends SimpleComponent implements Container { * * @post return != null * */ + @Override public Iterator children() { return m_panel.children(); } @@ -641,6 +665,7 @@ public class FormSection extends SimpleComponent implements Container { * @param pageState the state of the current page * @param parent the node that will be used to write to * */ + @Override public void generateXML(PageState pageState, Element parent) { if (isVisible(pageState)) { m_panel.generateXML(pageState, parent); @@ -653,6 +678,7 @@ public class FormSection extends SimpleComponent implements Container { * * @param pc the component to add to this container * */ + @Override public void add(Component pc) { m_panel.add(pc); } @@ -667,6 +693,7 @@ public class FormSection extends SimpleComponent implements Container { * @param constraints layout constraints (a * bitwise OR of static ints in the particular layout) * */ + @Override public void add(Component pc, int constraints) { m_panel.add(pc, constraints); } @@ -689,6 +716,7 @@ public class FormSection extends SimpleComponent implements Container { * specified component directly; false otherwise. * * */ + @Override public boolean contains(Object o) { return m_panel.contains(o); } @@ -706,6 +734,7 @@ public class FormSection extends SimpleComponent implements Container { * * @return the component at the specified position in this container * */ + @Override public Component get(int index) { return (Component) m_panel.get(index); } @@ -720,6 +749,7 @@ public class FormSection extends SimpleComponent implements Container { * the specified element, or -1 if this list does not contain this * element. * */ + @Override public int indexOf(Component pc) { return m_panel.indexOf(pc); } @@ -730,6 +760,7 @@ public class FormSection extends SimpleComponent implements Container { * @return true if this container contains no components * false otherwise. * */ + @Override public boolean isEmpty() { return m_panel.isEmpty(); } @@ -740,6 +771,7 @@ public class FormSection extends SimpleComponent implements Container { * * @return the number of components directly in this container. * */ + @Override public int size() { return m_panel.size(); } diff --git a/ccm-core/src/com/arsdigita/bebop/FormValidationException.java b/ccm-core/src/com/arsdigita/bebop/FormValidationException.java index 3f2792d7b..ecf962d9c 100755 --- a/ccm-core/src/com/arsdigita/bebop/FormValidationException.java +++ b/ccm-core/src/com/arsdigita/bebop/FormValidationException.java @@ -26,10 +26,11 @@ import com.arsdigita.bebop.form.Widget; * * @author rhs@mit.edu * @version $Id: FormValidationException.java 287 2005-02-22 00:29:02Z sskracic $ - **/ + */ public class FormValidationException extends FormProcessException { + /** */ private String m_name = null; public FormValidationException(String message) { diff --git a/ccm-core/src/com/arsdigita/bebop/PropertyEditor.java b/ccm-core/src/com/arsdigita/bebop/PropertyEditor.java index 9e7bf0ca7..ffe48d1ad 100755 --- a/ccm-core/src/com/arsdigita/bebop/PropertyEditor.java +++ b/ccm-core/src/com/arsdigita/bebop/PropertyEditor.java @@ -27,6 +27,7 @@ import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.list.DefaultListCellRenderer; import com.arsdigita.bebop.list.ListModelBuilder; import com.arsdigita.bebop.list.ListModel; +import com.arsdigita.bebop.util.GlobalizationUtil; import com.arsdigita.util.Assert; import com.arsdigita.util.LockableImpl; import com.arsdigita.util.SequentialMap; @@ -101,8 +102,8 @@ import java.util.Map; * that will display the right components in the editor. The * {@link #addComponent(String, Component)} method can be used to add * a component to the PropertyEditor without automatically - * generating the link for it. The {@link #addVisibilityListener(ActionLink, String)} method can - * then be used to add an appropriate {@link ActionListener} to any + * generating the link for it. The {@link #addVisibilityListener(ActionLink, String)} + * method can then be used to add an appropriate {@link ActionListener} to any * {@link ActionLink}. For example: * *

// Add a form
@@ -124,13 +125,13 @@ import java.util.Map;
  * Therefore, the PropertyEditor is a model-backed component,
  * as described in the Bebop tutorials. This means that the list
  * of properties for the editor could be generated dynamically during
- * each request. The {@link #setModelBuilder(PropertyEditorModelBuilder)} method can be used to set
- * a specialized {@link PropertyEditorModelBuilder} for the editor. In order
- * to write the model builder, you may choose to extend the protected
- * inner classes {@link PropertyEditor.DefaultModelBuilder} and
+ * each request. The {@link #setModelBuilder(PropertyEditorModelBuilder)} method 
+ * can be used to set a specialized {@link PropertyEditorModelBuilder} for the 
+ * editor. In order to write the model builder, you may choose to extend the 
+ * protected inner classes {@link PropertyEditor.DefaultModelBuilder} and
  * {@link PropertyEditor.DefaultModel}. It is also possible to write the model
- * builder and the corresponding model from scratch. However, most people won't need to
- * do this.
+ * builder and the corresponding model from scratch. However, most people won't 
+ * need to do this.
  * 

* For example, SecurityPropertyEditor uses a custom * {@link PropertyEditorModelBuilder} in order to hide the links for properties @@ -196,6 +197,7 @@ public class PropertyEditor extends SimpleContainer { // Should a ComponentSelectionModel be used here instead ? It's tempting, // but there doesn't seem to be a real need for it m_list.addChangeListener(new ChangeListener() { + @Override public void stateChanged(ChangeEvent e) { PageState state = e.getPageState(); @@ -262,6 +264,7 @@ public class PropertyEditor extends SimpleContainer { * Shows the component that is identified by the specified key. * * @param state the page state + * @param key */ public void showComponent(PageState state, String key) { m_list.setSelectedKey(state, key); @@ -273,7 +276,7 @@ public class PropertyEditor extends SimpleContainer { * @param state the page state * * @return the key of the currently visible component, or null if the - * display pane is visible. + * display pane is visible. */ public String getSelectedComponentKey(PageState state) { return (String)m_list.getSelectedKey(state); @@ -458,8 +461,7 @@ public class PropertyEditor extends SimpleContainer { } /** - * Adds a form to the set of forms that can be used to edit the - * properties. + * Adds a form to the set of forms that can be used to edit the properties. * * @param key the symbolic key for the form (must be unique * for this PropertyEditor) @@ -529,11 +531,14 @@ public class PropertyEditor extends SimpleContainer { final Submit theButton = cancelButton; form.addSubmissionListener(new FormSubmissionListener() { + @Override public void submitted(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); if(theButton.isSelected(state)) { showDisplayPane(state); - throw new FormProcessException("Submission Cancelled"); + throw new FormProcessException( + "Submission Cancelled", + GlobalizationUtil.globalize("bebop.cancel.msg")); } } }); @@ -549,6 +554,7 @@ public class PropertyEditor extends SimpleContainer { */ public void addProcessListener(FormSection form) { form.addProcessListener(new FormProcessListener() { + @Override public void process(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); showDisplayPane(state); @@ -587,6 +593,7 @@ public class PropertyEditor extends SimpleContainer { public void addVisibilityListener(ActionLink l, String key) { final String t_key = key; l.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { showComponent(e.getPageState(), t_key); } @@ -697,6 +704,8 @@ public class PropertyEditor extends SimpleContainer { * Return an iterator of all properties of the specified property * editor. These properties should be passed into the constructor * of the {@link PropertyEditor.DefaultModel} + * @param p + * @return */ protected Iterator getProperties(PropertyEditor p) { return p.getLabelsMap().entrySet().iterator(); @@ -706,6 +715,7 @@ public class PropertyEditor extends SimpleContainer { * Construct a {@link PropertyEditorModel} for the current * request. */ + @Override public PropertyEditorModel makeModel(PropertyEditor p, PageState s) { return new DefaultModel(getProperties(p)); } @@ -726,6 +736,7 @@ public class PropertyEditor extends SimpleContainer { m_entry = null; } + @Override public boolean next() { if(!m_iter.hasNext()) { m_entry = null; @@ -740,6 +751,7 @@ public class PropertyEditor extends SimpleContainer { * request to ensure proper localization. * @return */ + @Override public Component getComponent() { Assert.exists(m_entry); if ( m_entry.getValue() instanceof GlobalizedMessage ) { @@ -755,6 +767,7 @@ public class PropertyEditor extends SimpleContainer { } } + @Override public Object getKey() { Assert.exists(m_entry); return m_entry.getKey(); @@ -767,13 +780,14 @@ public class PropertyEditor extends SimpleContainer { private static final class BuilderAdapter extends LockableImpl implements ListModelBuilder { - private PropertyEditor m_parent; + private final PropertyEditor m_parent; public BuilderAdapter(PropertyEditor parent) { super(); m_parent = parent; } + @Override public ListModel makeModel(List l, PageState state) { return new ModelAdapter(m_parent.getModel(state)); } @@ -784,14 +798,17 @@ public class PropertyEditor extends SimpleContainer { */ private static final class ModelAdapter implements ListModel { - private PropertyEditorModel m_model; + private final PropertyEditorModel m_model; public ModelAdapter(PropertyEditorModel model) { m_model = model; } + @Override public boolean next() { return m_model.next(); } + @Override public Object getElement() { return m_model.getComponent(); } + @Override public String getKey() { return m_model.getKey().toString(); } } diff --git a/ccm-core/src/com/arsdigita/bebop/Wizard.java b/ccm-core/src/com/arsdigita/bebop/Wizard.java index 8f92775ae..1f59bf54b 100755 --- a/ccm-core/src/com/arsdigita/bebop/Wizard.java +++ b/ccm-core/src/com/arsdigita/bebop/Wizard.java @@ -28,6 +28,7 @@ import com.arsdigita.bebop.event.ChangeListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.form.Submit; import com.arsdigita.bebop.form.Widget; +import static com.arsdigita.bebop.util.GlobalizationUtil.globalize; import com.arsdigita.bebop.util.Traversal; /** @@ -115,8 +116,12 @@ public class Wizard extends MultiStepForm { private Component m_first = null; private Component m_last = null; - private RequestLocal m_hiddenSteps = new RequestLocal() { - protected Object initialValue(PageState state) { + /** + * + */ + private final RequestLocal m_hiddenSteps = new RequestLocal() { + @Override + protected Object initialValue(PageState state) { return new HashSet(); } }; @@ -189,19 +194,24 @@ public class Wizard extends MultiStepForm { - - + /** + * + * @param p + */ + @Override public void register(Page p) { super.register(p); - p.setVisibleDefault(m_back, false); + p.setVisibleDefault(m_back, false); if (!m_quickFinish) { - p.setVisibleDefault(m_finish, false); + p.setVisibleDefault(m_finish, false); } Traversal trav = new Traversal () { + @Override protected void act(Component c) { if (c instanceof Widget) { ((Widget) c).setValidationGuard(new Widget.ValidationGuard() { + @Override public boolean shouldValidate(PageState ps) { return m_back.isSelected(ps); } @@ -303,6 +313,7 @@ public class Wizard extends MultiStepForm { } + @Override protected void fireSubmitted(FormSectionEvent evt) throws FormProcessException { super.fireSubmitted(evt); @@ -311,9 +322,17 @@ public class Wizard extends MultiStepForm { if (m_cancel.isSelected(ps)) { super.fireCancel(evt); ps.reset(this); - throw new FormProcessException("cancel hit"); + throw new FormProcessException("Submission cancelled", + globalize("bebop.cancel.msg")); } } + + /** + * + * @param evt + * @throws FormProcessException + */ + @Override protected void fireProcess(FormSectionEvent evt) throws FormProcessException { PageState ps = evt.getPageState(); @@ -332,8 +351,17 @@ public class Wizard extends MultiStepForm { } } + /** + * + */ private class SkipStepListener implements ChangeListener { - public void stateChanged(ChangeEvent e) { + + /** + * + * @param e + */ + @Override + public void stateChanged(ChangeEvent e) { PageState state = e.getPageState(); s_log.debug("state of underlying modal container changed - " + "new visible component is " + @@ -348,7 +376,7 @@ public class Wizard extends MultiStepForm { } } - } + } } diff --git a/ccm-core/src/com/arsdigita/bebop/demo/DemoDispatcher.java b/ccm-core/src/com/arsdigita/bebop/demo/DemoDispatcher.java index cfb951c06..a3ad8159a 100755 --- a/ccm-core/src/com/arsdigita/bebop/demo/DemoDispatcher.java +++ b/ccm-core/src/com/arsdigita/bebop/demo/DemoDispatcher.java @@ -63,6 +63,7 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.util.BebopConstants; import com.arsdigita.bebop.util.GlobalizationUtil; +import static com.arsdigita.bebop.util.GlobalizationUtil.globalize; import com.arsdigita.bebop.util.Size; import com.arsdigita.dispatcher.Dispatcher; import com.arsdigita.globalization.GlobalizedMessage; @@ -814,6 +815,7 @@ public class DemoDispatcher extends AutoDispatcher implements BebopConstants { static final String CASH = "cash"; static final String CANNON = "cannon"; + @Override public void validate(FormSectionEvent e) throws FormProcessException { FormData data = e.getFormData(); @@ -822,8 +824,8 @@ public class DemoDispatcher extends AutoDispatcher implements BebopConstants { if ( ! CASH.equals(payment) && CANNON.equals(shipment)) { throw new FormProcessException( - "Must pay cash when shipping via Burger Cannon" - ); + "Must pay cash when shipping via Burger Cannon", + globalize("(key missing)") ); } } } diff --git a/ccm-core/src/com/arsdigita/bebop/event/FormSectionEvent.java b/ccm-core/src/com/arsdigita/bebop/event/FormSectionEvent.java index c7e9486e4..ae7f1eaa3 100755 --- a/ccm-core/src/com/arsdigita/bebop/event/FormSectionEvent.java +++ b/ccm-core/src/com/arsdigita/bebop/event/FormSectionEvent.java @@ -36,11 +36,13 @@ import com.arsdigita.bebop.PageState; */ public class FormSectionEvent extends PageEvent { - private transient FormData _formData; + private final transient FormData _formData; /** * Get the form data for to the form that fired the event in the current * request. + * + * @return form data */ public final FormData getFormData() { return _formData; diff --git a/ccm-core/src/com/arsdigita/bebop/event/ParameterListener.java b/ccm-core/src/com/arsdigita/bebop/event/ParameterListener.java index ce91dfe93..af5e259a8 100755 --- a/ccm-core/src/com/arsdigita/bebop/event/ParameterListener.java +++ b/ccm-core/src/com/arsdigita/bebop/event/ParameterListener.java @@ -36,7 +36,8 @@ public interface ParameterListener extends EventListener { * specific parameter. Validate should call * ParameterData.addError() with a message regarding the nature * of the error. + * @param e + * @throws com.arsdigita.bebop.FormProcessException */ - void validate(ParameterEvent e) throws FormProcessException; } diff --git a/ccm-core/src/com/arsdigita/bebop/form/FileUpload.java b/ccm-core/src/com/arsdigita/bebop/form/FileUpload.java index f24589bbd..2f40b6274 100755 --- a/ccm-core/src/com/arsdigita/bebop/form/FileUpload.java +++ b/ccm-core/src/com/arsdigita/bebop/form/FileUpload.java @@ -59,29 +59,34 @@ public class FileUpload extends Widget { } /** - * Returns a string naming the type of this widget. + * Returns a string naming the type of this widget. + * @return */ + @Override public String getType() { return "file"; } + /** + * + * @return + */ + @Override public boolean isCompound() { return false; } - /** - * Callback method for rendering this File widget in a visitor. - */ - /* public void accept(FormVisitor visitor) throws IOException { - visitor.visitFile(this); - }*/ + /** + * + */ private class FileExistsValidationListener extends GlobalizedParameterListener { public FileExistsValidationListener() { setError(new GlobalizedMessage("file_empty_or_not_found", getBundleBaseName())); } + @Override public void validate (ParameterEvent e) { ParameterData data = e.getParameterData(); HttpServletRequest request = e.getPageState().getRequest(); @@ -93,7 +98,9 @@ public class FileUpload extends Widget { return; } - if (((MultipartHttpServletRequest) request).getFile(data.getModel().getName()).length()==0) { + if (((MultipartHttpServletRequest) request).getFile(data.getModel() + .getName()) + .length()==0) { data.addError(filename + " " + getError().localize()); } } diff --git a/ccm-core/src/com/arsdigita/bebop/form/Option.java b/ccm-core/src/com/arsdigita/bebop/form/Option.java index e151ad3cf..7beb24503 100755 --- a/ccm-core/src/com/arsdigita/bebop/form/Option.java +++ b/ccm-core/src/com/arsdigita/bebop/form/Option.java @@ -90,12 +90,13 @@ public class Option extends BlockStylable { /** - * If the component is a Label (which most of the time it is) - * then this returns the value of the label. This assumes - * that the Component is a label + * If the component is a Label (which most of the time it is) + * then this returns the value of the label. This assumes + * that the Component is a label * - * @exception ClassCastException is thrown if the component is not - * a label + * @return + * @exception ClassCastException is thrown if the component is not + * a label */ public final String getLabel() { return ((Label)m_component).getLabel(); diff --git a/ccm-core/src/com/arsdigita/bebop/form/Widget.java b/ccm-core/src/com/arsdigita/bebop/form/Widget.java index e03481f07..d18ec6d67 100755 --- a/ccm-core/src/com/arsdigita/bebop/form/Widget.java +++ b/ccm-core/src/com/arsdigita/bebop/form/Widget.java @@ -48,19 +48,22 @@ import com.arsdigita.xml.Element; /** *

- * A class representing a widget in the graphical representation of a form.

+ * A class representing a widget in the graphical representation of a form. + *

* *

- * A widget may correspond to a standard HTML form element, or to a more specific element or set of - * elements, such as a date widget that allows input of month, day and year (and possibly time as - * well).

+ * A widget may correspond to a standard HTML form element, or to a more + * specific element or set of elements, such as a date widget that allows + * input of month, day and year (and possibly time as well).

* *

- * This class and its subclasses provide methods to set all element attributes except for - * VALUE, which is typically dependent on the request. At the time of a request, a - * widget object merges a dynamically specified value or set of values with its own set of - * persistent attributes to render the final HTML for the widget. Other dynamic attributes may be - * associated with the form component via a WidgetPeer associated with the widget.

+ * This class and its subclasses provide methods to set all element attributes + * except for VALUE, which is typically dependent on the request. + * At the time of a request, a widget object merges a dynamically specified + * value or set of values with its own set of persistent attributes to render + * the final HTML for the widget. Other dynamic attributes may be associated + * with the form component via a WidgetPeer associated with the + * widget.

* * @author Karl Goldstein * @author Uday Mathur @@ -73,7 +76,7 @@ public abstract class Widget extends BlockStylable implements Cloneable, private static final Logger s_log = Logger.getLogger(Widget.class); private ParameterModel m_parameterModel; - private EventListenerList m_listeners = new EventListenerList(); + private final EventListenerList m_listeners = new EventListenerList(); private ParameterListener m_forwardParameter = null; private PrintListener m_printListener; private Form m_form; @@ -96,17 +99,23 @@ public abstract class Widget extends BlockStylable implements Cloneable, /** * Returns true if the widget consists of multiple HTML elements. + * + * @return */ public abstract boolean isCompound(); /** - * Returns a string naming the type of this widget. Must be implemented by subclasses + * Returns a string naming the type of this widget. Must be implemented by + * subclasses! + * + * @return */ protected abstract String getType(); /** * Constructs a new widget. * + * @param name */ protected Widget(String name) { this(new StringParameter(name)); @@ -116,8 +125,10 @@ public abstract class Widget extends BlockStylable implements Cloneable, * Constructs a new widget. * *

- * Each new widget is associated with a ParameterModel describing the data object(s) submitted - * from the widget. + * Each new widget is associated with a ParameterModel describing the + * data object(s) submitted from the widget. + * + * @param model */ protected Widget(ParameterModel model) { Assert.exists(model, ParameterModel.class); @@ -125,8 +136,13 @@ public abstract class Widget extends BlockStylable implements Cloneable, m_parameterModel = model; } + /** + * + * @return + */ protected ParameterListener createParameterListener() { return new ParameterListener() { + @Override public void validate(ParameterEvent evt) throws FormProcessException { fireValidation(new ParameterEvent(Widget.this, evt.getParameterData())); @@ -149,8 +165,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, PageState ps = evt.getPageState(); - if ((!validateInvisible() && !ps.isVisibleOnPage(this)) || ((m_guard != null) && m_guard. - shouldValidate(ps))) { + if ( (!validateInvisible() && !ps.isVisibleOnPage(this)) + || ((m_guard != null) && m_guard.shouldValidate(ps)) ) { return; } @@ -191,12 +207,12 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Adds a print listener for this widget. Only one print listener can be set for a widget, since - * the PrintListener is expected to modify the target of the - * PrintEvent. + * Adds a print listener for this widget. Only one print listener can + * be set for a widget, since the PrintListener is expected + * to modify the target of the PrintEvent. * * @param listener the print listener - * @throws IlegalArgumentException listener is null + * @throws IllegalArgumentException listener is null * @throws TooManyListenersException a print listener has previously been added * @pre listener != null */ @@ -212,12 +228,13 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Set the print listener for this widget. Since there can only be one print listener for a - * widget, this lets you just set it and avoid writing a try/catch block for - * "TooManyListenersException". Any existing listener will be overwritten. + * Set the print listener for this widget. Since there can only be one + * print listener for a widget, this lets you just set it and avoid + * writing a try/catch block for "TooManyListenersException". Any existing + * listener will be overwritten. * * @param listener the print listener - * @throws IlegalArgumentException listener is null + * @throws IllegalArgumentException listener is null * @pre listener != null */ public void setPrintListener(PrintListener listener) @@ -229,13 +246,15 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Remove a previously added print listener. If listener is not the listener that - * has been added with {@link #addPrintListener - * addPrintListener}, an IllegalArgumentException will be thrown. + * Remove a previously added print listener. + * If listener is not the listener that has been added with + * {@link #addPrintListener addPrintListener}, an IllegalArgumentException + * will be thrown. * - * @param listener the listener that had been added with addPrintListener - * @throws IllegalArgumentException listener is not the currently registered print - * listener or is null. + * @param listener the listener that had been added with + * addPrintListener + * @throws IllegalArgumentException listener is not the + * currently registered print listener or is null. * @pre listener != null */ public void removePrintListener(PrintListener listener) @@ -252,7 +271,10 @@ public abstract class Widget extends BlockStylable implements Cloneable, /** * Registers the ParameterModel of this Widget with the containing Form. This method is used by * the Bebop framework and should not be used by application developers. + * @param form + * @param model */ + @Override public void register(Form form, FormModel model) { model.addFormParam(getParameterModel()); @@ -260,8 +282,9 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Sets the Form Object for this Widget. This method will throw an exception if the _form - * pointer is already set. To explicity change the m_form pointer the developer must first call + * Sets the Form Object for this Widget. + * This method will throw an exception if the _form pointer is already set. + * To explicity change the m_form pointer the developer must first call * setForm(null) * * @param form The Form Object for this Widget @@ -269,7 +292,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, */ public void setForm(final Form form) { if (m_form != null && form != null) { - throw new IllegalStateException("Form " + form.getName() + " already set for " + throw new IllegalStateException("Form " + form.getName() + + " already set for " + getName()); } @@ -277,8 +301,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Gets the Form Object for this Widget. Throws an exception if the Widget doesn't belong to a - * form. + * Gets the Form Object for this Widget. + * Throws an exception if the Widget doesn't belong to a form. * * @return the {@link Form} Object for this Widget. * @post return != null @@ -293,52 +317,70 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Sets the ONFOCUS attribute for the HTML tags that compose this element. + * Sets the ONFOCUS attribute for the HTML tags that compose + * this element. + * + * @param javascriptCode */ public void setOnFocus(String javascriptCode) { setAttribute(ON_FOCUS, javascriptCode); } /** - * Sets the ONBLUR attribute for the HTML tags that compose this element. + * Sets the ONBLUR attribute for the HTML tags that compose + * this element. + * + * @param javascriptCode */ public void setOnBlur(String javascriptCode) { setAttribute(ON_BLUR, javascriptCode); } /** - * Sets the ONSELECT attribute for the HTML tags that compose this element. + * Sets the ONSELECT attribute for the HTML tags that compose + * this element. + * + * @param javascriptCode */ public void setOnSelect(String javascriptCode) { setAttribute(ON_SELECT, javascriptCode); } /** - * Sets the ONCHANGE attribute for the HTML tags that compose this element. + * Sets the ONCHANGE attribute for the HTML tags that compose + * this element. + * + * @param javascriptCode */ public void setOnChange(String javascriptCode) { setAttribute(ON_CHANGE, javascriptCode); } /** - * Sets the ON_KEY_UP attribute for the HTML tags that compose this element. + * Sets the ON_KEY_UP attribute for the HTML tags that compose + * this element. * + * @param javascriptCode */ public void setOnKeyUp(String javascriptCode) { setAttribute(ON_KEY_UP, javascriptCode); } /** - * Sets the default value in the parameter model for this element. This is a static property and - * this method should not be invoked at request time (not even in a PrintListener). + * Sets the default value in the parameter model for this element. + * This is a static property and this method should not be invoked + * at request time (not even in a PrintListener). + * + * @param value */ public void setDefaultValue(Object value) { m_parameterModel.setDefaultValue(value); } /** - * Marks this widget as readonly, which has the effect of preventing the user from modifying the - * widget's contents. This method can only be called on unlocked widgets. + * Marks this widget as readonly, which has the effect of preventing the + * user from modifying the widget's contents. + * This method can only be called on unlocked widgets. */ public void setReadOnly() { Assert.isUnlocked(this); @@ -346,8 +388,9 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Marks this widget as disabled, which has the effect of preventing the widget's value being - * submitted with the form, and will typically cause the widget to be 'grayed out' on the form. + * Marks this widget as disabled, which has the effect of preventing the + * widget's value being submitted with the form, and will typically cause + * the widget to be 'grayed out' on the form. * This method can only be called on unlocked widgets. */ public void setDisabled() { @@ -358,8 +401,9 @@ public abstract class Widget extends BlockStylable implements Cloneable, /** * Sets a popup hint for the widget. * - * @deprecated refactor to use a GlobalizedMessage instead and use setHint(GlobalizedMessage - * hint) + * @param hint + * @deprecated refactor to use a GlobalizedMessage instead and use + * setHint(GlobalizedMessage hint) */ public void setHint(String hint) { Assert.isUnlocked(this); @@ -368,6 +412,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, /** * Sets a popup hint for the widget. + * + * @param hint */ public void setHint(GlobalizedMessage hint) { Assert.isUnlocked(this); @@ -376,6 +422,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, /** * Sets a Label for the widget. + * + * @param label */ public void setLabel(GlobalizedMessage label) { m_label = label; @@ -383,6 +431,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, /** * Sets a Label for the widget. + * + * @return */ public GlobalizedMessage getLabel() { return m_label; @@ -390,6 +440,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, /** * Gets the default value in the parameter model for this element. + * + * @return */ public String getDefaultValue() { Object o = m_parameterModel.getDefaultValue(); @@ -404,28 +456,30 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * The "pass in" property determines whether the value for this parameter is generally passed in - * from the outside. If this property is true, the model always tries to get the - * parameter value from the request, no matter whether the request is the initial request or a - * submission of the form to which the widget belongs. + * The "pass in" property determines whether the value for this parameter + * is generally passed in from the outside. + * If this property is true, the model always tries to get the + * parameter value from the request, no matter whether the request is the + * initial request or a submission of the form to which the widget belongs. * *

- * If this property is false, the parameter value is only read from the request if - * it is a submission of the form containing the widget. + * If this property is false, the parameter value is only read + * from the request if it is a submission of the form containing the widget. * *

* By default, this property is false. * - * @return true if an attempt should always be made to retrieve the parameter value - * from the request. + * @return true if an attempt should always be made to + * retrieve the parameter value from the request. */ public final boolean isPassIn() { return getParameterModel().isPassIn(); } /** - * Set whether this parameter should be treated as a "pass in" parameter. This is a static - * property of the ParameterModel and this method should not be invoked at request-time. + * Set whether this parameter should be treated as a "pass in" parameter. + * This is a static property of the ParameterModel and this method should + * not be invoked at request-time. * * @see #isPassIn * @param v true if this parameter is a pass in parameter. @@ -436,8 +490,12 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * The ParameterModel is normally set via the constructors. This method is only rarely needed. - * Please note that the previous ParameterModel and all its listeners will be lost. + * The ParameterModel is normally set via the constructors. + * This method is only rarely needed. + * Please note that the previous ParameterModel and all its listeners + * will be lost. + * + * @param parameterModel */ public final void setParameterModel(ParameterModel parameterModel) { Assert.isUnlocked(this); @@ -445,10 +503,13 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Allows access to underlying parameterModel. The ParameterModel contains static - * (request-independent) properties of a Widget such as its name, default value and its - * listeners. The ParameterModel can not be modified once Page.lock() has been invoked (not even - * in a PrintListener). This is done after the Page has been built, normally at server startup. + * Allows access to underlying parameterModel. The ParameterModel contains + * static (request-independent) properties of a Widget such as its name, + * default value and its listeners. The ParameterModel can not be modified + * once Page.lock() has been invoked (not even in a PrintListener). + * This is done after the Page has been built, normally at server startup. + * + * @return */ public final ParameterModel getParameterModel() { return m_parameterModel; @@ -456,14 +517,15 @@ public abstract class Widget extends BlockStylable implements Cloneable, /** *

- * This method creates the DOM for the widget. The method is called by the Bebop framework and - * should not be invoked by application developers. + * This method creates the DOM for the widget. The method is called by the + * Bebop framework and should not be invoked by application developers. *

* *

- * The method first fires the print event allowing application developers to set certain - * properties of the Widget at request time in a PrintListener. The methods generateWidget and - * generateErrors will then be invoked to generate either of the following + * The method first fires the print event allowing application developers + * to set certain properties of the Widget at request time in a + * PrintListener. The methods generateWidget and generateErrors will then + * be invoked to generate either of the following *

* *

@@ -476,7 +538,10 @@ public abstract class Widget extends BlockStylable implements Cloneable, * </bebop:formWidget> *

* + * @param state + * @param parent */ + @Override public void generateXML(final PageState state, final Element parent) { if (isVisible(state)) { @@ -507,7 +572,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, /** * The XML tag. * - * @return The tag to be used for the top level DOM element generated for this type of Widget. + * @return The tag to be used for the top level DOM element generated for + * this type of Widget. */ protected String getElementTag() { return BEBOP_FORMWIDGET; @@ -520,6 +586,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, *

* <bebop:formWidget name=... type=... value=... [onXXX=...]> * </bebop:formWidget> + * @param state + * @param parent */ protected void generateWidget(PageState state, Element parent) { Element widget = parent.newChildElement(getElementTag(), BEBOP_XML_NS); @@ -544,12 +612,15 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Generates the XML for the given widget + * Generates the XML for the given widget. *

* Generates XML fragment: - *

* <bebop:formErrors message=... id=name> * </bebop:formErrors> + *

+ * + * @param state + * @param parent */ protected void generateErrors(PageState state, Element parent) { Iterator i = getErrors(state); @@ -564,12 +635,15 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Get the value associated with this widget in the request described by ps. The - * type of the returned object depends on the ParameterModel underlying this - * widget. This method is typically called in a FormProcessListener to access the value that was - * submitted for a Widget in the Form. + * Get the value associated with this widget in the request described by + * ps. + * The type of the returned object depends on the ParameterModel + * underlying this widget. This method is typically called in a + * FormProcessListener to access the value that was submitted for a Widget + * in the Form. * * @param ps describes the request currently being processed + * @return * @pre ps != null * @post may return null */ @@ -591,18 +665,22 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Set the value of the parameter associated with this widget to a new value. The exact type of - * value depends on the ParameterModel underlying the widget. This - * method is typically called in a FormInitListener to initialize the value of a Widget in the + * Set the value of the parameter associated with this widget to a new value. + * The exact type of value depends on the + * ParameterModel underlying the widget. This method is typically + * called in a FormInitListener to initialize the value of a Widget in the * Form at request time. * + * @param ps + * @param value * @pre ps != null * @post value == getValue(ps) * - * @throws IllegalStateExeption the form to which the widget belongs has not been processed yet. + * @throws IllegalStateException the form to which the widget belongs has + * not been processed yet. */ public void setValue(PageState ps, Object value) - throws IllegalStateException { + throws IllegalStateException { Assert.exists(ps, "PageState"); ParameterData p = getParameterData(ps); // set value in session if it is being held - allows @@ -633,6 +711,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** + * + * @param ps * @return the parameter value for this widget * @post returns null if the FormData are missing */ @@ -646,12 +726,13 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Respond to an incoming request by calling respond on the form to which the - * widget belongs. This method is called by the Bebop framework and should not be invoked by - * application developers. It is somewhat questionable that this method should ever be called, - * rather than having {@link - * Form#respond Form.respond()} called directly. + * Respond to an incoming request by calling respond on the + * form to which the widget belongs. This method is called by the Bebop + * framework and should not be invoked by application developers. It is + * somewhat questionable that this method should ever be called, rather + * than having {@link Form#respond Form.respond()} called directly. * + * @throws javax.servlet.ServletException * @pre state != null */ @Override @@ -667,8 +748,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Specify a Widget.ValidationGuard implementation to use to determine if this widget should run - * its validation listeners. + * Specify a Widget. ValidationGuard implementation to use to determine if + * this widget should run its validation listeners. * * @param guard the Widget.ValidationGuard. */ @@ -678,8 +759,8 @@ public abstract class Widget extends BlockStylable implements Cloneable, } /** - * Inner interface used to determine if the validation listeners should be run for this widget - * or not. + * Inner interface used to determine if the validation listeners should be + * run for this widget or not. */ public interface ValidationGuard { @@ -689,18 +770,18 @@ public abstract class Widget extends BlockStylable implements Cloneable, /** * Adds an error to be displayed with this parameter. * - * @param mesg A GlobalizedMessage that will resolve to the error for the user. + * @param msg A GlobalizedMessage that will resolve to the error for the user. */ - public void addError(GlobalizedMessage mesg) { + public void addError(GlobalizedMessage msg) { PageState state = PageState.getPageState(); - String error = (String) mesg.localize(Kernel.getContext().getLocale()); - getParameterData(state).addError(error); + getParameterData(state).addError(msg); } /** * Adds an error to be displayed with this parameter. * * @param error A string showing the error to the user. + * @deprecated refactor to use addError(GlobalizedMessage) instead. */ public void addError(String error) { getParameterData(PageState.getPageState()).addError(error); diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/GlobalizedParameterListener.java b/ccm-core/src/com/arsdigita/bebop/parameters/GlobalizedParameterListener.java index aa114e3cf..1f28ba46e 100755 --- a/ccm-core/src/com/arsdigita/bebop/parameters/GlobalizedParameterListener.java +++ b/ccm-core/src/com/arsdigita/bebop/parameters/GlobalizedParameterListener.java @@ -23,50 +23,45 @@ import com.arsdigita.globalization.Globalized; import com.arsdigita.globalization.GlobalizedMessage; /** - *

* Abstract class to be extended by globalized parameters. - *

* * @version $Id: GlobalizedParameterListener.java 287 2005-02-22 00:29:02Z sskracic $ */ public abstract class GlobalizedParameterListener - implements Globalized, ParameterListener { + implements Globalized, ParameterListener { + /** Name of the resource file to map keys to localized output. */ private final static String BUNDLE_NAME = "com.arsdigita.bebop.parameters.ParameterResources"; + /** Property to hold the globalized user information about the error + * encountered. */ private GlobalizedMessage m_error = null; /** - *

- * Return the base name of the target ResourceBundle. - *

- * + * Provide client classes with the ResourceBundle to use. By default that + * one contained in this package's ParameterResources.properties. * @return String target ResourceBundle base name. */ public String getBundleBaseName() { return BUNDLE_NAME; } - /** - *

- * Get the error message for this parameter. - *

- * - * @return GlobalizedMessage The error. - */ - protected GlobalizedMessage getError() { - return m_error; - } /** - *

* Set the error message for this parameter. - *

* * @param error The error message to use for this parameter. */ protected void setError(GlobalizedMessage error) { m_error = error; } + /** + * Get the error message for this parameter. + * + * @return GlobalizedMessage The error. + */ + protected GlobalizedMessage getError() { + return m_error; + } } diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/NotNullValidationListener.java b/ccm-core/src/com/arsdigita/bebop/parameters/NotNullValidationListener.java index 657d0ee92..3a7cf7dcd 100755 --- a/ccm-core/src/com/arsdigita/bebop/parameters/NotNullValidationListener.java +++ b/ccm-core/src/com/arsdigita/bebop/parameters/NotNullValidationListener.java @@ -23,8 +23,7 @@ import com.arsdigita.bebop.event.ParameterEvent; import com.arsdigita.globalization.GlobalizedMessage; /** - * Verifies that the - * parameter's value is not null. + * Verifies that the parameter's value is not null. * * @author Karl Goldstein * @author Uday Mathur @@ -36,20 +35,41 @@ public class NotNullValidationListener extends GlobalizedParameterListener { public static final NotNullValidationListener DEFAULT = new NotNullValidationListener(); - public NotNullValidationListener(String title) { - setError(new GlobalizedMessage(title, getBundleBaseName())); - } - + /** + * Default constructor, used a default standard message as unser + * information. + */ public NotNullValidationListener() { - setError(new GlobalizedMessage( - "parameter_is_required", getBundleBaseName() - )); + setError(new GlobalizedMessage("bebop.parameters.parameter_is_required", + getBundleBaseName() )); } + /** + * Constructor, provides the facility to use a custom provided user + * information text. + * + * @param titleKey + */ + public NotNullValidationListener(String titleKey) { + setError(new GlobalizedMessage(titleKey, getBundleBaseName())); + } + + /** + * Constructor, provides the facility to use a custom provided user + * information text (as a GlobalizedMessage object). + * + * @param error + */ public NotNullValidationListener(GlobalizedMessage error) { setError(error); } + /** + * Validate the data. + * + * @param e Parameter event containing the data to validate. + */ + @Override public void validate (ParameterEvent e) { ParameterData data = e.getParameterData(); Object value = data.getValue(); @@ -57,7 +77,7 @@ public class NotNullValidationListener extends GlobalizedParameterListener { if (value != null && value.toString().length() > 0) { return; } - + // adds the error globalizedMessage to the ParameterData input object. data.addError(getError()); } } diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/NumberInRangeValidationListener.java b/ccm-core/src/com/arsdigita/bebop/parameters/NumberInRangeValidationListener.java index 69400e97d..7265ea36b 100755 --- a/ccm-core/src/com/arsdigita/bebop/parameters/NumberInRangeValidationListener.java +++ b/ccm-core/src/com/arsdigita/bebop/parameters/NumberInRangeValidationListener.java @@ -22,15 +22,15 @@ import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.parameters.ParameterData; import com.arsdigita.bebop.event.ParameterListener; import com.arsdigita.bebop.event.ParameterEvent; +import com.arsdigita.bebop.util.GlobalizationUtil; /** - * Verifies that the - * parameter's value is within a specified range. + * Verifies that the parameter's value is within a specified range. * - * @author Karl Goldstein - * @author Uday Mathur - * @author Stas Freidin - * @author Rory Solomon + * @author Karl Goldstein + * @author Uday Mathur + * @author Stas Freidin + * @author Rory Solomon * @version $Id: NumberInRangeValidationListener.java 287 2005-02-22 00:29:02Z sskracic $ */ public class NumberInRangeValidationListener implements ParameterListener { @@ -39,14 +39,29 @@ public class NumberInRangeValidationListener implements ParameterListener { private final double m_upperBound; private final String m_baseErrorMsg; + /** + * + * @param a + * @param b + */ public NumberInRangeValidationListener(Number a, Number b) { this(a.doubleValue(),b.doubleValue()); } + /** + * + * @param lower + * @param upper + */ public NumberInRangeValidationListener(long lower, long upper) { this( (double)lower, (double)upper ); } + /** + * + * @param lower + * @param upper + */ public NumberInRangeValidationListener(double lower, double upper) { if ( upper < lower ) { throw new IllegalArgumentException @@ -56,7 +71,7 @@ public class NumberInRangeValidationListener implements ParameterListener { m_lowerBound = lower; m_upperBound = upper; - StringBuffer msg = new StringBuffer(128); + StringBuilder msg = new StringBuilder(128); msg.append("The following values are out of the specified range of (") .append(m_lowerBound) .append(",") @@ -66,6 +81,12 @@ public class NumberInRangeValidationListener implements ParameterListener { m_baseErrorMsg = msg.toString(); } + /** + * + * @param e + * @throws FormProcessException + */ + @Override public void validate (ParameterEvent e) throws FormProcessException { // note: The abstract class Number is the superclass of classes // Byte, Double, Float, Integer, Long, and Short. @@ -103,7 +124,10 @@ public class NumberInRangeValidationListener implements ParameterListener { isValid = false; } } else { - throw new FormProcessException("Unexpected value type: " + obj.getClass()); + String[] errorMsg= new String[1]; + errorMsg[0]=obj.getClass().toString(); + throw new FormProcessException("Unexpected value type: " + obj.getClass(), + GlobalizationUtil.globalize("bebop.parameter.unexpected_value_type",errorMsg)); } if (!isValid) { diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterData.java b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterData.java index 92cf191d6..02cf5bda5 100755 --- a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterData.java +++ b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterData.java @@ -25,9 +25,9 @@ import com.arsdigita.bebop.FormProcessException; import com.arsdigita.globalization.GlobalizedMessage; /** - * This class is used to manage the data associated with a single - * parameter. A ParameterData object contains errors and values - * associated with a given parameter. + * This class is used to manage the data associated with a single parameter. + * A ParameterData object contains errors and values associated with a given + * parameter. * * @author Uday Mathur * @version $Id: ParameterData.java 287 2005-02-22 00:29:02Z sskracic $ @@ -87,6 +87,7 @@ public final class ParameterData implements Map.Entry, Cloneable { * Construct a new ParameterData object with the specified name and * value. * + * @param model * @param name name of the parameter model associated with this * parameter data * @@ -100,7 +101,11 @@ public final class ParameterData implements Map.Entry, Cloneable { /** * Clones this object making a new reference to the errors list. + * + * @return + * @throws java.lang.CloneNotSupportedException */ + @Override public Object clone() throws CloneNotSupportedException { ParameterData result = (ParameterData) super.clone(); result.m_errors = (LinkedList) m_errors.clone(); @@ -112,14 +117,17 @@ public final class ParameterData implements Map.Entry, Cloneable { * Return the value of this parameter. * * @return the value of this parameter. If isArray() is true, then the - * return value is an array + * return value is an array */ + @Override public final Object getValue() { return m_value; } /** * Return the ParameterModel underlying this parameter. + * + * @return */ public final ParameterModel getModel() { return m_model; @@ -140,6 +148,7 @@ public final class ParameterData implements Map.Entry, Cloneable { * * @return getName() **/ + @Override public Object getKey() { return getName(); } @@ -153,6 +162,7 @@ public final class ParameterData implements Map.Entry, Cloneable { * * @return the previous value of this parameter **/ + @Override public final Object setValue(Object value) { Object old = m_value; m_value=value; @@ -166,7 +176,6 @@ public final class ParameterData implements Map.Entry, Cloneable { * into the right object o so that * getValue().equals(o). * - * @param data the parameter data holding the value * @return the value as a readable string * @see ParameterModel#marshal */ @@ -190,6 +199,7 @@ public final class ParameterData implements Map.Entry, Cloneable { * FormData.addError and by ParameterListeners. * * @param message The error message to add to this parameter + * @deprecated use addError(GlobalizedMessage message) instead. */ public void addError(String message) { if(message != null && message.length() > 0) @@ -197,10 +207,8 @@ public final class ParameterData implements Map.Entry, Cloneable { } /** - *

* Adds an error to this parameter. This method is called by * FormData.addError and by ParameterListeners. - *

* * @param message GlobalizedMessage representing the error to add to this * parameter. @@ -244,6 +252,8 @@ public final class ParameterData implements Map.Entry, Cloneable { /** * Revalidate this ParameterData. If transformation failed, and the * value has not been reset, this will be a no-op. + * + * @throws com.arsdigita.bebop.FormProcessException */ public void validate() throws FormProcessException { if (isTransformed()) { @@ -306,8 +316,9 @@ public final class ParameterData implements Map.Entry, Cloneable { /** Convert to a String. * @return a human-readable representation of this. */ + @Override public String toString() { - StringBuffer to = new StringBuffer(); + StringBuilder to = new StringBuilder(); to.append("{") .append(m_value) .append(", ").append(m_errors); diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources.properties b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources.properties index a0c762514..3f10de225 100644 --- a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources.properties +++ b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources.properties @@ -1,4 +1,4 @@ -parameter_is_required=This parameter is required +bebop.parameters.parameter_is_required=This parameter is required parameter_not_unique=This parameter is not unique string_in_range=This parameter is not between {0} and {1} characters long type_check={0} must be of type {1} but got {2} of type {3} diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_de.properties b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_de.properties index c220ce670..60fbc7408 100644 --- a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_de.properties +++ b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_de.properties @@ -1,8 +1,8 @@ -parameter_is_required=Dieser Parameter ist erforderlich +bebop.parameters.parameter_is_required=Dieser Parameter ist erforderlich parameter_not_unique=Dieser Parameter ist nicht einzigartig string_in_range=Dieser Parameter ist nicht zwischen {0} und {1} Zeichen lang type_check={0} muss vom Typ {1} sein, ist aber {2} vom Typ {3} parameter.only.letters.digits=Dieser Parameter darf nur Buchstaben und/oder Zahlen enthalten file_empty_or_not_found=ist leer oder wurde nicht gefunden. -file_too_large=ist zu gro\u00DF +file_too_large=ist zu gro\u00df uri_parameter_is_invalid=Dieser Parameter muss ein URI sein, das entsprechend RFC2396 formatiert wird diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_en.properties b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_en.properties index a0c762514..3f10de225 100755 --- a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_en.properties +++ b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_en.properties @@ -1,4 +1,4 @@ -parameter_is_required=This parameter is required +bebop.parameters.parameter_is_required=This parameter is required parameter_not_unique=This parameter is not unique string_in_range=This parameter is not between {0} and {1} characters long type_check={0} must be of type {1} but got {2} of type {3} diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_es.properties b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_es.properties index 055630b8d..b896311f4 100755 --- a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_es.properties +++ b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_es.properties @@ -1,3 +1,3 @@ -parameter_is_required=Este par\u00E1metro es requerido -string_in_range=Este par\u00E1metro no tiene entre {0} y {1} caracteres +bebop.parameters.parameter_is_required=Este par\u00e1metro es requerido +string_in_range=Este par\u00e1metro no tiene entre {0} y {1} caracteres type_check={0} tiene que ser de clase {1} pero el objecto {2} es de clase {3} diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_fr.properties b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_fr.properties index bd94a1618..8f4ed9ccd 100755 --- a/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_fr.properties +++ b/ccm-core/src/com/arsdigita/bebop/parameters/ParameterResources_fr.properties @@ -1,4 +1,4 @@ -parameter_is_required=Ce paramètre est obligatoire -string_in_range=La longueur de ce paramètre n'est pas comprise entre {0} et {1} -type_check={0} doit être de type {1} mais possède {2} de type {3} -parameter.only.letters.digits=Ce paramètre ne doit contenir que des lettres ou des chiffres +bebop.parameters.parameter_is_required=Ce param\u00e8tre est obligatoire +string_in_range=La longueur de ce param\u00e8tre n'est pas comprise entre {0} et {1} +type_check={0} doit \u00eatre de type {1} mais poss\u00e8de {2} de type {3} +parameter.only.letters.digits=Ce param\u00e8tre ne doit contenir que des lettres ou des chiffres diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/StringIsLettersOrDigitsValidationListener.java b/ccm-core/src/com/arsdigita/bebop/parameters/StringIsLettersOrDigitsValidationListener.java index 0ec6dee2d..aa112a0f1 100755 --- a/ccm-core/src/com/arsdigita/bebop/parameters/StringIsLettersOrDigitsValidationListener.java +++ b/ccm-core/src/com/arsdigita/bebop/parameters/StringIsLettersOrDigitsValidationListener.java @@ -24,29 +24,43 @@ import com.arsdigita.bebop.event.ParameterEvent; import com.arsdigita.globalization.GlobalizedMessage; /** - * Verifies that the - * parameter's value contains only letters and/or digits. + * Verifies that the parameter's value contains only letters and/or digits. * * @author Dennis Gregorovic * @version $Id: StringIsLettersOrDigitsValidationListener.java 287 2005-02-22 00:29:02Z sskracic $ - **/ - + */ public class StringIsLettersOrDigitsValidationListener extends GlobalizedParameterListener { + /** + * + * @param title + */ public StringIsLettersOrDigitsValidationListener(String title) { setError(new GlobalizedMessage(title, getBundleBaseName())); } + /** + * + */ public StringIsLettersOrDigitsValidationListener() { - setError(new GlobalizedMessage( - "parameter.only.letters.digits", getBundleBaseName() - )); + setError(new GlobalizedMessage( "parameter.only.letters.digits", + getBundleBaseName() )); } + /** + * + * @param error + */ public StringIsLettersOrDigitsValidationListener(GlobalizedMessage error) { setError(error); } + /** + * + * @param e + * @throws FormProcessException + */ + @Override public void validate (ParameterEvent e) throws FormProcessException { ParameterData data = e.getParameterData(); Object obj = data.getValue(); diff --git a/ccm-core/src/com/arsdigita/bebop/util/GlobalizationUtil.java b/ccm-core/src/com/arsdigita/bebop/util/GlobalizationUtil.java index bf52ddd7b..e0458a410 100755 --- a/ccm-core/src/com/arsdigita/bebop/util/GlobalizationUtil.java +++ b/ccm-core/src/com/arsdigita/bebop/util/GlobalizationUtil.java @@ -22,21 +22,37 @@ import com.arsdigita.globalization.Globalized; import com.arsdigita.globalization.GlobalizedMessage; /** - *

- * . - * Contains methods to simplify globalizing keys - *

+ * 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. * * @version $Revision: #6 $ $Date: 2004/08/16 $ */ - public class GlobalizationUtil implements Globalized { - private static final String BUNDLE_NAME = "com.arsdigita.bebop.ui.BebopResources"; + /** Name of Java resource files to handle CMS's globalisation. */ + private static final String BUNDLE_NAME = "com.arsdigita.bebop.BebopResources"; + /** + * Returns a globalized message using the package specific bundle, + * provided by BUNDLE_NAME. + * @param key + * @return + */ 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 + * (i.e. {0}, {1},... for adding variable strings). + * @param key + * @param args + * @return new instance of a globalized message + */ public static GlobalizedMessage globalize(String key, Object[] args) { return new GlobalizedMessage(key, BUNDLE_NAME, args); diff --git a/ccm-core/src/com/arsdigita/categorization/CategorizationResources.properties b/ccm-core/src/com/arsdigita/categorization/CategorizationResources.properties new file mode 100755 index 000000000..898369fd8 --- /dev/null +++ b/ccm-core/src/com/arsdigita/categorization/CategorizationResources.properties @@ -0,0 +1,2 @@ +categorization.cancel=Cancel +categorization.cancel.msg=Submission Cancelled diff --git a/ccm-core/src/com/arsdigita/categorization/CategorizationResources_de.properties b/ccm-core/src/com/arsdigita/categorization/CategorizationResources_de.properties new file mode 100644 index 000000000..a8f6d07c7 --- /dev/null +++ b/ccm-core/src/com/arsdigita/categorization/CategorizationResources_de.properties @@ -0,0 +1,2 @@ +categorization.cancel=Abbrechen +categorization.cancel.msg=Bearbeitung abgebrochen diff --git a/ccm-core/src/com/arsdigita/categorization/CategorizationResources_fr.properties b/ccm-core/src/com/arsdigita/categorization/CategorizationResources_fr.properties new file mode 100755 index 000000000..12d6425a8 --- /dev/null +++ b/ccm-core/src/com/arsdigita/categorization/CategorizationResources_fr.properties @@ -0,0 +1,2 @@ +categorization.cancel=TRANSLATE THIS: Previous (categorization.cancel) +categorization.cancel.msg=TRANSLATE THIS: Previous (categorization.cancel.submission.msg) diff --git a/ccm-core/src/com/arsdigita/categorization/ui/ACSObjectCategoryForm.java b/ccm-core/src/com/arsdigita/categorization/ui/ACSObjectCategoryForm.java index 83d9757d4..ede2495f6 100755 --- a/ccm-core/src/com/arsdigita/categorization/ui/ACSObjectCategoryForm.java +++ b/ccm-core/src/com/arsdigita/categorization/ui/ACSObjectCategoryForm.java @@ -38,6 +38,7 @@ import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.categorization.CategorizedObject; import com.arsdigita.categorization.Category; import com.arsdigita.categorization.CategoryCollection; +import com.arsdigita.categorization.util.GlobalizationUtil; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.kernel.ACSObject; import com.arsdigita.persistence.OID; @@ -118,12 +119,10 @@ public abstract class ACSObjectCategoryForm extends Form { } BigDecimal[] ids = (BigDecimal[]) m_category.getValue(state); - for (int i = 0; i < ids.length; i++) { - Category cat = (Category) DomainObjectFactory.newInstance( - new OID(Category.BASE_DATA_OBJECT_TYPE, - ids[i])); - - if(!curSelectedCat.contains(ids[i])) { + for (BigDecimal id : ids) { + Category cat = (Category) DomainObjectFactory + .newInstance(new OID(Category.BASE_DATA_OBJECT_TYPE, id)); + if (!curSelectedCat.contains(id)) { cat.addChild(object); } else { cat.removeChild(object); @@ -143,7 +142,9 @@ public abstract class ACSObjectCategoryForm extends Form { if (m_buttons.getCancelButton().isSelected(state)) { fireCompletionEvent(state); - throw new FormProcessException("cancelled"); + throw new FormProcessException("Submission cancelled", + GlobalizationUtil.globalize( + "categorization.cancel.msg")); } } }); diff --git a/ccm-core/src/com/arsdigita/categorization/util/GlobalizationUtil.java b/ccm-core/src/com/arsdigita/categorization/util/GlobalizationUtil.java index 9cca7448b..a1f47b1af 100755 --- a/ccm-core/src/com/arsdigita/categorization/util/GlobalizationUtil.java +++ b/ccm-core/src/com/arsdigita/categorization/util/GlobalizationUtil.java @@ -29,7 +29,7 @@ import com.arsdigita.globalization.GlobalizedMessage; public class GlobalizationUtil implements Globalized { private static final String BUNDLE_NAME = - "com.arsdigita.categorization.ui.CategorizationResources"; + "com.arsdigita.categorization.CategorizationResources"; private GlobalizationUtil() {} diff --git a/ccm-core/src/com/arsdigita/dispatcher/MultipartHttpServletRequest.java b/ccm-core/src/com/arsdigita/dispatcher/MultipartHttpServletRequest.java index 26313e665..25a7a7f5c 100755 --- a/ccm-core/src/com/arsdigita/dispatcher/MultipartHttpServletRequest.java +++ b/ccm-core/src/com/arsdigita/dispatcher/MultipartHttpServletRequest.java @@ -48,11 +48,10 @@ import com.arsdigita.globalization.Globalization; import com.arsdigita.util.UncheckedWrapperException; /** - * MultipartHttpServletRequest provides - * multipart/form-data handling capabilities to facilitate file - * uploads for servlets. This request object parses the HTTP request - * with MIME type "multipart" and places the encoded object in a - * stream. + * MultipartHttpServletRequest provides multipart/form-data handling + * capabilities to facilitate file uploads for servlets. + * This request object parses the HTTP request with MIME type "multipart" and + * places the encoded object in a stream. * * @author Karl Goldstein * @author Michael Pih @@ -72,6 +71,8 @@ public class MultipartHttpServletRequest implements HttpServletRequest { * Create a multipart servlet request object and parse the request. * * @param request The request + * @throws javax.mail.MessagingException + * @throws java.io.IOException */ public MultipartHttpServletRequest(HttpServletRequest request) throws MessagingException, IOException { @@ -83,7 +84,8 @@ public class MultipartHttpServletRequest implements HttpServletRequest { /** * Create a multipart servlet request object and parse the request. * - * @param request The request + * @param original + * @param current */ public MultipartHttpServletRequest(MultipartHttpServletRequest original, HttpServletRequest current) { @@ -91,14 +93,31 @@ public class MultipartHttpServletRequest implements HttpServletRequest { m_parameters = original.m_parameters; } + /** + * + * @param name + * @return + */ + @Override public Object getAttribute(String name) { return m_request.getAttribute(name); } + /** + * + * @return + */ + @Override public Enumeration getAttributeNames() { return m_request.getAttributeNames(); } + /** + * + * @param name + * @return + */ + @Override public String getParameter(String name) { String[] values = (String[]) m_parameters.get(name); @@ -109,18 +128,38 @@ public class MultipartHttpServletRequest implements HttpServletRequest { } } + /** + * + * @return + */ + @Override public Map getParameterMap() { return m_parameters; } + /** + * + * @return + */ + @Override public Enumeration getParameterNames() { return Collections.enumeration(m_parameters.keySet()); } + /** + * + * @param name + * @return + */ public String getFileName(String name) { return getParameter(name); } + /** + * + * @param name + * @return + */ public File getFile(String name) { String path = getParameter(name + ".tmpfile"); @@ -131,16 +170,32 @@ public class MultipartHttpServletRequest implements HttpServletRequest { } } + /** + * + * @param name + * @return + */ + @Override public String[] getParameterValues(String name) { return (String[]) m_parameters.get(name); } // Additional methods for HttpServletRequest + /** + * + * @return + */ + @Override public String getAuthType() { return m_request.getAuthType(); } + /** + * + * @return + */ + @Override public Cookie[] getCookies() { return m_request.getCookies(); } @@ -214,10 +269,21 @@ public class MultipartHttpServletRequest implements HttpServletRequest { * of Servlet specification 2.3 which was resolved later. So it should be * save to use it now. (2012-02-06) */ + + /** + * + * @return + */ + @Override public StringBuffer getRequestURL() { return m_request.getRequestURL(); } + /** + * + * @return + */ + @Override public String getServletPath() { return m_request.getServletPath(); } @@ -252,6 +318,12 @@ public class MultipartHttpServletRequest implements HttpServletRequest { return m_request.getCharacterEncoding(); } + /** + * + * @param encoding + * @throws java.io.UnsupportedEncodingException + */ + @Override public void setCharacterEncoding(String encoding) throws java.io.UnsupportedEncodingException { throw new UnsupportedOperationException diff --git a/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources.properties b/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources.properties index e8a1f343e..73f2a7c60 100755 --- a/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources.properties +++ b/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources.properties @@ -64,3 +64,5 @@ formbuilder.ui.form_action.add_button=Add Form Action formbuilder.ui.form_action.delete_confirm=Are you sure you wish to delete this action? formbuilder.ui.move=move formbuilder.ui.delete_confirm=Are you sure you wish to delete this widget? +formbuilder.ui.cancel=Cancel +formbuilder.ui.cancel_msg=Submission Cancelled diff --git a/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources_de.properties b/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources_de.properties index aeabd592b..a6e4efa7a 100644 --- a/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources_de.properties +++ b/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources_de.properties @@ -64,3 +64,5 @@ formbuilder.ui.form_action.add_button=Formularaktion hinzuf\u00fcgen formbuilder.ui.form_action.delete_confirm=Sind sie sicher, diese Aktion zu l\u00f6schen? formbuilder.ui.move=verschieben formbuilder.ui.delete_confirm=Sind Sie sicher, dieses Element zu l\u00f6schen? +formbuilder.ui.cancel=Abbrechen +formbuilder.ui.cancel_msg=Bearbeitung abgebrochen diff --git a/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources_fr.properties b/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources_fr.properties index e5e2cead3..f9bbf9ad8 100755 --- a/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources_fr.properties +++ b/ccm-core/src/com/arsdigita/formbuilder/FormbuilderResources_fr.properties @@ -56,3 +56,5 @@ formbuilder.ui.form_action.add_button=Add Form Action formbuilder.ui.form_action.delete_confirm=Are you sure you wish to delete this action? formbuilder.ui.move=move formbuilder.ui.delete_confirm=Are you sure you wish to delete this widget? +formbuilder.ui.cancel=Cancel +formbuilder.ui.cancel_msg=Submission Cancelled diff --git a/ccm-core/src/com/arsdigita/formbuilder/ui/PropertiesForm.java b/ccm-core/src/com/arsdigita/formbuilder/ui/PropertiesForm.java index 90e141fc6..95b0ec3ef 100755 --- a/ccm-core/src/com/arsdigita/formbuilder/ui/PropertiesForm.java +++ b/ccm-core/src/com/arsdigita/formbuilder/ui/PropertiesForm.java @@ -29,53 +29,100 @@ import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SaveCancelSection; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSubmissionListener; +import com.arsdigita.formbuilder.util.GlobalizationUtil; +/** + * + * + */ public class PropertiesForm extends Form { SaveCancelSection m_buttons; String m_app; + /** + * + * @param name + */ public PropertiesForm(String name) { super(name); createWidgets(); addSubmissionListener(new FormSubmissionListener() { + /** + * + * @param e + * @throws FormProcessException + */ + @Override public void submitted(FormSectionEvent e) throws FormProcessException { if (m_buttons.getCancelButton().isSelected(e.getPageState())) - throw new FormProcessException("Cancel pressed"); + throw new FormProcessException( + "Cancel pressed", + GlobalizationUtil.globalize("formbuilder.ui.cancel_msg") + ); } }); } + /** + * + * @param app + */ public void setApplication(String app) { m_app = app; } + /** + * + * @return + */ public String getApplication() { return m_app; } + /** + * + */ protected void createWidgets() { addWidgets(this); addButtons(this); } + /** + * + * @param section + */ protected void addWidgets(FormSection section) { } + /** + * + * @param section + */ protected void addButtons(FormSection section) { m_buttons = new SaveCancelSection(); section.add(new Label("")); // Padding section.add(m_buttons); } + /** + * + * @param state + * @return + */ public boolean isComplete(PageState state) { return m_buttons.getCancelButton().isSelected(state) || m_buttons.getSaveButton().isSelected(state); } + /** + * + * @param state + * @return + */ public boolean isCancelled(PageState state) { return m_buttons.getCancelButton().isSelected(state); } diff --git a/ccm-core/src/com/arsdigita/formbuilder/ui/editors/WidgetLabelForm.java b/ccm-core/src/com/arsdigita/formbuilder/ui/editors/WidgetLabelForm.java index bd890c2ef..e27d775ce 100755 --- a/ccm-core/src/com/arsdigita/formbuilder/ui/editors/WidgetLabelForm.java +++ b/ccm-core/src/com/arsdigita/formbuilder/ui/editors/WidgetLabelForm.java @@ -18,38 +18,43 @@ */ package com.arsdigita.formbuilder.ui.editors; -import com.arsdigita.formbuilder.WidgetLabel; +import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormSection; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.SingleSelectionModel; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.form.TextField; +import com.arsdigita.bebop.form.Widget; +import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.bebop.parameters.StringInRangeValidationListener; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.domain.DataObjectNotFoundException; -import com.arsdigita.formbuilder.PersistentWidget; - - -import java.math.BigDecimal; -import com.arsdigita.formbuilder.PersistentFormSection; -import com.arsdigita.bebop.SingleSelectionModel; import com.arsdigita.formbuilder.PersistentLabel; -import com.arsdigita.bebop.parameters.NotNullValidationListener; -import com.arsdigita.bebop.parameters.StringInRangeValidationListener; -import com.arsdigita.bebop.ColumnPanel; -import com.arsdigita.bebop.form.Widget; +import com.arsdigita.formbuilder.PersistentWidget; +import com.arsdigita.formbuilder.PersistentFormSection; +import com.arsdigita.formbuilder.WidgetLabel; + import com.arsdigita.formbuilder.util.GlobalizationUtil ; + import com.arsdigita.globalization.GlobalizedMessage; +import java.math.BigDecimal; + +/** + * + * + */ public abstract class WidgetLabelForm extends WidgetForm { private Widget m_label; @@ -60,6 +65,7 @@ public abstract class WidgetLabelForm extends WidgetForm { super(name, form, control); } + @Override protected void addWidgets(FormSection section) { if (wantLabelMultiline()) { @@ -94,7 +100,8 @@ public abstract class WidgetLabelForm extends WidgetForm { } /** - * @deprecated used getGlobalizedLabelText() + * @return + * @deprecated used getGlobalizedLabelText() */ protected String getLabelText() { return (String)getGlobalizedLabelText().localize(); @@ -117,6 +124,7 @@ public abstract class WidgetLabelForm extends WidgetForm { return false; } + @Override protected void initWidgets(FormSectionEvent e, PersistentWidget widget) throws FormProcessException { @@ -137,6 +145,7 @@ public abstract class WidgetLabelForm extends WidgetForm { } } + @Override protected void processWidgets(FormSectionEvent e, PersistentWidget widget) throws FormProcessException { @@ -162,6 +171,13 @@ public abstract class WidgetLabelForm extends WidgetForm { l.save(); } + /** + * + * @param e + * @param widget + * @throws FormProcessException + */ + @Override protected void addToForm(FormSectionEvent e, PersistentWidget widget) throws FormProcessException { @@ -198,6 +214,11 @@ public abstract class WidgetLabelForm extends WidgetForm { * this step is ignored if needed. * * This will return null if not label is actually added. + * + * @param widget + * @param label + * @param form + * @return */ protected WidgetLabel addWidgetLabel(PersistentWidget widget, String label, @@ -209,9 +230,10 @@ public abstract class WidgetLabelForm extends WidgetForm { return l; } /** - * Added by CS Gupta to make Name Field invisible In EmailFormField. - * Should Name Html Control be on the form? Can be overridden by sub classes. - */ + * Added by CS Gupta to make Name Field invisible In EmailFormField. + * Should Name Html Control be on the form? Can be overridden by sub classes. + * @return + */ protected boolean isEmailFormField() { return true; diff --git a/ccm-core/src/com/arsdigita/formbuilder/util/GlobalizationUtil.java b/ccm-core/src/com/arsdigita/formbuilder/util/GlobalizationUtil.java index b20bace30..cab19899a 100755 --- a/ccm-core/src/com/arsdigita/formbuilder/util/GlobalizationUtil.java +++ b/ccm-core/src/com/arsdigita/formbuilder/util/GlobalizationUtil.java @@ -22,22 +22,38 @@ import com.arsdigita.globalization.Globalized; import com.arsdigita.globalization.GlobalizedMessage; /** - *

- * . - * Contains methods to simplify globalizing keys - *

+ * 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. * * @version $Revision: #6 $ $Date: 2004/08/16 $ */ - public class GlobalizationUtil implements Globalized { + /** Name of Java resource files to handle CMS's globalisation. */ private static final String BUNDLE_NAME = "com.arsdigita.formbuilder.FormbuilderResources"; + /** + * Returns a globalized message using the package specific bundle, + * provided by BUNDLE_NAME. + * @param key + * @return + */ 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 + * (i.e. {0}, {1},... for adding variable strings). + * @param key + * @param args + * @return new instance of a globalized message + */ public static GlobalizedMessage globalize(String key, Object[] args) { return new GlobalizedMessage(key, BUNDLE_NAME, args); diff --git a/ccm-core/src/com/arsdigita/toolbox/ToolboxResources.properties b/ccm-core/src/com/arsdigita/toolbox/ToolboxResources.properties new file mode 100755 index 000000000..c189195ed --- /dev/null +++ b/ccm-core/src/com/arsdigita/toolbox/ToolboxResources.properties @@ -0,0 +1,4 @@ +toolbox.ui.na=N/A +toolbox.ui.no_results=No Results. +toolbox.ui.cancel=Cancel +toolbox.ui.cancel_msg=Submission Cancel \ No newline at end of file diff --git a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_de.properties b/ccm-core/src/com/arsdigita/toolbox/ToolboxResources_de.properties similarity index 50% rename from ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_de.properties rename to ccm-core/src/com/arsdigita/toolbox/ToolboxResources_de.properties index 3663c33f2..25cc7b693 100644 --- a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_de.properties +++ b/ccm-core/src/com/arsdigita/toolbox/ToolboxResources_de.properties @@ -1,2 +1,4 @@ toolbox.ui.na=(nicht eingetragen) toolbox.ui.no_results=Keine Ergebnisse. +toolbox.ui.cancel=Abbrechen +toolbox.ui.cancel_msg=Bearbeitung abgebrochen \ No newline at end of file diff --git a/ccm-core/src/com/arsdigita/toolbox/ToolboxResources_fr.properties b/ccm-core/src/com/arsdigita/toolbox/ToolboxResources_fr.properties new file mode 100755 index 000000000..2a1f1f47b --- /dev/null +++ b/ccm-core/src/com/arsdigita/toolbox/ToolboxResources_fr.properties @@ -0,0 +1,4 @@ +toolbox.ui.na=N/A +toolbox.ui.no_results=Pas de r\u00e9sultats +toolbox.ui.cancel=Cancel +toolbox.ui.cancel_msg=Submission Cancel \ No newline at end of file diff --git a/ccm-core/src/com/arsdigita/toolbox/ui/ModalPanel.java b/ccm-core/src/com/arsdigita/toolbox/ui/ModalPanel.java index cbf6f7d56..858866e61 100755 --- a/ccm-core/src/com/arsdigita/toolbox/ui/ModalPanel.java +++ b/ccm-core/src/com/arsdigita/toolbox/ui/ModalPanel.java @@ -41,9 +41,10 @@ import com.arsdigita.bebop.parameters.ArrayParameter; import com.arsdigita.bebop.parameters.IntegerParameter; // Stacktraces is a support tool to use in a specifically difficult development // situation. It is abundant in production and for normal development work and -// it provved to have funny side effects in a production environment. So it is +// it proved to have funny side effects in a production environment. So it is // commented out here but kept for further references. // import com.arsdigita.developersupport.StackTraces; +import com.arsdigita.toolbox.util.GlobalizationUtil; import com.arsdigita.util.Assert; import com.arsdigita.xml.Element; import java.util.Iterator; @@ -339,6 +340,7 @@ public class ModalPanel extends ComponentMap { m_target = target; } + @Override public final void process(final FormSectionEvent e) throws FormProcessException { push(e.getPageState(), m_target); @@ -363,6 +365,7 @@ public class ModalPanel extends ComponentMap { m_target = target; } + @Override public final void process(final FormSectionEvent e) throws FormProcessException { final PageState state = e.getPageState(); @@ -401,6 +404,7 @@ public class ModalPanel extends ComponentMap { m_model = model; } + @Override public final void submitted(final FormSectionEvent e) throws FormProcessException { final PageState state = e.getPageState(); @@ -422,7 +426,9 @@ public class ModalPanel extends ComponentMap { m_model.clearSelection(state); } - throw new FormProcessException("cancelled"); + throw new FormProcessException("cancelled", + GlobalizationUtil.globalize( + "toolbox.ui.cancel_msg")); } } } diff --git a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources.properties b/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources.properties deleted file mode 100755 index 76b69bf6d..000000000 --- a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources.properties +++ /dev/null @@ -1,2 +0,0 @@ -toolbox.ui.na=N/A -toolbox.ui.no_results=No Results. diff --git a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_fr.properties b/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_fr.properties deleted file mode 100755 index b2fab7a0a..000000000 --- a/ccm-core/src/com/arsdigita/toolbox/ui/ToolboxResources_fr.properties +++ /dev/null @@ -1,2 +0,0 @@ -toolbox.ui.na=N/A -toolbox.ui.no_results=Pas de r\u00e9sultats diff --git a/ccm-core/src/com/arsdigita/ui/admin/AdminResources.properties b/ccm-core/src/com/arsdigita/ui/admin/AdminResources.properties index d00dc84a4..c04670af6 100644 --- a/ccm-core/src/com/arsdigita/ui/admin/AdminResources.properties +++ b/ccm-core/src/com/arsdigita/ui/admin/AdminResources.properties @@ -136,3 +136,5 @@ ui.admin.user.userinfo.screenname=Username: ui.admin.user.userinfo.primaryemail=Email: ui.admin.groups.name=Name: ui.admin.applications.placeholder=There is no administration panel for instances of this application type yet. +ui.admin.cancel=Cancel +ui.admin.cancel_msg=Submission cancelled diff --git a/ccm-core/src/com/arsdigita/ui/admin/AdminResources_de.properties b/ccm-core/src/com/arsdigita/ui/admin/AdminResources_de.properties index 3da85bd8d..6e85a9e71 100644 --- a/ccm-core/src/com/arsdigita/ui/admin/AdminResources_de.properties +++ b/ccm-core/src/com/arsdigita/ui/admin/AdminResources_de.properties @@ -136,3 +136,5 @@ ui.admin.user.userinfo.screenname=Benutzername: ui.admin.user.userinfo.primaryemail=E-Mail: ui.admin.groups.name=Name: ui.admin.applications.placeholder=F\u00fcr Applikationen dieses Typs gibt es noch keine Verwaltungsoberfl\u00e4che. +ui.admin.cancel=Abbrechen +ui.admin.cancel_msg=Bearbeitung abgebrochen diff --git a/ccm-core/src/com/arsdigita/ui/admin/AdminResources_en.properties b/ccm-core/src/com/arsdigita/ui/admin/AdminResources_en.properties index 27d4d6027..0439feb5f 100755 --- a/ccm-core/src/com/arsdigita/ui/admin/AdminResources_en.properties +++ b/ccm-core/src/com/arsdigita/ui/admin/AdminResources_en.properties @@ -136,3 +136,5 @@ ui.admin.user.userinfo.screenname= ui.admin.user.userinfo.primaryemail= ui.admin.groups.name= ui.admin.applications.placeholder= +ui.admin.cancel=Cancel +ui.admin.cancel_msg=Submission cancelled diff --git a/ccm-core/src/com/arsdigita/ui/admin/AdminResources_fr.properties b/ccm-core/src/com/arsdigita/ui/admin/AdminResources_fr.properties index 746bf4872..c2bd53332 100755 --- a/ccm-core/src/com/arsdigita/ui/admin/AdminResources_fr.properties +++ b/ccm-core/src/com/arsdigita/ui/admin/AdminResources_fr.properties @@ -122,3 +122,5 @@ ui.admin.user.userinfo.screenname= ui.admin.user.userinfo.primaryemail= ui.admin.groups.name= ui.admin.applications.placeholder= +ui.admin.cancel=Cancel +ui.admin.cancel_msg=Submission cancelled diff --git a/ccm-core/src/com/arsdigita/ui/admin/applications/ApplicationCreateForm.java b/ccm-core/src/com/arsdigita/ui/admin/applications/ApplicationCreateForm.java index accd5ebc5..7c9d6858e 100644 --- a/ccm-core/src/com/arsdigita/ui/admin/applications/ApplicationCreateForm.java +++ b/ccm-core/src/com/arsdigita/ui/admin/applications/ApplicationCreateForm.java @@ -19,7 +19,7 @@ package com.arsdigita.ui.admin.applications; import com.arsdigita.bebop.BoxPanel; -import com.arsdigita.bebop.Component; +//import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Container; import com.arsdigita.bebop.Form; import com.arsdigita.bebop.FormProcessException; @@ -49,16 +49,18 @@ import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.web.Application; import com.arsdigita.web.ApplicationCollection; import com.arsdigita.web.ApplicationType; -import java.util.ArrayList; -import java.util.List; + +//import java.util.ArrayList; +//import java.util.List; import java.util.TooManyListenersException; /** - * Basic form for creating new Application instances. Should be suitable for most applications types. If you have - * special needs... $todo + * Basic form for creating new Application instances. Should be suitable for + * most applications types. If you have special needs... $todo * - * This form does not support parent/child application structures. If your app needs this, add a widget for selecting - * the parent application and extend the process method. + * This form does not support parent/child application structures. If your app + * needs this, add a widget for selecting the parent application and extend + * the process method. * * @param Type of application * @@ -108,6 +110,7 @@ public class ApplicationCreateForm extends Form implement parentApp = new SingleSelect(PARENT_APP); try { parentApp.addPrintListener(new PrintListener() { + @Override public void prepare(final PrintEvent event) { final SingleSelect target = (SingleSelect) event.getTarget(); target.addOption(new Option("", "")); @@ -195,6 +198,7 @@ public class ApplicationCreateForm extends Form implement return saveCancelSection; } + @Override public void process(final FormSectionEvent event) throws FormProcessException { final PageState state = event.getPageState(); @@ -229,6 +233,7 @@ public class ApplicationCreateForm extends Form implement } } + @Override public void submitted(final FormSectionEvent event) throws FormProcessException { final PageState state = event.getPageState(); @@ -238,23 +243,32 @@ public class ApplicationCreateForm extends Form implement applicationUrl.setValue(state, ""); applicationDesc.setValue(state, ""); - throw new FormProcessException("Canceled"); + throw new FormProcessException("Cancelled", + GlobalizationUtil.globalize( + "ui.admin.cancel_msg")); } } + @Override public void validate(final FormSectionEvent event) throws FormProcessException { - final PageState state = event.getPageState(); + /** */ + final PageState state = event.getPageState(); + /** */ final String url = (String) applicationUrl.getValue(state); if (url.contains("/")) { - throw new FormProcessException((String) GlobalizationUtil.globalize( - "ui.admin.applications.url.validation.no_slash_allowed").localize()); + throw new FormProcessException( + "The URL fragement may not contain slashes", + GlobalizationUtil.globalize( + "ui.admin.applications.url.validation.no_slash_allowed")); } if (Application.isInstalled(Application.BASE_DATA_OBJECT_TYPE, url)) { - throw new FormProcessException((String) GlobalizationUtil.globalize( - "ui.admin.applications.url.validation.url_already_in_use").localize()); + throw new FormProcessException( + "The provided URL is already in use", + GlobalizationUtil.globalize( + "ui.admin.applications.url.validation.url_already_in_use")); } } } diff --git a/ccm-core/src/com/arsdigita/ui/login/LoginResources.properties b/ccm-core/src/com/arsdigita/ui/login/LoginResources.properties index 3210ba731..7527fdb1b 100644 --- a/ccm-core/src/com/arsdigita/ui/login/LoginResources.properties +++ b/ccm-core/src/com/arsdigita/ui/login/LoginResources.properties @@ -57,7 +57,7 @@ login.error.duplicateEmail=Some other user has this email address login.error.mismatchPassword=New passwords must match login.error.badPassword=Incorrect password login.error.badAnswer=Incorrect answer -login.error.badEmail=Unrecognized email address +login.error.badEmail=Unrecognized email address {0} login.error.bannedEmail=User cannot currently access system login.error.loginFail=Login failed login.changePasswortForm.greeting=Welcome {0} diff --git a/ccm-core/src/com/arsdigita/ui/login/LoginResources_de.properties b/ccm-core/src/com/arsdigita/ui/login/LoginResources_de.properties index 935591644..0e9ba5494 100644 --- a/ccm-core/src/com/arsdigita/ui/login/LoginResources_de.properties +++ b/ccm-core/src/com/arsdigita/ui/login/LoginResources_de.properties @@ -57,7 +57,7 @@ login.error.duplicateEmail=Ein anderer Nutzer verwendet diese E-Mail Adresse login.error.mismatchPassword=Die neuen Passw\u00f6rter m\u00fcssen gleich sein login.error.badPassword=Falsches Passwort login.error.badAnswer=Falsche Antwort -login.error.badEmail=Ung\u00fcltige E-Mail Adresse +login.error.badEmail=Ung\u00fcltige E-Mail Adresse: {0} login.error.bannedEmail=Benutzer kann zur Zeit das System nicht nutzen login.error.loginFail=Anmeldung nicht erfolgreich login.changePasswortForm.greeting=Willkommen {0} diff --git a/ccm-core/src/com/arsdigita/ui/login/LoginResources_en.properties b/ccm-core/src/com/arsdigita/ui/login/LoginResources_en.properties index f839f050c..c22d432b9 100644 --- a/ccm-core/src/com/arsdigita/ui/login/LoginResources_en.properties +++ b/ccm-core/src/com/arsdigita/ui/login/LoginResources_en.properties @@ -57,7 +57,7 @@ login.error.duplicateEmail=Some other user has this email address login.error.mismatchPassword=New passwords must match login.error.badPassword=Incorrect password login.error.badAnswer=Incorrect answer -login.error.badEmail=Unrecognized email address +login.error.badEmail=Unrecognized email address {0} login.error.bannedEmail=User cannot currently access system login.error.loginFail=Login failed login.changePasswortForm.greeting=Welcome {0} diff --git a/ccm-core/src/com/arsdigita/ui/login/UserForm.java b/ccm-core/src/com/arsdigita/ui/login/UserForm.java index 78f666792..afe6d2fd9 100755 --- a/ccm-core/src/com/arsdigita/ui/login/UserForm.java +++ b/ccm-core/src/com/arsdigita/ui/login/UserForm.java @@ -269,8 +269,12 @@ public abstract class UserForm extends Form try { address = new InternetAddress(user.getPrimaryEmail().toString()); } catch(AddressException e) { - throw new FormProcessException("Email address is bad: " - + user.getPrimaryEmail()); + String[] errorMsg = new String[1]; + errorMsg[0] = user.getPrimaryEmail().toString(); + throw new FormProcessException( + "Email address is bad: " + user.getPrimaryEmail(), + LoginHelper.getMessage("login.error.badEmail",errorMsg) + ); } m_email.setValue(state, address); diff --git a/ccm-core/src/com/arsdigita/web/BaseApplicationServlet.java b/ccm-core/src/com/arsdigita/web/BaseApplicationServlet.java index be3381919..44de6bfbe 100755 --- a/ccm-core/src/com/arsdigita/web/BaseApplicationServlet.java +++ b/ccm-core/src/com/arsdigita/web/BaseApplicationServlet.java @@ -66,7 +66,7 @@ import org.apache.log4j.Logger; public abstract class BaseApplicationServlet extends BaseServlet { /** Logger instance for debugging purpose. */ - private static Logger s_log = Logger.getLogger(BaseApplicationServlet.class); + private static final Logger s_log = Logger.getLogger(BaseApplicationServlet.class); /** *

The ID of the application whose service is requested. This @@ -92,12 +92,14 @@ public abstract class BaseApplicationServlet extends BaseServlet { *

Augments the context of the request and delegates to {@link * #doService(HttpServletRequest,HttpServletResponse,Application)}.

* + * @throws javax.servlet.ServletException + * @throws java.io.IOException * @see com.arsdigita.web.BaseServlet#doService(HttpServletRequest,HttpServletResponse) */ @Override protected final void doService(final HttpServletRequest sreq, final HttpServletResponse sresp) - throws ServletException, IOException { + throws ServletException, IOException { final Application app = getApplication(sreq); @@ -117,6 +119,7 @@ public abstract class BaseApplicationServlet extends BaseServlet { final IOException[] ioException = { null }; new KernelExcursion() { + @Override protected final void excurse() { setLocale(rc.getLocale()); setResource(app); @@ -141,12 +144,17 @@ public abstract class BaseApplicationServlet extends BaseServlet { } /** - *

The method that {@link - * #doService(HttpServletRequest,HttpServletResponse)} calls. + * The method that {@link #doService(HttpServletRequest,HttpServletResponse)} + * calls. * Servlet authors should implement this method to perform - * application-specific request handling.

- * + * application-specific request handling * @see javax.servlet.http.HttpServlet#service(HttpServletRequest,HttpServletResponse) + * + * @param sreq + * @param sresp + * @param app + * @throws javax.servlet.ServletException + * @throws java.io.IOException */ protected abstract void doService(HttpServletRequest sreq, HttpServletResponse sresp, @@ -212,31 +220,6 @@ public abstract class BaseApplicationServlet extends BaseServlet { final KernelRequestContext krc = new KernelRequestContext (irc, sc, uc); -// SiteNode node = null; - // Experimental: -// if (node == null) { -// return krc; -// } - -// try { -// node = SiteNode.getSiteNode(app.getPrimaryURL(), -// true); -// } catch (DataObjectNotFoundException ex) { -// throw new UncheckedWrapperException("cannot find root sitenode"); -// } - -// if (node == null) { -// s_log.debug("There is no site node at this URL; storing a " + -// "KernelRequestContext"); - - return krc; -// } else { -// s_log.debug("Creating a SiteNodeRequestContext"); - -// final SiteNodeRequestContext snrc = new SiteNodeRequestContext -// (sreq, krc, node, sreq.getServletPath() + "/"); - -// return snrc; -// } + return krc; } } diff --git a/ccm-core/src/com/arsdigita/web/Web.java b/ccm-core/src/com/arsdigita/web/Web.java index 63484a3c8..023f59a18 100755 --- a/ccm-core/src/com/arsdigita/web/Web.java +++ b/ccm-core/src/com/arsdigita/web/Web.java @@ -46,7 +46,7 @@ public class Web { /** Internal logger instance to faciliate debugging. Enable logging output * by editing /WEB-INF/conf/log4j.properties int the runtime environment * and set com.arsdigita.web.Web=DEBUG - * by uncommenting or adding the line. */ + * by uncommenting or adding the line. */ private static final Logger s_log = Logger.getLogger(Web.class); private static final WebConfig s_config = WebConfig.getInstanceOf(); diff --git a/ccm-core/src/com/arsdigita/web/ui/ApplicationConfigFormSection.java b/ccm-core/src/com/arsdigita/web/ui/ApplicationConfigFormSection.java index ce3c97c94..b87053f76 100755 --- a/ccm-core/src/com/arsdigita/web/ui/ApplicationConfigFormSection.java +++ b/ccm-core/src/com/arsdigita/web/ui/ApplicationConfigFormSection.java @@ -84,6 +84,7 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection { private void setup() { addInitListener(new FormInitListener() { + @Override public void init(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); @@ -99,6 +100,7 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection { }); addValidationListener(new FormValidationListener() { + @Override public void validate(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); @@ -148,7 +150,9 @@ public class ApplicationConfigFormSection extends ResourceConfigFormSection { /** * Initialize the form fields + * @param state * @param application the application being edited, if any + * @throws com.arsdigita.bebop.FormProcessException */ protected void initWidgets(PageState state, Application application) diff --git a/ccm-ldn-freeform/src/com/arsdigita/london/cms/freeform/ui/FreeformTextAssetEdit.java b/ccm-ldn-freeform/src/com/arsdigita/london/cms/freeform/ui/FreeformTextAssetEdit.java index 00da5360c..14bf00aa0 100755 --- a/ccm-ldn-freeform/src/com/arsdigita/london/cms/freeform/ui/FreeformTextAssetEdit.java +++ b/ccm-ldn-freeform/src/com/arsdigita/london/cms/freeform/ui/FreeformTextAssetEdit.java @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2002-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.london.cms.freeform.ui; import com.arsdigita.bebop.form.FormErrorDisplay; @@ -9,38 +28,33 @@ import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.FormProcessException; - - -import com.arsdigita.london.cms.freeform.asset.FreeformTextAsset; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SingleSelectionModel; import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ui.authoring.TextAssetBody; import com.arsdigita.london.cms.freeform.FreeformContentItem; +import com.arsdigita.london.cms.freeform.asset.FreeformTextAsset; import com.arsdigita.db.Sequences; import com.arsdigita.util.UncheckedWrapperException; -import java.math.BigDecimal; import com.arsdigita.cms.TextAsset; import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.Label; import com.arsdigita.cms.ContentItem; + +import java.math.BigDecimal; import java.sql.SQLException; + /** - * FreeformTextAssetEdit - * - * @author slater@arsdigita.com - * - * This is a fragment, meant for edit/creating FreeformTextAssets. + * FreeformTextAssetEdit is a fragment, meant for edit/creating + * FreeformTextAssets. * It should ultimately be combined with something that will do the * same for FreeformBinaryAssets - * * Modelled after some cms code {@link TextPageBody} * - **/ - - + * @author slater@arsdigita.com + */ public class FreeformTextAssetEdit extends TextAssetBody { //Members @@ -53,7 +67,8 @@ public class FreeformTextAssetEdit extends TextAssetBody { private static final String DESCRIPTION = "description"; // private TextField m_name; private TextField m_description; - //private static final String NAME_ERROR_MESSAGE = "Name must be unique and only have letters and numbers"; + //private static final String NAME_ERROR_MESSAGE = + //"Name must be unique and only have letters and numbers"; // Member/Listeners for the extension of the form from TextAssetBody @@ -61,13 +76,13 @@ public class FreeformTextAssetEdit extends TextAssetBody { private FormProcessListener m_ff_ProcessListener; - - /** * @param itemModel the item model that represents the FreeformContentItem * @param assetModel the model that represents the asset we are editing **/ - public FreeformTextAssetEdit(SingleSelectionModel assetModel, ItemSelectionModel itemModel, ViewAssets viewAssets ) { + public FreeformTextAssetEdit(SingleSelectionModel assetModel, + ItemSelectionModel itemModel, + ViewAssets viewAssets ) { super(new ItemSelectionModel(assetModel)); @@ -99,7 +114,8 @@ public class FreeformTextAssetEdit extends TextAssetBody { BigDecimal assetID = Sequences.getNextValue(); t.setID(assetID); - t.setName(((ContentItem)m_FreeformContentItemModel.getSelectedObject(ps)).getName() + "_freeform_text_" + assetID); + t.setName(((ContentItem)m_FreeformContentItemModel.getSelectedObject(ps)) + .getName() + "_freeform_text_" + assetID); } catch (SQLException ex) { ex.printStackTrace(); @@ -115,8 +131,8 @@ public class FreeformTextAssetEdit extends TextAssetBody { // Add the new asset to the FreeformContentItem and persist the // changes before returning - FreeformContentItem item = - (FreeformContentItem)m_FreeformContentItemModel.getSelectedObject(ps); + FreeformContentItem item = (FreeformContentItem)m_FreeformContentItemModel + .getSelectedObject(ps); t.save(); item.addAsset(t, new Integer(0)); item.save(); @@ -141,7 +157,6 @@ public class FreeformTextAssetEdit extends TextAssetBody { protected void updateTextAsset(PageState ps, TextAsset a) { // assign it to the parent FreeformContentItem - // (stas says this is unreliable) FreeformContentItem ffci = ((CMSPage) state.getPage()).getContentItem(state); a.setParent((ContentItem)m_FreeformContentItemModel.getSelectedObject(ps)); //save it. diff --git a/ccm-ldn-freeform/src/com/arsdigita/london/cms/freeform/ui/ViewAssets.java b/ccm-ldn-freeform/src/com/arsdigita/london/cms/freeform/ui/ViewAssets.java index 30d04b6ba..661e50ac8 100755 --- a/ccm-ldn-freeform/src/com/arsdigita/london/cms/freeform/ui/ViewAssets.java +++ b/ccm-ldn-freeform/src/com/arsdigita/london/cms/freeform/ui/ViewAssets.java @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2002-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.london.cms.freeform.ui; import com.arsdigita.london.cms.freeform.FreeformContentItem; @@ -33,7 +52,7 @@ import com.arsdigita.bebop.table.TableColumn; * * @author Phong Nguyen * @version $Revision: #2 $ - **/ + */ public class ViewAssets extends ResettableContainer { // $Source: /cvsroot/content-types/apps/freeform/src/ui/ViewAssets.java,v $ @@ -48,8 +67,8 @@ public class ViewAssets extends ResettableContainer { public static final String TEXT_ASSET_EDIT_KEY = "taek"; public static final String BINARY_ASSET_EDIT_KEY = "baek"; - private AuthoringKitWizard m_kitWizard; - private ItemSelectionModel m_itemModel; + private final AuthoringKitWizard m_kitWizard; + private final ItemSelectionModel m_itemModel; private ItemSelectionModel m_assetModel; private FreeformAssetTable m_assetTable; @@ -80,7 +99,9 @@ public class ViewAssets extends ResettableContainer { /** * Builds a container which holds a {@link AssetTable} and a link * to add a new {@link Asset}. - **/ + * + * @return + */ protected Container buildTablePanel() { ColumnPanel c = new ColumnPanel(1); c.setKey(ASSET_TABLE_KEY); @@ -99,6 +120,7 @@ public class ViewAssets extends ResettableContainer { emptyView.setFontWeight(Label.ITALIC); m_assetTable.setEmptyView(emptyView); m_assetTable.addTableActionListener(new TableActionListener() { + @Override public void cellSelected(TableActionEvent event) { TableColumn tc = m_assetTable.getColumnModel() .get(event.getColumn().intValue()); @@ -107,6 +129,7 @@ public class ViewAssets extends ResettableContainer { onlyShowComponent(event.getPageState(), ASSET_VIEW_KEY); } } + @Override public void headSelected(TableActionEvent event) {} }); @@ -123,6 +146,7 @@ public class ViewAssets extends ResettableContainer { ActionLink addLink = new ActionLink("Add text asset"); addLink.setClassAttr("actionLink"); addLink.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent event) { PageState state = event.getPageState(); @@ -136,6 +160,7 @@ public class ViewAssets extends ResettableContainer { addLink = new ActionLink("Add binary asset"); addLink.setClassAttr("actionLink"); addLink.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent event) { PageState state = event.getPageState(); @@ -152,6 +177,8 @@ public class ViewAssets extends ResettableContainer { /** * Builds a container which holds the {@link FreeformAssetView} * and a link to edit the displayed asset. + * + * @return **/ protected Container buildViewPanel() { ColumnPanel c = new ColumnPanel(1); @@ -167,6 +194,7 @@ public class ViewAssets extends ResettableContainer { ActionLink editLink = new ActionLink("Edit asset"); editLink.setClassAttr("actionLink"); editLink.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent event) { PageState state = event.getPageState(); Asset asset = (Asset)m_assetModel.getSelectedObject(state); @@ -192,9 +220,12 @@ public class ViewAssets extends ResettableContainer { ActionLink viewAllLink = new ActionLink("View all assets"); viewAllLink.setClassAttr("actionLink"); viewAllLink.addActionListener(new ActionListener() { + + @Override public void actionPerformed(ActionEvent event) { onlyShowComponent(event.getPageState(), ASSET_TABLE_KEY); } + }); c.add(viewAllLink); @@ -204,7 +235,9 @@ public class ViewAssets extends ResettableContainer { /** * Builds a container which holds the {@link FreeformTextAssetEdit}. - **/ + * + * @return + */ protected Container buildTextEditPanel() { ColumnPanel c = new ColumnPanel(1); c.setKey(TEXT_ASSET_EDIT_KEY); @@ -212,6 +245,7 @@ public class ViewAssets extends ResettableContainer { c.setPadColor("#ffffff"); c.add(new Label(new PrintListener() { + @Override public void prepare(PrintEvent event) { PageState state = event.getPageState(); Label label = (Label)event.getTarget(); @@ -232,6 +266,7 @@ public class ViewAssets extends ResettableContainer { ActionLink viewAllLink = new ActionLink("View all assets"); viewAllLink.setClassAttr("actionLink"); viewAllLink.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent event) { onlyShowComponent(event.getPageState(), ASSET_TABLE_KEY); } @@ -244,6 +279,8 @@ public class ViewAssets extends ResettableContainer { /** * Builds a container which holds the {@link FreeformBinaryAssetEdit}. + * + * @return **/ protected Container buildBinaryEditPanel() { ColumnPanel c = new ColumnPanel(1); @@ -252,6 +289,12 @@ public class ViewAssets extends ResettableContainer { c.setPadColor("#ffffff"); c.add(new Label(new PrintListener() { + + /** + * + * @param event + */ + @Override public void prepare(PrintEvent event) { PageState state = event.getPageState(); Label label = (Label)event.getTarget(); @@ -270,6 +313,7 @@ public class ViewAssets extends ResettableContainer { // Retrieves the newly created or editted asset and updates the item. m_binaryAssetEdit.addSubmissionListener(new FormSubmissionListener() { + public void submitted(FormSectionEvent event) throws FormProcessException { PageState state = event.getPageState(); @@ -290,6 +334,7 @@ public class ViewAssets extends ResettableContainer { ActionLink viewAllLink = new ActionLink("View all assets"); viewAllLink.setClassAttr("actionLink"); viewAllLink.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent event) { onlyShowComponent(event.getPageState(), ASSET_TABLE_KEY); } diff --git a/ccm-shortcuts/src/com/arsdigita/shortcuts/ShortcutsResources.properties b/ccm-shortcuts/src/com/arsdigita/shortcuts/ShortcutsResources.properties new file mode 100644 index 000000000..f313e3542 --- /dev/null +++ b/ccm-shortcuts/src/com/arsdigita/shortcuts/ShortcutsResources.properties @@ -0,0 +1,4 @@ +shortcuts.ui.invalid_key=Invalid Key +shortcuts.ui.duplicate_key=Duplicate Key +shortcuts.ui.key_already_exists=That key already exists! +shortcuts.ui.invalid_key_descr=URL key must start with the character '/' and only contain characters a-z, A-Z, 0-9, -, ., - diff --git a/ccm-shortcuts/src/com/arsdigita/shortcuts/ShortcutsResources_de.properties b/ccm-shortcuts/src/com/arsdigita/shortcuts/ShortcutsResources_de.properties new file mode 100644 index 000000000..b1c5f0a72 --- /dev/null +++ b/ccm-shortcuts/src/com/arsdigita/shortcuts/ShortcutsResources_de.properties @@ -0,0 +1,4 @@ +shortcuts.ui.invalid_key=ung\u00fcltiger Schl\u00fcssel +shortcuts.ui.duplicate_key=Doppelter Schl\u00fcssel +shortcuts.ui.key_already_exists=Dieser Schl\u00fcssel existiert bereits! +shortcuts.ui.invalid_key_descr=URL muss mit dem Zeichen '/' beginnen und nur die Zeichen a-z, A-Z, 0-9, -, ., - enhalten. diff --git a/ccm-shortcuts/src/com/arsdigita/shortcuts/ShortcutsResources_fr.properties b/ccm-shortcuts/src/com/arsdigita/shortcuts/ShortcutsResources_fr.properties new file mode 100644 index 000000000..0b424c978 --- /dev/null +++ b/ccm-shortcuts/src/com/arsdigita/shortcuts/ShortcutsResources_fr.properties @@ -0,0 +1,4 @@ +shortcuts.ui.invalid_key=TRANSLATE: Invalid Key +shortcuts.ui.duplicate_key=TRANSLATE: Duplicate Key +shortcuts.ui.key_already_exists=That key already exists! +shortcuts.ui.invalid_key_descr=URL diff --git a/ccm-shortcuts/src/com/arsdigita/shortcuts/ui/ShortcutForm.java b/ccm-shortcuts/src/com/arsdigita/shortcuts/ui/ShortcutForm.java index ff7c6ce2f..baca2ec6e 100755 --- a/ccm-shortcuts/src/com/arsdigita/shortcuts/ui/ShortcutForm.java +++ b/ccm-shortcuts/src/com/arsdigita/shortcuts/ui/ShortcutForm.java @@ -21,26 +21,28 @@ package com.arsdigita.shortcuts.ui; import java.math.BigDecimal; -import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.event.FormProcessListener; -import com.arsdigita.kernel.ui.ACSObjectSelectionModel; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.event.FormValidationListener; import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.form.Submit; -import com.arsdigita.shortcuts.ShortcutUtil; -import com.arsdigita.shortcuts.Shortcut; import com.arsdigita.bebop.Form; -import com.arsdigita.bebop.parameters.TrimmedStringParameter; -import com.arsdigita.bebop.parameters.NotEmptyValidationListener; import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.ParameterListener; import com.arsdigita.bebop.event.ParameterEvent; -import com.arsdigita.bebop.parameters.ParameterData; -import org.apache.log4j.Category; +import com.arsdigita.bebop.form.Submit; import com.arsdigita.bebop.form.TextField; +import com.arsdigita.bebop.parameters.ParameterData; +import com.arsdigita.bebop.parameters.TrimmedStringParameter; +import com.arsdigita.bebop.parameters.NotEmptyValidationListener; +import com.arsdigita.kernel.ui.ACSObjectSelectionModel; +import com.arsdigita.shortcuts.ShortcutUtil; +import com.arsdigita.shortcuts.Shortcut; +import com.arsdigita.shortcuts.util.GlobalizationUtil; import com.arsdigita.util.UncheckedWrapperException; + +import org.apache.log4j.Category; import org.apache.oro.text.perl.Perl5Util; import org.apache.oro.text.perl.MalformedPerl5PatternException; @@ -55,7 +57,7 @@ public class ShortcutForm extends Form { private TextField m_redirect; - private Submit m_submit; + private final Submit m_submit; public ShortcutForm(ACSObjectSelectionModel selected_shortcut) { super("ShortcutForm"); @@ -74,6 +76,7 @@ public class ShortcutForm extends Form { m_redirect = new TextField(redirectParameter); urlKeyParameter.addParameterListener(new ParameterListener() { + @Override public void validate(ParameterEvent e) throws FormProcessException { ParameterData data = e.getParameterData(); @@ -85,10 +88,12 @@ public class ShortcutForm extends Form { Perl5Util perl = new Perl5Util(); try { if (!perl.match("/^(\\/[-a-zA-Z0-9_.]+)+\\/?$/", key)) { - data.addError("URL key must start with the " - + "character '/' and only contains " - + "a-z, A-Z, 0-9, -, ., -"); - throw new FormProcessException("Invalid key"); + data.addError(GlobalizationUtil.globalize( + "shortcuts.ui.invalid_key_descr")); + throw new FormProcessException( + "Invalid key", + GlobalizationUtil.globalize("shortcuts.ui.invalid_key") + ); } } catch (MalformedPerl5PatternException ex) { throw new UncheckedWrapperException("bad regex", ex); @@ -97,6 +102,7 @@ public class ShortcutForm extends Form { }); redirectParameter.addParameterListener(new ParameterListener() { + @Override public void validate(ParameterEvent e) throws FormProcessException { ParameterData data = e.getParameterData(); @@ -141,6 +147,7 @@ public class ShortcutForm extends Form { } private class ShortcutInitListener implements FormInitListener { + @Override public void init(FormSectionEvent ev) throws FormProcessException { PageState state = ev.getPageState(); BigDecimal shortcutKey = (BigDecimal) m_selected_shortcut @@ -161,6 +168,7 @@ public class ShortcutForm extends Form { private class ShortcutFormValidationListener implements FormValidationListener { + @Override public void validate(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); @@ -175,41 +183,23 @@ public class ShortcutForm extends Form { if (shortcutKey == null) { String target = ShortcutUtil.getTarget(key); if (target != null) { - m_url.addError("that url key already exists"); - throw new FormProcessException("duplicate key"); + m_url.addError(GlobalizationUtil.globalize( + "shortcuts.ui.key_already_exists")); + throw new FormProcessException( + "duplicate key", + GlobalizationUtil.globalize("shortcuts.ui.duplicate_key") + ); } } int index = key.indexOf("/", 2); String base = key.substring(0, index + 1); - - return; - // disable checking application nodes -- this is not even the - // correct thing to - // check! - // SiteNode node = null; - // try { - // log.info("checking for site node : " + base); - // node = SiteNode.getSiteNode(base, true); - // } catch ( DataObjectNotFoundException ex ) { - // // node doesn't exist so return - // return; - // } - // - // if ( !base.equals(node.getURL()) ) { - // log.info("path does not match: " + node.getURL()); - // return; - // } - // - // m_url.addError("an application is already using the key starting - // with " + - // base); - // throw new FormProcessException("clash with sitenode"); } } private class ShortcutFormProcessListener implements FormProcessListener { + @Override public void process(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); diff --git a/ccm-shortcuts/src/com/arsdigita/shortcuts/util/GlobalizationUtil.java b/ccm-shortcuts/src/com/arsdigita/shortcuts/util/GlobalizationUtil.java new file mode 100755 index 000000000..ac74d54f0 --- /dev/null +++ b/ccm-shortcuts/src/com/arsdigita/shortcuts/util/GlobalizationUtil.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2001-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.shortcuts.util; + +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. + * + * @author yon@arsdigita.com + * @version $Revision: #1 $ $Date: 2003/11/18 $ + */ +public class GlobalizationUtil { + + /** Name of resource files to handle themedirector's globalisation. */ + public static final String BUNDLE_NAME = + "com.arsdigita.shortcuts.ShortcutsResources"; + + /** + * This returns a globalized message using the package specific bundle, + * provided by BUNDLE_NAME. + * + * @param key + * @return + */ + 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. + * + * @param key + * @param args + * @return + */ + public static GlobalizedMessage globalize(String key, Object[] args) { + return new GlobalizedMessage(key, BUNDLE_NAME, args); + } + +} diff --git a/ccm-subsite/src/com/arsdigita/subsite/ui/SubsiteResources.properties b/ccm-subsite/src/com/arsdigita/subsite/SubsiteResources.properties similarity index 91% rename from ccm-subsite/src/com/arsdigita/subsite/ui/SubsiteResources.properties rename to ccm-subsite/src/com/arsdigita/subsite/SubsiteResources.properties index 00bc3456c..b5a0f7a9e 100644 --- a/ccm-subsite/src/com/arsdigita/subsite/ui/SubsiteResources.properties +++ b/ccm-subsite/src/com/arsdigita/subsite/SubsiteResources.properties @@ -27,3 +27,6 @@ subsite.ui.delete.confirm=Are you sure to delete the subsite {0}? subsite.ui.no_subsites=No subites defined subsite.ui.default_app_label=Site Wide Default subsite.ui.default_style_label=Site Wide Default +subsite.ui.save.hint=Save the details in the form +subsite.ui.cancel.hint=Abort changes & reset the form +subsite.ui.other_style_label=Other (type in box below) diff --git a/ccm-subsite/src/com/arsdigita/subsite/ui/SubsiteResources_de.properties b/ccm-subsite/src/com/arsdigita/subsite/SubsiteResources_de.properties similarity index 89% rename from ccm-subsite/src/com/arsdigita/subsite/ui/SubsiteResources_de.properties rename to ccm-subsite/src/com/arsdigita/subsite/SubsiteResources_de.properties index 983c91b3b..859f83fdb 100644 --- a/ccm-subsite/src/com/arsdigita/subsite/ui/SubsiteResources_de.properties +++ b/ccm-subsite/src/com/arsdigita/subsite/SubsiteResources_de.properties @@ -27,3 +27,6 @@ subsite.ui.delete.confirm=Sind Sie sicher, dass Sie die Subsite {0} l\u00f6schen subsite.ui.no_subsites=Es sind keine Subsites eingerichtet. subsite.ui.default_app_label=Standard f\u00fcr diese Installation subsite.ui.default_style_label=Standard f\u00fcr diese Installation +subsite.ui.save.hint=Speichert die Angaben in dem Formular +subsite.ui.cancel.hint=Verwirft die Eintragungen und erzeugt ein neues, leeres Formualar +subsite.ui.other_style_label=Anderes (bitte in der Box unterhalb eintragen) diff --git a/ccm-subsite/src/com/arsdigita/subsite/ui/AppManagerPanel.java b/ccm-subsite/src/com/arsdigita/subsite/ui/AppManagerPanel.java index 4584970f9..3c080dbf1 100644 --- a/ccm-subsite/src/com/arsdigita/subsite/ui/AppManagerPanel.java +++ b/ccm-subsite/src/com/arsdigita/subsite/ui/AppManagerPanel.java @@ -29,7 +29,8 @@ import com.arsdigita.bebop.parameters.BigDecimalParameter; */ public class AppManagerPanel extends SimpleContainer { - private final SiteSelectionModel selectionModel = new SiteSelectionModel(new BigDecimalParameter("site")); + private final SiteSelectionModel selectionModel = + new SiteSelectionModel(new BigDecimalParameter("site")); public AppManagerPanel() { add(new SiteTable(selectionModel)); diff --git a/ccm-subsite/src/com/arsdigita/subsite/ui/ControlCenterPanel.java b/ccm-subsite/src/com/arsdigita/subsite/ui/ControlCenterPanel.java index a3b25a3fa..80d2befdd 100755 --- a/ccm-subsite/src/com/arsdigita/subsite/ui/ControlCenterPanel.java +++ b/ccm-subsite/src/com/arsdigita/subsite/ui/ControlCenterPanel.java @@ -18,7 +18,6 @@ package com.arsdigita.subsite.ui; -import com.arsdigita.bebop.Page; import com.arsdigita.subsite.Subsite; import com.arsdigita.bebop.SimpleContainer; diff --git a/ccm-subsite/src/com/arsdigita/subsite/ui/SiteForm.java b/ccm-subsite/src/com/arsdigita/subsite/ui/SiteForm.java index 17743afb1..23521764a 100755 --- a/ccm-subsite/src/com/arsdigita/subsite/ui/SiteForm.java +++ b/ccm-subsite/src/com/arsdigita/subsite/ui/SiteForm.java @@ -48,6 +48,8 @@ import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.SessionManager; import com.arsdigita.subsite.Site; import com.arsdigita.subsite.Subsite; +import com.arsdigita.subsite.util.SubsiteGlobalizationUtil; +import static com.arsdigita.subsite.util.SubsiteGlobalizationUtil.globalize; import com.arsdigita.ui.UI; import com.arsdigita.util.Assert; import com.arsdigita.util.Classes; @@ -65,34 +67,35 @@ import org.apache.log4j.Logger; /** * Class creates the administration input form. * - * Used by ControlCenterPanel to construct the 'create new site' and 'edit existing site' input - * forms. + * Used by ControlCenterPanel to construct the 'create new site' and + * 'edit existing site' input forms. */ public class SiteForm extends Form { - /** - * A logger instance. - */ + /** Internal logger instance to faciliate debugging. Enable logging output + * by editing /WEB-INF/conf/log4j.properties int the runtime environment + * and set com.arsdigita.subsite.ui.SiteForm=DEBUG + * by uncommenting or adding the line. */ private static final Logger s_log = Logger.getLogger(SiteForm.class); - private SiteSelectionModel m_site; - private BigDecimal siteDefaultRootPageID; + private final SiteSelectionModel m_site; + private final BigDecimal siteDefaultRootPageID; /** * Input field subsite title */ - private TextField m_title; - private TextField m_hostname; - private TextArea m_description; - private SingleSelect m_customFrontpageApp; - private TextField m_styleDir; - private CategoryPicker m_rootCategory; - private SingleSelect m_themes; - private SaveCancelSection m_buttons; + private final TextField m_title; + private final TextField m_hostname; + private final TextArea m_description; + private final SingleSelect m_customFrontpageApp; + private final TextField m_styleDir; + private final CategoryPicker m_rootCategory; + private final SingleSelect m_themes; + private final SaveCancelSection m_buttons; private final static String DEFAULT_APP = "DEFAULT_APP"; private final static String DEFAULT_APP_LABEL = "subsite.ui.default_app_label"; private final static String DEFAULT_STYLE = "DEFAULT_STYLE"; private final static String DEFAULT_STYLE_LABEL = "subsite.ui.default_style_label"; private final static String OTHER_STYLE = "OTHER_STYLE"; - private final static String OTHER_STYLE_LABEL = "Other (type in box below)"; + private final static String OTHER_STYLE_LABEL = "subsite.ui.other_style_label"; /** * Constructor create input widgets and adds them to form. @@ -116,8 +119,7 @@ public class SiteForm extends Form { m_title = new TextField(new StringParameter("title")); m_title.addValidationListener(new NotNullValidationListener()); m_title.setMetaDataAttribute("title", "Title"); - m_title.setHint((String) SubsiteGlobalizationUtil.globalize("subsite.ui.title.hint"). - localize()); + m_title.setHint(SubsiteGlobalizationUtil.globalize("subsite.ui.title.hint")); m_title.setSize(40); add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.title.label"))); add(m_title); // adds title input field to form @@ -129,8 +131,7 @@ public class SiteForm extends Form { m_hostname.addValidationListener(new HostNameValidationListener()); m_hostname.setMetaDataAttribute("title", "Hostname"); m_hostname.setSize(40); - m_hostname.setHint((String) SubsiteGlobalizationUtil.globalize("subsite.ui.hostname.hint"). - localize()); + m_hostname.setHint(SubsiteGlobalizationUtil.globalize("subsite.ui.hostname.hint")); add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.hostname.label"))); add(m_hostname); // adds hostname input field to form @@ -141,8 +142,8 @@ public class SiteForm extends Form { m_description.setMetaDataAttribute("title", "Description"); m_description.setCols(45); m_description.setRows(4); - m_description.setHint((String) SubsiteGlobalizationUtil.globalize( - "subsite.ui.description.hint").localize()); + m_description.setHint(SubsiteGlobalizationUtil.globalize( + "subsite.ui.description.hint")); add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.description.label"))); add(m_description); // adds description input field to form @@ -153,9 +154,8 @@ public class SiteForm extends Form { new StringParameter("customFrontpageApp")); m_customFrontpageApp.setMetaDataAttribute("title", "Front Page (url)"); // m_customFrontpageApp.setSize(40); - m_customFrontpageApp.setHint((String) SubsiteGlobalizationUtil.globalize( - "subsite.ui.customfrontpage.hint"). - localize()); + m_customFrontpageApp.setHint(globalize( + "subsite.ui.customfrontpage.hint")); try { m_customFrontpageApp.addPrintListener(new FrontpageAppListener()); } catch (TooManyListenersException ex) { @@ -168,8 +168,7 @@ public class SiteForm extends Form { /* Setup selection box for themes */ m_themes = new SingleSelect(new StringParameter("selectStyleDir")); m_themes.setMetaDataAttribute("title", "XSLT Directory"); - m_themes.setHint((String) SubsiteGlobalizationUtil.globalize("subsite.ui.theme.hint"). - localize()); + m_themes.setHint(SubsiteGlobalizationUtil.globalize("subsite.ui.theme.hint")); try { m_themes.addPrintListener(new ThemesListener()); } catch (TooManyListenersException ex) { @@ -183,8 +182,7 @@ public class SiteForm extends Form { m_styleDir = new TextField(new StringParameter("styleDir")); m_styleDir.setMetaDataAttribute("title", "XSLT Directory (Other)"); m_styleDir.setSize(40); - m_styleDir.setHint( - "Enter the directory for the custom XSLT styles, or leave blank for the default styling."); + m_styleDir.setHint(globalize("subsite.ui.styledir.hint") ); add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.styledir.label"))); add(m_styleDir); // adds inputfield style dir to form @@ -196,8 +194,8 @@ public class SiteForm extends Form { new Object[]{"rootCategory"}); if (m_rootCategory instanceof Widget) { ((Widget) m_rootCategory).setMetaDataAttribute("title", "Root category"); - ((Widget) m_rootCategory).setHint((String) SubsiteGlobalizationUtil.globalize( - "subsite.ui.root_category.hint").localize()); + ((Widget) m_rootCategory).setHint(SubsiteGlobalizationUtil.globalize( + "subsite.ui.root_category.hint")); } add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.root_category.label"))); add(m_rootCategory); // adds domain category selection box to form @@ -205,10 +203,10 @@ public class SiteForm extends Form { m_buttons = new SaveCancelSection(); m_buttons.getSaveButton().setButtonLabel(SubsiteGlobalizationUtil.globalize( "subsite.ui.save")); - m_buttons.getSaveButton().setHint("Save the details in the form"); + m_buttons.getSaveButton().setHint(globalize("subsite.ui.save.hint")); m_buttons.getCancelButton().setButtonLabel(SubsiteGlobalizationUtil.globalize( "subsite.ui.cancel")); - m_buttons.getCancelButton().setHint("Abort changes & reset the form"); + m_buttons.getCancelButton().setHint(globalize("subsite.ui.cancel.hint")); add(m_buttons); addSubmissionListener(new SiteSubmissionListener()); @@ -222,13 +220,17 @@ public class SiteForm extends Form { */ private class SiteSubmissionListener implements FormSubmissionListener { + @Override public void submitted(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); if (m_buttons.getCancelButton().isSelected(state)) { m_site.clearSelection(state); - throw new FormProcessException("cancel pressed"); + throw new FormProcessException( + "cancel pressed", + globalize("cms.ui.authoring.submission_cancelled") + ); } } @@ -239,6 +241,7 @@ public class SiteForm extends Form { */ private class SiteValidationListener implements FormValidationListener { + @Override public void validate(FormSectionEvent e) { PageState state = e.getPageState(); if (!m_buttons.getCancelButton().isSelected(state)) { @@ -289,6 +292,7 @@ public class SiteForm extends Form { */ private class HostNameValidationListener implements ParameterListener { + @Override public void validate(ParameterEvent e) { ParameterData data = e.getParameterData(); String hostname = (String) data.getValue(); @@ -318,6 +322,7 @@ public class SiteForm extends Form { */ private class SiteInitListener implements FormInitListener { + @Override public void init(FormSectionEvent e) throws FormProcessException { PageState state = e.getPageState(); @@ -337,7 +342,6 @@ public class SiteForm extends Form { m_hostname.setValue(state, site.getHostname()); m_description.setValue(state, site.getDescription()); - // BigDecimal siteDefaultRootPageID BigDecimal currentFrontpageID = site.getFrontPage().getID(); s_log.debug(" Site default frontpage is: " + siteDefaultRootPageID + ", Current frontpage is: " + currentFrontpageID); @@ -380,6 +384,7 @@ public class SiteForm extends Form { */ private class SiteProcessListener implements FormProcessListener { + @Override public void process(FormSectionEvent e) throws FormProcessException { @@ -475,30 +480,28 @@ public class SiteForm extends Form { */ private class FrontpageAppListener implements PrintListener { + @Override public void prepare(PrintEvent e) { final SingleSelect target = (SingleSelect) e.getTarget(); - // final PageState state = e.getPageState(); ApplicationCollection customApps; - // target.addOption(new Option(SELECT_APP, SELECT_APP_LABEL)); target.addOption(new Option(DEFAULT_APP, - (String) SubsiteGlobalizationUtil - .globalize(DEFAULT_APP_LABEL).localize())); + new Label(SubsiteGlobalizationUtil + .globalize(DEFAULT_APP_LABEL)))); String[] customAppTypes = (String[]) Subsite.getConfig() .getFrontPageApplicationTypes(); if (customAppTypes != null) { - for (int i = 0; i < customAppTypes.length; i++) { - customApps = Application.retrieveAllApplications( - customAppTypes[i]); + for (String customAppType : customAppTypes) { + customApps = Application.retrieveAllApplications(customAppType); while (customApps.next()) { /* Create an entry for each application, consisting * of the (BigDecimal) ID as value and the URL as * label. */ String appID = customApps.get(ACSObject.ID).toString(); target.addOption(new Option(appID, - (customApps.getPrimaryURL() - + "(" + appID + ")"))); + (customApps.getPrimaryURL() + + "(" + appID + ")"))); } } @@ -513,14 +516,15 @@ public class SiteForm extends Form { */ private class ThemesListener implements PrintListener { + @Override public void prepare(PrintEvent e) { SingleSelect target = (SingleSelect) e.getTarget(); PageState state = e.getPageState(); Map themes = Subsite.getConfig().getThemes(); Set entrySet = themes.entrySet(); target.addOption(new Option(DEFAULT_STYLE, - (String) SubsiteGlobalizationUtil.globalize( - DEFAULT_STYLE_LABEL).localize())); + new Label(SubsiteGlobalizationUtil.globalize( + DEFAULT_STYLE_LABEL)))); if (entrySet != null) { Iterator entries = entrySet.iterator(); while (entries.hasNext()) { @@ -530,7 +534,9 @@ public class SiteForm extends Form { state); } } - target.addOption(new Option(OTHER_STYLE, OTHER_STYLE_LABEL)); + target.addOption(new Option(OTHER_STYLE, + new Label(SubsiteGlobalizationUtil.globalize( + OTHER_STYLE_LABEL)))); } } diff --git a/ccm-subsite/src/com/arsdigita/subsite/ui/SiteListing.java b/ccm-subsite/src/com/arsdigita/subsite/ui/SiteListing.java index 6e82467fb..773bdfecc 100755 --- a/ccm-subsite/src/com/arsdigita/subsite/ui/SiteListing.java +++ b/ccm-subsite/src/com/arsdigita/subsite/ui/SiteListing.java @@ -35,7 +35,7 @@ import com.arsdigita.xml.Element; */ public class SiteListing extends SimpleComponent { - private SiteSelectionModel m_site; + private final SiteSelectionModel m_site; public SiteListing(SiteSelectionModel site) { m_site = site; diff --git a/ccm-subsite/src/com/arsdigita/subsite/ui/SiteTable.java b/ccm-subsite/src/com/arsdigita/subsite/ui/SiteTable.java index be7d9b444..5b444a63e 100644 --- a/ccm-subsite/src/com/arsdigita/subsite/ui/SiteTable.java +++ b/ccm-subsite/src/com/arsdigita/subsite/ui/SiteTable.java @@ -36,6 +36,7 @@ import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.persistence.OID; import com.arsdigita.persistence.SessionManager; import com.arsdigita.subsite.Site; +import com.arsdigita.subsite.util.SubsiteGlobalizationUtil; import com.arsdigita.util.LockableImpl; /** diff --git a/ccm-subsite/src/com/arsdigita/subsite/ui/SubsiteGlobalizationUtil.java b/ccm-subsite/src/com/arsdigita/subsite/ui/SubsiteGlobalizationUtil.java deleted file mode 100644 index 91bb7a9d8..000000000 --- a/ccm-subsite/src/com/arsdigita/subsite/ui/SubsiteGlobalizationUtil.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.arsdigita.subsite.ui; - -import com.arsdigita.globalization.GlobalizedMessage; - -/** - * - * @author Jens Pelzetter - * @version $Id$ - */ -public class SubsiteGlobalizationUtil { - - public static final String BUNDLE_NAME = "com.arsdigita.subsite.ui.SubsiteResources"; - - public static GlobalizedMessage globalize(final String key) { - return new GlobalizedMessage(key, BUNDLE_NAME); - } - - public static GlobalizedMessage globalize(final String key, - final Object[] args) { - return new GlobalizedMessage(key, BUNDLE_NAME, args); - } - -} diff --git a/ccm-subsite/src/com/arsdigita/subsite/util/SubsiteGlobalizationUtil.java b/ccm-subsite/src/com/arsdigita/subsite/util/SubsiteGlobalizationUtil.java new file mode 100644 index 000000000..9eb68f44b --- /dev/null +++ b/ccm-subsite/src/com/arsdigita/subsite/util/SubsiteGlobalizationUtil.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2013 Jens Pelzetter, Universitaet Bremen. 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.subsite.util; + +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. + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class SubsiteGlobalizationUtil { + + /** Name of Java resource files to handle CMS's globalisation. */ + public static final String BUNDLE_NAME = "com.arsdigita.subsite.SubsiteResources"; + + /** + * Returns a globalized message using the package specific bundle, + * provided by BUNDLE_NAME. + */ + public static GlobalizedMessage globalize(final 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 + * (i.e. parameter as {0}, {1} for handling variable parts). + */ + public static GlobalizedMessage globalize(final String key, + final Object[] args) { + return new GlobalizedMessage(key, BUNDLE_NAME, args); + } + +}