From c58251ff82c44a5a07f23ee2131c9e590df2b1fe Mon Sep 17 00:00:00 2001 From: pb Date: Thu, 20 Jun 2013 15:14:57 +0000 Subject: [PATCH] Verbesserung der Lokalisierung LDN Contact. Noch nicht fehlerfrei!. git-svn-id: https://svn.libreccm.org/ccm/trunk@2224 8810af33-2d31-482b-a856-94f89814c4df --- .../ui/mparticle/SectionTable.java | 37 +- .../com/arsdigita/cms/CMSResources.properties | 1 - .../arsdigita/cms/CMSResources_de.properties | 1 - .../cms/CMSResources_en_GB.properties | 1 - .../arsdigita/cms/CMSResources_fr.properties | 1 - .../contenttypes/ContactResources.properties | 53 +-- .../ContactResources_de.properties | 31 ++ .../ContactResources_fr.properties | 31 ++ .../ui/ContactAddressProperties.java | 67 ++-- .../ui/ContactAddressPropertyForm.java | 35 +- .../london/contenttypes/ui/ContactCreate.java | 97 ++--- .../contenttypes/ui/ContactCreatePhone.java | 134 ++++--- .../contenttypes/ui/ContactPhonesPanel.java | 43 +- .../contenttypes/ui/ContactPhonesTable.java | 368 +++++++++++------- .../ui/ContactPropertiesStep.java | 105 +++-- .../contenttypes/ui/ContactPropertyForm.java | 29 +- 16 files changed, 598 insertions(+), 436 deletions(-) create mode 100755 ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources_de.properties create mode 100755 ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources_fr.properties diff --git a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionTable.java b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionTable.java index e3002ef8c..86f6c49f3 100755 --- a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionTable.java +++ b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/ui/mparticle/SectionTable.java @@ -38,7 +38,6 @@ import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.contenttypes.ArticleSection; import com.arsdigita.cms.contenttypes.ArticleSectionCollection; import com.arsdigita.cms.contenttypes.MultiPartArticle; -import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.cms.contenttypes.util.MPArticleGlobalizationUtil; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.persistence.OID; @@ -58,8 +57,7 @@ import java.math.BigDecimal; */ public class SectionTable extends Table { - private static final Logger log = - Logger.getLogger(SectionTable.class.getName()); + private static final Logger s_log = Logger.getLogger(SectionTable.class); // match columns by (symbolic) index, makes for easier reordering public static final int COL_INDEX_TITLE = 0; // "Section"; @@ -69,18 +67,18 @@ public class SectionTable extends Table private ItemSelectionModel m_selArticle; private ItemSelectionModel m_selSection; - private ItemSelectionModel m_moveSection; - private static final Logger s_log = Logger.getLogger(SectionTable.class); /** - * Constructor. + * Constructor. Create an instance of this class. * * @param selArticle a selection model that returns the MultiPartArticle - * which holds the sections to display. + * which holds the sections to display. * @param moveSection */ - public SectionTable ( ItemSelectionModel selArticle, ItemSelectionModel moveSection ) { + public SectionTable ( ItemSelectionModel selArticle, + ItemSelectionModel moveSection ) { + super(); m_selArticle = selArticle; m_moveSection = moveSection; @@ -177,12 +175,17 @@ public class SectionTable extends Table * The model builder to generate a suitable model for the SectionTable */ protected class SectionTableModelBuilder extends LockableImpl - implements TableModelBuilder - { + implements TableModelBuilder { + protected ItemSelectionModel m_selArticle; protected ItemSelectionModel m_moveSection; + /** + * Private class constructor. + * @param selArticle + * @param moveSection + */ public SectionTableModelBuilder ( ItemSelectionModel selArticle, ItemSelectionModel moveSection ) { m_selArticle = selArticle; @@ -190,6 +193,12 @@ public class SectionTable extends Table } + /** + * + * @param table + * @param state + * @return + */ public TableModel makeModel ( Table table, PageState state ) { table.getRowSelectionModel().clearSelection(state); @@ -202,9 +211,10 @@ public class SectionTable extends Table } - protected class SectionTableModel - implements TableModel - { + /** + * Internal class + */ + protected class SectionTableModel implements TableModel { private TableColumnModel m_colModel; private SectionTable m_table; @@ -318,7 +328,6 @@ public class SectionTable extends Table Object key, int row, int column ) { Component ret = null; - // SecurityManager sm = Utilities.getSecurityManager(state); SecurityManager sm = CMS.getSecurityManager(state); ContentItem item = (ContentItem)m_selArticle.getSelectedObject(state); diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties index 87cebd1ce..f13783463 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties @@ -981,7 +981,6 @@ cms.contenttypes.ui.person.delete_alias=Remove former name cms.contenttypes.ui.person.alias.none=No former name cms.contenttypes.ui.person.alias=Former name cms.contenttypes.ui.person.alias.select=Select former name -cms.contenttypes.ui.contact.alias.select.add=Select former name cms.contenttypes.person.alias.select.wrong_type=No person selected cms.contenttypes.person.alias.select.same_as_person=Selected person is the same as the current person. Alias and person can't be identical. cms.contenttypes.person.alias.select.no_suitable_language_variant=The selected item has no suitable language variant. diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties index b69b0cfca..39ef4ca5f 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties @@ -972,7 +972,6 @@ cms.contenttypes.ui.person.delete_alias=Fr\u00fcheren Namen entfernen cms.contenttypes.ui.person.alias.none=Kein fr\u00fcherer Name cms.contenttypes.ui.person.alias=Fr\u00fcherer Name cms.contenttypes.ui.person.alias.select=Fr\u00fcheren Namen ausw\u00e4hlen -cms.contenttypes.ui.contact.alias.select.add=Fr\u00fcheren Namen ausw\u00e4hlen cms.contenttypes.person.alias.select.wrong_type=Kein Personendatensatz ausgew\u00e4hlt cms.contenttypes.person.alias.select.same_as_person=Der ausgew\u00e4hlte Datensatz ist der gleiche Datensatz wie der aktuelle Datensatz. Alias und Person k\u00f6nnen nicht identisch sein. cms.contenttypes.person.alias.select.no_suitable_language_variant=Das ausgew\u00e4hlte Item hat keine passende Sprachvariante. 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 faf5afba8..bcc5d6fc3 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties @@ -20,7 +20,6 @@ cms.contenttypes.ui.person.delete_alias=Remove former name cms.contenttypes.ui.person.alias.none=No former name cms.contenttypes.ui.person.alias=Former name cms.contenttypes.ui.person.alias.select=Select former name -cms.contenttypes.ui.contact.alias.select.add=Select former name cms.contenttypes.person.alias.select.wrong_type=No person selected cms.contenttypes.person.alias.select.same_as_person=Selected person is the same as the current person. Alias and person can't be identical. cms.contenttypes.person.alias.select.no_suitable_language_variant=The selected item has no suitable language variant. diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties index b1539d8b9..63edb0d78 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties @@ -501,7 +501,6 @@ cms.contenttypes.ui.person.delete_alias=Remove former name cms.contenttypes.ui.person.alias.none=No former name cms.contenttypes.ui.person.alias=Former name cms.contenttypes.ui.person.alias.select=Select former name -cms.contenttypes.ui.contact.alias.select.add=Select former name cms.contenttypes.person.alias.select.wrong_type=No person selected cms.contenttypes.person.alias.select.same_as_person=Selected person is the same as the current person. Alias and person can't be identical. cms.contenttypes.person.alias.select.no_suitable_language_variant=The selected item has no suitable language variant. diff --git a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources.properties b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources.properties index cf2ca7974..5cfd277fd 100755 --- a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources.properties +++ b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources.properties @@ -1,26 +1,31 @@ -com.arsdigita.london.contenttypes.ui.contact.address_saon=SAON -com.arsdigita.london.contenttypes.ui.contact.address_paon=PAON -com.arsdigita.london.contenttypes.ui.contact.address_streetdesc=Street Description -com.arsdigita.london.contenttypes.ui.contact.address_streetrefno=Street Reference No -com.arsdigita.london.contenttypes.ui.contact.address_locality=Locality -com.arsdigita.london.contenttypes.ui.contact.address_town=Town -com.arsdigita.london.contenttypes.ui.contact.address_administrative_area=Administrative Area -com.arsdigita.london.contenttypes.ui.contact.address_posttown=Postal Town -com.arsdigita.london.contenttypes.ui.contact.address_postcode=Postal Code -com.arsdigita.london.contenttypes.ui.contact.address_proprefno=Property Reference No -com.arsdigita.london.contenttypes.ui.contact_type=Contact Type -com.arsdigita.london.contenttypes.ui.contact_orgname=Organization Name -com.arsdigita.london.contenttypes.ui.contact_deptname=Department Name -com.arsdigita.london.contenttypes.ui.contact_role=Role of Contact -com.arsdigita.london.contenttypes.ui.contact_givenname=Given Name -com.arsdigita.london.contenttypes.ui.contact_familyname=Family Name -com.arsdigita.london.contenttypes.ui.contact_suffix=Suffix -com.arsdigita.london.contenttypes.ui.contact_description=Contact Description -com.arsdigita.london.contenttypes.ui.contact.phone_number=Number -com.arsdigita.london.contenttypes.ui.phone_type=Types -com.arsdigita.london.contenttypes.ui.contact_emails=Emails +london.contenttypes.ui.contact.address.saon=SAON +london.contenttypes.ui.contact.address.paon=PAON +london.contenttypes.ui.contact.address.streetdesc=Street Description +london.contenttypes.ui.contact.address.streetrefno=Street Reference No +london.contenttypes.ui.contact.address.locality=Locality +london.contenttypes.ui.contact.address.town=Town +london.contenttypes.ui.contact.address.administrative_area=Administrative Area +london.contenttypes.ui.contact.address.posttown=Postal Town +london.contenttypes.ui.contact.address.postcode=Postal Code +london.contenttypes.ui.contact.address.proprefno=Property Reference No +london.contenttypes.ui.contact.type=Contact Type +london.contenttypes.ui.contact.orgname=Organization Name +london.contenttypes.ui.contact.deptname=Department Name +london.contenttypes.ui.contact.role=Role of Contact +london.contenttypes.ui.contact.givenname=Given Name +london.contenttypes.ui.contact.familyname=Family Name +london.contenttypes.ui.contact.suffix=Suffix +london.contenttypes.ui.contact.phone_number=Number +london.contenttypes.ui.contact.phone_type=Types +london.contenttypes.ui.contact.emails=Emails com.arsdigita.london.contenttypes.contact_authoring_step_description=Contact com.arsdigita.london.contenttypes.contact_authoring_step_label=Contact -com.arsdigita.london.contenttypes.ui.name=Name -com.arsdigita.london.contenttypes.ui.title=Title -com.arsdigita.london.contenttypes.ui.description=Description +com.arsdigita.london.contenttypes.ui.contact.select_contact=Select Contact +london.contenttypes.ui.contact.add_phone_button=Add Phone +london.contenttypes.ui.contact.phonetable.no_entries_msg=No Phones associated with this Contact +london.contenttypes.ui.contact.phonetable.header_type=Phone Type +london.contenttypes.ui.contact.phonetable.header_num=Phone Number +london.contenttypes.ui.contact.phonetable.header_delete=Delete +london.contenttypes.ui.contact.phonetable.confirm_delete=Delete this Phone? +london.contenttypes.ui.contact.phonetable.link_delete=delete +london.contenttypes.ui.contact.phonetable.delete_confirmation=Delete this Phone? diff --git a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources_de.properties b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources_de.properties new file mode 100755 index 000000000..ff799a317 --- /dev/null +++ b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources_de.properties @@ -0,0 +1,31 @@ +london.contenttypes.ui.contact.address.saon=SAON +london.contenttypes.ui.contact.address.paon=PAON +london.contenttypes.ui.contact.address.streetdesc=Stra\u00dfenname +london.contenttypes.ui.contact.address.streetrefno=Stra\u00dfennummer +london.contenttypes.ui.contact.address.locality=Region +london.contenttypes.ui.contact.address.town=Ort +london.contenttypes.ui.contact.address.administrative_area=Administrative Area +london.contenttypes.ui.contact.address.posttown=Postalischer Ort +london.contenttypes.ui.contact.address.postcode=Postalischer Code +london.contenttypes.ui.contact.address.proprefno=Gebietsreferenz +london.contenttypes.ui.contact.type=Kontakt Typ +london.contenttypes.ui.contact.orgname=Organisation (Name) +london.contenttypes.ui.contact.deptname=Kreis +london.contenttypes.ui.contact.role=Rolle des Kontakts +london.contenttypes.ui.contact.givenname=Vorname +london.contenttypes.ui.contact.familyname=Familienname +london.contenttypes.ui.contact.suffix=Erg\u00e4nzung +london.contenttypes.ui.contact.phone_number=Telefonnummer +london.contenttypes.ui.contact.phone_type=Telefon Typ +london.contenttypes.ui.contact.emails=E-Mail +com.arsdigita.london.contenttypes.contact_authoring_step_description=Kontakteintrag +com.arsdigita.london.contenttypes.contact_authoring_step_label=Kontakt +com.arsdigita.london.contenttypes.ui.contact.select_contact=Einen Kontakt ausw\u00e4hlen +london.contenttypes.ui.contact.add_phone_button=Telefonnummer hinzuf\u00fchren +london.contenttypes.ui.contact.phonetable.no_entries_msg=Es sind keine Telefonnummer mit diesem Kontakt verkn\u00fcpft. +london.contenttypes.ui.contact.phonetable.header_type=Telefon Typ +london.contenttypes.ui.contact.phonetable.header_num=Telefonnummer +london.contenttypes.ui.contact.phonetable.header_delete=L\u00f6schen +london.contenttypes.ui.contact.phonetable.confirm_delete=Delete this Phone? +london.contenttypes.ui.contact.phonetable.link_delete=l\u00f6schen +london.contenttypes.ui.contact.phonetable.delete_confirmation=Diesen Eintrag l\u00f6schen? diff --git a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources_fr.properties b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources_fr.properties new file mode 100755 index 000000000..5cfd277fd --- /dev/null +++ b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ContactResources_fr.properties @@ -0,0 +1,31 @@ +london.contenttypes.ui.contact.address.saon=SAON +london.contenttypes.ui.contact.address.paon=PAON +london.contenttypes.ui.contact.address.streetdesc=Street Description +london.contenttypes.ui.contact.address.streetrefno=Street Reference No +london.contenttypes.ui.contact.address.locality=Locality +london.contenttypes.ui.contact.address.town=Town +london.contenttypes.ui.contact.address.administrative_area=Administrative Area +london.contenttypes.ui.contact.address.posttown=Postal Town +london.contenttypes.ui.contact.address.postcode=Postal Code +london.contenttypes.ui.contact.address.proprefno=Property Reference No +london.contenttypes.ui.contact.type=Contact Type +london.contenttypes.ui.contact.orgname=Organization Name +london.contenttypes.ui.contact.deptname=Department Name +london.contenttypes.ui.contact.role=Role of Contact +london.contenttypes.ui.contact.givenname=Given Name +london.contenttypes.ui.contact.familyname=Family Name +london.contenttypes.ui.contact.suffix=Suffix +london.contenttypes.ui.contact.phone_number=Number +london.contenttypes.ui.contact.phone_type=Types +london.contenttypes.ui.contact.emails=Emails +com.arsdigita.london.contenttypes.contact_authoring_step_description=Contact +com.arsdigita.london.contenttypes.contact_authoring_step_label=Contact +com.arsdigita.london.contenttypes.ui.contact.select_contact=Select Contact +london.contenttypes.ui.contact.add_phone_button=Add Phone +london.contenttypes.ui.contact.phonetable.no_entries_msg=No Phones associated with this Contact +london.contenttypes.ui.contact.phonetable.header_type=Phone Type +london.contenttypes.ui.contact.phonetable.header_num=Phone Number +london.contenttypes.ui.contact.phonetable.header_delete=Delete +london.contenttypes.ui.contact.phonetable.confirm_delete=Delete this Phone? +london.contenttypes.ui.contact.phonetable.link_delete=delete +london.contenttypes.ui.contact.phonetable.delete_confirmation=Delete this Phone? diff --git a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactAddressProperties.java b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactAddressProperties.java index 76c751140..8a9f76cf1 100755 --- a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactAddressProperties.java +++ b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactAddressProperties.java @@ -25,6 +25,7 @@ import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.BasicItemForm; import com.arsdigita.cms.ui.authoring.SimpleEditStep; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; +import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; /** @@ -50,9 +51,9 @@ public class ContactAddressProperties extends SimpleEditStep { form = new ContactAddressPropertyForm(itemModel); add(EDIT_SHEET_NAME, - "Edit", - new WorkflowLockedComponentAccess(form, itemModel), - form.getSaveCancelSection().getCancelButton()); + GlobalizationUtil.globalize("cms.ui.edit"), + new WorkflowLockedComponentAccess(form, itemModel), + form.getSaveCancelSection().getCancelButton()); setDisplayComponent(getAddressPropertySheet(itemModel)); } @@ -69,45 +70,45 @@ public class ContactAddressProperties extends SimpleEditStep { public static Component getAddressPropertySheet(ItemSelectionModel itemModel) { DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact.address_saon"), - "contactAddress.saon"); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.address.saon"), + "contactAddress.saon"); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact.address_paon"), - "contactAddress.paon"); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.address.paon"), + "contactAddress.paon"); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact.address_streetdesc"), - "contactAddress.streetDesc"); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.address.streetdesc"), + "contactAddress.streetDesc"); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact.address_streetrefno"), - "contactAddress.streetRefNo"); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.address.streetrefno"), + "contactAddress.streetRefNo"); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact.address_locality"), - "contactAddress.locality"); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.address.locality"), + "contactAddress.locality"); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact.address_town"), - "contactAddress.town"); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.address.town"), + "contactAddress.town"); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact.address_administrative_area"), - "contactAddress.administrativeArea"); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.address.administrative_area"), + "contactAddress.administrativeArea"); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact.address_posttown"), - "contactAddress.postTown"); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.address.posttown"), + "contactAddress.postTown"); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact.address_postcode"), - "contactAddress.postCode"); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.address.postcode"), + "contactAddress.postCode"); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact.address_proprefno"), - "contactAddress.referenceNo"); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.address.proprefno"), + "contactAddress.referenceNo"); return sheet; } diff --git a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactAddressPropertyForm.java b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactAddressPropertyForm.java index 1a8d4611b..09e931e62 100755 --- a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactAddressPropertyForm.java +++ b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactAddressPropertyForm.java @@ -42,20 +42,21 @@ import com.arsdigita.cms.ui.authoring.BasicItemForm; * */ public class ContactAddressPropertyForm extends BasicItemForm { + + private static final Logger s_log = Logger.getLogger( + ContactAddressPropertyForm.class); /** Name of this form */ private static final String ID = "Contact_address_edit"; - private static final Logger s_log = Logger.getLogger(ContactAddressPropertyForm.class); - /** - * Creates a new form to edit the ContactAddress object - * properties associated with the Contact object specified by - * the item selection model passed in. + * Creates a new form to edit the ContactAddress object properties + * associated with the Contact object specified by the + * item selection model passed in. * * @param itemModel The ItemSelectionModel to use to obtain the Contact - * object to work on - **/ + * object to work on + */ public ContactAddressPropertyForm(ItemSelectionModel itemModel) { super(ID, itemModel); } @@ -81,7 +82,7 @@ public class ContactAddressPropertyForm extends BasicItemForm { protected void addSAON() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact.address_saon"))); + .globalize("london.contenttypes.ui.contact.address.saon"))); ParameterModel saonParam = new StringParameter(ContactAddress.SAON); TextField saon = new TextField(saonParam); add(saon); @@ -89,7 +90,7 @@ public class ContactAddressPropertyForm extends BasicItemForm { protected void addPAON() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact.address_paon"))); + .globalize("london.contenttypes.ui.contact.address.paon"))); ParameterModel paonParam = new StringParameter(ContactAddress.PAON); TextField paon = new TextField(paonParam); paon.addValidationListener(new NotNullValidationListener()); @@ -98,7 +99,7 @@ public class ContactAddressPropertyForm extends BasicItemForm { protected void addStreetDesc() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact.address_streetdesc"))); + .globalize("london.contenttypes.ui.contact.address.streetdesc"))); ParameterModel streetDescParam = new StringParameter(ContactAddress.STREET_DESC); TextField streetDesc = new TextField(streetDescParam); streetDesc.addValidationListener(new NotNullValidationListener()); @@ -107,7 +108,7 @@ public class ContactAddressPropertyForm extends BasicItemForm { protected void addStreetRefNo() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact.address_streetrefno"))); + .globalize("london.contenttypes.ui.contact.address.streetrefno"))); ParameterModel streetRefNoParam = new StringParameter(ContactAddress.STREET_REF_NO); TextField streetRefNo = new TextField(streetRefNoParam); add(streetRefNo); @@ -115,7 +116,7 @@ public class ContactAddressPropertyForm extends BasicItemForm { protected void addLocality() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact.address_locality"))); + .globalize("london.contenttypes.ui.contact.address.locality"))); ParameterModel localityParam = new StringParameter(ContactAddress.LOCALITY); TextField locality = new TextField(localityParam); add(locality); @@ -123,7 +124,7 @@ public class ContactAddressPropertyForm extends BasicItemForm { protected void addTown() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact.address_town"))); + .globalize("london.contenttypes.ui.contact.address.town"))); ParameterModel townParam = new StringParameter(ContactAddress.TOWN); TextField town = new TextField(townParam); add(town); @@ -131,7 +132,7 @@ public class ContactAddressPropertyForm extends BasicItemForm { protected void addArea() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact.address_administrative_area"))); + .globalize("london.contenttypes.ui.contact.address.administrative_area"))); ParameterModel adAreaParam = new StringParameter(ContactAddress.ADMINISTRATIVE_AREA); TextField adArea = new TextField(adAreaParam); add(adArea); @@ -139,7 +140,7 @@ public class ContactAddressPropertyForm extends BasicItemForm { protected void addPostTown() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact.address_posttown"))); + .globalize("london.contenttypes.ui.contact.address.posttown"))); ParameterModel postTownParam = new StringParameter(ContactAddress.POST_TOWN); TextField postTown = new TextField(postTownParam); add(postTown); @@ -147,7 +148,7 @@ public class ContactAddressPropertyForm extends BasicItemForm { protected void addPostCode() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact.address_postcode"))); + .globalize("london.contenttypes.ui.contact.address.postcode"))); ParameterModel postCodeParam = new StringParameter(ContactAddress.POST_CODE); TextField postCode = new TextField(postCodeParam); add(postCode); @@ -155,7 +156,7 @@ public class ContactAddressPropertyForm extends BasicItemForm { protected void addPropRefNo() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact.address_proprefno"))); + .globalize("london.contenttypes.ui.contact.address.proprefno"))); ParameterModel propRefNoParam = new StringParameter(ContactAddress.PROP_REF_NO); TextField propRefNo = new TextField(propRefNoParam); add(propRefNo); diff --git a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactCreate.java b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactCreate.java index 5c6f03891..1a1f56a0a 100755 --- a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactCreate.java +++ b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactCreate.java @@ -35,67 +35,72 @@ import com.arsdigita.cms.ui.authoring.CreationSelector; import com.arsdigita.cms.ui.authoring.PageCreate; /** - * Authoring kit create component to create objects of Contact - * ContentType objects. - * - * @author Shashin Shinde sshinde@redhat.com + * Authoring kit create component to create objects of Contact + * ContentType objects. Replaces the default PageCreate class usually used + * for most content items. * + * @author Shashin Shinde sshinde@redhat.com * @version $Id: ContactCreate.java 287 2005-02-22 00:29:02Z sskracic $ - * */ public class ContactCreate extends PageCreate { - private CreationSelector m_parent; + private CreationSelector m_parent; - public ContactCreate(ItemSelectionModel itemModel, - CreationSelector parent) { + public ContactCreate(ItemSelectionModel itemModel, + CreationSelector parent) { - super(itemModel, parent); - m_parent = parent; - } - - protected void addWidgets () { + super(itemModel, parent); + m_parent = parent; + } - super.addWidgets(); + protected void addWidgets() { - TextField givenName = new TextField(Contact.GIVEN_NAME); - add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact_givenname"))); - givenName.addValidationListener(new NotNullValidationListener()); - add(givenName); + /* Add the standard widgets title, name, and optional launchdate */ + super.addWidgets(); - TextField familyName = new TextField(Contact.FAMILY_NAME); - add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact_familyname"))); - familyName.addValidationListener(new NotNullValidationListener()); - add(familyName); - } + TextField givenName = new TextField(Contact.GIVEN_NAME); + add(new Label(ContactGlobalizationUtil + .globalize("london.contenttypes.ui.contact.givenname"))); + givenName.addValidationListener(new NotNullValidationListener()); + add(givenName); - public void process ( FormSectionEvent e ) throws FormProcessException{ + TextField familyName = new TextField(Contact.FAMILY_NAME); + add(new Label(ContactGlobalizationUtil + .globalize("london.contenttypes.ui.contact.familyname"))); + familyName.addValidationListener(new NotNullValidationListener()); + add(familyName); + } - FormData data = e.getFormData(); - PageState state = e.getPageState(); + /** + * + * @param e + * @throws FormProcessException + */ + @Override + public void process(FormSectionEvent e) throws FormProcessException { - // try to get the contact section from the state parameter - Folder f = m_parent.getFolder(state); - ContentSection sec = m_parent.getContentSection(state); - Contact contact = (Contact) createContentPage(state); - contact.setLanguage((String) data.get(LANGUAGE)); - contact.setName((String)data.get(NAME)); - contact.setTitle((String)data.get(TITLE)); - contact.setGivenName((String)data.get(Contact.GIVEN_NAME)); - contact.setFamilyName((String)data.get(Contact.FAMILY_NAME)); - contact.save(); + FormData data = e.getFormData(); + PageState state = e.getPageState(); - final ContentBundle bundle = new ContentBundle(contact); - bundle.setParent(f); - bundle.setContentSection(m_parent.getContentSection(state)); - bundle.save(); + // try to get the contact section from the state parameter + Folder f = m_parent.getFolder(state); + ContentSection sec = m_parent.getContentSection(state); + Contact contact = (Contact) createContentPage(state); + contact.setLanguage((String) data.get(LANGUAGE)); + contact.setName((String) data.get(NAME)); + contact.setTitle((String) data.get(TITLE)); + contact.setGivenName((String) data.get(Contact.GIVEN_NAME)); + contact.setFamilyName((String) data.get(Contact.FAMILY_NAME)); + contact.save(); - // aplaws default workflow - getWorkflowSection().applyWorkflow(state, contact); + final ContentBundle bundle = new ContentBundle(contact); + bundle.setParent(f); + bundle.setContentSection(m_parent.getContentSection(state)); + bundle.save(); - m_parent.editItem(state, contact); - } + // aplaws default workflow + getWorkflowSection().applyWorkflow(state, contact); + m_parent.editItem(state, contact); + } } diff --git a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactCreatePhone.java b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactCreatePhone.java index 54437b5e5..89a70f8ef 100755 --- a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactCreatePhone.java +++ b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactCreatePhone.java @@ -38,85 +38,83 @@ import java.util.ArrayList; /** * Form to Create objects of type ContactPhone. - * + * * @author Shashin Shinde - * * @version $Id: ContactCreatePhone.java 287 2005-02-22 00:29:02Z sskracic $ - * */ class ContactCreatePhone extends BasicItemForm { - private ItemSelectionModel m_model; + private ItemSelectionModel m_model; - /** - * Creates a new form to create the ContactPhone object - * type associated with the Contact object specified - * by the item selection model passed in. - * - * @param itemModel - * The ItemSelectionModel to use to obtain the Contact object to - * work on - */ - public ContactCreatePhone(ItemSelectionModel itemModel) { - super("Contact_phone_create", itemModel); - m_model = itemModel; - } + /** + * Creates a new form to create the + * ContactPhone object type associated with the + * Contact object specified by the item selection model passed + * in. + * + * @param itemModel The ItemSelectionModel to use to obtain the Contact + * object to work on + */ + public ContactCreatePhone(ItemSelectionModel itemModel) { + super("Contact_phone_create", itemModel); + m_model = itemModel; + } - /** - * Adds widgets to edit the address properties to form. Only paon and - * streetDesc are required, rest are optional. - */ + /** + * Adds widgets to edit the address properties to form. Only paon and + * streetDesc are required, rest are optional. + */ @Override - protected void addWidgets() { + protected void addWidgets() { - add(new Label(ContactGlobalizationUtil.globalize( - "com.arsdigita.london.contenttypes.ui.contact.phone_number"))); - ParameterModel phoneNoParam = new StringParameter(ContactPhone.PHONE_NUMBER); - TextField phoneNo = new TextField(phoneNoParam); - phoneNo.addValidationListener(new NotNullValidationListener()); - add(phoneNo); + add(new Label(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.phone_number"))); + ParameterModel phoneNoParam = new StringParameter(ContactPhone.PHONE_NUMBER); + TextField phoneNo = new TextField(phoneNoParam); + phoneNo.addValidationListener(new NotNullValidationListener()); + add(phoneNo); - add(new Label(ContactGlobalizationUtil.globalize( - "com.arsdigita.london.contenttypes.ui.phone_type"))); - ParameterModel phoneTypeParam = new StringParameter(ContactPhone.PHONE_TYPE); - SingleSelect phoneType = new SingleSelect(phoneTypeParam); - add(phoneType); - // retrieve static Phone types - ArrayList phTypes = ContactInitializer.getPhoneTypes(); - for (int i = 0; i < phTypes.size(); i++) { - phoneType.addOption( - new Option(phTypes.get(i).toString(), phTypes.get(i).toString())); + add(new Label(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.phone_type"))); + ParameterModel phoneTypeParam = new StringParameter(ContactPhone.PHONE_TYPE); + SingleSelect phoneType = new SingleSelect(phoneTypeParam); + add(phoneType); + // retrieve static Phone types + ArrayList phTypes = ContactInitializer.getPhoneTypes(); + for (int i = 0; i < phTypes.size(); i++) { + phoneType.addOption( + new Option(phTypes.get(i).toString(), phTypes.get(i).toString())); + } } - } - /** - */ - public void init(FormSectionEvent e) { - //Do nothing. - } - - /** - * Create an object of type ContactPhone and add it to Contact - * object retrieved from passed in ItemSelectionModel. - */ - public void process(FormSectionEvent fse) { - FormData data = fse.getFormData(); - Contact contact = (Contact) m_model.getSelectedObject(fse.getPageState()); - - // save only if save button was pressed - if (contact != null - && getSaveCancelSection().getSaveButton().isSelected( - fse.getPageState())) { - - ContactPhone cph = new ContactPhone(); - cph.setName("phone-for-contact-" + contact.getID()); - - cph.setPhoneType((String) data.get(ContactPhone.PHONE_TYPE)); - cph.setPhoneNumber((String) data.get(ContactPhone.PHONE_NUMBER)); - cph.save(); - - //Add it to the contact. - contact.addPhone(cph); + /** + */ + public void init(FormSectionEvent e) { + //Do nothing. + } + + /** + * Create an object of type ContactPhone and add it + * to Contact object retrieved from passed in ItemSelectionModel. + */ + public void process(FormSectionEvent fse) { + FormData data = fse.getFormData(); + Contact contact = (Contact) m_model.getSelectedObject(fse.getPageState()); + + // save only if save button was pressed + if (contact != null + && getSaveCancelSection().getSaveButton().isSelected( + fse.getPageState())) { + + ContactPhone cph = new ContactPhone(); + cph.setName("phone-for-contact-" + contact.getID()); + + cph.setPhoneType((String) data.get(ContactPhone.PHONE_TYPE)); + cph.setPhoneNumber((String) data.get(ContactPhone.PHONE_NUMBER)); + cph.save(); + + //Add it to the contact. + contact.addPhone(cph); + } } - } } diff --git a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPhonesPanel.java b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPhonesPanel.java index 99dc12c79..4692b89ba 100755 --- a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPhonesPanel.java +++ b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPhonesPanel.java @@ -23,35 +23,36 @@ import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.BasicItemForm; import com.arsdigita.cms.ui.authoring.SimpleEditStep; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; +import com.arsdigita.london.contenttypes.util.ContactGlobalizationUtil; /** - * A UI step to manipulate Phones for the Contact object - * which is retrieved from the ItemSelectionModel. - * - * @author Shashin Shinde sshinde@redhat.com - * + * A UI step to manipulate Phones for the Contact object which is + * retrieved from the ItemSelectionModel. + * + * @author Shashin Shinde sshinde@redhat.com * @version $Id: ContactPhonesPanel.java 287 2005-02-22 00:29:02Z sskracic $ - * */ public class ContactPhonesPanel extends SimpleEditStep { - /** The name of the editing sheet added to this step */ - private static String EDIT_SHEET_NAME = "manage-phones"; + /** + * The name of the editing sheet added to this step + */ + private static String EDIT_SHEET_NAME = "manage-phones"; - public ContactPhonesPanel(ItemSelectionModel itemModel, AuthoringKitWizard parent) { - super(itemModel, parent); + public ContactPhonesPanel(ItemSelectionModel itemModel, + AuthoringKitWizard parent) { + super(itemModel, parent); - BasicItemForm form = new ContactCreatePhone(itemModel); + BasicItemForm form = new ContactCreatePhone(itemModel); + add(EDIT_SHEET_NAME, + ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.add_phone_button"), + new WorkflowLockedComponentAccess(form, itemModel), + form.getSaveCancelSection().getCancelButton()); - add( - EDIT_SHEET_NAME, - "Add Phone", - new WorkflowLockedComponentAccess(form, itemModel), - form.getSaveCancelSection().getCancelButton()); - - ContactPhonesTable phTable = new ContactPhonesTable(itemModel); - setDisplayComponent(phTable); - - } + ContactPhonesTable phTable = new ContactPhonesTable(itemModel); + setDisplayComponent(phTable); + } } \ No newline at end of file diff --git a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPhonesTable.java b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPhonesTable.java index cd4bd961f..969bc2cd8 100755 --- a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPhonesTable.java +++ b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPhonesTable.java @@ -30,182 +30,268 @@ import com.arsdigita.bebop.table.TableColumn; import com.arsdigita.bebop.table.TableColumnModel; import com.arsdigita.bebop.table.TableModel; import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.cms.CMS; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.SecurityManager; import com.arsdigita.london.contenttypes.Contact; import com.arsdigita.london.contenttypes.ContactPhone; import com.arsdigita.london.contenttypes.ContactPhonesCollection; -import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.london.contenttypes.util.ContactGlobalizationUtil; import com.arsdigita.util.LockableImpl; +import org.apache.log4j.Logger; + import java.math.BigDecimal; /** - * A Table to display the Phones associated with the Contact object. - * Provides links to delete the corresponding phone in each row. - * + * A Table to display the Phones associated with the Contact object. Provides + * links to delete the corresponding phone in each row. + * * @author Shashin Shinde sshinde@redhat.com - * * @version $Id: ContactPhonesTable.java 287 2005-02-22 00:29:02Z sskracic $ - * */ -class ContactPhonesTable extends Table implements TableActionListener{ +class ContactPhonesTable extends Table implements TableActionListener { - private ItemSelectionModel m_contactSel; - - private static final String COL_PHONE_TYPE ="Phone Type"; - private static final String COL_PHONE_NUM="Phone Number"; - private static final String COL_DELETE ="Delete"; - - /** - * Constructor.Create an instance of this class. - * - * @param selContact , ItemSelectionModel which provides the - * Contact object whose Phones are to be manipulated. - */ - public ContactPhonesTable(ItemSelectionModel selContact) { - super(); - m_contactSel = selContact; + private static final Logger log = + Logger.getLogger(ContactPhonesTable.class.getName()); - setEmptyView(new Label("No Phones associated with this Contact")); + // match columns by (symbolic) index, makes for easier reordering + private static final int COL_INDEX_PHONE_TYPE = 0; //"Phone Type"; + private static final int COL_INDEX_PHONE_NUM = 1; //"Phone Number"; + private static final int COL_INDEX_DELETE = 2; //"Delete"; - TableColumnModel model = getColumnModel(); - model.add( new TableColumn( 0, COL_PHONE_TYPE )); - model.add( new TableColumn( 1, COL_PHONE_NUM )); - model.add( new TableColumn( 2, COL_DELETE )); + private ItemSelectionModel m_selContact; - setModelBuilder(new PhonesTableModelBuilder(selContact)); - - model.get(2).setCellRenderer(new DeleteCellRenderer()); - - addTableActionListener(this); + /** + * Constructor. Create an instance of this class. + * + * @param selContact ItemSelectionModel which provides the + * Contact object whose Phones are to be + * manipulated. + */ + public ContactPhonesTable(ItemSelectionModel selContact) { - } + super(); + m_selContact = selContact; - private class PhonesTableModelBuilder extends LockableImpl implements TableModelBuilder { + setEmptyView(new Label(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.phonetable.no_entries_msg"))); - private ItemSelectionModel m_sel; - - private PhonesTableModelBuilder(ItemSelectionModel sel){ - m_sel = sel; - } + TableColumnModel model = getColumnModel(); + model.add(new TableColumn( + COL_INDEX_PHONE_TYPE, + new Label(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.phonetable.header_type") + ) )); + model.add(new TableColumn( + COL_INDEX_PHONE_NUM, + new Label(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.phonetable.header_num") + ) )); + model.add(new TableColumn( + COL_INDEX_DELETE, + new Label(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.phonetable.header_delete") + ) )); - public TableModel makeModel ( Table table, PageState state ) { - table.getRowSelectionModel().clearSelection(state); + model.get(2).setCellRenderer(new DeleteCellRenderer()); - Contact contact = (Contact) m_sel.getSelectedObject(state); + setModelBuilder(new PhonesTableModelBuilder(selContact)); + + addTableActionListener(this); - return new PhonesTableModel(table, state, contact); - } - } - - private class PhonesTableModel implements TableModel{ - - private Table m_table; - private ContactPhonesCollection m_phones; - private ContactPhone m_phone; - - private PhonesTableModel(Table t,PageState ps,Contact c){ - m_table = t; - m_phones = c.getPhones(); - } - - public int getColumnCount() { - return m_table.getColumnModel().size(); } /** - * check collection for the existence of another row.If it has fetch the - * value of Current Phone object into m_phone class variable. + * */ - public boolean nextRow() { - if(m_phones != null && m_phones.next()){ - m_phone = m_phones.getPhone(); - return true; - } else { - return false; - } - } - - /** - * Return the phoneType and phoneNumber attributes for the Type and - * Number columns respectively. - * @see com.arsdigita.bebop.table.TableModel#getElementAt(int) - */ - public Object getElementAt(int columnIndex) { - switch (columnIndex){ - case 0: - return m_phone.getPhoneType(); - case 1: - return m_phone.getPhoneNumber(); - case 2: - return "Delete"; - default: - return null; - } - } + private class PhonesTableModelBuilder extends LockableImpl + implements TableModelBuilder { - /** - * Always return the ID of Phone represented by current row. - * @see com.arsdigita.bebop.table.TableModel#getKeyAt(int) - */ - public Object getKeyAt(int columnIndex) { - return m_phone.getID(); - } + private ItemSelectionModel m_sel; - } - - /** - * Check for the permissions to delete item and put either a Lable or - * a ControlLink accordingly. - */ - private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer{ + /** + * Private class constructor + * @param sel + */ + private PhonesTableModelBuilder(ItemSelectionModel sel) { + m_sel = sel; + } - public Component getComponent(Table table,PageState state,Object value, - boolean isSelected,Object key, - int row,int column) { + /** + * + * @param table + * @param state + * @return + */ + public TableModel makeModel(Table table, PageState state) { + table.getRowSelectionModel().clearSelection(state); - - SecurityManager sm = Utilities.getSecurityManager(state); - Contact item = (Contact) m_contactSel.getSelectedObject(state); - - boolean canDelete = sm.canAccess(state.getRequest(), - SecurityManager.DELETE_ITEM, - item); - if ( canDelete) { - ControlLink link = new ControlLink(value.toString()); - link.setConfirmation("Delete this Phone ?"); - return link; - } else { - return new Label(value.toString()); + Contact contact = (Contact) m_sel.getSelectedObject(state); + + return new PhonesTableModel(table, state, contact); } } -} - /** - * Provide implementation to TableActionListener method. - * Code that comes into picture when a link on the table is clicked. - * Handles delete event. - */ - public void cellSelected(TableActionEvent evt) { - PageState state = evt.getPageState(); + /** + * Internal private class. + */ + private class PhonesTableModel implements TableModel { - TableColumn col = getColumnModel().get(evt.getColumn().intValue()); - String colName = (String) col.getHeaderValue(); - - if ( COL_DELETE.equals(colName) ) { - BigDecimal phoneID = new BigDecimal(evt.getRowKey().toString()); - Contact contact = (Contact) m_contactSel.getSelectedObject(state); - ContactPhone ph = new ContactPhone(phoneID); - contact.removePhone(ph); + private Table m_table; + private ContactPhonesCollection m_phones; + private ContactPhone m_phone; + + /** + * Private class constructor. + * @param t + * @param ps + * @param c + */ + private PhonesTableModel(Table t, PageState ps, Contact c) { + m_table = t; + m_phones = c.getPhones(); + } + + /** Return the number of columsn this TableModel has. */ + public int getColumnCount() { + return m_table.getColumnModel().size(); + } + + /** + * check collection for the existence of another row. If it has fetch + * the value of Current Phone object into m_phone class variable. + */ + public boolean nextRow() { + if (m_phones != null && m_phones.next()) { + m_phone = m_phones.getPhone(); + return true; + } else { + return false; + } + } + + /** + * Return the phoneType and phoneNumber attributes for the Type and + * Number columns respectively. + * + * @see com.arsdigita.bebop.table.TableModel#getElementAt(int) + */ + public Object getElementAt(int columnIndex) { + + switch (columnIndex) { + case 0: + return m_phone.getPhoneType(); + case 1: + return m_phone.getPhoneNumber(); + case 2: + // return "Delete"; + return new Label( + ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.phonetable.link_delete") + ); + default: + return null; + } + } + + /** + * Always return the ID of + * Phone represented by current row. + * + * @see com.arsdigita.bebop.table.TableModel#getKeyAt(int) + */ + public Object getKeyAt(int columnIndex) { + return m_phone.getID(); + } } - } - /** - * provide Implementation to TableActionListener method. - * Does nothing in our case. - */ - public void headSelected(TableActionEvent e) { - throw new UnsupportedOperationException("Not Implemented"); - } + /** + * Private class to check for the permissions to delete item and put either + * a Lable or a ControlLink accordingly. + */ + private class DeleteCellRenderer extends LockableImpl + implements TableCellRenderer { + + /** + * + * @param table + * @param state + * @param value + * @param isSelected + * @param key + * @param row + * @param column + * @return + */ + public Component getComponent(Table table, PageState state, + Object value, boolean isSelected, + Object key, int row, int column) { + + Component ret = null; + SecurityManager sm = CMS.getSecurityManager(state); + Contact item = (Contact) m_selContact.getSelectedObject(state); + + /* Check for permission to delete item */ + boolean canDelete = sm.canAccess(state.getRequest(), + SecurityManager.DELETE_ITEM, + item); + + if ( value instanceof Label ) { // just the delete Controllink + + if (canDelete) { + ret = new ControlLink((Component)value); + // ret.setConfirmation(ContactGlobalizationUtil.globalize( + // "london.contenttypes.ui.contact.phonetable.confirm_delete")); + } else { + ret = (Component)value; + } + + } else if ( value instanceof String ) { // phone type and value + + // if (canDelete) { + // ret = new ControlLink(value.toString()); + // ret = new ControlLink((String)value); + // link.setConfirmation("Delete this Phone ?"); + // return link; + // } else { + ret = new Label((String)value); + // } + + } else { + // return new Label(value.toString()); + /* Just returns the label without underlying link */ + ret = new Label(value.toString()); + } + + return ret; + } + } + + /** + * Provide implementation to TableActionListener method. Code that comes + * into picture when a link on the table is clicked. Handles delete event. + */ + public void cellSelected(TableActionEvent evt) { + PageState state = evt.getPageState(); + + TableColumn col = getColumnModel().get(evt.getColumn().intValue()); + int columnIndex = col.getModelIndex(); + + // if (COL_DELETE.equals(colName)) { + if ( columnIndex == COL_INDEX_DELETE ) { + BigDecimal phoneID = new BigDecimal(evt.getRowKey().toString()); + Contact contact = (Contact) m_selContact.getSelectedObject(state); + ContactPhone ph = new ContactPhone(phoneID); + contact.removePhone(ph); + } + } + + /** + * provide Implementation to TableActionListener method. Does nothing in our + * case. + */ + public void headSelected(TableActionEvent e) { + throw new UnsupportedOperationException("Not Implemented"); + } } diff --git a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPropertiesStep.java b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPropertiesStep.java index f844e2f58..c62b8f12d 100755 --- a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPropertiesStep.java +++ b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPropertiesStep.java @@ -20,14 +20,14 @@ package com.arsdigita.london.contenttypes.ui; import com.arsdigita.bebop.Component; import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.london.contenttypes.Contact; -import com.arsdigita.london.contenttypes.util.ContactGlobalizationUtil; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.SimpleEditStep; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.domain.DomainObject; +import com.arsdigita.london.contenttypes.Contact; +import com.arsdigita.london.contenttypes.util.ContactGlobalizationUtil; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.bebop.PageState; @@ -51,11 +51,10 @@ public class ContactPropertiesStep extends SimpleEditStep { BasicPageForm editSheet; editSheet = new ContactPropertyForm(itemModel); - add( - EDIT_SHEET_NAME, - "Edit", - new WorkflowLockedComponentAccess(editSheet, itemModel), - editSheet.getSaveCancelSection().getCancelButton()); + add(EDIT_SHEET_NAME, + GlobalizationUtil.globalize("cms.ui.edit"), + new WorkflowLockedComponentAccess(editSheet, itemModel), + editSheet.getSaveCancelSection().getCancelButton()); setDisplayComponent(getContactPropertySheet(itemModel)); } @@ -71,62 +70,60 @@ public class ContactPropertiesStep extends SimpleEditStep { public static Component getContactPropertySheet(ItemSelectionModel itemModel) { DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); - sheet.add( - GlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.title"), - Contact.TITLE); + sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"), + Contact.TITLE); - sheet.add( - GlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.name"), - Contact.NAME); + sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"), + Contact.NAME); - sheet.add( - ContactGlobalizationUtil.globalize( - "com.arsdigita.london.contenttypes.ui.contact_givenname"), - Contact.GIVEN_NAME); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.givenname"), + Contact.GIVEN_NAME); - sheet.add( - ContactGlobalizationUtil.globalize( - "com.arsdigita.london.contenttypes.ui.contact_familyname"), - Contact.FAMILY_NAME); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.familyname"), + Contact.FAMILY_NAME); + + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.suffix"), + Contact.SUFFIX); - sheet.add( - ContactGlobalizationUtil.globalize("cms.contenttypes.ui.contact_type"), - Contact.CONTACT_TYPE, - new DomainObjectPropertySheet.AttributeFormatter() { - public String format(DomainObject item,String attribute,PageState state) { - Contact contact = (Contact) item; - if (contact.getContactType() != null) { - return contact.getContactTypeName(); - } else { - return "unknown"; - } - } - }); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.type"), + Contact.CONTACT_TYPE, + new DomainObjectPropertySheet.AttributeFormatter() { + public String format(DomainObject item, + String attribute, + PageState state) { + Contact contact = (Contact) item; + if (contact.getContactType() != null) { + return contact.getContactTypeName(); + } else { + return (String) GlobalizationUtil + .globalize("cms.ui.unknown") + .localize(); + } + } + }); - sheet.add( - GlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.description"), - Contact.DESCRIPTION); + sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.description"), + Contact.DESCRIPTION); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact_emails"), - Contact.EMAILS); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.emails"), + Contact.EMAILS); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact_suffix"), - Contact.SUFFIX); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.orgname"), + Contact.ORG_NAME); - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact_orgname"), - Contact.ORG_NAME); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.deptname"), + Contact.DEPT_NAME); - sheet.add( - ContactGlobalizationUtil.globalize( - "com.arsdigita.london.contenttypes.ui.contact_deptname"), - Contact.DEPT_NAME); - - sheet.add( - ContactGlobalizationUtil.globalize("com.arsdigita.london.contenttypes.ui.contact_role"), - Contact.ROLE); + sheet.add(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.role"), + Contact.ROLE); return sheet; } diff --git a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPropertyForm.java b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPropertyForm.java index a9aaa74d6..c7e560851 100755 --- a/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPropertyForm.java +++ b/ccm-ldn-types-contact/src/com/arsdigita/london/contenttypes/ui/ContactPropertyForm.java @@ -35,6 +35,7 @@ import com.arsdigita.london.contenttypes.ContactType; import com.arsdigita.london.contenttypes.ContactTypesCollection; import com.arsdigita.london.contenttypes.util.ContactGlobalizationUtil; import com.arsdigita.cms.ui.authoring.BasicPageForm; +import com.arsdigita.cms.util.GlobalizationUtil; /** * Form to edit basic properties of Contact object. Used by @@ -81,32 +82,32 @@ public class ContactPropertyForm extends BasicPageForm { } protected void addGivenNameWidget() { - add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact_givenname"))); + add(new Label(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.givenname"))); ParameterModel givenNameParam = new StringParameter(Contact.GIVEN_NAME); TextField givenName = new TextField(givenNameParam); add(givenName); } protected void addFamilyNameWidget() { - add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact_familyname"))); + add(new Label(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.familyname"))); ParameterModel familyNameParam = new StringParameter(Contact.FAMILY_NAME); TextField familyName = new TextField(familyNameParam); add(familyName); } protected void addSuffixWidget() { - add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact_suffix"))); + add(new Label(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.suffix"))); ParameterModel suffixParam = new StringParameter(Contact.SUFFIX); TextField suffix = new TextField(suffixParam); add(suffix); } protected void addContactTypeWidget() { - add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact_type"))); + add(new Label(ContactGlobalizationUtil.globalize( + "london.contenttypes.ui.contact.type"))); ParameterModel contactTypeParam = new StringParameter(Contact.CONTACT_TYPE); SingleSelect contactType = new SingleSelect(contactTypeParam); add(contactType); @@ -118,8 +119,8 @@ public class ContactPropertyForm extends BasicPageForm { } protected void addDescriptionWidget() { - add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact_description"))); + add(new Label(GlobalizationUtil.globalize( + "cms.contenttypes.ui.description"))); ParameterModel descParam = new StringParameter(Contact.DESCRIPTION); TextArea desc = new TextArea(descParam); desc.setRows(5); @@ -128,7 +129,7 @@ public class ContactPropertyForm extends BasicPageForm { protected void addEmailsWidget() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact_emails"))); + .globalize("london.contenttypes.ui.contact.emails"))); ParameterModel emailsParam = new StringParameter(Contact.EMAILS); TextField emails = new TextField(emailsParam); add(emails); @@ -136,7 +137,7 @@ public class ContactPropertyForm extends BasicPageForm { protected void addOrganizationNameWidget() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact_orgname"))); + .globalize("london.contenttypes.ui.contact.orgname"))); ParameterModel orgNameParam = new StringParameter(Contact.ORG_NAME); TextField orgName = new TextField(orgNameParam); add(orgName); @@ -144,7 +145,7 @@ public class ContactPropertyForm extends BasicPageForm { protected void addDepartmentNameWidget() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact_deptname"))); + .globalize("london.contenttypes.ui.contact.deptname"))); ParameterModel deptParam = new StringParameter(Contact.DEPT_NAME); TextField deptName = new TextField(deptParam); add(deptName); @@ -152,7 +153,7 @@ public class ContactPropertyForm extends BasicPageForm { protected void addRoleWidget() { add(new Label(ContactGlobalizationUtil - .globalize("com.arsdigita.london.contenttypes.ui.contact_role"))); + .globalize("london.contenttypes.ui.contact.role"))); ParameterModel roleParam = new StringParameter(Contact.ROLE); TextField role = new TextField(roleParam); add(role);