diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties index 3f277948f..907521385 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources.properties @@ -133,3 +133,4 @@ cms.contenttypes.ui.person.contact.del=Delete cms.contenttypes.ui.genericorgaunit.contact.up=Up cms.contenttypes.ui.genericorgaunit.contact.down=Down cms.contenttypes.ui.genericorgaunit.contact.edit=Edit association +cms.contenttypes.ui.genericorganunit.persons.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 7948e092e..39e43540e 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources_de.properties +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContenttypesResources_de.properties @@ -144,3 +144,4 @@ cms.contenttypes.ui.person.contact.del=L\u00f6schen cms.contenttypes.ui.genericorgaunit.contact.up=Hoch cms.contenttypes.ui.genericorgaunit.contact.down=Runter cms.contenttypes.ui.genericorgaunit.contact.edit=Verkn\u00fcpfung bearbeiten +cms.contenttypes.ui.genericorganunit.persons.edit=Verkn\u00fcpfung bearbeiten diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitPersonCollection.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitPersonCollection.java index db07a5e24..3a3b7f88e 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitPersonCollection.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericOrganizationalUnitPersonCollection.java @@ -21,6 +21,7 @@ package com.arsdigita.cms.contenttypes; import com.arsdigita.domain.DomainCollection; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.persistence.DataCollection; +import com.arsdigita.persistence.DataObject; /** * Collection class for the GenericOrganizationalUnit -> Person relation. @@ -29,8 +30,10 @@ import com.arsdigita.persistence.DataCollection; */ public class GenericOrganizationalUnitPersonCollection extends DomainCollection { - public static final String PERSON_ROLE = "link.role_name"; - public static final String STATUS = "link.status"; + public static final String LINK_PERSON_ROLE = "link.role_name"; + public static final String LINK_STATUS = "link.status"; + public static final String PERSON_ROLE = "role_name"; + public static final String STATUS = "status"; public GenericOrganizationalUnitPersonCollection( DataCollection dataCollection) { @@ -44,11 +47,23 @@ public class GenericOrganizationalUnitPersonCollection extends DomainCollection * @return */ public String getRoleName() { - return (String) m_dataCollection.get(PERSON_ROLE); + return (String) m_dataCollection.get(LINK_PERSON_ROLE); + } + + public void setRoleName(final String roleName) { + DataObject link = (DataObject) this.get("link"); + + link.set(PERSON_ROLE, roleName); } public String getStatus() { - return (String) m_dataCollection.get(STATUS); + return (String) m_dataCollection.get(LINK_STATUS); + } + + public void setStatus(final String status) { + DataObject link = (DataObject) this.get("link"); + + link.set(STATUS, status); } public GenericPerson getPerson() { 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 37ebeb20f..82e7aa342 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactAddForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitContactAddForm.java @@ -25,6 +25,7 @@ import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SaveCancelSection; import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.parameters.NotNullValidationListener; @@ -44,11 +45,13 @@ import com.arsdigita.dispatcher.DispatcherHelper; import org.apache.log4j.Logger; /** - * Form for addings an related contact to an organization. + * Form for adding an related contact to an organization. * * @author Jens Pelzetter */ -public class GenericOrganizationalUnitContactAddForm extends BasicItemForm { +public class GenericOrganizationalUnitContactAddForm + extends BasicItemForm + implements FormSubmissionListener { private final static Logger s_log = Logger.getLogger( GenericOrganizationalUnitContactAddForm.class); @@ -65,6 +68,7 @@ public class GenericOrganizationalUnitContactAddForm extends BasicItemForm { super("ContactEntryAddForm", itemModel); m_itemModel = itemModel; this.editStep = editStep; + addSubmissionListener(this); } @Override @@ -162,4 +166,14 @@ public class GenericOrganizationalUnitContactAddForm extends BasicItemForm { init(fse); } + + public void submitted(FormSectionEvent fse) throws FormProcessException { + if (getSaveCancelSection().getCancelButton().isSelected( + fse.getPageState())) { + editStep.setSelectedContact(null); + editStep.setSelectedContactType(null); + + init(fse); + } + } } 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 8d6b864c6..d4e087c2e 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonAddForm.java @@ -24,9 +24,9 @@ import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.SingleSelect; -import com.arsdigita.bebop.parameters.NotEmptyValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.StringParameter; @@ -48,16 +48,23 @@ import org.apache.log4j.Logger; * * @author Jens Pelzetter */ -public class GenericOrganizationalUnitPersonAddForm extends BasicItemForm { +public class GenericOrganizationalUnitPersonAddForm + extends BasicItemForm + implements FormSubmissionListener { private static final Logger logger = Logger.getLogger( GenericOrganizationalUnitPersonAddForm.class); private GenericOrganizationalUnitPersonPropertiesStep m_step; private ItemSearchWidget m_itemSearch; private final String ITEM_SEARCH = "orgaunitPerson"; + private GenericOrganizationalUnitPersonSelector selector; + private Label selectedPersonNameLabel; - public GenericOrganizationalUnitPersonAddForm(ItemSelectionModel itemModel) { + public GenericOrganizationalUnitPersonAddForm(ItemSelectionModel itemModel, + GenericOrganizationalUnitPersonSelector selector) { super("PersonAddForm", itemModel); + this.selector = selector; + addSubmissionListener(this); } @Override @@ -70,6 +77,9 @@ public class GenericOrganizationalUnitPersonAddForm extends BasicItemForm { new NotNullValidationListener()); add(this.m_itemSearch); + selectedPersonNameLabel = new Label(""); + add(selectedPersonNameLabel); + add(new Label(ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.genericorgaunit.person.role"))); ParameterModel roleParam = @@ -117,8 +127,32 @@ public class GenericOrganizationalUnitPersonAddForm extends BasicItemForm { @Override public void init(FormSectionEvent fse) { + FormData data = fse.getFormData(); PageState state = fse.getPageState(); + GenericPerson person; + String role; + String status; + + person = selector.getSelectedPerson(); + role = selector.getSelectedPersonRole(); + status = selector.getSelectedPersonStatus(); + + if (person == null) { + //m_itemSearch.setVisible(state, true); + //selectedPersonNameLabel.setVisible(state, false); + } else { + data.put(ITEM_SEARCH, person); + data.put(GenericOrganizationalUnitPersonCollection.PERSON_ROLE, + role); + data.put(GenericOrganizationalUnitPersonCollection.STATUS, + status); + + //m_itemSearch.setVisible(state, false); + //selectedPersonNameLabel.setVisible(state, true); + //selectedPersonNameLabel.setLabel(person.getFullName(), state); + } + setVisible(state, true); } @@ -130,23 +164,58 @@ public class GenericOrganizationalUnitPersonAddForm extends BasicItemForm { getSelectedObject(state); if (this.getSaveCancelSection().getSaveButton().isSelected(state)) { - if (data.get(ITEM_SEARCH) == null) { - logger.warn("Person to add is null!!!"); - } else { + + GenericPerson person; + person = selector.getSelectedPerson(); + + if (person == null) { logger.debug(String.format("Adding person %s", ((GenericPerson) data.get(ITEM_SEARCH)). getFullName())); + + orga.addPerson((GenericPerson) data.get(ITEM_SEARCH), + (String) data.get( + GenericOrganizationalUnitPersonCollection.PERSON_ROLE), + (String) data.get( + GenericOrganizationalUnitPersonCollection.STATUS)); + } else { + GenericOrganizationalUnitPersonCollection persons; + + persons = orga.getPersons(); + + while (persons.next()) { + if (persons.getPerson().equals(person)) { + break; + } + } + + persons.setRoleName((String) data.get( + GenericOrganizationalUnitPersonCollection.PERSON_ROLE)); + persons.setStatus((String) data.get( + GenericOrganizationalUnitPersonCollection.STATUS)); + + selector.setSelectedPerson(null); + selector.setSelectedPersonRole(null); + selector.setSelectedPersonRole(null); + + persons.close(); } - orga.addPerson((GenericPerson) data.get(ITEM_SEARCH), - (String) data.get( - GenericOrganizationalUnitPersonCollection.PERSON_ROLE), - (String) data.get( - GenericOrganizationalUnitPersonCollection.STATUS)); } init(fse); } + public void submitted(FormSectionEvent fse) throws FormProcessException { + if (getSaveCancelSection().getCancelButton().isSelected( + fse.getPageState())) { + selector.setSelectedPerson(null); + selector.setSelectedPersonRole(null); + selector.setSelectedPersonRole(null); + + init(fse); + } + } + protected String getPersonType() { return GenericPerson.class.getName(); } 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 fb72f6e0d..b2e735ee5 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonPropertiesStep.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonPropertiesStep.java @@ -19,7 +19,9 @@ */ package com.arsdigita.cms.contenttypes.ui; +import com.arsdigita.bebop.PageState; import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.GenericPerson; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -32,9 +34,13 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; * @author Jens Pelzetter */ public class GenericOrganizationalUnitPersonPropertiesStep - extends SimpleEditStep { + extends SimpleEditStep + implements GenericOrganizationalUnitPersonSelector { - private static final String ADD_PERSON_SHEET_NAME = "addPerson"; + public static final String ADD_PERSON_SHEET_NAME = "addPerson"; + private GenericPerson selectedPerson; + private String selectedPersonRole; + private String selectedPersonStatus; public GenericOrganizationalUnitPersonPropertiesStep( ItemSelectionModel itemModel, @@ -46,10 +52,11 @@ public class GenericOrganizationalUnitPersonPropertiesStep ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) { - super(itemModel, parent, prefix); - + super(itemModel, parent, prefix); + BasicItemForm addPersonSheet = - new GenericOrganizationalUnitPersonAddForm(itemModel); + new GenericOrganizationalUnitPersonAddForm(itemModel, + this); add(ADD_PERSON_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.genericorgaunit.add_person").localize(), @@ -57,7 +64,43 @@ public class GenericOrganizationalUnitPersonPropertiesStep addPersonSheet.getSaveCancelSection().getCancelButton()); GenericOrganizationalUnitPersonsTable personsTable = new GenericOrganizationalUnitPersonsTable( - itemModel); + itemModel, + this); setDisplayComponent(personsTable); } + + @Override + public GenericPerson getSelectedPerson() { + return selectedPerson; + } + + @Override + public void setSelectedPerson(GenericPerson selectedPerson) { + this.selectedPerson = selectedPerson; + } + + @Override + public String getSelectedPersonRole() { + return selectedPersonRole; + } + + @Override + public void setSelectedPersonRole(String selectedPersonRole) { + this.selectedPersonRole = selectedPersonRole; + } + + @Override + public String getSelectedPersonStatus() { + return selectedPersonStatus; + } + + @Override + public void setSelectedPersonStatus(String selectedPersonStatus) { + this.selectedPersonStatus = selectedPersonStatus; + } + + @Override + public void showEditComponent(final PageState state) { + showComponent(state, ADD_PERSON_SHEET_NAME); + } } diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonSelector.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonSelector.java new file mode 100644 index 000000000..c94ef9d49 --- /dev/null +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonSelector.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2011 Jens Pelzetter, + * for the Center of Social Politics of the University of Bremen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.PageState; +import com.arsdigita.cms.contenttypes.GenericPerson; + +/** + * + * @author Jens Pelzetter + */ +public interface GenericOrganizationalUnitPersonSelector { + + public GenericPerson getSelectedPerson(); + + public void setSelectedPerson(GenericPerson selectedPerson); + + public String getSelectedPersonRole(); + + public void setSelectedPersonRole(String selectedPersonRole); + + public String getSelectedPersonStatus(); + + public void setSelectedPersonStatus(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 ad6bf348a..e07d3cecb 100644 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonsTable.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/GenericOrganizationalUnitPersonsTable.java @@ -42,6 +42,7 @@ import com.arsdigita.cms.contenttypes.GenericPerson; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.cms.SecurityManager; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.util.LockableImpl; import java.math.BigDecimal; @@ -61,11 +62,14 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements private final String TABLE_COL_EDIT_LINK = "table_col_edit_link"; private final String TABLE_COL_DEL = "table_col_del"; private ItemSelectionModel m_itemModel; + private GenericOrganizationalUnitPersonSelector personSelector; public GenericOrganizationalUnitPersonsTable( - final ItemSelectionModel itemModel) { + final ItemSelectionModel itemModel, + final GenericOrganizationalUnitPersonSelector personSelector) { super(); m_itemModel = itemModel; + this.personSelector = personSelector; setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.genericorgaunit.persons.none"))); @@ -74,7 +78,8 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements tabModel.add(new TableColumn( 0, ContenttypesGlobalizationUtil.globalize( - "cms.contenttypes.ui.genericorgaunit.persons.name").localize())); + "cms.contenttypes.ui.genericorgaunit.persons.name").localize(), + TABLE_COL_EDIT)); tabModel.add(new TableColumn( 1, ContenttypesGlobalizationUtil.globalize( @@ -83,19 +88,26 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements new TableColumn( 2, ContenttypesGlobalizationUtil.globalize( - "cms.contenttypes.ui.genericorgaunit.persons.status").localize())); + "cms.contenttypes.ui.genericorgaunit.persons.status").localize())); tabModel.add( new TableColumn( 3, ContenttypesGlobalizationUtil.globalize( + "cms.contenttypes.ui.genericorganunit.persons.edit").localize(), + TABLE_COL_EDIT_LINK)); + tabModel.add( + new TableColumn( + 4, + ContenttypesGlobalizationUtil.globalize( "cms.contenttypes.ui.genericorgaunit.persons.delete").localize(), TABLE_COL_DEL)); setModelBuilder( new GenericOrganizationalUnitTableModelBuilder(itemModel)); - tabModel.get(0).setCellRenderer(new EditCellRenderer()); - tabModel.get(3).setCellRenderer(new DeleteCellRenderer()); + tabModel.get(0).setCellRenderer(new EditCellRenderer()); + tabModel.get(3).setCellRenderer(new EditLinkCellRenderer()); + tabModel.get(4).setCellRenderer(new DeleteCellRenderer()); addTableActionListener(this); } @@ -165,7 +177,10 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements getRoleAttributeName(), m_personsCollection.getRoleName()); if (role.next()) { - return role.getName(); + String roleName; + roleName = role.getName(); + role.close(); + return roleName; } else { return ContenttypesGlobalizationUtil.globalize( "cms.ui.unknownRole").localize(); @@ -175,12 +190,18 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements getStatusAttributeName(), m_personsCollection.getStatus()); if (status.next()) { - return status.getName(); + String statusName; + statusName = status.getName(); + status.close(); + return statusName; } else { return ContenttypesGlobalizationUtil.globalize( "cms.ui.unknownStatus").localize(); - } + } case 3: + return ContenttypesGlobalizationUtil.globalize( + "cms.ui.edit_assoc").localize(); + case 4: return ContenttypesGlobalizationUtil.globalize( "cms.ui.delete").localize(); default: @@ -238,7 +259,37 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements } } } - + + private class EditLinkCellRenderer + extends LockableImpl + implements TableCellRenderer { + + public Component getComponent(Table table, + PageState state, + Object value, + boolean isSelected, + Object key, + int row, + int column) { + 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 { + Label label = new Label(value.toString()); + return label; + } + } + } + private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer { @@ -250,14 +301,14 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements Object key, int row, int col) { - com.arsdigita.cms.SecurityManager securityManager = Utilities. - getSecurityManager(state); + SecurityManager securityManager = + Utilities.getSecurityManager(state); GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) m_itemModel. getSelectedObject( state); boolean canEdit = securityManager.canAccess(state.getRequest(), - com.arsdigita.cms.SecurityManager.DELETE_ITEM, + SecurityManager.DELETE_ITEM, orgaunit); if (canEdit) { ControlLink link = new ControlLink(value.toString()); @@ -286,10 +337,27 @@ public class GenericOrganizationalUnitPersonsTable extends Table implements GenericOrganizationalUnit orga = (GenericOrganizationalUnit) m_itemModel. getSelectedObject(state); + GenericOrganizationalUnitPersonCollection persons = orga.getPersons(); + TableColumn col = getColumnModel().get(event.getColumn().intValue()); - if (col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) { - } else if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) { + if (TABLE_COL_EDIT.equals(col.getHeaderKey().toString())) { + } else if (TABLE_COL_EDIT_LINK.equals(col.getHeaderKey().toString())) { + while (persons.next()) { + if (persons.getPerson().equals(person)) { + break; + } + } + + personSelector.setSelectedPerson(person); + personSelector.setSelectedPersonRole(persons.getRoleName()); + personSelector.setSelectedPersonStatus(persons.getStatus()); + + persons.close(); + + personSelector.showEditComponent(state); + + } else if (TABLE_COL_DEL.equals(col.getHeaderKey().toString())) { s_log.debug("Removing person assoc..."); orga.removePerson(person); } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java index eea93f821..418b5c33a 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java @@ -26,6 +26,7 @@ import com.arsdigita.bebop.FormSection; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SaveCancelSection; +import com.arsdigita.bebop.event.FormCancelListener; import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; @@ -55,8 +56,10 @@ import java.util.Collection; * @author Stanislav Freidin (stas@arsdigita.com) * @version $Revision: #13 $ $DateTime: 2004/08/17 23:15:09 $ **/ -public abstract class BasicItemForm extends FormSection - implements FormInitListener, FormProcessListener, +public abstract class BasicItemForm + extends FormSection + implements FormInitListener, + FormProcessListener, FormValidationListener { private static final Logger s_log = Logger.getLogger(BasicItemForm.class); @@ -201,23 +204,28 @@ public abstract class BasicItemForm extends FormSection * Perform form initialization. Children should override this * this method to pre-fill the widgets with data, instantiate * the content item, etc. + * @param e + * @throws FormProcessException */ public abstract void init(FormSectionEvent e) throws FormProcessException; /** * Process the form. Children should override this method to save * the user's changes to the database. + * @param e + * @throws FormProcessException */ public abstract void process(FormSectionEvent e) throws FormProcessException; /** * Validate the form. Children should override this method to provide * custom form validation. + * @param e */ public void validate(FormSectionEvent e) throws FormProcessException { // do nothing } - + /** * Ensure that the name of an item is unique within a folder. A "New * item" form should call this method in the validation listener. diff --git a/ccm-core/src/com/arsdigita/bebop/FormSection.java b/ccm-core/src/com/arsdigita/bebop/FormSection.java index 039bd6a55..c15782924 100755 --- a/ccm-core/src/com/arsdigita/bebop/FormSection.java +++ b/ccm-core/src/com/arsdigita/bebop/FormSection.java @@ -63,19 +63,16 @@ import org.apache.log4j.Logger; public class FormSection extends SimpleComponent implements Container { private static final Logger s_log = Logger.getLogger(FormSection.class); - /** * Underlying FormModel that stores * the parameter models for all the widgets in this form section. */ protected FormModel m_formModel; - /** * The container to which all children are added. A * ColumnPanel by default. */ protected Container m_panel; - /** * Contains all the listeners that were added with the various * addXXXListener methods. @@ -85,13 +82,12 @@ public class FormSection extends SimpleComponent implements Container { * FormModel. */ private EventListenerList m_listeners; - // Listeners we attach to the FormModel to forward // form model events to our listeners with the right source private FormSubmissionListener m_forwardSubmission; - private FormInitListener m_forwardInit; + private FormInitListener m_forwardInit; private FormValidationListener m_forwardValidation; - private FormProcessListener m_forwardProcess; + private FormProcessListener m_forwardProcess; /** * Constructs a new form section. Sets the implicit layout Container of @@ -143,8 +139,7 @@ public class FormSection extends SimpleComponent implements Container { */ public void addSubmissionListener(FormSubmissionListener listener) { if (s_log.isDebugEnabled()) { - s_log.debug("Adding submission listener " + listener + " to " + - this); + s_log.debug("Adding submission listener " + listener + " to " + this); } Assert.exists(listener, "Submission Listener"); @@ -161,8 +156,8 @@ public class FormSection extends SimpleComponent implements Container { */ public void removeSubmissionListener(FormSubmissionListener listener) { if (s_log.isDebugEnabled()) { - s_log.debug("Removing submission listener " + listener + " from " + - this); + s_log.debug("Removing submission listener " + listener + " from " + + this); } Assert.exists(listener, "Submission Listener"); @@ -179,14 +174,15 @@ public class FormSection extends SimpleComponent implements Container { * exception. */ protected void fireSubmitted(FormSectionEvent e) - throws FormProcessException { + throws FormProcessException { Assert.exists(e.getFormData(), "FormData"); FormProcessException delayedException = null; - Iterator i = m_listeners.getListenerIterator(FormSubmissionListener - .class); + Iterator i = m_listeners.getListenerIterator( + FormSubmissionListener.class); while (i.hasNext()) { - final FormSubmissionListener listener = (FormSubmissionListener) i.next(); + final FormSubmissionListener listener = (FormSubmissionListener) i. + next(); if (s_log.isDebugEnabled()) { s_log.debug("Firing submission listener " + listener); @@ -195,10 +191,11 @@ public class FormSection extends SimpleComponent implements Container { try { listener.submitted(e); } catch (FormProcessException ex) { + s_log.error(ex); delayedException = ex; } } - if ( delayedException != null ) { + if (delayedException != null) { throw delayedException; } } @@ -219,13 +216,14 @@ public class FormSection extends SimpleComponent implements Container { */ protected FormSubmissionListener createSubmissionListener() { return new FormSubmissionListener() { - public void submitted(FormSectionEvent e) + + public void submitted(FormSectionEvent e) throws FormProcessException { - fireSubmitted(new FormSectionEvent(FormSection.this, - e.getPageState(), - e.getFormData())); - } - }; + fireSubmitted(new FormSectionEvent(FormSection.this, + e.getPageState(), + e.getFormData())); + } + }; } /** @@ -258,8 +256,7 @@ public class FormSection extends SimpleComponent implements Container { */ public void removeInitListener(FormInitListener listener) { if (s_log.isDebugEnabled()) { - s_log.debug("Removing init listener " + listener + " from " + - this); + s_log.debug("Removing init listener " + listener + " from " + this); } Assert.exists(listener, "Init Listener"); @@ -297,7 +294,6 @@ public class FormSection extends SimpleComponent implements Container { } } - /** * Creates the init listener that forwards init events to this form * section. @@ -307,13 +303,31 @@ public class FormSection extends SimpleComponent implements Container { */ protected FormInitListener createInitListener() { return new FormInitListener() { - public void init(FormSectionEvent e) + + public void init(FormSectionEvent e) throws FormProcessException { - fireInit(new FormSectionEvent(FormSection.this, - e.getPageState(), - e.getFormData())); - } - }; + fireInit(new FormSectionEvent(FormSection.this, + e.getPageState(), + e.getFormData())); + } + }; + } + + /** + * Creates the cancel listener that forwards cancel events to this form + * section + * + * @return an cancel listener + */ + protected FormCancelListener createCancelListener() { + return new FormCancelListener() { + + public void cancel(FormSectionEvent e) throws FormProcessException { + fireCancel(new FormSectionEvent(FormSection.this, + e.getPageState(), + e.getFormData())); + } + }; } /** @@ -326,8 +340,7 @@ public class FormSection extends SimpleComponent implements Container { * */ public void addValidationListener(FormValidationListener listener) { if (s_log.isDebugEnabled()) { - s_log.debug("Adding validation listener " + listener + " to " + - this); + s_log.debug("Adding validation listener " + listener + " to " + this); } Assert.exists(listener, "FormValidationListener"); @@ -344,8 +357,8 @@ public class FormSection extends SimpleComponent implements Container { */ public void removeValidationListener(FormValidationListener listener) { if (s_log.isDebugEnabled()) { - s_log.debug("Removing validation listener " + listener + " from " + - this); + s_log.debug("Removing validation listener " + listener + " from " + + this); } Assert.exists(listener, "Validation Listener"); @@ -362,12 +375,12 @@ public class FormSection extends SimpleComponent implements Container { protected void fireValidate(FormSectionEvent e) { FormData data = e.getFormData(); Assert.exists(data, "FormData"); - Iterator i = m_listeners.getListenerIterator(FormValidationListener - .class); + Iterator i = m_listeners.getListenerIterator( + FormValidationListener.class); while (i.hasNext()) { try { final FormValidationListener listener = - (FormValidationListener) i.next(); + (FormValidationListener) i.next(); if (s_log.isDebugEnabled()) { s_log.debug("Firing validation listener " + listener); @@ -375,12 +388,12 @@ public class FormSection extends SimpleComponent implements Container { listener.validate(e); } catch (FormProcessException fpe) { + s_log.error(fpe); data.addError(fpe.getMessage()); } } } - protected void forwardValidation() { if (m_forwardValidation == null) { m_forwardValidation = createValidationListener(); @@ -388,7 +401,6 @@ public class FormSection extends SimpleComponent implements Container { } } - /** * Create the validation listener that forwards validation events to this * form section. @@ -398,12 +410,13 @@ public class FormSection extends SimpleComponent implements Container { */ protected FormValidationListener createValidationListener() { return new FormValidationListener() { - public void validate(FormSectionEvent e) { - fireValidate(new FormSectionEvent(FormSection.this, - e.getPageState(), - e.getFormData())); - } - }; + + public void validate(FormSectionEvent e) { + fireValidate(new FormSectionEvent(FormSection.this, + e.getPageState(), + e.getFormData())); + } + }; } /** @@ -437,8 +450,8 @@ public class FormSection extends SimpleComponent implements Container { */ public void removeProcessListener(FormProcessListener listener) { if (s_log.isDebugEnabled()) { - s_log.debug("Removing process listener " + listener + " from " + - this); + s_log.debug("Removing process listener " + listener + " from " + + this); } Assert.exists(listener, "Process Listener"); @@ -447,24 +460,23 @@ public class FormSection extends SimpleComponent implements Container { m_listeners.remove(FormProcessListener.class, listener); } - protected void forwardProcess() { - if ( m_forwardProcess == null ) { + if (m_forwardProcess == null) { m_forwardProcess = createProcessListener(); getModel().addProcessListener(m_forwardProcess); } } - protected FormProcessListener createProcessListener() { return new FormProcessListener() { - public void process(FormSectionEvent e) + + public void process(FormSectionEvent e) throws FormProcessException { - fireProcess(new FormSectionEvent(FormSection.this, - e.getPageState(), - e.getFormData())); - } - }; + fireProcess(new FormSectionEvent(FormSection.this, + e.getPageState(), + e.getFormData())); + } + }; } /** @@ -476,7 +488,7 @@ public class FormSection extends SimpleComponent implements Container { * exception. */ protected void fireProcess(FormSectionEvent e) - throws FormProcessException { + throws FormProcessException { Assert.exists(e.getFormData(), "FormData"); Iterator i = m_listeners.getListenerIterator(FormProcessListener.class); while (i.hasNext()) { @@ -499,7 +511,7 @@ public class FormSection extends SimpleComponent implements Container { * not meaningful. */ public FormData process(PageState data) - throws javax.servlet.ServletException { + throws javax.servlet.ServletException { throw new UnsupportedOperationException(); } @@ -529,8 +541,7 @@ public class FormSection extends SimpleComponent implements Container { */ public void removeCancelListener(FormCancelListener listener) { if (s_log.isDebugEnabled()) { - s_log.debug("Removing cancel listener " + listener + " from " + - this); + s_log.debug("Removing cancel listener " + listener + " from " + this); } Assert.exists(listener, "Cancel Listener"); @@ -547,7 +558,7 @@ public class FormSection extends SimpleComponent implements Container { * exception. */ protected void fireCancel(FormSectionEvent e) - throws FormProcessException { + throws FormProcessException { Assert.exists(e.getFormData(), "FormData"); Iterator i = m_listeners.getListenerIterator(FormCancelListener.class); while (i.hasNext()) { @@ -593,6 +604,7 @@ public class FormSection extends SimpleComponent implements Container { m_panel.lock(); super.lock(); } + public void respond(PageState state) throws javax.servlet.ServletException { //call listeners here. throw new UnsupportedOperationException(); @@ -603,7 +615,7 @@ public class FormSection extends SimpleComponent implements Container { * * This must not be final, because MetaFrom needs to override it. * */ - public Container getPanel(){ + public Container getPanel() { return m_panel; } @@ -629,14 +641,13 @@ public class FormSection extends SimpleComponent implements Container { * @param pageState the state of the current page * @param parent the node that will be used to write to * */ - public void generateXML(PageState pageState, Element parent) { - if ( isVisible(pageState) ) { + public void generateXML(PageState pageState, Element parent) { + if (isVisible(pageState)) { m_panel.generateXML(pageState, parent); } } // Container methods - /** * Adds a component to this container. * @@ -696,7 +707,7 @@ public class FormSection extends SimpleComponent implements Container { * @return the component at the specified position in this container * */ public Component get(int index) { - return (Component)m_panel.get(index); + return (Component) m_panel.get(index); } /** diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java index 65b9b714b..1ea671479 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java @@ -26,6 +26,7 @@ import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.RadioGroup; import com.arsdigita.bebop.parameters.BooleanParameter; @@ -48,7 +49,8 @@ import org.apache.log4j.Logger; public class PublicationAuthorAddForm extends BasicItemForm implements FormProcessListener, - FormInitListener { + FormInitListener, + FormSubmissionListener { private static final Logger s_log = Logger.getLogger( PublicationAuthorAddForm.class); @@ -58,7 +60,6 @@ public class PublicationAuthorAddForm private final String ITEM_SEARCH = "authors"; private ItemSelectionModel m_itemModel; private SimpleEditStep editStep; - private Label selectedAuthorLabel; public PublicationAuthorAddForm(ItemSelectionModel itemModel, @@ -66,6 +67,7 @@ public class PublicationAuthorAddForm super("AuthorsEntryForm", itemModel); m_itemModel = itemModel; this.editStep = editStep; + addSubmissionListener(this); } @Override @@ -118,7 +120,7 @@ public class PublicationAuthorAddForm if (author == null) { s_log.warn("No author selected."); - // m_itemSearch.setVisible(state, true); + m_itemSearch.setVisible(state, true); selectedAuthorLabel.setVisible(state, false); } else { s_log.warn(String.format("Author is here: %s", author.getFullName())); @@ -169,9 +171,23 @@ public class PublicationAuthorAddForm null); ((PublicationAuthorsPropertyStep) editStep). setSelectedAuthorEditor(null); + + authors.close(); } } init(fse); } + + public void submitted(FormSectionEvent fse) throws FormProcessException { + if (getSaveCancelSection().getCancelButton().isSelected( + fse.getPageState())) { + ((PublicationAuthorsPropertyStep) editStep).setSelectedAuthor( + null); + ((PublicationAuthorsPropertyStep) editStep).setSelectedAuthorEditor( + null); + + init(fse); + } + } } 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 9299e9180..ecfdc3f7e 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 @@ -25,6 +25,7 @@ import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SaveCancelSection; import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.parameters.DateParameter; import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.cms.ContentType; @@ -43,7 +44,9 @@ import org.apache.log4j.Logger; * * @author Jens Pelzetter */ -public class SeriesEditshipAddForm extends BasicItemForm { +public class SeriesEditshipAddForm + extends BasicItemForm + implements FormSubmissionListener { private static final Logger s_log = Logger.getLogger(SeriesEditshipAddForm.class); @@ -60,6 +63,7 @@ public class SeriesEditshipAddForm extends BasicItemForm { super("EditorsEntryForm", itemModel); m_itemModel = itemModel; this.editStep = editStep; + addSubmissionListener(this); } @Override @@ -107,6 +111,7 @@ public class SeriesEditshipAddForm extends BasicItemForm { to = editStep.getSelectedEditorDateTo(); if (editor == null) { + m_itemSearch.setVisible(state, true); selectedEditorLabel.setVisible(state, false); } else { data.put(ITEM_SEARCH, editor); @@ -159,6 +164,18 @@ public class SeriesEditshipAddForm extends BasicItemForm { } init(fse); + } + + public void submitted(FormSectionEvent fse) throws FormProcessException { + + if (getSaveCancelSection().getCancelButton().isSelected( + fse.getPageState())) { + editStep.setSelectedEditor(null); + editStep.setSelectedEditorDateFrom(null); + editStep.setSelectedEditorDateTo(null); + + init(fse); + } } } 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 3164d897f..836e8a507 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 @@ -35,7 +35,6 @@ import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.contenttypes.EditshipCollection; import com.arsdigita.cms.contenttypes.GenericPerson; -import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Series; import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.cms.ui.authoring.SimpleEditStep; @@ -57,13 +56,13 @@ public class SeriesEditshipTable extends Table implements TableActionListener { //private final String TABLE_COL_UP = "table_col_up"; //private final String TABLE_COL_DOWN = "table_col_down"; private ItemSelectionModel m_itemModel; - private SimpleEditStep editStep; + private SeriesEditshipStep editStep; public SeriesEditshipTable(ItemSelectionModel itemModel, SimpleEditStep editStep) { super(); m_itemModel = itemModel; - this.editStep = editStep; + this.editStep = (SeriesEditshipStep)editStep; setEmptyView( new Label(PublicationGlobalizationUtil.globalize( @@ -373,9 +372,9 @@ public class SeriesEditshipTable extends Table implements TableActionListener { } } - ((SeriesEditshipStep)editStep).setSelectedEditor(editor); - ((SeriesEditshipStep)editStep).setSelectedEditorDateFrom(editors.getFrom()); - ((SeriesEditshipStep)editStep).setSelectedEditorDateTo(editors.getTo()); + editStep.setSelectedEditor(editor); + editStep.setSelectedEditorDateFrom(editors.getFrom()); + editStep.setSelectedEditorDateTo(editors.getTo()); editors.close(); diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberAddForm.java index 3283fe1dc..06fe7b42a 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberAddForm.java @@ -36,8 +36,9 @@ import com.arsdigita.cms.contenttypes.SciDepartment; public class SciDepartmentMemberAddForm extends GenericOrganizationalUnitPersonAddForm { - public SciDepartmentMemberAddForm(ItemSelectionModel itemModel) { - super(itemModel); + public SciDepartmentMemberAddForm(ItemSelectionModel itemModel, + GenericOrganizationalUnitPersonSelector personSelector) { + super(itemModel, personSelector); } @Override diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberStep.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberStep.java index 2aa0e52d9..a57c2552d 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberStep.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberStep.java @@ -19,7 +19,9 @@ */ package com.arsdigita.cms.contenttypes.ui; +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; @@ -30,9 +32,14 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; * * @author Jens Pelzetter */ -public class SciDepartmentMemberStep extends SimpleEditStep { +public class SciDepartmentMemberStep + extends SimpleEditStep + implements GenericOrganizationalUnitPersonSelector { private static final String ADD_MEMBER_SHEET_NAME = "addMember"; + private GenericPerson selectedPerson; + private String selectedPersonRole; + private String selectedPersonStatus; public SciDepartmentMemberStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { @@ -45,7 +52,8 @@ public class SciDepartmentMemberStep extends SimpleEditStep { super(itemModel, parent, prefix); BasicItemForm addMemberSheet = - new SciDepartmentMemberAddForm(itemModel); + new SciDepartmentMemberAddForm(itemModel, + this); add(ADD_MEMBER_SHEET_NAME, (String) SciOrganizationGlobalizationUtil.globalize( "sciorganization.ui.department.add_member").localize(), @@ -53,7 +61,36 @@ public class SciDepartmentMemberStep extends SimpleEditStep { addMemberSheet.getSaveCancelSection().getCancelButton()); SciDepartmentMemberTable memberTable = new SciDepartmentMemberTable( - itemModel); + itemModel, + this); setDisplayComponent(memberTable); } + + public GenericPerson getSelectedPerson() { + return selectedPerson; + } + + public void setSelectedPerson(final GenericPerson selectedPerson) { + this.selectedPerson = selectedPerson; + } + + public String getSelectedPersonRole() { + return selectedPersonRole; + } + + public void setSelectedPersonRole(final String selectedPersonRole) { + this.selectedPersonRole = selectedPersonRole; + } + + public String getSelectedPersonStatus() { + return selectedPersonStatus; + } + + public void setSelectedPersonStatus(final String selectedPersonStatus) { + this.selectedPersonStatus = selectedPersonStatus; + } + + public void showEditComponent(PageState state) { + showComponent(state, ADD_MEMBER_SHEET_NAME); + } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberTable.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberTable.java index e6292526a..19a8ef255 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberTable.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentMemberTable.java @@ -27,13 +27,13 @@ import com.arsdigita.cms.ItemSelectionModel; */ public class SciDepartmentMemberTable extends GenericOrganizationalUnitPersonsTable { - public SciDepartmentMemberTable(ItemSelectionModel itemModel) { - super(itemModel); + public SciDepartmentMemberTable(ItemSelectionModel itemModel, + GenericOrganizationalUnitPersonSelector personSelector) { + super(itemModel, personSelector); } @Override protected String getRoleAttributeName() { return "SciDepartmentRole"; } - } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberAddForm.java index 0908c6953..26312d167 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberAddForm.java @@ -19,9 +19,11 @@ */ package com.arsdigita.cms.contenttypes.ui; -import com.arsdigita.cms.contenttypes.GenericPerson; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.GenericPerson; +import com.arsdigita.cms.contenttypes.SciMember; import com.arsdigita.cms.contenttypes.SciOrganization; /** @@ -35,13 +37,15 @@ import com.arsdigita.cms.contenttypes.SciOrganization; * @see GenericPerson * @see GenericOrganizationalUnitPersonAddForm */ -public class SciOrganizationMemberAddForm +public class SciOrganizationMemberAddForm extends GenericOrganizationalUnitPersonAddForm { - public SciOrganizationMemberAddForm(ItemSelectionModel itemModel) { - super(itemModel); + public SciOrganizationMemberAddForm( + ItemSelectionModel itemModel, + GenericOrganizationalUnitPersonSelector personSelector) { + super(itemModel, personSelector); } - + @Override protected String getPersonType() { return GenericPerson.class.getName(); diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberStep.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberStep.java index c113280da..9486098e3 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberStep.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberStep.java @@ -19,7 +19,9 @@ */ package com.arsdigita.cms.contenttypes.ui; +import com.arsdigita.bebop.PageState; import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.GenericPerson; import com.arsdigita.cms.contenttypes.SciMember; import com.arsdigita.cms.contenttypes.SciOrganization; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; @@ -35,9 +37,14 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; * @see SciMember * @see SciOrganization */ -public class SciOrganizationMemberStep extends SimpleEditStep { +public class SciOrganizationMemberStep + extends SimpleEditStep + implements GenericOrganizationalUnitPersonSelector { - private static final String ADD_MEMBER_SHEET_NAME = "addMember"; + public static final String ADD_MEMBER_SHEET_NAME = "addMember"; + private GenericPerson selectedPerson; + private String selectedPersonRole; + private String selectedPersonStatus; public SciOrganizationMemberStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { @@ -50,7 +57,7 @@ public class SciOrganizationMemberStep extends SimpleEditStep { super(itemModel, parent, prefix); BasicItemForm addMemberSheet = - new SciOrganizationMemberAddForm(itemModel); + new SciOrganizationMemberAddForm(itemModel, this); add(ADD_MEMBER_SHEET_NAME, (String) SciOrganizationGlobalizationUtil.globalize( "sciorganization.ui.orgnization.add_member").localize(), @@ -58,7 +65,35 @@ public class SciOrganizationMemberStep extends SimpleEditStep { addMemberSheet.getSaveCancelSection().getCancelButton()); SciOrganizationMemberTable memberTable = new SciOrganizationMemberTable( - itemModel); + itemModel, this); setDisplayComponent(memberTable); } + + public GenericPerson getSelectedPerson() { + return selectedPerson; + } + + public void setSelectedPerson(final GenericPerson selectedPerson) { + this.selectedPerson = selectedPerson; + } + + public String getSelectedPersonRole() { + return selectedPersonRole; + } + + public void setSelectedPersonRole(final String selectedPersonRole) { + this.selectedPersonRole = selectedPersonRole; + } + + public String getSelectedPersonStatus() { + return selectedPersonStatus; + } + + public void setSelectedPersonStatus(final String selectedPersonStatus) { + this.selectedPersonStatus = selectedPersonStatus; + } + + public void showEditComponent(final PageState state) { + showComponent(state, ADD_MEMBER_SHEET_NAME); + } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberTable.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberTable.java index 2b6104406..a8fd810d3 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberTable.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationMemberTable.java @@ -27,8 +27,9 @@ import com.arsdigita.cms.ItemSelectionModel; */ public class SciOrganizationMemberTable extends GenericOrganizationalUnitPersonsTable { - public SciOrganizationMemberTable(ItemSelectionModel itemModel) { - super(itemModel); + public SciOrganizationMemberTable(ItemSelectionModel itemModel, + GenericOrganizationalUnitPersonSelector personSelector) { + super(itemModel, personSelector); } @Override diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberAddForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberAddForm.java index 09a83ba29..d1c80867b 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberAddForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberAddForm.java @@ -32,8 +32,9 @@ public class SciProjectMemberAddForm extends GenericOrganizationalUnitPersonAddForm { public SciProjectMemberAddForm( - ItemSelectionModel itemModel) { - super(itemModel); + ItemSelectionModel itemModel, + GenericOrganizationalUnitPersonSelector personSelector) { + super(itemModel, personSelector); } @Override diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberStep.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberStep.java index 1ec1634e4..01d029fc4 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberStep.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberStep.java @@ -19,7 +19,9 @@ */ package com.arsdigita.cms.contenttypes.ui; +import com.arsdigita.bebop.PageState; import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.GenericPerson; import com.arsdigita.cms.contenttypes.SciProject; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.BasicItemForm; @@ -31,9 +33,14 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; * * @author Jens Pelzetter */ -public class SciProjectMemberStep extends SimpleEditStep { +public class SciProjectMemberStep + extends SimpleEditStep + implements GenericOrganizationalUnitPersonSelector { private static final String ADD_MEMBER_SHEET_NAME = "addMember"; + private GenericPerson selectedPerson; + private String selectedPersonRole; + private String selectedPersonStatus; public SciProjectMemberStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { @@ -46,7 +53,8 @@ public class SciProjectMemberStep extends SimpleEditStep { super(itemModel, parent, prefix); BasicItemForm addMemberSheet = - new SciProjectMemberAddForm(itemModel); + new SciProjectMemberAddForm(itemModel, + this); add(ADD_MEMBER_SHEET_NAME, (String) SciOrganizationGlobalizationUtil.globalize( "sciorganization.ui.project.add_member").localize(), @@ -54,7 +62,35 @@ public class SciProjectMemberStep extends SimpleEditStep { addMemberSheet.getSaveCancelSection().getCancelButton()); SciProjectMemberTable memberTable = new SciProjectMemberTable( - itemModel); + itemModel, this); setDisplayComponent(memberTable); } + + public GenericPerson getSelectedPerson() { + return selectedPerson; + } + + public void setSelectedPerson(final GenericPerson selectedPerson) { + this.selectedPerson = selectedPerson; + } + + public String getSelectedPersonRole() { + return selectedPersonRole; + } + + public void setSelectedPersonRole(final String selectedPersonRole) { + this.selectedPersonRole = selectedPersonRole; + } + + public String getSelectedPersonStatus() { + return selectedPersonStatus; + } + + public void setSelectedPersonStatus(final String selectedPersonStatus) { + this.selectedPersonStatus = selectedPersonStatus; + } + + public void showEditComponent(PageState state) { + showComponent(state, ADD_MEMBER_SHEET_NAME); + } } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberTable.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberTable.java index 301f67876..f195ac1b4 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberTable.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectMemberTable.java @@ -27,9 +27,10 @@ import com.arsdigita.cms.ItemSelectionModel; */ public class SciProjectMemberTable extends GenericOrganizationalUnitPersonsTable { - - public SciProjectMemberTable(ItemSelectionModel itemModel) { - super(itemModel); + + public SciProjectMemberTable(ItemSelectionModel itemModel, + GenericOrganizationalUnitPersonSelector personSelector) { + super(itemModel, personSelector); } @Override