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 new file mode 100644 index 000000000..f3c1dbf53 --- /dev/null +++ b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactAddressPropertiesStep.java @@ -0,0 +1,107 @@ +/* + * BaseContactAddressPropertiesStep.java + * + * Created on 4. Juli 2009, 15:15 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.PageState; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.cms.ui.authoring.BasicPageForm; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; +import com.arsdigita.domain.DomainObject; +import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.Label; +import com.arsdigita.cms.contenttypes.BaseAddress; +import com.arsdigita.cms.contenttypes.BaseContact; +import com.arsdigita.cms.contenttypes.util.BaseAddressGlobalizationUtil; +import com.arsdigita.cms.contenttypes.util.BaseContactGlobalizationUtil; +import com.arsdigita.cms.ui.authoring.SimpleEditStep; + +/** + * + * @author quasi + */ +public class BaseContactAddressPropertiesStep extends SimpleEditStep { + + public static final String ADD_ADDRESS_SHEET_NAME = "addAddress"; + public static final String EDIT_ADDRESS_SHEET_NAME = "editAddress"; + public static final String CHANGE_ADDRESS_SHEET_NAME = "changeAddress"; + public static final String DELETE_ADDRESS_SHEET_NAME = "deleteAddress"; + + + /** Creates a new instance of BaseContactAddressPropertiesStep */ + public BaseContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { + this(itemModel, parent, ""); + } + + public BaseContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) { + super(itemModel, parent, prefix); + +//XXX + if(false/*EMPTY*/) { +// BasicPageForm editAddressSheet = new BaseContactAddAddressPropertyForm(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)); + + } else { + + // editAddress + BasicPageForm editAddressSheet = new BaseContactEditAddressPropertyForm(itemModel, this); + add(EDIT_ADDRESS_SHEET_NAME, "Edit Address", new WorkflowLockedComponentAccess(editAddressSheet, itemModel), editAddressSheet.getSaveCancelSection().getCancelButton()); + + BasicPageForm changeAddressSheet = new BaseContactEditAddressPropertyForm(itemModel, this); + add(CHANGE_ADDRESS_SHEET_NAME, "Change Address", new WorkflowLockedComponentAccess(changeAddressSheet, itemModel), changeAddressSheet.getSaveCancelSection().getCancelButton()); + +// BasicPageForm deleteAddressSheet = new BaseContactDeleteAddressPropertyForm(itemModel, this); +// add(DELETE_ADDRESS_SHEET_NAME, "Delete Address", new WorkflowLockedComponentAccess(deleteAddressSheet, itemModel), DeleteAddressSheet.getSaveCancelSection().getCancelButton()); + + /* Set the displayComponent for this step */ + setDisplayComponent(getBaseAddressPropertySheet(itemModel)); + } + + } + + public static Component getBaseAddressPropertySheet(ItemSelectionModel itemModel) { + + DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); + + sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.address").localize(), "address." + BaseAddress.ADDRESS); + sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.postal_code").localize(), "address." + BaseAddress.POSTAL_CODE); + sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.city").localize(), "address." + BaseAddress.CITY); + sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.state").localize(), "address." + BaseAddress.STATE); + + sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.iso_country_code").localize(), + "address." + BaseAddress.ISO_COUNTRY_CODE, + new DomainObjectPropertySheet.AttributeFormatter() { + public String format(DomainObject item, + String attribute, + PageState state) { + BaseAddress baseAddress = ((BaseContact)item).getAddress(); + if(baseAddress != null && baseAddress.getIsoCountryCode() != null) { + return BaseAddress.getCountryNameFromIsoCode(baseAddress.getIsoCountryCode()); + } else { + return (String)BaseAddressGlobalizationUtil.globalize + ("cms.ui.unknown").localize(); + } + } + } + ); + + return sheet; + + } + + public static Component getEmptyBaseAddressPropertySheet(ItemSelectionModel itemModel) { + return new Label(((String)BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.emptyAddress").localize())); + } + +} 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 new file mode 100644 index 000000000..5997a0880 --- /dev/null +++ b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactEditAddressPropertyForm.java @@ -0,0 +1,182 @@ +/* + * BaseContactEditAddressPropertyForm.java + * + * Created on 8. Juli 2009, 10:27 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +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.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.FormSubmissionListener; +import com.arsdigita.bebop.event.ParameterEvent; +import com.arsdigita.bebop.event.ParameterListener; +import com.arsdigita.bebop.form.Option; +import com.arsdigita.bebop.form.SingleSelect; +import com.arsdigita.bebop.form.TextArea; +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.bebop.parameters.ParameterData; +import com.arsdigita.cms.ItemSelectionModel; +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.util.BaseAddressGlobalizationUtil; + +import org.apache.log4j.Logger; + +/** + * + * @author quasi + */ +public class BaseContactEditAddressPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener { + + private static final Logger logger = Logger.getLogger(BaseContactPropertyForm.class); + + private BaseContactAddressPropertiesStep m_step; + + public static final String ADDRESS = BaseAddress.ADDRESS; + public static final String POSTAL_CODE = BaseAddress.POSTAL_CODE; + public static final String CITY = BaseAddress.CITY; + public static final String STATE = BaseAddress.STATE; + public static final String ISO_COUNTRY_CODE = BaseAddress.ISO_COUNTRY_CODE; + + /** + * ID of the form + */ + public static final String ID = "BaseContactEditAddress"; + + /** + * Constrctor taking an ItemSelectionModel + * + * @param itemModel + */ + public BaseContactEditAddressPropertyForm(ItemSelectionModel itemModel) { + this(itemModel, null); + } + + /** + * Constrctor taking an ItemSelectionModel and an instance of BaseContactPropertiesStep. + * + * @param itemModel + * @param step + */ + public BaseContactEditAddressPropertyForm(ItemSelectionModel itemModel, BaseContactAddressPropertiesStep step) { + super(ID, itemModel); + m_step = step; + addSubmissionListener(this); + } + + @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( ) ); + addressParam.addParameterListener( new StringInRangeValidationListener(0, 1000) ); + TextArea address = new TextArea(addressParam); + address.setRows(5); + address.setCols(30); + add(address); + + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.postal_code").localize())); + ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE); + TextField postalCode = new TextField(postalCodeParam); + /* XXX NumberListener ?*/ + add(postalCode); + + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.city").localize())); + ParameterModel cityParam = new StringParameter(CITY); + TextField city = new TextField(cityParam); + add(city); + + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.state").localize())); + ParameterModel stateParam = new StringParameter(STATE); + TextField state = new TextField(stateParam); + add(state); + + if (!BaseAddress.getConfig().getHideCountryCodeSelection()) { + add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.iso_country_code").localize())); + ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE); + countryParam.addParameterListener(new StringInRangeValidationListener(0, 2)); + + SingleSelect country = new SingleSelect(countryParam); + + country.addOption(new Option("", new Label((String)BaseAddressGlobalizationUtil.globalize("cms.ui.select_one" ).localize()))); + + Iterator countries = BaseAddress.getSortedListOfCountries(null).entrySet().iterator(); + while(countries.hasNext()) { + Map.Entry elem = (Map.Entry)countries.next(); + country.addOption(new Option(elem.getValue().toString(), elem.getKey().toString())); + } + + country.addValidationListener( + new ParameterListener() { + public void validate(ParameterEvent e) throws FormProcessException { + ParameterData data = e.getParameterData(); + String isoCode = (String) data.getValue() ; + if (isoCode == null || isoCode.length() == 0) { + data.addError((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.address.error_iso_country").localize()); + } + } + } + ); + + add(country); + } + + } + + 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()); +// } + } + + 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(); + + BaseAddress baseAddress = (BaseAddress)super.processBasicWidgets(fse); + + if (baseAddress != 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)); + + baseAddress.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/BaseContactEditPersonPropertyForm.java b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactEditPersonPropertyForm.java new file mode 100644 index 000000000..291e01d45 --- /dev/null +++ b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactEditPersonPropertyForm.java @@ -0,0 +1,117 @@ +/* + * BaseContactEditPersonPropertyForm.java + * + * Created on 8. Juli 2009, 10:27 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.cms.ui.authoring.BasicPageForm; +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.cms.ItemSelectionModel; +import com.arsdigita.bebop.FormData; +import com.arsdigita.cms.contenttypes.BaseContact; + +import org.apache.log4j.Logger; + +/** + * + * @author quasi + */ +public class BaseContactEditPersonPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener { + + private static final Logger logger = Logger.getLogger(BaseContactPropertyForm.class); + + private BaseContactPersonPropertiesStep m_step; + +// public static final String +// public static final String +// public static final String + + /** + * ID of the form + */ + public static final String ID = "BaseContactEditPerson"; + + /** + * Constrctor taking an ItemSelectionModel + * + * @param itemModel + */ + public BaseContactEditPersonPropertyForm(ItemSelectionModel itemModel) { + this(itemModel, null); + } + + /** + * Constrctor taking an ItemSelectionModel and an instance of BaseContactPropertiesStep. + * + * @param itemModel + * @param step + */ + public BaseContactEditPersonPropertyForm(ItemSelectionModel itemModel, BaseContactPersonPropertiesStep step) { + super(ID, itemModel); + m_step = step; + addSubmissionListener(this); + } + + @Override + public void addWidgets() { + super.addWidgets(); + +/* + 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(GlobalizationUtil.globalize("cms.contenttypes.genericorganization.ui.organizationnameaddendum"))); + TextField organizationNameAddendum = new TextField(ORGANIZATIONNAMEADDENDUM); + add(organizationNameAddendum); + + add(new Label(GlobalizationUtil.globalize("cms.contenttypes.genericorganzation.ui.description"))); + TextArea description = new TextArea(DESCRIPTION); + description.setRows(5); + description.setCols(30); + add(description); +*/ + } + + @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 submitted(FormSectionEvent e) throws FormProcessException { + if((m_step != null) && (getSaveCancelSection().getCancelButton().isSelected(e.getPageState()))) { + m_step.cancelStreamlinedCreation(e.getPageState()); + } + } +} 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 new file mode 100644 index 000000000..65a47c170 --- /dev/null +++ b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactPersonPropertiesStep.java @@ -0,0 +1,86 @@ +/* + * BaseContactPersonPropertiesStep.java + * + * Created on 4. Juli 2009, 15:12 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.cms.ui.authoring.BasicPageForm; +import com.arsdigita.cms.ui.authoring.SimpleEditStep; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; +import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.Label; +import com.arsdigita.cms.contenttypes.Person; +import com.arsdigita.cms.contenttypes.util.PersonGlobalizationUtil; +import com.arsdigita.cms.contenttypes.util.BaseContactGlobalizationUtil; + +/** + * + * @author quasi + */ +public class BaseContactPersonPropertiesStep extends SimpleEditStep { + + public static final String ADD_PERSON_SHEET_NAME = "addPerson"; + public static final String EDIT_PERSON_SHEET_NAME = "editPerson"; + public static final String CHANGE_PERSON_SHEET_NAME = "changePerson"; + public static final String DELETE_PERSON_SHEET_NAME = "deletePerson"; + + /** + * Creates a new instance of BaseContactPersonPropertiesStep + */ + public BaseContactPersonPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { + this(itemModel, parent, ""); + } + + public BaseContactPersonPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) { + 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()); + + /* Set the displayComponent for this step */ + setDisplayComponent(getEmptyPersonPropertySheet(itemModel)); + + } else { + + BasicPageForm editPersonSheet = new BaseContactEditPersonPropertyForm(itemModel, this); + add(EDIT_PERSON_SHEET_NAME, "Edit Person", new WorkflowLockedComponentAccess(editPersonSheet, itemModel), editPersonSheet.getSaveCancelSection().getCancelButton()); + + BasicPageForm changePersonSheet = new BaseContactEditPersonPropertyForm(itemModel, this); + add(CHANGE_PERSON_SHEET_NAME, "Change Person", new WorkflowLockedComponentAccess(changePersonSheet, itemModel), changePersonSheet.getSaveCancelSection().getCancelButton()); + +// BasicPageForm deletePersonSheet = new BaseContactDeletePersonPropertyForm(itemModel, this); +// add(DELETE_PERSON_SHEET_NAME, "Delete Person", new WorkflowLockedComponentAccess(deletePersonSheet, itemModel), deletePersonSheet.getSaveCancelSection().getCancelButton()); + + /* Set the displayComponent for this step */ + setDisplayComponent(getPersonPropertySheet(itemModel)); + } + + } + + public static Component getPersonPropertySheet(ItemSelectionModel itemModel) { + DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); + + sheet.add((String)PersonGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname").localize(), "person." + Person.SURNAME); + sheet.add((String)PersonGlobalizationUtil.globalize("cms.contenttypes.ui.person.givenname").localize(), "person." + Person.GIVENNAME); + sheet.add((String)PersonGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepre").localize(), "person." + Person.TITLEPRE); + sheet.add((String)PersonGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepost").localize(), "person." + Person.TITLEPOST); + + return sheet; + } + + public static Component getEmptyPersonPropertySheet(ItemSelectionModel itemModel) { + return new Label(((String)BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.emptyPerson").localize())); + } +} diff --git a/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactPropertiesStep.java b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactPropertiesStep.java index 19b11f696..a42de1576 100644 --- a/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactPropertiesStep.java +++ b/ccm-cms-types-baseContact/src/com/arsdigita/cms/contenttypes/ui/BaseContactPropertiesStep.java @@ -14,11 +14,7 @@ import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.SegmentedPanel; -import com.arsdigita.cms.contenttypes.BaseAddress; -import com.arsdigita.cms.contenttypes.BaseContact; import com.arsdigita.cms.contenttypes.Person; -import com.arsdigita.cms.contenttypes.util.BaseAddressGlobalizationUtil; -import com.arsdigita.cms.contenttypes.util.BaseContactGlobalizationUtil; import com.arsdigita.cms.contenttypes.util.PersonGlobalizationUtil; import java.text.DateFormat; @@ -36,10 +32,6 @@ public class BaseContactPropertiesStep extends SimpleEditStep { * It has the same value in almost all PropertiesStep classes) */ public static final String EDIT_BASIC_SHEET_NAME = "editBasic"; - public static final String EDIT_PERSON_SHEET_NAME = "editPerson"; - public static final String EDIT_ADDRESS_SHEET_NAME = "editAddress"; - public static final String CHANGE_PERSON_SHEET_NAME = "changePerson"; - public static final String CHANGE_ADDRESS_SHEET_NAME = "changeAddress"; /** * Constructor for the PropertiesStep. @@ -53,7 +45,7 @@ public class BaseContactPropertiesStep extends SimpleEditStep { /* Use a Segmented Panel for the multiple parts of data */ SegmentedPanel segmentedPanel = new SegmentedPanel(); -// setDefaultEditKey(EDIT_BASIC_SHEET_NAME); + setDefaultEditKey(EDIT_BASIC_SHEET_NAME); /* The different parts of information are displayed in seperated segments each containing a SimpleEditStep */ /* Well, not so simple anymore... */ @@ -66,44 +58,14 @@ public class BaseContactPropertiesStep extends SimpleEditStep { /* Set the displayComponent for this step */ basicProperties.setDisplayComponent(getBaseContactPropertySheet(itemModel)); - /* A new SimpleEditStep */ - SimpleEditStep personProperties = new SimpleEditStep(itemModel, parent, EDIT_PERSON_SHEET_NAME); - /* Create the edit component for this SimpleEditStep and the corresponding link */ -//XXX - BasicPageForm editPersonSheet = new BaseContactPropertyForm(itemModel, this); - personProperties.add(EDIT_PERSON_SHEET_NAME, "Edit Person", new WorkflowLockedComponentAccess(editPersonSheet, itemModel), editPersonSheet.getSaveCancelSection().getCancelButton()); -//XXX - BasicPageForm changePersonSheet = new BaseContactPropertyForm(itemModel, this); - personProperties.add(CHANGE_PERSON_SHEET_NAME, "Change Person", new WorkflowLockedComponentAccess(changePersonSheet, itemModel), changePersonSheet.getSaveCancelSection().getCancelButton()); - /* Set the displayComponent for this step */ - personProperties.setDisplayComponent(getPersonPropertySheet(itemModel)); - - /* A new SimpleEditStep */ - SimpleEditStep addressProperties = new SimpleEditStep(itemModel, parent, EDIT_ADDRESS_SHEET_NAME); - /* Create the edit component for this SimpleEditStep and the corresponding link */ -//XXX - BasicPageForm editAddressSheet = new BaseContactPropertyForm(itemModel, this); - addressProperties.add(EDIT_ADDRESS_SHEET_NAME, "Edit Address", new WorkflowLockedComponentAccess(editAddressSheet, itemModel), editAddressSheet.getSaveCancelSection().getCancelButton()); -//XXX - BasicPageForm changeAddressSheet = new BaseContactPropertyForm(itemModel, this); - addressProperties.add(CHANGE_ADDRESS_SHEET_NAME, "Change Address", new WorkflowLockedComponentAccess(changeAddressSheet, itemModel), changeAddressSheet.getSaveCancelSection().getCancelButton()); - /* Set the displayComponent for this step */ - addressProperties.setDisplayComponent(getBaseAddressPropertySheet(itemModel)); + BaseContactPersonPropertiesStep personProperties = new BaseContactPersonPropertiesStep(itemModel, parent); + BaseContactAddressPropertiesStep addressProperties = new BaseContactAddressPropertiesStep(itemModel, parent); /* Add the SimpleEditStep to the segmented panel */ segmentedPanel.addSegment(new Label("Basic"), basicProperties); segmentedPanel.addSegment(new Label((String)GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.person").localize()), personProperties); segmentedPanel.addSegment(new Label((String)GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.address").localize()), addressProperties); -// segmentedPanel.addSegment(new Label((String)GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.baseContactEntries").localize()), BaseContactEntriesSection); - -// editPersonSheet = new BaseContactEditPersonForm(itemModel, this); -// changePersonSheet = new BaseContactChangePersonForm(itemModel, this); - -// editAddressSheet = new BaseContactEditAddressForm(itemModel, this); -// add(EDIT_ADDRESS_SHEET_NAME, "Edit Address", new WorkflowLockedComponentAccess(editAddressSheet, itemModel), editAddressSheet.getSaveCancelSection().getCancelButton()); -// changeAddressSheet = new BaseContactChangeAddressForm(itemModel, this); -// add(CHANGE_ADDRESS_SHEET_NAME, "Change Address", new WorkflowLockedComponentAccess(changeAddressSheet, itemModel), changeAddressSheet.getSaveCancelSection().getCancelButton()); - +// segmentedPanel.addSegment(new Label((String)GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.baseContactEntries").localize()), BaseContactEntriesSection); /* Sets the composed segmentedPanel as display component */ setDisplayComponent(segmentedPanel); @@ -143,45 +105,4 @@ public class BaseContactPropertiesStep extends SimpleEditStep { return sheet; } - public static Component getPersonPropertySheet(ItemSelectionModel itemModel) { - DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); - - sheet.add((String)PersonGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname").localize(), "person." + Person.SURNAME); - sheet.add((String)PersonGlobalizationUtil.globalize("cms.contenttypes.ui.person.givenname").localize(), "person." + Person.GIVENNAME); - sheet.add((String)PersonGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepre").localize(), "person." + Person.TITLEPRE); - sheet.add((String)PersonGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepost").localize(), "person." + Person.TITLEPOST); - - return sheet; - } - - public static Component getBaseAddressPropertySheet(ItemSelectionModel itemModel) { - - DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); - - sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.address").localize(), "address." + BaseAddress.ADDRESS); - sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.postal_code").localize(), "address." + BaseAddress.POSTAL_CODE); - sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.city").localize(), "address." + BaseAddress.CITY); - sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.state").localize(), "address." + BaseAddress.STATE); - - sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.iso_country_code").localize(), - "address." + BaseAddress.ISO_COUNTRY_CODE, - new DomainObjectPropertySheet.AttributeFormatter() { - public String format(DomainObject item, - String attribute, - PageState state) { - BaseAddress baseAddress = ((BaseContact)item).getAddress(); - if(baseAddress != null && baseAddress.getIsoCountryCode() != null) { - return BaseAddress.getCountryNameFromIsoCode(baseAddress.getIsoCountryCode()); - } else { - return (String)BaseAddressGlobalizationUtil.globalize - ("cms.ui.unknown").localize(); - } - } - } - ); - - return sheet; - - } - }