From 7efbf47fb990fc7890b1e2f433e99c585f91fdcd Mon Sep 17 00:00:00 2001 From: jensp Date: Mon, 26 Jun 2017 16:42:34 +0000 Subject: [PATCH] Bugfix for SciProject etc. for a bug when editing the association between a organizational unit and a person git-svn-id: https://svn.libreccm.org/ccm/trunk@4814 8810af33-2d31-482b-a856-94f89814c4df --- ...enericOrganizationalUnitPersonAddForm.java | 101 ++++++++++-------- ...rganizationalUnitPersonPropertiesStep.java | 24 +++-- ...nericOrganizationalUnitPersonSelector.java | 15 +-- ...GenericOrganizationalUnitPersonsTable.java | 6 +- .../ui/SciDepartmentMembersStep.java | 53 +++++---- .../ui/SciInstituteMembersStep.java | 32 ++++-- .../ui/SciProjectMembersStep.java | 74 ++++++++----- 7 files changed, 187 insertions(+), 118 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java index 6faee4292..6259a25e9 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java @@ -83,7 +83,8 @@ public class GenericOrganizationalUnitPersonAddForm // add(new Label(ContenttypesGlobalizationUtil.globalize( // "cms.contenttypes.ui.genericorgaunit.select_person"))); m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. - findByAssociatedObjectType(getPersonType())); + findByAssociatedObjectType( + getPersonType())); /*m_itemSearch.getItemField().addValidationListener( new NotNullValidationListener());*/ m_itemSearch.setLabel(ContenttypesGlobalizationUtil.globalize( @@ -114,9 +115,11 @@ public class GenericOrganizationalUnitPersonAddForm new Label(ContenttypesGlobalizationUtil .globalize("cms.ui.select_one")))); - final RelationAttributeCollection roles = new RelationAttributeCollection( - getRoleAttributeName()); - roles.addLanguageFilter(Kernel.getConfig().getDefaultLanguage()); + final RelationAttributeCollection roles + = new RelationAttributeCollection( + getRoleAttributeName()); + roles.addLanguageFilter(Kernel.getConfig() + .getDefaultLanguage()); while (roles.next()) { RelationAttribute role; role = roles.getRelationAttribute(); @@ -124,15 +127,16 @@ public class GenericOrganizationalUnitPersonAddForm target.addOption(new Option( role.getKey(), new Label(new GlobalizedMessage( - role.getKey(), - getRoleAttributeName(), - new RelationAttributeResourceBundleControl())))); + role.getKey(), + getRoleAttributeName(), + new RelationAttributeResourceBundleControl())))); } } }); } catch (TooManyListenersException ex) { - throw new UncheckedWrapperException("Something has gone terribly wrong...", ex); + throw new UncheckedWrapperException( + "Something has gone terribly wrong...", ex); } add(roleSelect); @@ -151,12 +155,16 @@ public class GenericOrganizationalUnitPersonAddForm target.clearOptions(); target.addOption(new Option("", - new Label(ContenttypesGlobalizationUtil. - globalize("cms.ui.select_one")))); + new Label( + ContenttypesGlobalizationUtil + .globalize( + "cms.ui.select_one")))); - RelationAttributeCollection statusColl = new RelationAttributeCollection( - getStatusAttributeName()); - statusColl.addLanguageFilter(Kernel.getConfig().getDefaultLanguage()); + RelationAttributeCollection statusColl + = new RelationAttributeCollection( + getStatusAttributeName()); + statusColl.addLanguageFilter(Kernel.getConfig() + .getDefaultLanguage()); while (statusColl.next()) { RelationAttribute status; status = statusColl.getRelationAttribute(); @@ -164,32 +172,29 @@ public class GenericOrganizationalUnitPersonAddForm target.addOption(new Option( status.getKey(), new Label(new GlobalizedMessage( - status.getKey(), - getStatusAttributeName(), - new RelationAttributeResourceBundleControl())))); + status.getKey(), + getStatusAttributeName(), + new RelationAttributeResourceBundleControl())))); } } }); } catch (TooManyListenersException ex) { - throw new UncheckedWrapperException("Somethin has gone terribly wrong", ex); + throw new UncheckedWrapperException( + "Somethin has gone terribly wrong", ex); } add(statusSelect); } @Override - public void init(FormSectionEvent fse) throws FormProcessException { - FormData data = fse.getFormData(); - PageState state = fse.getPageState(); + public void init(final FormSectionEvent fse) throws FormProcessException { + final FormData data = fse.getFormData(); + final PageState state = fse.getPageState(); - GenericPerson person; - String role; - String status; - - person = selector.getSelectedPerson(); - role = selector.getSelectedPersonRole(); - status = selector.getSelectedPersonStatus(); + final GenericPerson person = selector.getSelectedPerson(state); + final String role = selector.getSelectedPersonRole(state); + final String status = selector.getSelectedPersonStatus(state); if (person == null) { m_itemSearch.setVisible(state, true); @@ -213,16 +218,18 @@ public class GenericOrganizationalUnitPersonAddForm public void process(FormSectionEvent fse) throws FormProcessException { FormData data = fse.getFormData(); PageState state = fse.getPageState(); - GenericOrganizationalUnit orga = (GenericOrganizationalUnit) getItemSelectionModel(). - getSelectedObject(state); + GenericOrganizationalUnit orga + = (GenericOrganizationalUnit) getItemSelectionModel() + .getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { GenericPerson person; - person = selector.getSelectedPerson(); + person = selector.getSelectedPerson(state); if (person == null) { - GenericPerson personToAdd = (GenericPerson) data.get(ITEM_SEARCH); + GenericPerson personToAdd = (GenericPerson) data + .get(ITEM_SEARCH); logger.debug(String.format("Adding person %s", personToAdd.getFullName())); @@ -248,9 +255,9 @@ public class GenericOrganizationalUnitPersonAddForm persons.setStatus((String) data.get( GenericOrganizationalUnitPersonCollection.STATUS)); - selector.setSelectedPerson(null); - selector.setSelectedPersonRole(null); - selector.setSelectedPersonStatus(null); + selector.setSelectedPerson(state, null); + selector.setSelectedPersonRole(state, null); + selector.setSelectedPersonStatus(state, null); persons.close(); } @@ -259,12 +266,16 @@ public class GenericOrganizationalUnitPersonAddForm init(fse); } + @Override public void submitted(FormSectionEvent fse) throws FormProcessException { - if (this.getSaveCancelSection().getCancelButton().isSelected( - fse.getPageState())) { - selector.setSelectedPerson(null); - selector.setSelectedPersonRole(null); - selector.setSelectedPersonStatus(null); + + final PageState state = fse.getPageState(); + + if (getSaveCancelSection().getCancelButton().isSelected(state)) { + + selector.setSelectedPerson(state, null); + selector.setSelectedPersonRole(state, null); + selector.setSelectedPersonStatus(state, null); init(fse); } @@ -275,7 +286,7 @@ public class GenericOrganizationalUnitPersonAddForm final PageState state = fse.getPageState(); final FormData data = fse.getFormData(); - if ((selector.getSelectedPerson() == null) + if ((selector.getSelectedPerson(state) == null) && (data.get(ITEM_SEARCH) == null)) { data.addError( ContenttypesGlobalizationUtil.globalize( @@ -283,9 +294,10 @@ public class GenericOrganizationalUnitPersonAddForm return; } - if (selector.getSelectedPerson() == null) { - GenericOrganizationalUnit orga = (GenericOrganizationalUnit) getItemSelectionModel(). - getSelectedObject(state); + if (selector.getSelectedPerson(state) == null) { + GenericOrganizationalUnit orga + = (GenericOrganizationalUnit) getItemSelectionModel() + .getSelectedObject(state); GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH); @@ -299,7 +311,8 @@ public class GenericOrganizationalUnitPersonAddForm return; }*/ final ContentBundle bundle = person.getContentBundle(); - final GenericOrganizationalUnitPersonCollection persons = orga.getPersons(); + final GenericOrganizationalUnitPersonCollection persons = orga + .getPersons(); persons.addFilter(String.format("id = %s", bundle.getID().toString())); diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonPropertiesStep.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonPropertiesStep.java index 60c7c67d9..f0823cae9 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonPropertiesStep.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonPropertiesStep.java @@ -37,7 +37,8 @@ public class GenericOrganizationalUnitPersonPropertiesStep implements GenericOrganizationalUnitPersonSelector { public static final String ADD_PERSON_SHEET_NAME = "addPerson"; - private GenericPerson selectedPerson; + public static final String SELECTED_PERSON = "selected-person"; + private final ItemSelectionModel selectedPerson; private String selectedPersonRole; private String selectedPersonStatus; @@ -65,35 +66,40 @@ public class GenericOrganizationalUnitPersonPropertiesStep GenericOrganizationalUnitPersonsTable personsTable = new GenericOrganizationalUnitPersonsTable(itemModel,this); setDisplayComponent(personsTable); + + selectedPerson = new ItemSelectionModel(SELECTED_PERSON); } @Override - public GenericPerson getSelectedPerson() { - return selectedPerson; + public GenericPerson getSelectedPerson(final PageState state) { + return (GenericPerson) selectedPerson.getSelectedItem(state); } @Override - public void setSelectedPerson(GenericPerson selectedPerson) { - this.selectedPerson = selectedPerson; + public void setSelectedPerson(final PageState state, + final GenericPerson selectedPerson) { + this.selectedPerson.setSelectedObject(state, selectedPerson); } @Override - public String getSelectedPersonRole() { + public String getSelectedPersonRole(final PageState state) { return selectedPersonRole; } @Override - public void setSelectedPersonRole(String selectedPersonRole) { + public void setSelectedPersonRole(final PageState state, + final String selectedPersonRole) { this.selectedPersonRole = selectedPersonRole; } @Override - public String getSelectedPersonStatus() { + public String getSelectedPersonStatus(final PageState state) { return selectedPersonStatus; } @Override - public void setSelectedPersonStatus(String selectedPersonStatus) { + public void setSelectedPersonStatus(final PageState state, + final String selectedPersonStatus) { this.selectedPersonStatus = selectedPersonStatus; } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonSelector.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonSelector.java index 42a749a12..c70efd74c 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonSelector.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonSelector.java @@ -27,17 +27,20 @@ import com.arsdigita.cms.contenttypes.GenericPerson; */ public interface GenericOrganizationalUnitPersonSelector { - public GenericPerson getSelectedPerson(); + public GenericPerson getSelectedPerson(PageState state); - public void setSelectedPerson(GenericPerson selectedPerson); + public void setSelectedPerson(PageState state, + GenericPerson selectedPerson); - public String getSelectedPersonRole(); + public String getSelectedPersonRole(PageState state); - public void setSelectedPersonRole(String selectedPersonRole); + public void setSelectedPersonRole(PageState state, + String selectedPersonRole); - public String getSelectedPersonStatus(); + public String getSelectedPersonStatus(PageState state); - public void setSelectedPersonStatus(String selectedPersonStatus); + public void setSelectedPersonStatus(PageState state, + String selectedPersonStatus); public void showEditComponent(PageState state); } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonsTable.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonsTable.java index 4287e0bed..a8cdc9d6a 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonsTable.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonsTable.java @@ -377,9 +377,9 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements } } - personSelector.setSelectedPerson(person); - personSelector.setSelectedPersonRole(persons.getRoleName()); - personSelector.setSelectedPersonStatus(persons.getStatus()); + personSelector.setSelectedPerson(state, person); + personSelector.setSelectedPersonRole(state, persons.getRoleName()); + personSelector.setSelectedPersonStatus(state, persons.getStatus()); persons.close(); diff --git a/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMembersStep.java b/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMembersStep.java index 87fcc98b1..02847afed 100644 --- a/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMembersStep.java +++ b/ccm-sci-types-department/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMembersStep.java @@ -18,6 +18,7 @@ */ package com.arsdigita.cms.contenttypes.ui; +import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.GenericPerson; @@ -28,17 +29,18 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; /** * Authoring step for editing the memberships of the SciDepartment. - * - * @author Jens Pelzetter + * + * @author Jens Pelzetter * @version $Id$ */ public class SciDepartmentMembersStep - extends SimpleEditStep - implements GenericOrganizationalUnitPersonSelector { + extends SimpleEditStep + implements GenericOrganizationalUnitPersonSelector { - private static final String ADD_DEPARTMENT_MEMBER_SHEET_NAME = - "SciDepartmentAddMember"; - private GenericPerson selectedPerson; + private static final String ADD_DEPARTMENT_MEMBER_SHEET_NAME + = "SciDepartmentAddMember"; + private static final String SELECTED_PERSON = "selected-person"; + private final ItemSelectionModel selectedPerson; private String selectedPersonRole; private String selectedPersonStatus; @@ -53,45 +55,58 @@ public class SciDepartmentMembersStep super(itemModel, parent, prefix); final BasicItemForm addMemberSheet = new SciDepartmentMemberAddForm( - itemModel, this); + itemModel, this); add(ADD_DEPARTMENT_MEMBER_SHEET_NAME, - SciDepartmentGlobalizationUtil.globalize("scidepartment.ui.members.add"), + SciDepartmentGlobalizationUtil.globalize( + "scidepartment.ui.members.add"), new WorkflowLockedComponentAccess(addMemberSheet, itemModel), addMemberSheet.getSaveCancelSection().getCancelButton()); - final SciDepartmentMemberTable memberTable = - new SciDepartmentMemberTable( + final SciDepartmentMemberTable memberTable + = new SciDepartmentMemberTable( itemModel, this); setDisplayComponent(memberTable); + + selectedPerson = new ItemSelectionModel(SELECTED_PERSON); } @Override - public GenericPerson getSelectedPerson() { - return selectedPerson; + public void register(final Page page) { + super.register(page); + + page.addGlobalStateParam(selectedPerson.getStateParameter()); } @Override - public void setSelectedPerson(final GenericPerson selectedPerson) { - this.selectedPerson = selectedPerson; + public GenericPerson getSelectedPerson(final PageState state) { + return (GenericPerson) selectedPerson.getSelectedItem(state); } @Override - public String getSelectedPersonRole() { + public void setSelectedPerson(final PageState state, + final GenericPerson selectedPerson) { + this.selectedPerson.setSelectedObject(state, selectedPerson); + } + + @Override + public String getSelectedPersonRole(final PageState state) { return selectedPersonRole; } @Override - public void setSelectedPersonRole(final String selectedPersonRole) { + public void setSelectedPersonRole(final PageState state, + final String selectedPersonRole) { this.selectedPersonRole = selectedPersonRole; } @Override - public String getSelectedPersonStatus() { + public String getSelectedPersonStatus(final PageState state) { return selectedPersonStatus; } @Override - public void setSelectedPersonStatus(final String selectedPersonStatus) { + public void setSelectedPersonStatus(final PageState state, + final String selectedPersonStatus) { this.selectedPersonStatus = selectedPersonStatus; } diff --git a/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteMembersStep.java b/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteMembersStep.java index 6653624cc..7e6e904bb 100644 --- a/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteMembersStep.java +++ b/ccm-sci-types-institute/src/com/arsdigita/cms/contenttypes/ui/SciInstituteMembersStep.java @@ -1,5 +1,6 @@ package com.arsdigita.cms.contenttypes.ui; +import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.GenericPerson; @@ -19,7 +20,8 @@ public class SciInstituteMembersStep implements GenericOrganizationalUnitPersonSelector { private String ADD_INSTITUTE_MEMBER_STEP = "SciInstituteAddMember"; - private GenericPerson selectedPerson; + public static final String SELECTED_PERSON = "selected-person"; + private final ItemSelectionModel selectedPerson; private String selectedPersonRole; private String selectedPersonStatus; @@ -45,35 +47,47 @@ public class SciInstituteMembersStep new SciInstituteMembersTable(itemModel, this); setDisplayComponent(memberTable); + + selectedPerson = new ItemSelectionModel(SELECTED_PERSON); } @Override - public GenericPerson getSelectedPerson() { - return selectedPerson; + public void register(final Page page) { + super.register(page); + + page.addGlobalStateParam(selectedPerson.getStateParameter()); + } + + @Override + public GenericPerson getSelectedPerson(final PageState state) { + return (GenericPerson) selectedPerson.getSelectedItem(state); } @Override - public void setSelectedPerson(final GenericPerson selectedPerson) { - this.selectedPerson = selectedPerson; + public void setSelectedPerson(final PageState state, + final GenericPerson selectedPerson) { + this.selectedPerson.setSelectedObject(state, selectedPerson); } @Override - public String getSelectedPersonRole() { + public String getSelectedPersonRole(final PageState state) { return selectedPersonRole; } @Override - public void setSelectedPersonRole(final String selectedPersonRole) { + public void setSelectedPersonRole(final PageState state, + final String selectedPersonRole) { this.selectedPersonRole = selectedPersonRole; } @Override - public String getSelectedPersonStatus() { + public String getSelectedPersonStatus(final PageState state) { return selectedPersonStatus; } @Override - public void setSelectedPersonStatus(final String selectedPersonStatus) { + public void setSelectedPersonStatus(final PageState state, + final String selectedPersonStatus) { this.selectedPersonStatus = selectedPersonStatus; } diff --git a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectMembersStep.java b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectMembersStep.java index 642e59c50..ddecc148f 100644 --- a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectMembersStep.java +++ b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectMembersStep.java @@ -4,76 +4,93 @@ */ package com.arsdigita.cms.contenttypes.ui; +import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.GenericPerson; 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.item.ContentItemRequestLocal; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; /** * - * @author Jens Pelzetter + * @author Jens Pelzetter */ public class SciProjectMembersStep - extends SimpleEditStep -implements GenericOrganizationalUnitPersonSelector{ - - private static final String ADD_PROJECT_MEMBER_SHEET_NAME = "SciProjectAddMember"; - private GenericPerson selectedPerson; + extends SimpleEditStep + implements GenericOrganizationalUnitPersonSelector { + + private static final String ADD_PROJECT_MEMBER_SHEET_NAME + = "SciProjectAddMember"; + public static final String SELECTED_PERSON = "selected-person"; + private final ItemSelectionModel selectedPerson; +// private GenericPerson selectedPerson; private String selectedPersonRole; private String selectedPersonStatus; - + public SciProjectMembersStep(final ItemSelectionModel itemModel, final AuthoringKitWizard parent) { this(itemModel, parent, null); } - + public SciProjectMembersStep(final ItemSelectionModel itemModel, final AuthoringKitWizard parent, final String prefix) { super(itemModel, parent, prefix); - + final BasicItemForm addMemberSheet = new SciProjectMemberAddForm( - itemModel, this); - add(ADD_PROJECT_MEMBER_SHEET_NAME, + itemModel, this); + add(ADD_PROJECT_MEMBER_SHEET_NAME, SciProjectGlobalizationUtil.globalize("sciproject.ui.members.add"), new WorkflowLockedComponentAccess(addMemberSheet, itemModel), addMemberSheet.getSaveCancelSection().getCancelButton()); - + final SciProjectMemberTable memberTable = new SciProjectMemberTable( - itemModel, this); - setDisplayComponent(memberTable); + itemModel, this); + setDisplayComponent(memberTable); + + selectedPerson = new ItemSelectionModel(SELECTED_PERSON); } - + @Override - public GenericPerson getSelectedPerson() { - return selectedPerson; + public void register(final Page page) { + super.register(page); + + page.addGlobalStateParam(selectedPerson.getStateParameter()); } - + @Override - public void setSelectedPerson(final GenericPerson selectedPerson) { - this.selectedPerson = selectedPerson; + public GenericPerson getSelectedPerson(final PageState state) { + return (GenericPerson) selectedPerson.getSelectedItem(state); } - + @Override - public String getSelectedPersonRole() { + public void setSelectedPerson(final PageState state, + final GenericPerson selectedPerson) { + this.selectedPerson.setSelectedObject(state, selectedPerson); + } + + @Override + public String getSelectedPersonRole(final PageState state) { return selectedPersonRole; } - + @Override - public void setSelectedPersonRole(final String selectedPersonRole) { + public void setSelectedPersonRole(final PageState state, + final String selectedPersonRole) { this.selectedPersonRole = selectedPersonRole; } - + @Override - public String getSelectedPersonStatus() { + public String getSelectedPersonStatus(final PageState state) { return selectedPersonStatus; } - + @Override - public void setSelectedPersonStatus(final String selectedPersonStatus) { + public void setSelectedPersonStatus(final PageState state, + final String selectedPersonStatus) { this.selectedPersonStatus = selectedPersonStatus; } @@ -81,4 +98,5 @@ implements GenericOrganizationalUnitPersonSelector{ public void showEditComponent(final PageState state) { showComponent(state, ADD_PROJECT_MEMBER_SHEET_NAME); } + }