Hinzufügen von Mitgliedern zu einer Organizationseinheit. UI funktioniert noch nicht!
git-svn-id: https://svn.libreccm.org/ccm/trunk@206 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
afac9682ae
commit
c084e9a837
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// Copyright (C) 2009 Center of Socialpolitics, University of Bremen
|
// Copyright (C) 2009 Center for Social Policy Reseearch, University of Bremen
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public License
|
// modify it under the terms of the GNU Lesser General Public License
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@
|
||||||
<ccm:dependencies>
|
<ccm:dependencies>
|
||||||
<ccm:requires name="ccm-core" version="6.6.0" relation="ge"/>
|
<ccm:requires name="ccm-core" version="6.6.0" relation="ge"/>
|
||||||
<ccm:requires name="ccm-cms" version="6.6.0" relation="ge"/>
|
<ccm:requires name="ccm-cms" version="6.6.0" relation="ge"/>
|
||||||
<ccm:requires name="ccm-cms-types-person" version="6.6.0" relation="ge"/>
|
<ccm:requires name="ccm-cms-types-person" version="6.6.0" relation="ge"/>
|
||||||
<ccm:requires name="ccm-cms-types-article" version="6.6.0" requires="ge"/>
|
|
||||||
</ccm:dependencies>
|
</ccm:dependencies>
|
||||||
<ccm:directories>
|
<ccm:directories>
|
||||||
<ccm:directory name="pdl"/>
|
<ccm:directory name="pdl"/>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
//
|
||||||
|
// Copyright (C) 2009 Center for Social Policy Reseearch, 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
|
||||||
|
|
||||||
|
model com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.kernel.ACSObject;
|
||||||
|
|
||||||
|
object type Membership extends ACSObject {
|
||||||
|
MembershipStatus[1..1] status = join ct_memberships.status_id to ct_membershipstatus.status_id;
|
||||||
|
Date[1..1] memberFrom = ct_memberships.member_from DATE;
|
||||||
|
Date[1..1] memberTo = ct_memberships.member_to DATE;
|
||||||
|
Person[0..1] targetItem = join ct_memberships.target_item_id to ct_persons.person_id;
|
||||||
|
|
||||||
|
reference key(ct_memberships.membership_id);
|
||||||
|
aggressive load (membershipOwner.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
association {
|
||||||
|
composite OrganizationalUnit[0..1] membershipOwner = join ct_memberships.owner_id to ct_organizationalunits.organizationalunit_id;
|
||||||
|
composite Membership[0..n] members = join ct_organizationalunits.organizationalunit_id to ct_memberships.ownerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
query getMembershipsReferingToUnits {
|
||||||
|
BigDecimal id;
|
||||||
|
|
||||||
|
do {
|
||||||
|
select m.membership_id from memberships m where m.target_item_id = :itemID;
|
||||||
|
} map {
|
||||||
|
id = m.membership_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009 Center for Social Policy Research, 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
|
||||||
|
//
|
||||||
|
|
||||||
|
model com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.kernel.ACSObject;
|
||||||
|
|
||||||
|
object type MembershipStatus extends ACSObject {
|
||||||
|
|
||||||
|
String[1..1] membershipStatusName = ct_membershipstatus.status_name VARCHAR(250);
|
||||||
|
|
||||||
|
reference key(ct_membershipstatus.status_id);
|
||||||
|
}
|
||||||
|
|
@ -15,15 +15,30 @@
|
||||||
labelBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
labelBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
||||||
descriptionKey="organizationalunit.authoring.basic_properties.description"
|
descriptionKey="organizationalunit.authoring.basic_properties.description"
|
||||||
descriptionBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
descriptionBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
||||||
component="com.arsdigita.cms.contenttypes.ui.OrganizationalUnitPropertiesStep"
|
component="com.arsdigita.cms.contenttypes.ui.organizationalunit.OrganizationalUnitPropertiesStep"
|
||||||
ordering="1"/>
|
ordering="1"/>
|
||||||
|
|
||||||
<ctd:authoring-step labelKey="organizationalunit.authoring.subunits.title"
|
<ctd:authoring-step labelKey="organizationalunit.authoring.subunits.title"
|
||||||
labelBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
labelBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
||||||
descriptionKey="organizationalunit.authoring.subunits_properties.description"
|
descriptionKey="organizationalunit.authoring.subunits_properties.description"
|
||||||
descriptionBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
descriptionBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
||||||
component="com.arsdigita.cms.contenttypes.ui.OrgaUnit2OrgaUnitPropertiesStep"
|
component="com.arsdigita.cms.contenttypes.ui.organizationalunit.OrgaUnit2OrgaUnitPropertiesStep"
|
||||||
ordering="2"/>
|
ordering="2"/>
|
||||||
|
|
||||||
|
<ctd:authoring-step labelKey="organizationalunit.authoring.members.title"
|
||||||
|
labelBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
||||||
|
descriptionKey="organizationalunit.authoring.members_properties.description"
|
||||||
|
descriptionBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
||||||
|
component="com.arsdigita.cms.contenttypes.ui.organizationalunit.MembershipPropertiesStep"
|
||||||
|
ordering="3"/>
|
||||||
|
|
||||||
|
<ctd:authoring-step labelKey="organizationalunit.authoring.membershipstatus.title"
|
||||||
|
labelBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
||||||
|
descriptionKey="organizationalunit.authoring.membershipstatus_properties.description"
|
||||||
|
descriptionBundle="com.arsdigita.cms.contenttypes.OrganizationalUnitResources"
|
||||||
|
component="com.arsdigita.cms.contenttypes.ui.organizationalunit.MembershipStatusPropertiesStep"
|
||||||
|
ordering="4"/>
|
||||||
|
|
||||||
|
|
||||||
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
||||||
</ctd:authoring-kit>
|
</ctd:authoring-kit>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@
|
||||||
<provides>
|
<provides>
|
||||||
<table name="ct_organizationalunits" />
|
<table name="ct_organizationalunits" />
|
||||||
<table name="ct_orgaunit2orgaunits" />
|
<table name="ct_orgaunit2orgaunits" />
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.OrganizationalUnitInitializer"/>
|
<table name="ct_membershipstatus" />
|
||||||
|
<initializer class="com.arsdigita.cms.contenttypes.OrganizationalUnitInitializer"/>
|
||||||
</provides>
|
</provides>
|
||||||
<scripts>
|
<scripts>
|
||||||
<schema directory="ccm-cms-types-organizationalunit" />
|
<schema directory="ccm-cms-types-organizationalunit" />
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,162 @@
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.ContentSection;
|
||||||
|
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.kernel.ACSObject;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.Filter;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.persistence.Session;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.web.URL;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class Membership extends ACSObject {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(Membership.class);
|
||||||
|
public final static String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Membership";
|
||||||
|
public final static String STATUS = "status";
|
||||||
|
public final static String FROM = "memberFrom";
|
||||||
|
public final static String TO = "memberTo";
|
||||||
|
public final static String MEMBERSHIP_OWNER = "membershipOwner";
|
||||||
|
public final static String TARGET_ITEM = "targetItem";
|
||||||
|
|
||||||
|
public Membership() {
|
||||||
|
super(BASE_DATA_OBJECT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Membership(DataObject obj) {
|
||||||
|
super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Membership(BigDecimal id) {
|
||||||
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Membership(OID oid) {
|
||||||
|
super(oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Membership(String type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MembershipStatus getStatus() {
|
||||||
|
DataObject obj = (DataObject) get(STATUS);
|
||||||
|
if (obj != null) {
|
||||||
|
return new MembershipStatus(obj);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(MembershipStatus status) {
|
||||||
|
setAssociation(STATUS, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatusName() {
|
||||||
|
String name = "";
|
||||||
|
if (getStatus() != null) {
|
||||||
|
name = getStatus().getStatusName();
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formatDate(Date date) {
|
||||||
|
if (date != null) {
|
||||||
|
return DateFormat.getDateInstance(DateFormat.LONG).format(date);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getFrom() {
|
||||||
|
return (Date) get(FROM);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayFrom() {
|
||||||
|
return formatDate(getFrom());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrom(Date from) {
|
||||||
|
set(FROM, from);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getTo() {
|
||||||
|
return (Date) get(TO);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayTo() {
|
||||||
|
return formatDate(getTo());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTo(Date to) {
|
||||||
|
set(TO, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrganizationalUnit getMembershipOwner() {
|
||||||
|
DataObject obj = (DataObject) get(MEMBERSHIP_OWNER);
|
||||||
|
if (obj == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return (OrganizationalUnit) DomainObjectFactory.newInstance(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMembershipOwner(OrganizationalUnit ou) {
|
||||||
|
Assert.exists(ou, OrganizationalUnit.class);
|
||||||
|
setAssociation(MEMBERSHIP_OWNER, ou);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Person getTargetItem() {
|
||||||
|
DataObject obj = (DataObject) get(TARGET_ITEM);
|
||||||
|
return (Person) DomainObjectFactory.newInstance(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTargetItem(Person person) {
|
||||||
|
Assert.exists(person, Person.class);
|
||||||
|
setAssociation(TARGET_ITEM, person);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getURI(PageState state) {
|
||||||
|
Person person = this.getTargetItem();
|
||||||
|
|
||||||
|
if (person == null) {
|
||||||
|
logger.error(getOID() + " is a link between a OrganizationalUnit and a Person, but the associated Person is null");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentSection section = person.getContentSection();
|
||||||
|
ItemResolver resolver = section.getItemResolver();
|
||||||
|
String url = resolver.generateItemURL(state, person, section, person.getVersion());
|
||||||
|
|
||||||
|
return URL.there(state.getRequest(), url).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataCollection getReferingPersons(Person person) {
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
DataCollection memberships = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
|
Filter filter = memberships.addInSubqueryFilter("id", "com.arsdigita.cms.contenttypes.getReferingPersons");
|
||||||
|
filter.set("itemID", person.getID());
|
||||||
|
|
||||||
|
return memberships;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataCollection getMemberships(OrganizationalUnit ou) {
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
DataCollection dc = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
|
dc.addEqualsFilter(MEMBERSHIP_OWNER + ".id", ou.getID());
|
||||||
|
return dc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.kernel.ACSObject;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipStatus extends ACSObject {
|
||||||
|
|
||||||
|
public static final Logger logger = Logger.getLogger(MembershipStatus.class);
|
||||||
|
|
||||||
|
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.MembershipStatus";
|
||||||
|
|
||||||
|
public static final String MEMBERSHIP_STATUS_NAME = "membershipStatusName";
|
||||||
|
|
||||||
|
public MembershipStatus() {
|
||||||
|
super(BASE_DATA_OBJECT_TYPE);
|
||||||
|
logger.debug("Paramless constructor...");
|
||||||
|
}
|
||||||
|
|
||||||
|
public MembershipStatus(BigDecimal id) throws DataObjectNotFoundException {
|
||||||
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
logger.debug("id constructor...");
|
||||||
|
}
|
||||||
|
|
||||||
|
public MembershipStatus(OID id) throws DataObjectNotFoundException {
|
||||||
|
super(id);
|
||||||
|
logger.debug("oid constructor...");
|
||||||
|
}
|
||||||
|
|
||||||
|
public MembershipStatus(DataObject obj) {
|
||||||
|
super(obj);
|
||||||
|
logger.debug("obj constructor...");
|
||||||
|
}
|
||||||
|
|
||||||
|
public MembershipStatus(String type) {
|
||||||
|
super(type);
|
||||||
|
logger.debug("type constructor...");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatusName() {
|
||||||
|
return (String) get(MEMBERSHIP_STATUS_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatusName(String typeName) {
|
||||||
|
set(MEMBERSHIP_STATUS_NAME, typeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.domain.DomainCollection;
|
||||||
|
import com.arsdigita.domain.DomainObject;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipStatusCollection extends DomainCollection {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(MembershipStatusCollection.class);
|
||||||
|
|
||||||
|
public static MembershipStatusCollection getMembershipStatusCollection() {
|
||||||
|
logger.debug("Getting MembershipStatusCollection...");
|
||||||
|
SessionManager.getSession().retrieve(MembershipStatus.BASE_DATA_OBJECT_TYPE);
|
||||||
|
DataCollection statusCollection = SessionManager.getSession().retrieve(MembershipStatus.BASE_DATA_OBJECT_TYPE);
|
||||||
|
return new MembershipStatusCollection(statusCollection);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MembershipStatusCollection(DataCollection dataCollection) {
|
||||||
|
super(dataCollection);
|
||||||
|
logger.debug("MembershipStatusCollection constructor...");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DomainObject getDomainObject() {
|
||||||
|
return new MembershipStatus(m_dataCollection.getDataObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MembershipStatus getMembershipStatus() {
|
||||||
|
return (MembershipStatus) getDomainObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMembershipStatusName() {
|
||||||
|
return getMembershipStatus().getStatusName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getMembershipStatusId() {
|
||||||
|
return getMembershipStatus().getID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormSection;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.ResettableContainer;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedContainer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipPropertiesStep extends ResettableContainer {
|
||||||
|
|
||||||
|
private AuthoringKitWizard m_parent;
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private BigDecimalParameter m_membershipParam = new BigDecimalParameter("membership");
|
||||||
|
private MembershipSelectionModel m_membershipModel; // = new MembershipSelectionModel(m_membershipParam);
|
||||||
|
|
||||||
|
public MembershipPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_parent = parent;
|
||||||
|
setMembershipSelectionModel();
|
||||||
|
add(getDisplayComponent());
|
||||||
|
|
||||||
|
Form form = new Form("membershipEditForm");
|
||||||
|
form.add(getEditSheet());
|
||||||
|
|
||||||
|
WorkflowLockedContainer edit = new WorkflowLockedContainer(itemModel);
|
||||||
|
edit.add(form);
|
||||||
|
add(edit);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setMembershipSelectionModel() {
|
||||||
|
setMembershipSelectionModel(new MembershipSelectionModel(this.m_membershipParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setMembershipSelectionModel(MembershipSelectionModel membershipModel) {
|
||||||
|
this.m_membershipModel = membershipModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MembershipSelectionModel getMembershipSelectionModel() {
|
||||||
|
return this.m_membershipModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BigDecimalParameter getMembershipParam() {
|
||||||
|
return this.m_membershipParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getDisplayComponent() {
|
||||||
|
SimpleContainer container = new SimpleContainer();
|
||||||
|
container.add(new MembershipTable(m_itemModel, m_membershipModel));
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormSection getEditSheet() {
|
||||||
|
return new MembershipPropertyForm(m_itemModel, m_membershipModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(Page p) {
|
||||||
|
super.register(p);
|
||||||
|
p.addComponentStateParam(this, m_membershipParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,214 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
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.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.event.FormValidationListener;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.form.Option;
|
||||||
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
|
import com.arsdigita.bebop.form.Submit;
|
||||||
|
import com.arsdigita.bebop.parameters.DateParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.cms.ContentType;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.Membership;
|
||||||
|
import com.arsdigita.cms.contenttypes.MembershipStatusCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.OrganizationalUnit;
|
||||||
|
import com.arsdigita.cms.contenttypes.Person;
|
||||||
|
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipPropertyForm extends FormSection implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(MembershipPropertyForm.class);
|
||||||
|
|
||||||
|
public final static String ID = "membership_edit";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private MembershipSelectionModel m_membershipModel;
|
||||||
|
|
||||||
|
private ItemSearchWidget m_personSearch;
|
||||||
|
private final static String PERSON_SEARCH = "membership";
|
||||||
|
private SingleSelect m_status;
|
||||||
|
private com.arsdigita.bebop.form.Date m_from;
|
||||||
|
private com.arsdigita.bebop.form.Date m_to;
|
||||||
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
|
||||||
|
public MembershipPropertyForm(ItemSelectionModel itemModel, MembershipSelectionModel membershipModel) {
|
||||||
|
super(new ColumnPanel(2));
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_membershipModel = membershipModel;
|
||||||
|
|
||||||
|
addWidgets();
|
||||||
|
addSaveCancelSection();
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addValidationListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addWidgets() {
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.orgnizationalunit.membership.Person")));
|
||||||
|
this.m_personSearch = new ItemSearchWidget(PERSON_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.Person"));
|
||||||
|
add(this.m_personSearch);
|
||||||
|
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.orgnizationalunit.membership.Status")));
|
||||||
|
ParameterModel statusParam = new StringParameter((Membership.STATUS));
|
||||||
|
this.m_status = new SingleSelect(statusParam);
|
||||||
|
add(this.m_status);
|
||||||
|
MembershipStatusCollection statusValues = MembershipStatusCollection.getMembershipStatusCollection();
|
||||||
|
while(statusValues.next()) {
|
||||||
|
this.m_status.addOption(new Option(statusValues.getMembershipStatusId().toString(), statusValues.getMembershipStatusName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.organizationalunit.membership.from")));
|
||||||
|
ParameterModel fromParam = new DateParameter(Membership.FROM);
|
||||||
|
//fromParam.addParameterListener(new NotNullValidationListener());
|
||||||
|
this.m_from = new com.arsdigita.bebop.form.Date(fromParam);
|
||||||
|
add(this.m_from);
|
||||||
|
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.organizationalunit.membership.to")));
|
||||||
|
ParameterModel toParam = new DateParameter(Membership.TO);
|
||||||
|
this.m_to = new com.arsdigita.bebop.form.Date(toParam);
|
||||||
|
add(this.m_to);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addSaveCancelSection() {
|
||||||
|
this.m_saveCancelSection = new SaveCancelSection();
|
||||||
|
try {
|
||||||
|
this.m_saveCancelSection.getCancelButton().addPrintListener(new PrintListener() {
|
||||||
|
|
||||||
|
public void prepare(PrintEvent e) {
|
||||||
|
Submit target = (Submit) e.getTarget();
|
||||||
|
if (m_membershipModel.isSelected(e.getPageState())) {
|
||||||
|
target.setButtonLabel("cancel");
|
||||||
|
} else {
|
||||||
|
target.setButtonLabel("Reset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.m_saveCancelSection.getSaveButton().addPrintListener(new PrintListener() {
|
||||||
|
|
||||||
|
public void prepare(PrintEvent e) {
|
||||||
|
Submit target = (Submit) e.getTarget();
|
||||||
|
if (m_membershipModel.isSelected(e.getPageState())) {
|
||||||
|
target.setButtonLabel("Save");
|
||||||
|
} else {
|
||||||
|
target.setButtonLabel("Create");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch(Exception ex) {
|
||||||
|
throw new UncheckedWrapperException("this cannot happen", ex);
|
||||||
|
}
|
||||||
|
add(this.m_saveCancelSection, ColumnPanel.FULL_WIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SaveCancelSection getSaveCancelSection() {
|
||||||
|
return this.m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MembershipSelectionModel getMembershipSelectionModel() {
|
||||||
|
return this.m_membershipModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected OrganizationalUnit getOrganizationalUnit(PageState state) {
|
||||||
|
return (OrganizationalUnit) m_itemModel.getSelectedItem(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Membership createMembership(PageState state) {
|
||||||
|
OrganizationalUnit ou = this.getOrganizationalUnit(state);
|
||||||
|
Assert.exists(ou);
|
||||||
|
Membership membership = new Membership();
|
||||||
|
membership.setMembershipOwner(ou);
|
||||||
|
return membership;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setMembershipProperties(Membership membership, FormSectionEvent event) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
FormData data = event.getFormData();
|
||||||
|
|
||||||
|
membership.setTargetItem((Person) data.get(PERSON_SEARCH));
|
||||||
|
|
||||||
|
membership.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(FormSectionEvent e) throws FormProcessException {
|
||||||
|
FormData data = e.getFormData();
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
|
||||||
|
setVisible(state, true);
|
||||||
|
|
||||||
|
Membership membership;
|
||||||
|
if (m_membershipModel.isSelected(state)) {
|
||||||
|
membership = m_membershipModel.getSelectedMembership(state);
|
||||||
|
try {
|
||||||
|
data.put(PERSON_SEARCH, membership.getTargetItem());
|
||||||
|
data.put(Membership.STATUS, membership.getStatus());
|
||||||
|
data.put(Membership.FROM, membership.getFrom());
|
||||||
|
data.put(Membership.TO, membership.getTo());
|
||||||
|
} catch (IllegalStateException ex) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data.put(PERSON_SEARCH, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(FormSectionEvent e) throws FormProcessException {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
Membership membership;
|
||||||
|
|
||||||
|
if (this.getSaveCancelSection().getCancelButton().isSelected(state)) {
|
||||||
|
this.m_membershipModel.clearSelection(state);
|
||||||
|
} else {
|
||||||
|
if (this.m_membershipModel.isSelected(state)) {
|
||||||
|
membership = m_membershipModel.getSelectedMembership(state);
|
||||||
|
} else {
|
||||||
|
membership = createMembership(state);
|
||||||
|
}
|
||||||
|
setMembershipProperties(membership, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.m_membershipModel.clearSelection(state);
|
||||||
|
init(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(FormSectionEvent e) throws FormProcessException {
|
||||||
|
if (e.getFormData().get(PERSON_SEARCH) == null) {
|
||||||
|
throw new FormProcessException("Person selection is required");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e.getFormData().get(Membership.STATUS) == null) {
|
||||||
|
throw new FormProcessException("Status of membership is required");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted(FormSectionEvent e) throws FormProcessException {
|
||||||
|
if (this.m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) {
|
||||||
|
m_membershipModel.clearSelection(e.getPageState());
|
||||||
|
init(e);
|
||||||
|
throw new FormProcessException("cancelled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
import com.arsdigita.cms.contenttypes.Membership;
|
||||||
|
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipSelectionModel extends ACSObjectSelectionModel {
|
||||||
|
|
||||||
|
public MembershipSelectionModel(BigDecimalParameter param) {
|
||||||
|
super(Membership.class.getName(), Membership.BASE_DATA_OBJECT_TYPE, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MembershipSelectionModel(String itemClass, String objectType, BigDecimalParameter param) {
|
||||||
|
super(itemClass, objectType, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Membership getSelectedMembership(PageState state) {
|
||||||
|
return (Membership) getSelectedObject(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.*;
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormSection;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedContainer;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipStatusPropertiesStep extends ResettableContainer {
|
||||||
|
|
||||||
|
private Logger logger = Logger.getLogger(MembershipStatusPropertiesStep.class);
|
||||||
|
|
||||||
|
private AuthoringKitWizard m_parent;
|
||||||
|
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private BigDecimalParameter m_statusParam = new BigDecimalParameter(("membershipstatus"));
|
||||||
|
private MembershipStatusSelectionModel m_statusModel = new MembershipStatusSelectionModel(m_statusParam);
|
||||||
|
|
||||||
|
public MembershipStatusPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||||
|
logger.debug("Invoking MembershipStatusPropertiesStep(itemModel, parent)...");
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_parent = parent;
|
||||||
|
setMembershipStatusSelectionModel();
|
||||||
|
add(getDisplayComponent());
|
||||||
|
|
||||||
|
Form form = form = new Form("membershipStatusEditForm");
|
||||||
|
form.add(getEditSheet());
|
||||||
|
|
||||||
|
WorkflowLockedContainer edit = new WorkflowLockedContainer(itemModel);
|
||||||
|
edit.add(form);
|
||||||
|
add(edit);
|
||||||
|
logger.debug("finished.");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setMembershipStatusSelectionModel() {
|
||||||
|
setMembershipStatusSelectionModel(new MembershipStatusSelectionModel(m_statusParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setMembershipStatusSelectionModel(MembershipStatusSelectionModel statusModel) {
|
||||||
|
this.m_statusModel = statusModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MembershipStatusSelectionModel getMembershipStatusSelectionModel() {
|
||||||
|
return this.m_statusModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BigDecimalParameter getStatusParam() {
|
||||||
|
return this.m_statusParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Component getDisplayComponent() {
|
||||||
|
SimpleContainer container = new SimpleContainer();
|
||||||
|
container.add(new MembershipStatusTable(this.m_itemModel, this.m_statusModel));
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected FormSection getEditSheet() {
|
||||||
|
return new MembershipStatusPropertyForm((this.m_itemModel), this.m_statusModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(Page p) {
|
||||||
|
this.logger.info("registering...");
|
||||||
|
super.register(p);
|
||||||
|
p.addComponentStateParam(this, this.m_statusParam);
|
||||||
|
this.logger.info("finished...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,181 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
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.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.event.FormValidationListener;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.form.Submit;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.MembershipStatus;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipStatusPropertyForm extends FormSection implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(MembershipStatusPropertyForm.class);
|
||||||
|
|
||||||
|
public final static String ID = "membershipStatusEditForm_edit";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private MembershipStatusSelectionModel m_statusModel;
|
||||||
|
private TextField m_statusName;
|
||||||
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
|
||||||
|
public MembershipStatusPropertyForm(ItemSelectionModel itemModel, MembershipStatusSelectionModel statusModel) {
|
||||||
|
super(new ColumnPanel(2));
|
||||||
|
logger.debug("Constructor...");
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_statusModel = statusModel;
|
||||||
|
|
||||||
|
addWidgets();
|
||||||
|
addSaveCancelSection();
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addValidationListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
addSubmissionListener(this);
|
||||||
|
logger.debug("Constructor finished...");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addWidgets() {
|
||||||
|
logger.debug("Adding widgets...");
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.membershipstatus.warning_changes_here_significant_for_all")));
|
||||||
|
this.m_statusName = new TextField("statusName");
|
||||||
|
this.m_statusName.addValidationListener(new NotNullValidationListener());
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.membershipstatus.statusname")));
|
||||||
|
add(this.m_statusName);
|
||||||
|
logger.debug("widgets added");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addSaveCancelSection() {
|
||||||
|
logger.debug("adding savecancelsec...");
|
||||||
|
this.m_saveCancelSection = new SaveCancelSection();
|
||||||
|
try {
|
||||||
|
this.m_saveCancelSection.getCancelButton().addPrintListener(new PrintListener() {
|
||||||
|
|
||||||
|
public void prepare(PrintEvent e) {
|
||||||
|
Submit target = (Submit) e.getTarget();
|
||||||
|
if (m_statusModel.isSelected(e.getPageState())) {
|
||||||
|
target.setButtonLabel("Cancel");
|
||||||
|
} else {
|
||||||
|
target.setButtonLabel("Reset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.m_saveCancelSection.getSaveButton().addPrintListener(new PrintListener() {
|
||||||
|
|
||||||
|
public void prepare(PrintEvent e) {
|
||||||
|
Submit target = (Submit) e.getTarget();
|
||||||
|
if (m_statusModel.isSelected(e.getPageState())) {
|
||||||
|
target.setButtonLabel("Save");
|
||||||
|
} else {
|
||||||
|
target.setButtonLabel("Create");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch(Exception ex) {
|
||||||
|
throw new UncheckedWrapperException("this cannot happen", ex);
|
||||||
|
}
|
||||||
|
add(this.m_saveCancelSection, ColumnPanel.FULL_WIDTH);
|
||||||
|
logger.debug("savecancelsec added.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public SaveCancelSection getSaveCancelSection() {
|
||||||
|
return this.m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MembershipStatusSelectionModel getMembershipStatusSelectionModel() {
|
||||||
|
return this.m_statusModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MembershipStatus createMembershipStatus(PageState state) {
|
||||||
|
logger.debug("creating new membership status...");
|
||||||
|
MembershipStatus status = new MembershipStatus();
|
||||||
|
logger.debug("new membership status created.");
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setMembershipStatusProperties(MembershipStatus status, FormSectionEvent e) {
|
||||||
|
logger.debug("setting properties...");
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
//FormData data = e.getFormData();
|
||||||
|
|
||||||
|
status.setStatusName((String) m_statusName.getValue(state));
|
||||||
|
|
||||||
|
status.save();
|
||||||
|
logger.debug("properties set");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(FormSectionEvent e) throws FormProcessException {
|
||||||
|
logger.debug("init Listener invoked.");
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
//FormData data = e.getFormData();
|
||||||
|
|
||||||
|
setVisible(state, true);
|
||||||
|
|
||||||
|
MembershipStatus status;
|
||||||
|
if (m_statusModel.isSelected(state)) {
|
||||||
|
status = m_statusModel.getSelectedMembershipStatus(state);
|
||||||
|
try {
|
||||||
|
m_statusName.setValue(state, status.getStatusName());
|
||||||
|
} catch (IllegalStateException ex) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_statusName.setValue(state, null);
|
||||||
|
}
|
||||||
|
logger.debug("init Listener finished.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(FormSectionEvent e) throws FormProcessException {
|
||||||
|
logger.debug("process Listener invoked.");
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
MembershipStatus status;
|
||||||
|
|
||||||
|
if (this.getSaveCancelSection().getCancelButton().isSelected(state)) {
|
||||||
|
m_statusModel.clearSelection(state);
|
||||||
|
} else {
|
||||||
|
if (m_statusModel.isSelected(state)) {
|
||||||
|
status = m_statusModel.getSelectedMembershipStatus(state);
|
||||||
|
} else {
|
||||||
|
status = createMembershipStatus(state);
|
||||||
|
}
|
||||||
|
setMembershipStatusProperties(status, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_statusModel.clearSelection(state);
|
||||||
|
init(e);
|
||||||
|
logger.debug("process Listener finished.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(FormSectionEvent e) throws FormProcessException {
|
||||||
|
//Nothing yet
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted(FormSectionEvent e) throws FormProcessException {
|
||||||
|
logger.debug("submit Listener invoked.");
|
||||||
|
if (this.m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) {
|
||||||
|
m_statusModel.clearSelection(e.getPageState());
|
||||||
|
init(e);
|
||||||
|
throw new FormProcessException("cancelled");
|
||||||
|
}
|
||||||
|
logger.debug("submit Listener finished.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
import com.arsdigita.cms.contenttypes.MembershipStatus;
|
||||||
|
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipStatusSelectionModel extends ACSObjectSelectionModel {
|
||||||
|
|
||||||
|
public MembershipStatusSelectionModel(BigDecimalParameter param) {
|
||||||
|
super(MembershipStatus.class.getName(), MembershipStatus.BASE_DATA_OBJECT_TYPE, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MembershipStatusSelectionModel(String itemClass, String objectType, BigDecimalParameter parameter) {
|
||||||
|
super(itemClass, objectType, parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MembershipStatus getSelectedMembershipStatus(PageState state) {
|
||||||
|
return (MembershipStatus) getSelectedObject(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,166 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.RequestLocal;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.TableActionListener;
|
||||||
|
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.bebop.table.TableColumnModel;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import com.arsdigita.cms.contenttypes.MembershipStatus;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipStatusTable extends Table {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(MembershipStatusTable.class);
|
||||||
|
private MembershipStatusSelectionModel m_statusModel;
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private TableColumn m_statusNameCol;
|
||||||
|
private TableColumn m_editCol;
|
||||||
|
private TableColumn m_delCol;
|
||||||
|
private RequestLocal m_size;
|
||||||
|
private RequestLocal m_editor;
|
||||||
|
protected final static String EDIT_EVENT = "Edit";
|
||||||
|
protected final static String DELETE_EVENT = "Delete";
|
||||||
|
|
||||||
|
public MembershipStatusTable(ItemSelectionModel itemModel, MembershipStatusSelectionModel statusModel) {
|
||||||
|
super();
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_statusModel = statusModel;
|
||||||
|
addColumns();
|
||||||
|
|
||||||
|
m_size = new RequestLocal();
|
||||||
|
m_editor = new RequestLocal() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object initialValue(PageState state) {
|
||||||
|
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
ContentItem item = m_itemModel.getSelectedItem(state);
|
||||||
|
Boolean val = new Boolean(sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM, item));
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Label empty = new Label("There are no status.");
|
||||||
|
setEmptyView(empty);
|
||||||
|
addTableActionListener(new MembershipStatusTableActionListener());
|
||||||
|
setRowSelectionModel(this.m_statusModel);
|
||||||
|
setDefaultCellRenderer(new MembershipStatusTableRenderer());
|
||||||
|
setModelBuilder(new MembershipStatusTableModelBuilder(itemModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addColumns() {
|
||||||
|
TableColumnModel model = getColumnModel();
|
||||||
|
int i = 0;
|
||||||
|
this.m_statusNameCol = new TableColumn(i, "Status name");
|
||||||
|
this.m_editCol = new TableColumn(++i, "Edit");
|
||||||
|
this.m_delCol = new TableColumn(++i, "Delete");
|
||||||
|
|
||||||
|
model.add(this.m_statusNameCol);
|
||||||
|
model.add(this.m_editCol);
|
||||||
|
model.add(this.m_delCol);
|
||||||
|
setColumnModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MembershipStatusTableRenderer implements TableCellRenderer {
|
||||||
|
|
||||||
|
public Component getComponent(Table table, PageState state, Object value, boolean isSelected, Object key, int row, int column) {
|
||||||
|
|
||||||
|
MembershipStatus status = (MembershipStatus) value;
|
||||||
|
boolean isFirst = (row == 0);
|
||||||
|
if (m_size.get(state) == null) {
|
||||||
|
m_size.set(state, new Long(((MembershipStatusTableModelBuilder.MembershipStatusTableModel) table.getTableModel(state)).size()));
|
||||||
|
}
|
||||||
|
boolean isLast = (row == ((Long) m_size.get(state)).intValue() - 1);
|
||||||
|
|
||||||
|
if (column == m_statusNameCol.getModelIndex()) {
|
||||||
|
Label statusNameLabel = new Label(status.getStatusName());
|
||||||
|
return statusNameLabel;
|
||||||
|
} else if (column == m_editCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
if (isSelected) {
|
||||||
|
return new Label(EDIT_EVENT, Label.BOLD);
|
||||||
|
} else {
|
||||||
|
return new ControlLink(EDIT_EVENT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return new Label(EDIT_EVENT);
|
||||||
|
}
|
||||||
|
} else if (column == m_delCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
return new ControlLink(DELETE_EVENT);
|
||||||
|
} else {
|
||||||
|
return new Label(DELETE_EVENT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new UncheckedWrapperException("column index out of bounds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MembershipStatusTableActionListener implements TableActionListener {
|
||||||
|
|
||||||
|
private MembershipStatus getMembershipStatus(TableActionEvent e) {
|
||||||
|
Object o = e.getRowKey();
|
||||||
|
BigDecimal id;
|
||||||
|
if (o instanceof String) {
|
||||||
|
id = new BigDecimal((String) o);
|
||||||
|
} else {
|
||||||
|
id = (BigDecimal) e.getRowKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.exists(id);
|
||||||
|
MembershipStatus status;
|
||||||
|
try {
|
||||||
|
status = (MembershipStatus) DomainObjectFactory.newInstance(new OID(MembershipStatus.BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
} catch (DataObjectNotFoundException ex) {
|
||||||
|
throw new UncheckedWrapperException(ex);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cellSelected(TableActionEvent e) {
|
||||||
|
int col = e.getColumn().intValue();
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
MembershipStatus status = getMembershipStatus(e);
|
||||||
|
Assert.exists(status);
|
||||||
|
|
||||||
|
if (col == m_editCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
m_statusModel.setSelectedObject(state, status);
|
||||||
|
}
|
||||||
|
} else if (col == m_delCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
try {
|
||||||
|
m_statusModel.clearSelection(state);
|
||||||
|
status.delete();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new UncheckedWrapperException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void headSelected(TableActionEvent e) {
|
||||||
|
//Nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.table.TableModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.MembershipStatus;
|
||||||
|
import com.arsdigita.cms.contenttypes.MembershipStatusCollection;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipStatusTableModelBuilder extends LockableImpl implements TableModelBuilder {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(MembershipStatusTableModelBuilder.class);
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public MembershipStatusTableModelBuilder(ItemSelectionModel itemModel) {
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableModel makeModel(Table t, PageState s) {
|
||||||
|
DataCollection statusValues = getStatus(s);
|
||||||
|
|
||||||
|
if (statusValues.isEmpty()) {
|
||||||
|
return Table.EMPTY_MODEL;
|
||||||
|
} else {
|
||||||
|
return new MembershipStatusTableModel(statusValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataCollection getStatus(PageState state) {
|
||||||
|
//Assert.isTrue(this.m_itemModel.isSelected(state), "item selected");
|
||||||
|
return (DataCollection) MembershipStatusCollection.getMembershipStatusCollection().getDomainObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MembershipStatusTableModel implements TableModel {
|
||||||
|
|
||||||
|
MembershipStatus m_status;
|
||||||
|
DataCollection m_statusValues;
|
||||||
|
|
||||||
|
public MembershipStatusTableModel(DataCollection statusValues) {
|
||||||
|
m_statusValues = statusValues;
|
||||||
|
m_status = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColumnCount() {
|
||||||
|
return (int) m_statusValues.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean nextRow() {
|
||||||
|
if (m_statusValues.next()) {
|
||||||
|
DataObject obj = m_statusValues.getDataObject();
|
||||||
|
m_status = (MembershipStatus) DomainObjectFactory.newInstance(obj);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
return m_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_status.getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long size() {
|
||||||
|
return m_statusValues.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,160 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
import com.arsdigita.bebop.ExternalLink;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.RequestLocal;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.TableActionListener;
|
||||||
|
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.bebop.table.TableColumnModel;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.Membership;
|
||||||
|
import com.arsdigita.cms.contenttypes.MembershipStatus;
|
||||||
|
import com.arsdigita.cms.contenttypes.Person;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipTable extends Table {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(MembershipTable.class);
|
||||||
|
private MembershipSelectionModel m_membershipModel;
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
private TableColumn m_personCol;
|
||||||
|
private TableColumn m_statusCol;
|
||||||
|
private TableColumn m_editCol;
|
||||||
|
//private TableColumn m_delCol;
|
||||||
|
private RequestLocal m_size;
|
||||||
|
private RequestLocal m_editor;
|
||||||
|
|
||||||
|
protected final static String EDIT_EVENT = "Edit";
|
||||||
|
protected final static String DELETE_EVENT = "Delete";
|
||||||
|
|
||||||
|
public MembershipTable(ItemSelectionModel itemModel, MembershipSelectionModel membershipModel) {
|
||||||
|
super();
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
this.m_membershipModel = membershipModel;
|
||||||
|
addColumns();
|
||||||
|
|
||||||
|
m_size = new RequestLocal();
|
||||||
|
m_editor = new RequestLocal() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object initialValue(PageState state) {
|
||||||
|
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
ContentItem item = m_itemModel.getSelectedItem(state);
|
||||||
|
Boolean val = new Boolean(sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM, item));
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Label empty = new Label("This organizational unit has no members.");
|
||||||
|
setEmptyView(empty);
|
||||||
|
addTableActionListener(new MembershipTableActionListener());
|
||||||
|
setRowSelectionModel(m_membershipModel);
|
||||||
|
setDefaultCellRenderer(new MembershipTableRenderer());
|
||||||
|
setModelBuilder(new MembershipTableModelBuilder(itemModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addColumns() {
|
||||||
|
TableColumnModel model = getColumnModel();
|
||||||
|
int i = 0;
|
||||||
|
this.m_personCol = new TableColumn(i, "Person");
|
||||||
|
this.m_statusCol = new TableColumn(++i, "Status");
|
||||||
|
this.m_editCol = new TableColumn(++i, "Edit");
|
||||||
|
|
||||||
|
model.add(this.m_personCol);
|
||||||
|
model.add(this.m_statusCol);
|
||||||
|
model.add(this.m_editCol);
|
||||||
|
setColumnModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MembershipTableRenderer implements TableCellRenderer {
|
||||||
|
|
||||||
|
public Component getComponent(Table table, PageState state, Object value, boolean isSelected, Object key, int row, int column) {
|
||||||
|
Membership membership = (Membership) value;
|
||||||
|
if (m_size.get(state) == null) {
|
||||||
|
m_size.set(state, new Long(((MembershipTableModelBuilder.MembershipTableModel) table.getTableModel(state)).size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
String url = membership.getURI(state);
|
||||||
|
if (column == m_personCol.getModelIndex()) {
|
||||||
|
Person person = membership.getTargetItem();
|
||||||
|
String fullName = String.format("%s %s %s, %s", person.getTitlePre(), person.getGivenName(), person.getSurname(), person.getTitlePost());
|
||||||
|
ExternalLink extLink = new ExternalLink(fullName, url);
|
||||||
|
return extLink;
|
||||||
|
} else if(column == m_statusCol.getModelIndex()) {
|
||||||
|
MembershipStatus status = membership.getStatus();
|
||||||
|
return new Label(status.getStatusName());
|
||||||
|
} else if(column == m_editCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
if (isSelected) {
|
||||||
|
return new Label(EDIT_EVENT, Label.BOLD);
|
||||||
|
} else {
|
||||||
|
return new ControlLink(EDIT_EVENT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return new Label(EDIT_EVENT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new UncheckedWrapperException("column out of bounds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MembershipTableActionListener implements TableActionListener {
|
||||||
|
|
||||||
|
private Membership getMembership(TableActionEvent event) {
|
||||||
|
Object obj = event.getRowKey();
|
||||||
|
BigDecimal id;
|
||||||
|
if (obj instanceof String) {
|
||||||
|
id = new BigDecimal((String) obj);
|
||||||
|
} else {
|
||||||
|
id = (BigDecimal) obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.exists(id);
|
||||||
|
Membership membership;
|
||||||
|
try {
|
||||||
|
membership = (Membership) DomainObjectFactory.newInstance(new OID(Membership.BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
} catch (DataObjectNotFoundException ex) {
|
||||||
|
throw new UncheckedWrapperException(ex);
|
||||||
|
}
|
||||||
|
return membership;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cellSelected(TableActionEvent e) {
|
||||||
|
int col = e.getColumn().intValue();
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
Membership membership = getMembership(e);
|
||||||
|
Assert.exists(membership);
|
||||||
|
|
||||||
|
if (col == m_editCol.getModelIndex()) {
|
||||||
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
|
m_membershipModel.setSelectedObject(state, membership);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void headSelected(TableActionEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.table.TableModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.Membership;
|
||||||
|
import com.arsdigita.cms.contenttypes.OrganizationalUnit;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
*/
|
||||||
|
public class MembershipTableModelBuilder extends LockableImpl implements TableModelBuilder {
|
||||||
|
|
||||||
|
private final static Logger logger = Logger.getLogger(MembershipTableModelBuilder.class);
|
||||||
|
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public MembershipTableModelBuilder(ItemSelectionModel itemModel) {
|
||||||
|
this.m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableModel makeModel(Table t, PageState s) {
|
||||||
|
DataCollection members = getMembers(s);
|
||||||
|
|
||||||
|
if(members.isEmpty()) {
|
||||||
|
return Table.EMPTY_MODEL;
|
||||||
|
} else {
|
||||||
|
return new MembershipTableModel(members);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataCollection getMembers(PageState state) {
|
||||||
|
Assert.isTrue(this.m_itemModel.isSelected(state), "item selected");
|
||||||
|
OrganizationalUnit unit = (OrganizationalUnit) this.m_itemModel.getSelectedItem(state);
|
||||||
|
return Membership.getMemberships(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MembershipTableModel implements TableModel {
|
||||||
|
|
||||||
|
Membership m_membership;
|
||||||
|
DataCollection m_memberships;
|
||||||
|
|
||||||
|
public MembershipTableModel(DataCollection memberships) {
|
||||||
|
m_memberships = memberships;
|
||||||
|
m_membership = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColumnCount() {
|
||||||
|
return (int) m_memberships.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean nextRow() {
|
||||||
|
if (m_memberships.next()) {
|
||||||
|
DataObject obj = m_memberships.getDataObject();
|
||||||
|
m_membership = (Membership) DomainObjectFactory.newInstance(obj);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
return m_membership;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_membership.getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long size() {
|
||||||
|
return m_memberships.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.*;
|
||||||
import com.arsdigita.bebop.Component;
|
import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.Form;
|
import com.arsdigita.bebop.Form;
|
||||||
import com.arsdigita.bebop.FormSection;
|
import com.arsdigita.bebop.FormSection;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
import com.arsdigita.bebop.ColumnPanel;
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
import com.arsdigita.bebop.FormData;
|
import com.arsdigita.bebop.FormData;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.ControlLink;
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.Table;
|
import com.arsdigita.bebop.Table;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui.organizationalunit;
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
import com.arsdigita.bebop.FormData;
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
|
@ -41,19 +41,23 @@
|
||||||
// in the section change
|
// in the section change
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if (Utilities.getLastSectionRefresh(section).after(timestamp)) {
|
if (Utilities.getLastSectionRefresh(section).after(timestamp)) {
|
||||||
s_log.error("refreshing itemPage");
|
s_log.debug("refreshing itemPage");
|
||||||
|
s_log.debug("Creating new ContentItemPage instance...");
|
||||||
itemPage = new ContentItemPage();
|
itemPage = new ContentItemPage();
|
||||||
|
s_log.debug("Calling init on new instance...");
|
||||||
itemPage.init();
|
itemPage.init();
|
||||||
|
s_log.debug("Creating time stamp...");
|
||||||
timestamp = new Date();
|
timestamp = new Date();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s_log.debug("Starting dispatch process...");
|
||||||
RequestContext context = DispatcherHelper.getRequestContext(request);
|
RequestContext context = DispatcherHelper.getRequestContext(request);
|
||||||
if(itemPage == null) {
|
if(itemPage == null) {
|
||||||
s_log.error("WARNING: itemPage is NULL");
|
s_log.warn("WARNING: itemPage is NULL");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
s_log.error("ALL OK: itemPage is not null");
|
s_log.info("ALL OK: itemPage is not null");
|
||||||
}
|
}
|
||||||
itemPage.dispatch(request, response, context);
|
itemPage.dispatch(request, response, context);
|
||||||
s_log.debug("exited item.jsp's service method");
|
s_log.debug("exited item.jsp's service method");
|
||||||
|
|
|
||||||
|
|
@ -81,17 +81,15 @@ import org.apache.log4j.Logger;
|
||||||
* @version $Id: Page.java 1270 2006-07-18 13:34:55Z cgyg9330 $
|
* @version $Id: Page.java 1270 2006-07-18 13:34:55Z cgyg9330 $
|
||||||
*/
|
*/
|
||||||
public class Page extends BlockStylable implements Container {
|
public class Page extends BlockStylable implements Container {
|
||||||
|
|
||||||
public static final String versionId =
|
public static final String versionId =
|
||||||
"$Id: Page.java 1270 2006-07-18 13:34:55Z cgyg9330 $" +
|
"$Id: Page.java 1270 2006-07-18 13:34:55Z cgyg9330 $" +
|
||||||
"by $Author: cgyg9330 $, $DateTime: 2004/08/16 18:10:38 $";
|
"by $Author: cgyg9330 $, $DateTime: 2004/08/16 18:10:38 $";
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(Page.class);
|
private static final Logger s_log = Logger.getLogger(Page.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The delimiter character for components naming
|
* The delimiter character for components naming
|
||||||
*/
|
*/
|
||||||
private static final String DELIMITER = ".";
|
private static final String DELIMITER = ".";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The prefix that gets prepended to all state variables. Components must
|
* The prefix that gets prepended to all state variables. Components must
|
||||||
* not use variables starting with this prefix. This guarantees that the
|
* not use variables starting with this prefix. This guarantees that the
|
||||||
|
|
@ -99,33 +97,28 @@ public class Page extends BlockStylable implements Container {
|
||||||
* interfere with each other.
|
* interfere with each other.
|
||||||
*/
|
*/
|
||||||
private static final String COMPONENT_PREFIX = "bbp" + DELIMITER;
|
private static final String COMPONENT_PREFIX = "bbp" + DELIMITER;
|
||||||
|
|
||||||
private static final String INTERNAL = COMPONENT_PREFIX;
|
private static final String INTERNAL = COMPONENT_PREFIX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the special parameter that indicates which component has
|
* The name of the special parameter that indicates which component has
|
||||||
* been selected.
|
* been selected.
|
||||||
*/
|
*/
|
||||||
static final String SELECTED = INTERNAL + "s";
|
static final String SELECTED = INTERNAL + "s";
|
||||||
|
|
||||||
static final String CONTROL_EVENT = INTERNAL + "e";
|
static final String CONTROL_EVENT = INTERNAL + "e";
|
||||||
|
|
||||||
static final String CONTROL_VALUE = INTERNAL + "v";
|
static final String CONTROL_VALUE = INTERNAL + "v";
|
||||||
|
|
||||||
static final Collection CONTROL_EVENT_KEYS;
|
static final Collection CONTROL_EVENT_KEYS;
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
CONTROL_EVENT_KEYS = new ArrayList(3);
|
CONTROL_EVENT_KEYS = new ArrayList(3);
|
||||||
CONTROL_EVENT_KEYS.add(SELECTED);
|
CONTROL_EVENT_KEYS.add(SELECTED);
|
||||||
CONTROL_EVENT_KEYS.add(CONTROL_EVENT);
|
CONTROL_EVENT_KEYS.add(CONTROL_EVENT);
|
||||||
CONTROL_EVENT_KEYS.add(CONTROL_VALUE);
|
CONTROL_EVENT_KEYS.add(CONTROL_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the request parameter used for the visibility state of
|
* The name of the request parameter used for the visibility state of
|
||||||
* components stored in m_invisible.
|
* components stored in m_invisible.
|
||||||
*/
|
*/
|
||||||
static final String INVISIBLE = INTERNAL + "i";
|
static final String INVISIBLE = INTERNAL + "i";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of stateful components (id --> Component)
|
* Map of stateful components (id --> Component)
|
||||||
* SortedMap used because component based hash for page is based on concatenation of
|
* SortedMap used because component based hash for page is based on concatenation of
|
||||||
|
|
@ -134,48 +127,36 @@ public class Page extends BlockStylable implements Container {
|
||||||
*/
|
*/
|
||||||
private SortedMap m_componentMap;
|
private SortedMap m_componentMap;
|
||||||
private List m_components;
|
private List m_components;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of component -> owned parameter collection
|
* Map of component -> owned parameter collection
|
||||||
*/
|
*/
|
||||||
private Map m_componentParameterMap = new HashMap();
|
private Map m_componentParameterMap = new HashMap();
|
||||||
|
|
||||||
private FormModel m_stateModel;
|
private FormModel m_stateModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>Container</code> that renders this <code>Page</code>.
|
* <code>Container</code> that renders this <code>Page</code>.
|
||||||
*/
|
*/
|
||||||
protected Container m_panel;
|
protected Container m_panel;
|
||||||
|
|
||||||
private List m_actionListeners;
|
private List m_actionListeners;
|
||||||
|
|
||||||
private List m_requestListeners;
|
private List m_requestListeners;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The title of the page to be added in the head of HTML output. The
|
* The title of the page to be added in the head of HTML output. The
|
||||||
* title is wrapped in a Label to allow developers to add
|
* title is wrapped in a Label to allow developers to add
|
||||||
* PrintListeners to dynamically change the value of the title.
|
* PrintListeners to dynamically change the value of the title.
|
||||||
*/
|
*/
|
||||||
private Label m_title;
|
private Label m_title;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the actual title for the current request. The title may be
|
* Stores the actual title for the current request. The title may be
|
||||||
* generated with a PrintListener of the m_title Label.
|
* generated with a PrintListener of the m_title Label.
|
||||||
*/
|
*/
|
||||||
private RequestLocal m_currentTitle;
|
private RequestLocal m_currentTitle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of all the client-side stylesheets. The elements of the list
|
* A list of all the client-side stylesheets. The elements of the list
|
||||||
* are of type Page.Stylesheet, defined at the end of this file.
|
* are of type Page.Stylesheet, defined at the end of this file.
|
||||||
*/
|
*/
|
||||||
private List m_clientStylesheets;
|
private List m_clientStylesheets;
|
||||||
|
|
||||||
private StringParameter m_selected;
|
private StringParameter m_selected;
|
||||||
|
|
||||||
private StringParameter m_controlEvent;
|
private StringParameter m_controlEvent;
|
||||||
|
|
||||||
private StringParameter m_controlValue;
|
private StringParameter m_controlValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default (initial) visibility of components. The encoding is
|
* The default (initial) visibility of components. The encoding is
|
||||||
* identical to that for PageState.m_invisible.
|
* identical to that for PageState.m_invisible.
|
||||||
|
|
@ -184,18 +165,15 @@ public class Page extends BlockStylable implements Container {
|
||||||
* PageState.
|
* PageState.
|
||||||
*/
|
*/
|
||||||
protected BitSet m_invisible;
|
protected BitSet m_invisible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The PageErrorDisplay component that will display page state validation
|
* The PageErrorDisplay component that will display page state validation
|
||||||
* errors on this page
|
* errors on this page
|
||||||
*/
|
*/
|
||||||
private Component m_errorDisplay;
|
private Component m_errorDisplay;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether finish() has been called on this Page.
|
* Indicates whether finish() has been called on this Page.
|
||||||
*/
|
*/
|
||||||
private boolean m_finished = false;
|
private boolean m_finished = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* indicates whether pageState.stateAsURL() should export the
|
* indicates whether pageState.stateAsURL() should export the
|
||||||
* entire state for this page, or whether it should only export
|
* entire state for this page, or whether it should only export
|
||||||
|
|
@ -273,10 +251,11 @@ public class Page extends BlockStylable implements Container {
|
||||||
// Initialize the RequestLocal where the title for the current
|
// Initialize the RequestLocal where the title for the current
|
||||||
// request will be kept
|
// request will be kept
|
||||||
m_currentTitle = new RequestLocal() {
|
m_currentTitle = new RequestLocal() {
|
||||||
protected Object initialValue(PageState state) {
|
|
||||||
return m_title.firePrintEvent(state);
|
protected Object initialValue(PageState state) {
|
||||||
}
|
return m_title.firePrintEvent(state);
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Initialize the set of state parameters to hold
|
// Initialize the set of state parameters to hold
|
||||||
// the ones necessary for keeping track of the selected component and
|
// the ones necessary for keeping track of the selected component and
|
||||||
|
|
@ -285,15 +264,15 @@ public class Page extends BlockStylable implements Container {
|
||||||
m_controlEvent = new StringParameter(CONTROL_EVENT);
|
m_controlEvent = new StringParameter(CONTROL_EVENT);
|
||||||
m_controlValue = new StringParameter(CONTROL_VALUE);
|
m_controlValue = new StringParameter(CONTROL_VALUE);
|
||||||
|
|
||||||
m_stateModel=new FormModel("stateModel", true);
|
m_stateModel = new FormModel("stateModel", true);
|
||||||
m_stateModel.addFormParam(m_selected);
|
m_stateModel.addFormParam(m_selected);
|
||||||
m_stateModel.addFormParam(m_controlEvent);
|
m_stateModel.addFormParam(m_controlEvent);
|
||||||
m_stateModel.addFormParam(m_controlValue);
|
m_stateModel.addFormParam(m_controlValue);
|
||||||
|
|
||||||
// Set up the visibility tracking parameters
|
// Set up the visibility tracking parameters
|
||||||
m_invisible = new BitSet(32);
|
m_invisible = new BitSet(32);
|
||||||
BitSetParameter p = new BitSetParameter(INVISIBLE,
|
BitSetParameter p = new BitSetParameter(INVISIBLE,
|
||||||
BitSetParameter.ENCODE_DGAP);
|
BitSetParameter.ENCODE_DGAP);
|
||||||
m_stateModel.addFormParam(p);
|
m_stateModel.addFormParam(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -334,7 +313,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
*/
|
*/
|
||||||
public void add(Component c) {
|
public void add(Component c) {
|
||||||
m_panel.add(c);
|
m_panel.add(c);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -444,7 +423,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
*
|
*
|
||||||
* @author Matthew Booth (mbooth@redhat.com)
|
* @author Matthew Booth (mbooth@redhat.com)
|
||||||
*/
|
*/
|
||||||
public void setPanel( Container c ) {
|
public void setPanel(Container c) {
|
||||||
m_panel = c;
|
m_panel = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -466,7 +445,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
* @return the title of the page for the current request.
|
* @return the title of the page for the current request.
|
||||||
*/
|
*/
|
||||||
public final Label getTitle(PageState state) {
|
public final Label getTitle(PageState state) {
|
||||||
return (Label)m_currentTitle.get(state);
|
return (Label) m_currentTitle.get(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -620,7 +599,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
Element title = page.newChildElement("bebop:title", BEBOP_XML_NS);
|
Element title = page.newChildElement("bebop:title", BEBOP_XML_NS);
|
||||||
title.setText(getTitle(ps).getLabel(ps));
|
title.setText(getTitle(ps).getLabel(ps));
|
||||||
|
|
||||||
for (Iterator i = m_clientStylesheets.iterator(); i.hasNext(); ) {
|
for (Iterator i = m_clientStylesheets.iterator(); i.hasNext();) {
|
||||||
((Stylesheet) i.next()).generateXML(page);
|
((Stylesheet) i.next()).generateXML(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -655,10 +634,10 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Kernel.getConfig().isDebugEnabled() &&
|
if (Kernel.getConfig().isDebugEnabled() &&
|
||||||
debugStructure(state.getRequest()) ) {
|
debugStructure(state.getRequest())) {
|
||||||
|
|
||||||
Element structure =
|
Element structure =
|
||||||
page.newChildElement("bebop:structure", BEBOP_XML_NS);
|
page.newChildElement("bebop:structure", BEBOP_XML_NS);
|
||||||
|
|
||||||
showStructure(state, structure);
|
showStructure(state, structure);
|
||||||
}
|
}
|
||||||
|
|
@ -689,8 +668,8 @@ public class Page extends BlockStylable implements Container {
|
||||||
* @pre response != null
|
* @pre response != null
|
||||||
*/
|
*/
|
||||||
public PageState process(HttpServletRequest request,
|
public PageState process(HttpServletRequest request,
|
||||||
HttpServletResponse response)
|
HttpServletResponse response)
|
||||||
throws ServletException {
|
throws ServletException {
|
||||||
|
|
||||||
PageState result = new PageState(this, request, response);
|
PageState result = new PageState(this, request, response);
|
||||||
try {
|
try {
|
||||||
|
|
@ -744,7 +723,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
* #process(HttpServletRequest,HttpServletResponse)} instead.
|
* #process(HttpServletRequest,HttpServletResponse)} instead.
|
||||||
*/
|
*/
|
||||||
protected PageState prepare(HttpServletRequest req, HttpServletResponse res)
|
protected PageState prepare(HttpServletRequest req, HttpServletResponse res)
|
||||||
throws ServletException {
|
throws ServletException {
|
||||||
|
|
||||||
Assert.assertLocked(this);
|
Assert.assertLocked(this);
|
||||||
PageState state = process(req, res);
|
PageState state = process(req, res);
|
||||||
|
|
@ -763,8 +742,8 @@ public class Page extends BlockStylable implements Container {
|
||||||
* @post res.isCommitted() == (return == null)
|
* @post res.isCommitted() == (return == null)
|
||||||
*/
|
*/
|
||||||
public Document buildDocument(HttpServletRequest req,
|
public Document buildDocument(HttpServletRequest req,
|
||||||
HttpServletResponse res)
|
HttpServletResponse res)
|
||||||
throws ServletException {
|
throws ServletException {
|
||||||
try {
|
try {
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
PageState state = process(req, res);
|
PageState state = process(req, res);
|
||||||
|
|
@ -801,11 +780,15 @@ public class Page extends BlockStylable implements Container {
|
||||||
Assert.assertNotLocked(this);
|
Assert.assertNotLocked(this);
|
||||||
|
|
||||||
Traversal componentRegistrar = new Traversal() {
|
Traversal componentRegistrar = new Traversal() {
|
||||||
protected void act(Component c) {
|
|
||||||
addComponent(c);
|
protected void act(Component c) {
|
||||||
c.register(Page.this);
|
addComponent(c);
|
||||||
}
|
c.register(Page.this);
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
if (m_panel == null) {
|
||||||
|
s_log.warn("m_panel is null");
|
||||||
|
}
|
||||||
componentRegistrar.preorder(m_panel);
|
componentRegistrar.preorder(m_panel);
|
||||||
if (m_errorDisplay != null) {
|
if (m_errorDisplay != null) {
|
||||||
addComponent(m_errorDisplay);
|
addComponent(m_errorDisplay);
|
||||||
|
|
@ -828,10 +811,11 @@ public class Page extends BlockStylable implements Container {
|
||||||
}
|
}
|
||||||
m_stateModel.lock();
|
m_stateModel.lock();
|
||||||
Traversal componentLocker = new Traversal() {
|
Traversal componentLocker = new Traversal() {
|
||||||
protected void act(Component c) {
|
|
||||||
c.lock();
|
protected void act(Component c) {
|
||||||
}
|
c.lock();
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
componentLocker.preorder(m_panel);
|
componentLocker.preorder(m_panel);
|
||||||
|
|
||||||
|
|
@ -896,7 +880,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
protected void fireActionEvent(PageState state) {
|
protected void fireActionEvent(PageState state) {
|
||||||
ActionEvent e = null;
|
ActionEvent e = null;
|
||||||
|
|
||||||
for (Iterator i = m_actionListeners.iterator(); i.hasNext(); ) {
|
for (Iterator i = m_actionListeners.iterator(); i.hasNext();) {
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
e = new ActionEvent(this, state);
|
e = new ActionEvent(this, state);
|
||||||
}
|
}
|
||||||
|
|
@ -922,7 +906,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
protected void fireRequestEvent(PageState state) {
|
protected void fireRequestEvent(PageState state) {
|
||||||
RequestEvent e = null;
|
RequestEvent e = null;
|
||||||
|
|
||||||
for (Iterator i = m_requestListeners.iterator(); i.hasNext(); ) {
|
for (Iterator i = m_requestListeners.iterator(); i.hasNext();) {
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
e = new RequestEvent(this, state);
|
e = new RequestEvent(this, state);
|
||||||
}
|
}
|
||||||
|
|
@ -939,6 +923,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
|
|
||||||
// Client-side stylesheet storage
|
// Client-side stylesheet storage
|
||||||
private class Stylesheet {
|
private class Stylesheet {
|
||||||
|
|
||||||
String m_URI;
|
String m_URI;
|
||||||
String m_type;
|
String m_type;
|
||||||
|
|
||||||
|
|
@ -964,20 +949,19 @@ public class Page extends BlockStylable implements Container {
|
||||||
public void addComponent(Component c) {
|
public void addComponent(Component c) {
|
||||||
Assert.assertNotLocked(this);
|
Assert.assertNotLocked(this);
|
||||||
|
|
||||||
if ( ! stateContains(c) ) {
|
if (!stateContains(c)) {
|
||||||
if(c == null) {
|
if (c == null) {
|
||||||
s_log.error("c is null");
|
s_log.error("c is null");
|
||||||
} else {
|
} /*else {
|
||||||
//s_log.error("c: " + c.toString());
|
s_log.error("c: " + c.toString());
|
||||||
}
|
}*/
|
||||||
String key = c.getKey();
|
String key = c.getKey();
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
key = Integer.toString(m_components.size());
|
key = Integer.toString(m_components.size());
|
||||||
}
|
}
|
||||||
if (m_componentMap.get(key) != null) {
|
if (m_componentMap.get(key) != null) {
|
||||||
throw new IllegalArgumentException
|
throw new IllegalArgumentException("Component key must not be duplicated. The key " +
|
||||||
("Component key must not be duplicated. The key " +
|
key + " is shared by more than one component.");
|
||||||
key + " is shared by more than one component.");
|
|
||||||
}
|
}
|
||||||
m_componentMap.put(key, c);
|
m_componentMap.put(key, c);
|
||||||
m_components.add(c);
|
m_components.add(c);
|
||||||
|
|
@ -1004,15 +988,14 @@ public class Page extends BlockStylable implements Container {
|
||||||
public void addComponentStateParam(Component c, ParameterModel p) {
|
public void addComponentStateParam(Component c, ParameterModel p) {
|
||||||
Assert.assertNotLocked(this);
|
Assert.assertNotLocked(this);
|
||||||
|
|
||||||
if ( ! stateContains(c)) {
|
if (!stateContains(c)) {
|
||||||
throw new IllegalArgumentException
|
throw new IllegalArgumentException("Component must be registered in Page");
|
||||||
("Component must be registered in Page");
|
|
||||||
}
|
}
|
||||||
if ( ! m_stateModel.containsFormParam(p) ) {
|
if (!m_stateModel.containsFormParam(p)) {
|
||||||
p.setName(parameterName(c, p.getName()));
|
p.setName(parameterName(c, p.getName()));
|
||||||
m_stateModel.addFormParam(p);
|
m_stateModel.addFormParam(p);
|
||||||
|
|
||||||
Collection params = (Collection)m_componentParameterMap.get(c);
|
Collection params = (Collection) m_componentParameterMap.get(c);
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
params = new ArrayList();
|
params = new ArrayList();
|
||||||
m_componentParameterMap.put(c, params);
|
m_componentParameterMap.put(c, params);
|
||||||
|
|
@ -1025,10 +1008,9 @@ public class Page extends BlockStylable implements Container {
|
||||||
* <p>Get the parameters registered for a given component.</p>
|
* <p>Get the parameters registered for a given component.</p>
|
||||||
*/
|
*/
|
||||||
public Collection getComponentParameters(Component c) {
|
public Collection getComponentParameters(Component c) {
|
||||||
return (Collection)m_componentParameterMap.get(c);
|
return (Collection) m_componentParameterMap.get(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the state index of a component. This is the number assigned
|
* Gets the state index of a component. This is the number assigned
|
||||||
* to the component in the register traveral
|
* to the component in the register traveral
|
||||||
|
|
@ -1113,7 +1095,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
public boolean isVisibleDefault(Component c) {
|
public boolean isVisibleDefault(Component c) {
|
||||||
Assert.assertTrue(stateContains(c));
|
Assert.assertTrue(stateContains(c));
|
||||||
|
|
||||||
return ! m_invisible.get(stateIndex(c));
|
return !m_invisible.get(stateIndex(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1131,12 +1113,12 @@ public class Page extends BlockStylable implements Container {
|
||||||
* @see Component#setVisible Component.setVisible
|
* @see Component#setVisible Component.setVisible
|
||||||
* @see Component#register Component.register
|
* @see Component#register Component.register
|
||||||
*/
|
*/
|
||||||
public void setVisibleDefault(Component c, boolean v) {
|
public void setVisibleDefault(Component c, boolean v) {
|
||||||
Assert.assertNotLocked(this);
|
Assert.assertNotLocked(this);
|
||||||
|
|
||||||
addComponent(c);
|
addComponent(c);
|
||||||
int i = stateIndex(c);
|
int i = stateIndex(c);
|
||||||
if ( v ) {
|
if (v) {
|
||||||
m_invisible.clear(i);
|
m_invisible.clear(i);
|
||||||
} else {
|
} else {
|
||||||
m_invisible.set(i);
|
m_invisible.set(i);
|
||||||
|
|
@ -1148,7 +1130,7 @@ public class Page extends BlockStylable implements Container {
|
||||||
* <code>c</code>.
|
* <code>c</code>.
|
||||||
*/
|
*/
|
||||||
public String parameterName(Component c, String name) {
|
public String parameterName(Component c, String name) {
|
||||||
if ( c == null || ! stateContains(c) ) {
|
if (c == null || !stateContains(c)) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1164,40 +1146,37 @@ public class Page extends BlockStylable implements Container {
|
||||||
|
|
||||||
void reset(final PageState ps, Component cmpnt) {
|
void reset(final PageState ps, Component cmpnt) {
|
||||||
Traversal resetter = new Traversal() {
|
Traversal resetter = new Traversal() {
|
||||||
protected void act(Component c) {
|
|
||||||
Collection cp = getComponentParameters(c);
|
protected void act(Component c) {
|
||||||
if (cp != null) {
|
Collection cp = getComponentParameters(c);
|
||||||
Iterator iter = cp.iterator();
|
if (cp != null) {
|
||||||
while ( iter.hasNext() ) {
|
Iterator iter = cp.iterator();
|
||||||
ParameterModel p = (ParameterModel) iter.next();
|
while (iter.hasNext()) {
|
||||||
ps.setValue(p, null);
|
ParameterModel p = (ParameterModel) iter.next();
|
||||||
}
|
ps.setValue(p, null);
|
||||||
}
|
}
|
||||||
c.setVisible(ps, isVisibleDefault(c));
|
|
||||||
}
|
}
|
||||||
};
|
c.setVisible(ps, isVisibleDefault(c));
|
||||||
|
}
|
||||||
|
};
|
||||||
resetter.preorder(cmpnt);
|
resetter.preorder(cmpnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the prefix that is prepended to each component's state
|
* Return the prefix that is prepended to each component's state
|
||||||
* parameters to keep them unique.
|
* parameters to keep them unique.
|
||||||
*/
|
*/
|
||||||
private final String componentPrefix(Component c) {
|
private final String componentPrefix(Component c) {
|
||||||
if ( c==null ) {
|
if (c == null) {
|
||||||
return COMPONENT_PREFIX + "g" + DELIMITER;
|
return COMPONENT_PREFIX + "g" + DELIMITER;
|
||||||
} else {
|
} else {
|
||||||
// WRS: preferentially use key if it exists
|
// WRS: preferentially use key if it exists
|
||||||
String key = c.getKey();
|
String key = c.getKey();
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
if ( stateContains(c) ) {
|
if (stateContains(c)) {
|
||||||
key = String.valueOf(stateIndex(c));
|
key = String.valueOf(stateIndex(c));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException
|
throw new IllegalArgumentException("Cannot generate prefix for component: key is null " + "and component " + c.toString() + "/" + c.getKey() + " did not register with page.");
|
||||||
("Cannot generate prefix for component: key is null "
|
|
||||||
+ "and component " + c.toString() + "/" + c.getKey()
|
|
||||||
+ " did not register with page.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return COMPONENT_PREFIX + key + DELIMITER;
|
return COMPONENT_PREFIX + key + DELIMITER;
|
||||||
|
|
@ -1211,19 +1190,18 @@ public class Page extends BlockStylable implements Container {
|
||||||
* @return the unmangled name.
|
* @return the unmangled name.
|
||||||
*/
|
*/
|
||||||
private static final String unmangle(String name) {
|
private static final String unmangle(String name) {
|
||||||
if ( ! name.startsWith(COMPONENT_PREFIX) ) {
|
if (!name.startsWith(COMPONENT_PREFIX)) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
// Find the second occurence of delimiter
|
// Find the second occurence of delimiter
|
||||||
int prefix = name.indexOf(DELIMITER, name.indexOf(DELIMITER)+1);
|
int prefix = name.indexOf(DELIMITER, name.indexOf(DELIMITER) + 1);
|
||||||
if ( prefix >= 0 && prefix < name.length() ) {
|
if (prefix >= 0 && prefix < name.length()) {
|
||||||
return name.substring(prefix+1);
|
return name.substring(prefix + 1);
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Procs for debugging output
|
// Procs for debugging output
|
||||||
|
|
||||||
private static String NAME = "name";
|
private static String NAME = "name";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1241,22 +1219,22 @@ public class Page extends BlockStylable implements Container {
|
||||||
|
|
||||||
// Control event
|
// Control event
|
||||||
Element eventName =
|
Element eventName =
|
||||||
state.newChildElement("bebop:eventName", BEBOP_XML_NS);
|
state.newChildElement("bebop:eventName", BEBOP_XML_NS);
|
||||||
eventName.addAttribute(NAME, m_controlEvent.getName());
|
eventName.addAttribute(NAME, m_controlEvent.getName());
|
||||||
eventName.setText(req.getParameter(m_controlEvent.getName()));
|
eventName.setText(req.getParameter(m_controlEvent.getName()));
|
||||||
Element eventValue =
|
Element eventValue =
|
||||||
state.newChildElement("bebop:eventValue", BEBOP_XML_NS);
|
state.newChildElement("bebop:eventValue", BEBOP_XML_NS);
|
||||||
eventValue.addAttribute(NAME, m_controlValue.getName());
|
eventValue.addAttribute(NAME, m_controlValue.getName());
|
||||||
eventValue.setText(req.getParameter(m_controlValue.getName()));
|
eventValue.setText(req.getParameter(m_controlValue.getName()));
|
||||||
|
|
||||||
// Global parameters
|
// Global parameters
|
||||||
Element globalState =
|
Element globalState =
|
||||||
root.newChildElement("bebop:params", BEBOP_XML_NS);
|
root.newChildElement("bebop:params", BEBOP_XML_NS);
|
||||||
for (Iterator ii=getStateModel().getParameters(); ii.hasNext(); ) {
|
for (Iterator ii = getStateModel().getParameters(); ii.hasNext();) {
|
||||||
ParameterModel p = (ParameterModel) ii.next();
|
ParameterModel p = (ParameterModel) ii.next();
|
||||||
if ( !p.getName().startsWith(COMPONENT_PREFIX) ) {
|
if (!p.getName().startsWith(COMPONENT_PREFIX)) {
|
||||||
Element param =
|
Element param =
|
||||||
globalState.newChildElement("bebop:param", BEBOP_XML_NS);
|
globalState.newChildElement("bebop:param", BEBOP_XML_NS);
|
||||||
param.addAttribute(NAME, p.getName());
|
param.addAttribute(NAME, p.getName());
|
||||||
param.setText(String.valueOf(s.getValue(p)));
|
param.setText(String.valueOf(s.getValue(p)));
|
||||||
}
|
}
|
||||||
|
|
@ -1277,32 +1255,36 @@ public class Page extends BlockStylable implements Container {
|
||||||
cmp.addAttribute("isVisible", (s.isVisible(c) ? "yes" : "no"));
|
cmp.addAttribute("isVisible", (s.isVisible(c) ? "yes" : "no"));
|
||||||
cmp.addAttribute("class", c.getClass().getName());
|
cmp.addAttribute("class", c.getClass().getName());
|
||||||
|
|
||||||
if ( c.getKey() != null ) {
|
if (c.getKey() != null) {
|
||||||
String prefix = componentPrefix(c);
|
String prefix = componentPrefix(c);
|
||||||
for (Iterator i = getStateModel().getParameters(); i.hasNext(); ) {
|
for (Iterator i = getStateModel().getParameters(); i.hasNext();) {
|
||||||
ParameterModel p = (ParameterModel) i.next();
|
ParameterModel p = (ParameterModel) i.next();
|
||||||
if ( !p.getName().startsWith(prefix) ) { continue; }
|
if (!p.getName().startsWith(prefix)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Element param =
|
Element param =
|
||||||
parent.newChildElement("bebop:param", BEBOP_XML_NS);
|
parent.newChildElement("bebop:param", BEBOP_XML_NS);
|
||||||
param.addAttribute(NAME, unmangle(p.getName()));
|
param.addAttribute(NAME, unmangle(p.getName()));
|
||||||
param.addAttribute("defaultValue",
|
param.addAttribute("defaultValue",
|
||||||
String.valueOf(req.getParameter(p.getName())));
|
String.valueOf(req.getParameter(p.getName())));
|
||||||
param.addAttribute("currentValue", String.valueOf(s.getValue(p)));
|
param.addAttribute("currentValue", String.valueOf(s.getValue(p)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Iterator i = c.children(); i.hasNext(); ) {
|
for (Iterator i = c.children(); i.hasNext();) {
|
||||||
showVisibility(s, ((Component) i.next()), cmp);
|
showVisibility(s, ((Component) i.next()), cmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getDebugLabel(Component c) {
|
private static String getDebugLabel(Component c) {
|
||||||
if ( c.getKey() != null ) { return c.getKey(); }
|
if (c.getKey() != null) {
|
||||||
|
return c.getKey();
|
||||||
|
}
|
||||||
|
|
||||||
String klass = c.getClass().getName();
|
String klass = c.getClass().getName();
|
||||||
return klass.substring(klass.lastIndexOf(".")+1, klass.length());
|
return klass.substring(klass.lastIndexOf(".") + 1, klass.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return a string that represents an ordered list of component
|
* return a string that represents an ordered list of component
|
||||||
* ids used on the page. For situations where only the
|
* ids used on the page. For situations where only the
|
||||||
|
|
@ -1310,25 +1292,25 @@ public class Page extends BlockStylable implements Container {
|
||||||
* by implementations of hashCode & equals
|
* by implementations of hashCode & equals
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getComponentString () {
|
public String getComponentString() {
|
||||||
Iterator it = m_componentMap.keySet().iterator();
|
Iterator it = m_componentMap.keySet().iterator();
|
||||||
/*int hash = 0;
|
/*int hash = 0;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
String componentId = (String)it.next();
|
String componentId = (String)it.next();
|
||||||
s_log.debug("component id = " + componentId);
|
s_log.debug("component id = " + componentId);
|
||||||
hash = hash | componentId.hashCode();
|
hash = hash | componentId.hashCode();
|
||||||
s_log.debug("hash so far = " + hash);
|
s_log.debug("hash so far = " + hash);
|
||||||
}*/
|
}*/
|
||||||
Date start = new Date();
|
Date start = new Date();
|
||||||
|
|
||||||
StringBuffer hashString = new StringBuffer();
|
StringBuffer hashString = new StringBuffer();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
String componentId = (String)it.next();
|
String componentId = (String) it.next();
|
||||||
hashString.append(componentId);
|
hashString.append(componentId);
|
||||||
}
|
}
|
||||||
s_log.debug("Time to create hashCode for page: " + (new Date().getTime() - start.getTime()));
|
s_log.debug("Time to create hashCode for page: " + (new Date().getTime() - start.getTime()));
|
||||||
return hashString.toString();
|
return hashString.toString();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,8 @@ public abstract class Traversal {
|
||||||
("Component " + c + " is part of a cycle");
|
("Component " + c + " is part of a cycle");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//s_log.debug("preorder called for component " + c.toString());
|
||||||
|
|
||||||
int flag = test(c);
|
int flag = test(c);
|
||||||
|
|
||||||
if (flag == PERFORM_ACTION) {
|
if (flag == PERFORM_ACTION) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue