diff --git a/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactAddressPropertiesStep.java b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactAddressPropertiesStep.java index f3c1dbf53..4e8fb95b9 100644 --- a/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactAddressPropertiesStep.java +++ b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactAddressPropertiesStep.java @@ -43,11 +43,14 @@ public class BaseContactAddressPropertiesStep extends SimpleEditStep { public BaseContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) { super(itemModel, parent, prefix); + +// BaseContact baseContact = (BaseContact)itemModel.getSelectedObject(state); //XXX - if(false/*EMPTY*/) { -// BasicPageForm editAddressSheet = new BaseContactAddAddressPropertyForm(itemModel, this); -// add(ADD_ADDRESS_SHEET_NAME, "Add Address", new WorkflowLockedComponentAccess(addAddressSheet, itemModel), addAddressSheet.getSaveCancelSection().getCancelButton()); + if(/*baseContact.getAddress() == null*/ true) { +// BasicPageForm addAddressSheet = new BaseContactAddAddressPropertyForm(itemModel, this); + BasicPageForm addAddressSheet = new BaseContactEditAddressPropertyForm(itemModel, this); + add(ADD_ADDRESS_SHEET_NAME, "Add Address", new WorkflowLockedComponentAccess(addAddressSheet, itemModel), addAddressSheet.getSaveCancelSection().getCancelButton()); /* Set the displayComponent for this step */ setDisplayComponent(getEmptyBaseAddressPropertySheet(itemModel)); diff --git a/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactEditAddressPropertyForm.java b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactEditAddressPropertyForm.java index 5997a0880..be654e868 100644 --- a/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactEditAddressPropertyForm.java +++ b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactEditAddressPropertyForm.java @@ -12,6 +12,7 @@ package com.arsdigita.cms.contenttypes.ui; import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; @@ -32,6 +33,7 @@ import com.arsdigita.cms.ui.authoring.BasicPageForm; import java.util.Iterator; import java.util.Map; import com.arsdigita.cms.contenttypes.BaseAddress; +import com.arsdigita.cms.contenttypes.BaseContact; import com.arsdigita.cms.contenttypes.util.BaseAddressGlobalizationUtil; import org.apache.log4j.Logger; @@ -80,8 +82,6 @@ public class BaseContactEditAddressPropertyForm extends BasicPageForm implements @Override public void addWidgets() { -// super.addWidgets(); - add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.address").localize())); ParameterModel addressParam = new StringParameter(ADDRESS); addressParam.addParameterListener( new NotNullValidationListener( ) ); @@ -141,15 +141,18 @@ public class BaseContactEditAddressPropertyForm extends BasicPageForm implements public void init(FormSectionEvent fse) { FormData data = fse.getFormData(); -// BaseAddress baseAddress = (BaseAddress)super.initBasicWidgets(fse); - -// data.put(ADDRESS, baseAddress.getAddress()); -// data.put(POSTAL_CODE, baseAddress.getPostalCode()); -// data.put(CITY, baseAddress.getCity()); -// data.put(STATE, baseAddress.getState()); -// if(!BaseAddress.getConfig().getHideCountryCodeSelection()) { -// data.put(ISO_COUNTRY_CODE, baseAddress.getIsoCountryCode()); -// } + PageState state = fse.getPageState(); + BaseContact baseContact = (BaseContact)getItemSelectionModel().getSelectedObject(state); + + if(baseContact.getAddress() != null) { + data.put(ADDRESS, baseContact.getAddress().getAddress()); + data.put(POSTAL_CODE, baseContact.getAddress().getPostalCode()); + data.put(CITY, baseContact.getAddress().getCity()); + data.put(STATE, baseContact.getAddress().getState()); + if(!BaseAddress.getConfig().getHideCountryCodeSelection()) { + data.put(ISO_COUNTRY_CODE, baseContact.getAddress().getIsoCountryCode()); + } + } } public void submitted(FormSectionEvent fse) { @@ -161,18 +164,18 @@ public class BaseContactEditAddressPropertyForm extends BasicPageForm implements public void process(FormSectionEvent fse) { FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + BaseContact baseContact = (BaseContact)getItemSelectionModel().getSelectedObject(state); - BaseAddress baseAddress = (BaseAddress)super.processBasicWidgets(fse); - - if (baseAddress != null && + if (baseContact.getAddress() != null && getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) { - baseAddress.setAddress((String)data.get(ADDRESS)); - baseAddress.setPostalCode((String)data.get(POSTAL_CODE)); - baseAddress.setCity((String)data.get(CITY)); - baseAddress.setState((String)data.get(STATE)); - baseAddress.setIsoCountryCode((String)data.get(ISO_COUNTRY_CODE)); + baseContact.getAddress().setAddress((String)data.get(ADDRESS)); + baseContact.getAddress().setPostalCode((String)data.get(POSTAL_CODE)); + baseContact.getAddress().setCity((String)data.get(CITY)); + baseContact.getAddress().setState((String)data.get(STATE)); + baseContact.getAddress().setIsoCountryCode((String)data.get(ISO_COUNTRY_CODE)); - baseAddress.save(); + baseContact.getAddress().save(); } if (m_step != null) { diff --git a/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactEditPersonPropertyForm.java b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactEditPersonPropertyForm.java index 291e01d45..e5c4b4fde 100644 --- a/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactEditPersonPropertyForm.java +++ b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactEditPersonPropertyForm.java @@ -9,15 +9,23 @@ package com.arsdigita.cms.contenttypes.ui; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.cms.ui.authoring.BasicPageForm; +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSubmissionListener; +import com.arsdigita.bebop.form.TextField; +import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.bebop.parameters.StringInRangeValidationListener; +import com.arsdigita.bebop.parameters.ParameterModel; +import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.bebop.FormData; +import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.contenttypes.BaseContact; +import com.arsdigita.cms.contenttypes.Person; +import com.arsdigita.cms.contenttypes.util.BaseAddressGlobalizationUtil; import org.apache.log4j.Logger; @@ -31,9 +39,10 @@ public class BaseContactEditPersonPropertyForm extends BasicPageForm implements private BaseContactPersonPropertiesStep m_step; -// public static final String -// public static final String -// public static final String + public static final String SURNAME = Person.SURNAME; + public static final String GIVENNAME = Person.GIVENNAME; + public static final String TITLEPRE = Person.TITLEPRE; + public static final String TITLEPOST = Person.TITLEPOST; /** * ID of the form @@ -63,55 +72,70 @@ public class BaseContactEditPersonPropertyForm extends BasicPageForm implements @Override public void addWidgets() { - super.addWidgets(); + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname").localize())); + ParameterModel surnameParam = new StringParameter(SURNAME); + surnameParam.addParameterListener( new NotNullValidationListener( ) ); + surnameParam.addParameterListener( new StringInRangeValidationListener(0, 1000) ); + TextField surname = new TextField(surnameParam); + add(surname); -/* - add(new Label(GlobalizationUtil.globalize("cms.contenttypes.genericorganization.ui.organizationname"))); - ParameterModel organizationNameParam = new StringParameter(ORGANIZATIONAME); - TextField organizationName = new TextField(organizationNameParam); - organizationName.addValidationListener(new NotNullValidationListener()); - add(organizationName); + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.person.givenname").localize())); + ParameterModel givennameParam = new StringParameter(GIVENNAME); + givennameParam.addParameterListener( new NotNullValidationListener( ) ); + givennameParam.addParameterListener( new StringInRangeValidationListener(0, 1000) ); + TextField givenname = new TextField(givennameParam); + add(givenname); - add(new Label(GlobalizationUtil.globalize("cms.contenttypes.genericorganization.ui.organizationnameaddendum"))); - TextField organizationNameAddendum = new TextField(ORGANIZATIONNAMEADDENDUM); - add(organizationNameAddendum); + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepre").localize())); + ParameterModel titlepreParam = new StringParameter(TITLEPRE); + titlepreParam.addParameterListener( new StringInRangeValidationListener(0, 1000) ); + TextField titlepre = new TextField(titlepreParam); + add(titlepre); - add(new Label(GlobalizationUtil.globalize("cms.contenttypes.genericorganzation.ui.description"))); - TextArea description = new TextArea(DESCRIPTION); - description.setRows(5); - description.setCols(30); - add(description); -*/ + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepost").localize())); + ParameterModel titlepostParam = new StringParameter(TITLEPOST); + titlepostParam.addParameterListener( new StringInRangeValidationListener(0, 1000) ); + TextField titlepost = new TextField(titlepostParam); + add(titlepost); } - @Override - public void init(FormSectionEvent e) throws FormProcessException { - FormData data = e.getFormData(); -// BaseContact baseContact = (BaseContact)super.initBasicWidgets(e); - -// data.put(DESCRIPTION, baseContact.getDescription()); - } - - @Override - public void process(FormSectionEvent e) throws FormProcessException { - FormData data = e.getFormData(); - -// BaseContact baseContact = (BaseContact)super.processBasicWidgets(e); - -// if((baseContact != null) && (getSaveCancelSection().getSaveButton().isSelected(e.getPageState()))) { -// baseContact.setDescription((String)data.get(DESCRIPTION)); - -// baseContact.save(); -// } - - if(m_step != null) { - m_step.maybeForwardToNextStep(e.getPageState()); + public void init(FormSectionEvent fse) { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + BaseContact baseContact = (BaseContact)getItemSelectionModel().getSelectedObject(state); + + if(baseContact.getPerson() != null) { + data.put(SURNAME, baseContact.getPerson().getSurname()); + data.put(GIVENNAME, baseContact.getPerson().getGivenName()); + data.put(TITLEPRE, baseContact.getPerson().getTitlePre()); + data.put(TITLEPOST, baseContact.getPerson().getTitlePost()); } } - public void submitted(FormSectionEvent e) throws FormProcessException { - if((m_step != null) && (getSaveCancelSection().getCancelButton().isSelected(e.getPageState()))) { - m_step.cancelStreamlinedCreation(e.getPageState()); - } + public void submitted(FormSectionEvent fse) { + if (m_step != null && + getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) { + m_step.cancelStreamlinedCreation(fse.getPageState()); + } } -} + + public void process(FormSectionEvent fse) { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + BaseContact baseContact = (BaseContact)getItemSelectionModel().getSelectedObject(state); + + if (baseContact.getPerson() != null && + getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) { + baseContact.getPerson().setSurname((String)data.get(SURNAME)); + baseContact.getPerson().setGivenName((String)data.get(GIVENNAME)); + baseContact.getPerson().setTitlePre((String)data.get(TITLEPRE)); + baseContact.getPerson().setTitlePost((String)data.get(TITLEPOST)); + + baseContact.getPerson().save(); + } + + if (m_step != null) { + m_step.maybeForwardToNextStep(fse.getPageState()); + } + } +} \ No newline at end of file diff --git a/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactPersonPropertiesStep.java b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactPersonPropertiesStep.java index 65a47c170..6f258dac9 100644 --- a/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactPersonPropertiesStep.java +++ b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactPersonPropertiesStep.java @@ -43,11 +43,11 @@ public class BaseContactPersonPropertiesStep extends SimpleEditStep { super(itemModel, parent, prefix); //XXX -//Alternativ addPerson if(false/*EMPTY*/) { -// BasicPageForm editPersonSheet = new BaseContactAddPersonPropertyForm(itemModel, this); -// add(EDIT_PERSON_SHEET_NAME, "Edit Person", new WorkflowLockedComponentAccess(editPersonSheet, itemModel), editPersonSheet.getSaveCancelSection().getCancelButton()); + BasicPageForm addPersonSheet = new BaseContactEditPersonPropertyForm(itemModel, this); +// BasicPageForm addPersonSheet = new BaseContactAddPersonPropertyForm(itemModel, this); + add(EDIT_PERSON_SHEET_NAME, "Add Person", new WorkflowLockedComponentAccess(addPersonSheet, itemModel), addPersonSheet.getSaveCancelSection().getCancelButton()); /* Set the displayComponent for this step */ setDisplayComponent(getEmptyPersonPropertySheet(itemModel));