diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties index 36936a40b..68b3063b8 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties @@ -1066,3 +1066,4 @@ cms.ui.workflow.approve_this_content=Approve cms.ui.unknownRole=Unknown role cms.ui.unknownStatus=Unknown status cms.contenttypes.ui.genericorgaunit.persons.status=Status +cms.ui.edit_assoc=Edit association diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties index c51cc3304..9fcc62a1f 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties @@ -1057,3 +1057,4 @@ cms.ui.workflow.approve_this_content=Aktzeptieren cms.ui.unknownRole=Unbekannte Rolle cms.ui.unknownStatus=Unbekannter status cms.contenttypes.ui.genericorgaunit.persons.status=Status +cms.ui.edit_assoc=Verkn\u00fcpfung bearbeiten 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 938a86394..706899595 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties @@ -5,3 +5,4 @@ cms.ui.unknownRole= cms.ui.unknownStatus=Unknown status cms.contenttypes.ui.genericorgaunit.persons.status=Status cms.contenttypes.shared.basic_properties.title= +cms.ui.edit_assoc= diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties index 554286500..6e2d9bed3 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties @@ -536,3 +536,4 @@ cms.contenttypes.ui.address.uri=URL (TRANSLATE THIS cms.contenttypes.ui.address. cms.contenttypes.ui.address.email.desc=Means of contacting someone at this address (TRANSLATE THIS cms.contenttypes.ui.address.email.desc) cms.contenttypes.ui.address.uri.desc=A URL to find more information about this Address (TRANSLATE THIS cms.contenttypes.ui.address.uri.desc) cms.contenttypes.shared.basic_properties.title= +cms.ui.edit_assoc= diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties index 10d492a03..3f277948f 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties @@ -132,3 +132,4 @@ cms.contenttypes.ui.person.contact.del=Delete "cms.contenttypes.ui.genericorgaunit.contacts.none=No contacts associated yet cms.contenttypes.ui.genericorgaunit.contact.up=Up cms.contenttypes.ui.genericorgaunit.contact.down=Down +cms.contenttypes.ui.genericorgaunit.contact.edit=Edit association diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources_de.properties b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources_de.properties index 00e557b92..7948e092e 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources_de.properties +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources_de.properties @@ -143,3 +143,4 @@ cms.contenttypes.ui.person.contact.del=L\u00f6schen "cms.contenttypes.ui.genericorgaunit.contacts.none=Derzeit sind keine Kontakte verkn\u00fcpft cms.contenttypes.ui.genericorgaunit.contact.up=Hoch cms.contenttypes.ui.genericorgaunit.contact.down=Runter +cms.contenttypes.ui.genericorgaunit.contact.edit=Verkn\u00fcpfung bearbeiten diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitContactCollection.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitContactCollection.java index 3cda2d3bd..7100b23dc 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitContactCollection.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitContactCollection.java @@ -21,7 +21,6 @@ package com.arsdigita.cms.contenttypes; import com.arsdigita.domain.DomainCollection; import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; -import java.math.BigDecimal; import org.apache.log4j.Logger; /** @@ -34,30 +33,38 @@ public class GenericOrganizationalUnitContactCollection extends DomainCollection private final static Logger s_log = Logger.getLogger( GenericOrganizationalUnitContactCollection.class); - public static final String CONTACT_ORDER = "link.contact_order"; - public static final String CONTACT_TYPE = "link.contact_type"; + public static final String LINK_CONTACT_ORDER = "link.contact_order"; + public static final String LINK_CONTACT_TYPE = "link.contact_type"; + public static final String CONTACT_ORDER = "contact_order"; + public static final String CONTACT_TYPE = "contact_type"; public GenericOrganizationalUnitContactCollection( DataCollection dataCollection) { super(dataCollection); - m_dataCollection.addOrder(CONTACT_ORDER); + m_dataCollection.addOrder(LINK_CONTACT_ORDER); } // Get the contact type of the link public String getContactType() { - return (String) m_dataCollection.get(CONTACT_TYPE); + return (String) m_dataCollection.get(LINK_CONTACT_TYPE); + } + + public void setContactType(final String contactType) { + DataObject link = (DataObject) this.get("link"); + + link.set(CONTACT_TYPE, contactType); } // Get the contact order of the link public Integer getContactOrder() { - return (Integer) m_dataCollection.get(CONTACT_ORDER); + return (Integer) m_dataCollection.get(LINK_CONTACT_ORDER); } public void setContactOrder(Integer order) { DataObject link = (DataObject) this.get("link"); - link.set(CONTACT_ORDER, order); + link.set(LINK_CONTACT_ORDER, order); } /** diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactAddForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactAddForm.java index 670641fd9..37ebeb20f 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactAddForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactAddForm.java @@ -57,10 +57,14 @@ public class GenericOrganizationalUnitContactAddForm extends BasicItemForm { private SaveCancelSection m_saveCancelSection; private final String ITEM_SEARCH = "personAddress"; private ItemSelectionModel m_itemModel; + private GenericOrganizationalUnitContactPropertiesStep editStep; + private Label selectedContactLabel; - public GenericOrganizationalUnitContactAddForm(ItemSelectionModel itemModel) { + public GenericOrganizationalUnitContactAddForm(ItemSelectionModel itemModel, + GenericOrganizationalUnitContactPropertiesStep editStep) { super("ContactEntryAddForm", itemModel); m_itemModel = itemModel; + this.editStep = editStep; } @Override @@ -71,6 +75,9 @@ public class GenericOrganizationalUnitContactAddForm extends BasicItemForm { findByAssociatedObjectType(GenericContact.class.getName())); add(m_itemSearch); + selectedContactLabel = new Label(""); + add(selectedContactLabel); + add(new Label(ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.genericorgaunit.contact.type"))); ParameterModel contactTypeParam = new StringParameter( @@ -94,9 +101,25 @@ public class GenericOrganizationalUnitContactAddForm extends BasicItemForm { } @Override - public void init(FormSectionEvent fse) throws FormProcessException { + public void init(FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); PageState state = fse.getPageState(); + GenericContact selectedContact = editStep.getSelectedContact(); + String selectedContactType = editStep.getSelectedContactType(); + + if (selectedContact == null) { + selectedContactLabel.setVisible(state, false); + } else { + data.put(ITEM_SEARCH, selectedContact); + data.put(GenericOrganizationalUnitContactCollection.CONTACT_TYPE, + selectedContactType); + + m_itemSearch.setVisible(state, false); + selectedContactLabel.setLabel(selectedContact.getTitle(), state); + selectedContactLabel.setVisible(state, true); + } + setVisible(state, true); } @@ -107,12 +130,36 @@ public class GenericOrganizationalUnitContactAddForm extends BasicItemForm { GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel(). getSelectedObject(state); + + if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - orgaunit.addContact((GenericContact) data.get(ITEM_SEARCH), - (String) data.get( - GenericOrganizationalUnit.CONTACT_TYPE)); + GenericContact selectedContact; + selectedContact = editStep.getSelectedContact(); + + if (selectedContact == null) { + orgaunit.addContact((GenericContact) data.get(ITEM_SEARCH), + (String) data.get( + GenericOrganizationalUnit.CONTACT_TYPE)); + } else { + GenericOrganizationalUnitContactCollection contacts; + + contacts = orgaunit.getContacts(); + + while (contacts.next()) { + if (contacts.getContact().equals(selectedContact)) { + break; + } + } + + contacts.setContactType((String) data.get( + GenericOrganizationalUnitContactCollection.CONTACT_TYPE)); + + editStep.setSelectedContact(null); + editStep.setSelectedContactType(null); + contacts.close(); + } } - //init(fse); + init(fse); } } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactPropertiesStep.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactPropertiesStep.java index 2f6fcd2c5..f8d429253 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactPropertiesStep.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactPropertiesStep.java @@ -20,6 +20,7 @@ package com.arsdigita.cms.contenttypes.ui; import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.GenericContact; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -34,7 +35,9 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; public class GenericOrganizationalUnitContactPropertiesStep extends SimpleEditStep { - private static String ADD_CONTACT_SHEET_NAME = "addContact"; + public static final String ADD_CONTACT_SHEET_NAME = "addContact"; + private GenericContact selectedContact; + private String selectedContactType; public GenericOrganizationalUnitContactPropertiesStep( ItemSelectionModel itemModel, AuthoringKitWizard parent) { @@ -43,12 +46,12 @@ public class GenericOrganizationalUnitContactPropertiesStep public GenericOrganizationalUnitContactPropertiesStep( ItemSelectionModel itemModel, AuthoringKitWizard parent, - String prefix) { + String prefix) { super(itemModel, parent, prefix); - BasicItemForm addContactSheet = - new GenericOrganizationalUnitContactAddForm( - itemModel); + BasicItemForm addContactSheet = + new GenericOrganizationalUnitContactAddForm(itemModel, + this); add(ADD_CONTACT_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.genericorgaunit.add_contact").localize(), @@ -56,7 +59,23 @@ public class GenericOrganizationalUnitContactPropertiesStep addContactSheet.getSaveCancelSection().getCancelButton()); GenericOrganizationalUnitContactTable contactsTable = new GenericOrganizationalUnitContactTable( - itemModel); + itemModel, this); setDisplayComponent(contactsTable); } + + public GenericContact getSelectedContact() { + return selectedContact; + } + + public void setSelectedContact(final GenericContact selectedContact) { + this.selectedContact = selectedContact; + } + + public String getSelectedContactType() { + return selectedContactType; + } + + public void setSelectedContactType(final String selectedContactType) { + this.selectedContactType = selectedContactType; + } } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactTable.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactTable.java index 2e7f17ccf..857ded69e 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactTable.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactTable.java @@ -45,9 +45,14 @@ import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.domain.DataObjectNotFoundException; -import com.arsdigita.cms.util.GlobalizationUtil;; +import com.arsdigita.cms.util.GlobalizationUtil; + +; + import com.arsdigita.util.LockableImpl; + import java.math.BigDecimal; + import org.apache.log4j.Logger; /** @@ -61,15 +66,19 @@ public class GenericOrganizationalUnitContactTable extends Table implements private final static Logger s_log = Logger.getLogger( GenericOrganizationalUnitContactTable.class); private final static String TABLE_COL_EDIT = "table_col_edit"; + private final static String TABLE_COL_EDIT_ASSOC = "table_col_edit_assoc"; private final static String TABLE_COL_DEL = "table_col_del"; private final static String TABLE_COL_UP = "table_col_up"; private final static String TABLE_COL_DOWN = "table_col_down"; private ItemSelectionModel m_itemModel; + private GenericOrganizationalUnitContactPropertiesStep editStep; public GenericOrganizationalUnitContactTable( - final ItemSelectionModel itemModel) { + final ItemSelectionModel itemModel, + final GenericOrganizationalUnitContactPropertiesStep editStep) { super(); this.m_itemModel = itemModel; + this.editStep = editStep; setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.genericorgaunit.contacts.none"))); @@ -87,15 +96,20 @@ public class GenericOrganizationalUnitContactTable extends Table implements tabModel.add(new TableColumn( 2, ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.genericorgaunit.contact.edit").localize(), + TABLE_COL_EDIT_ASSOC)); + tabModel.add(new TableColumn( + 3, + ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.genericorgaunit.contact.action").localize(), TABLE_COL_DEL)); tabModel.add(new TableColumn( - 3, + 4, ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.genericorgaunit.contact.up").localize(), TABLE_COL_UP)); tabModel.add(new TableColumn( - 4, + 5, ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.genericorgaunit.contact.down").localize(), TABLE_COL_DOWN)); @@ -104,9 +118,10 @@ public class GenericOrganizationalUnitContactTable extends Table implements new GenericOrganizationalUnitTableModelBuilder(itemModel)); tabModel.get(1).setCellRenderer(new EditCellRenderer()); - tabModel.get(2).setCellRenderer(new DeleteCellRenderer()); - tabModel.get(3).setCellRenderer(new UpCellRenderer()); - tabModel.get(4).setCellRenderer(new DownCellRenderer()); + tabModel.get(2).setCellRenderer(new EditAssocCellRenderer()); + tabModel.get(3).setCellRenderer(new DeleteCellRenderer()); + tabModel.get(4).setCellRenderer(new UpCellRenderer()); + tabModel.get(5).setCellRenderer(new DownCellRenderer()); addTableActionListener(this); } @@ -179,9 +194,10 @@ public class GenericOrganizationalUnitContactTable extends Table implements getLanguage(); if (m_contacttypes.size() <= 0) { s_log.warn(String.format("No matching relation " - + "attributes for contact type '%s' found. " - + "Using key as fallback.", - m_contactCollection.getContactType())); + + "attributes for contact type '%s' found. " + + "Using key as fallback.", + m_contactCollection. + getContactType())); return m_contactCollection.getContactType(); } if (m_contacttypes.getRelationAttribute(m_contactCollection. @@ -189,9 +205,8 @@ public class GenericOrganizationalUnitContactTable extends Table implements s_log.debug(String.format( "No human readable name " + "found for '%s' for language '%s' Using key.", - m_contactCollection. - getContactType(), - lang)); + m_contactCollection.getContactType(), + lang)); return m_contactCollection.getContactType(); } else { s_log.debug(String.format( @@ -208,6 +223,9 @@ public class GenericOrganizationalUnitContactTable extends Table implements case 1: return m_contact.getTitle(); case 2: + return GlobalizationUtil.globalize("cms.ui.edit_assoc"). + localize(); + case 3: return GlobalizationUtil.globalize("cms.ui.delete").localize(); default: return null; @@ -262,6 +280,36 @@ public class GenericOrganizationalUnitContactTable extends Table implements } } + private class EditAssocCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent( + Table table, + PageState state, + Object value, + boolean isSelected, + Object key, + int row, + int col) { + SecurityManager securityManager = + Utilities.getSecurityManager(state); + GenericOrganizationalUnit orgaunit = + (GenericOrganizationalUnit) m_itemModel. + getSelectedObject(state); + + boolean canEdit = securityManager.canAccess(state.getRequest(), + SecurityManager.EDIT_ITEM, + orgaunit); + if (canEdit) { + ControlLink link = new ControlLink(value.toString()); + return link; + } else { + return new Label(value.toString()); + } + } + } + private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer { @@ -368,6 +416,21 @@ public class GenericOrganizationalUnitContactTable extends Table implements TableColumn column = getColumnModel().get(event.getColumn().intValue()); if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) { + } else if (column.getHeaderKey().toString().equals( + TABLE_COL_EDIT_ASSOC)) { + while (contacts.next()) { + if (contacts.getContact().equals(contact)) { + break; + } + } + + editStep.setSelectedContact(contact); + editStep.setSelectedContactType(contacts.getContactType()); + + contacts.close(); + + editStep.showComponent(state, + GenericOrganizationalUnitContactPropertiesStep.ADD_CONTACT_SHEET_NAME); } else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) { orgaunit.removeContact(contact); } else if (column.getHeaderKey().toString().equals(TABLE_COL_UP)) { diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipAddForm.java index a68425bb5..9299e9180 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipAddForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipAddForm.java @@ -131,7 +131,7 @@ public class SeriesEditshipAddForm extends BasicItemForm { if (!(this.getSaveCancelSection(). getCancelButton().isSelected(state))) { GenericPerson editor; - editor = ((SeriesEditshipStep) editStep).getSelectedEditor(); + editor = editStep.getSelectedEditor(); if (editor == null) { series.addEditor((GenericPerson) data.get(ITEM_SEARCH), @@ -154,6 +154,7 @@ public class SeriesEditshipAddForm extends BasicItemForm { editStep.setSelectedEditor(null); editStep.setSelectedEditorDateFrom(null); editStep.setSelectedEditorDateTo(null); + editors.close(); } } diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipTable.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipTable.java index d20104a60..3164d897f 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipTable.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/SeriesEditshipTable.java @@ -377,6 +377,8 @@ public class SeriesEditshipTable extends Table implements TableActionListener { ((SeriesEditshipStep)editStep).setSelectedEditorDateFrom(editors.getFrom()); ((SeriesEditshipStep)editStep).setSelectedEditorDateTo(editors.getTo()); + editors.close(); + editStep.showComponent(state, SeriesEditshipStep.ADD_EDITOR_SHEET_NAME); } else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) { series.removeEditor(editor);