* GenericPerson und GenericContact angepaßt

* Tabelle für Kontaktarten eingeführt - hat allerdings noch einen unschönen Namen (GenericContactType) was eigentlich GenericContact - Type bedeuten sollte, aber wahrscheinlich als Generic - ContentType interpretiert wird.
 * Erste Version von GenericOrganization.pdl

git-svn-id: https://svn.libreccm.org/ccm/trunk@466 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2010-06-30 08:18:23 +00:00
parent fe4c91f27d
commit 2ac510fb7d
22 changed files with 1461 additions and 90 deletions

View File

@ -1,3 +1,22 @@
//
// Copyright (C) 2010 Sören Bernstein, for the Center of Social Politics of the University of Bremen
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//
model com.arsdigita.cms.contenttypes; model com.arsdigita.cms.contenttypes;
import com.arsdigita.kernel.ACSObject; import com.arsdigita.kernel.ACSObject;
@ -6,9 +25,6 @@ import com.arsdigita.cms.*;
// Contact Object // Contact Object
object type GenericContact extends ContentPage { object type GenericContact extends ContentPage {
GenericPerson [0..1] person = join cms_contacts.person_id
to cms_persons.person_id;
GenericAddress [0..1] address = join cms_contacts.address_id GenericAddress [0..1] address = join cms_contacts.address_id
to cms_addresses.address_id; to cms_addresses.address_id;
@ -27,3 +43,31 @@ object type GenericContactEntry extends ContentItem {
reference key ( cms_contactEntries.contactentry_id ); reference key ( cms_contactEntries.contactentry_id );
} }
object type GenericContactType extends ACSObject {
String[1..1] key = cms_contacttypes.key VARCHAR(100);
String[1..1] language = cms_contacttypes.language VARCHAR(2);
String[1..1] name = cms_contacttypes.name VARCHAR(100);
reference key (cms_contacttypes.contacttypes_id);
unique (key, language);
}
association {
GenericPerson[0..1] person = join cms_contacts.contact_id
to cms_person_contact_map.contact_id,
join cms_person_contact_map.person_id
to cms_persons.person_id;
GenericContact[0..n] contacts = join cms_persons.person_id
to cms_person_contact_map.person_id,
join cms_person_contact_map.contact_id
to cms_contacts.contact_id;
// Link Attribute
BigDecimal[1..1] contact_order = cms_person_contact_map.contact_order INTEGER;
// Can't use a join statement here because contacttype_id is not unique
String[1..1] contact_type = cms_person_contact_map.key VARCHAR(100);
}

View File

@ -0,0 +1,67 @@
//
// Copyright (C) 2010 Sören Bernstein, for the Center of Social Politics of the University of Bremen
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//
model com.arsdigita.cms.contenttypes;
//import com.arsdigita.cms.ContentPage;
//object GenericOrganization extends ContentPage {
// String[0..1] addendum = cms_organization.nameaddendum VARCHAR(512);
// reference key (cms_organization.organization_id);
//}
//object OrganizationRole extends XXX {
// String[1..1] roleName = cms_organizationrole.name VARCHAR(256);
//
//}
//association {
// GenericOrganization[0..n] children = join cms_organization.organization_id
// to cms_organization_organization_map.children_id,
// join cms_organization_organization_map.parent_id
// to cms_organization.organization_id;
// GenericOrganization[0..1] parent = join cms_organization.organization_id
// to cms_organization_organization_map.parent_id,
// join cms_organization_organization_map.children_id
// to cms_organization.organization_id;
// Integer[0..1] order = cms_organization_organization_map.order INTERGER;
//}
//association {
// GenericOrganization[0..1] organization = join cms_contacts.contact_id
// to cms_organization_contact_map.contact_id,
// join cms_organization_contact_map.organization_id
// to cms_organizations.organization_id;
// GenericContact[0..n] contacts = join cms_organizations.organization_id
// to cms_organization_contact_map.organization_id,
// join cms_organization_contact_map.contact_id
// to cms_contacts.contact_id;
// Link Attribute
// String contact_type = cms_organization_contact_map.contact_type VARCHAR(100);
// BigDecimal contact_order = cms_organization_contact_map.contact_order INTEGER;
//}

View File

@ -1,5 +1,5 @@
// //
// Copyright (C) 2009 Jens Pelzetter, for the Center of Social Politics of the University of Bremen // Copyright (C) 2010 Sören Bernstein, for the Center of Social Politics of the 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
@ -27,5 +27,7 @@ object type GenericPerson extends ContentPage {
String[0..1] titlepre = cms_persons.titlepre VARCHAR(256); String[0..1] titlepre = cms_persons.titlepre VARCHAR(256);
String[0..1] titlepost = cms_persons.titlepost VARCHAR(256); String[0..1] titlepost = cms_persons.titlepost VARCHAR(256);
Date[0..1] birthdate = cms_persons.birthdate DATE;
reference key (cms_persons.person_id); reference key (cms_persons.person_id);
} }

View File

@ -11,8 +11,7 @@
classname="com.arsdigita.cms.contenttypes.GenericPerson" classname="com.arsdigita.cms.contenttypes.GenericPerson"
isInternal="yes"> isInternal="yes">
<ctd:authoring-kit <ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
<ctd:authoring-step <ctd:authoring-step
labelKey="cms.contenttypes.shared.basic_properties.title" labelKey="cms.contenttypes.shared.basic_properties.title"
@ -22,6 +21,14 @@
component="com.arsdigita.cms.contenttypes.ui.GenericPersonPropertiesStep" component="com.arsdigita.cms.contenttypes.ui.GenericPersonPropertiesStep"
ordering="1"/> ordering="1"/>
<ctd:authoring-step
labelKey="person.authoring.contact_properties.title"
labelBundle="com.arsdigita.cms.contenttypes.ContenttypesResources"
descriptionKey="person.authoring.contact_properties.description"
descriptionBundle="com.arsdigita.cms.contenttypes.ContenttypesResources"
component="com.arsdigita.cms.contenttypes.ui.GenericPersonContactPropertiesStep"
ordering="2"/>
<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>

View File

@ -1,3 +1,5 @@
address.authoring.basic_properties.title=Basic Properties
cms.contenttypes.ui.address.address=Address cms.contenttypes.ui.address.address=Address
cms.contenttypes.ui.address.postal_code=Postal Code cms.contenttypes.ui.address.postal_code=Postal Code
cms.contenttypes.ui.address.city=City cms.contenttypes.ui.address.city=City
@ -5,12 +7,20 @@ cms.contenttypes.ui.address.state=State
cms.contenttypes.ui.address.iso_country_code=Country cms.contenttypes.ui.address.iso_country_code=Country
cms.contenttypes.ui.address.error_iso_country=You must select a country cms.contenttypes.ui.address.error_iso_country=You must select a country
person.authoring.contact_properties.title=Contacts
person.authoring.contact_properties.description=Manage contacts
cms.contenttypes.ui.person.basic_properties=Basic Properties
cms.contenttypes.ui.person.edit_basic_properties=Edit Basic Properties
cms.contenttypes.ui.person.surname=Surname cms.contenttypes.ui.person.surname=Surname
cms.contenttypes.ui.person.givenname=Given name cms.contenttypes.ui.person.givenname=Given name
cms.contenttypes.ui.person.titlepre=Title cms.contenttypes.ui.person.titlepre=Title
cms.contenttypes.ui.person.titlepost=Name appendix cms.contenttypes.ui.person.titlepost=Name appendix
cms.contenttypes.ui.person.birthdate=Birth date
address.authoring.basic_properties.title=Basic Properties cms.contenttypes.ui.person.contact=Contacts
cms.contenttypes.ui.person.contacts.none=No contacts
cms.contenttypes.ui.person.add_contact=Add contact
cms.contenttypes.ui.contact.basic_properties=Basic Properties cms.contenttypes.ui.contact.basic_properties=Basic Properties
cms.contenttypes.ui.contact.edit_basic_properties=Edit Basic Properties cms.contenttypes.ui.contact.edit_basic_properties=Edit Basic Properties

View File

@ -1,3 +1,5 @@
address.authoring.basic_properties.title=Eigenschaften von Adresse
cms.contenttypes.ui.address.address=Anschrift cms.contenttypes.ui.address.address=Anschrift
cms.contenttypes.ui.address.postal_code=Postleitzahl cms.contenttypes.ui.address.postal_code=Postleitzahl
cms.contenttypes.ui.address.city=Stadt cms.contenttypes.ui.address.city=Stadt
@ -5,12 +7,20 @@ cms.contenttypes.ui.address.state=Bundesland
cms.contenttypes.ui.address.iso_country_code=Land cms.contenttypes.ui.address.iso_country_code=Land
cms.contenttypes.ui.address.error_iso_country=Bitte w\u00E4hlen Sie ein Land aus cms.contenttypes.ui.address.error_iso_country=Bitte w\u00E4hlen Sie ein Land aus
person.authoring.contact_properties.title=Kontakte
person.authoring.contact_properties.description=Kontakte verwalten
cms.contenttypes.ui.person.basic_properties=Basiseigenschaften
cms.contenttypes.ui.person.edit_basic_properties=Bearbeiten
cms.contenttypes.ui.person.surname=Nachname cms.contenttypes.ui.person.surname=Nachname
cms.contenttypes.ui.person.givenname=Vorname cms.contenttypes.ui.person.givenname=Vorname
cms.contenttypes.ui.person.titlepre=Titel cms.contenttypes.ui.person.titlepre=Titel
cms.contenttypes.ui.person.titlepost=Namesanhang cms.contenttypes.ui.person.titlepost=Namesanhang
cms.contenttypes.ui.person.birthdate=Geburtstag
address.authoring.basic_properties.title=Eigenschaften von Adresse cms.contenttypes.ui.person.contact=Kontakte
cms.contenttypes.ui.person.contacts.none=Zur Zeit sind keine Kontakte vorhanden
cms.contenttypes.ui.person.add_contact=Kontakt hinzuf\u00FCgen
cms.contenttypes.ui.contact.basic_properties=Eigenschaften von Contact cms.contenttypes.ui.contact.basic_properties=Eigenschaften von Contact
cms.contenttypes.ui.contact.edit_basic_properties=Bearbeiten cms.contenttypes.ui.contact.edit_basic_properties=Bearbeiten
@ -63,4 +73,4 @@ cms.contenttypes.ui.contact.contactEntry.key.im=Instant Messenger
cms.contenttypes.ui.contact.contactEntry.key.www=Homepage cms.contenttypes.ui.contact.contactEntry.key.www=Homepage
cms.contenttypes.ui.contact.contactEntry.none=Zur Zeit sind keine Kontaktinformatioonen vorhanden cms.contenttypes.ui.contact.contactEntry.none=Zur Zeit sind keine Kontaktinformationen vorhanden

View File

@ -33,7 +33,7 @@ import org.apache.log4j.Logger;
*/ */
public class GenericContactEntry extends ContentItem { public class GenericContactEntry extends ContentItem {
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.ContactEntry"; public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericContactEntry";
private static final String BASE_DATA_OBJECT_PACKAGE = "com.arsdigita.cms.contenttypes"; private static final String BASE_DATA_OBJECT_PACKAGE = "com.arsdigita.cms.contenttypes";
private static final Logger s_log = Logger.getLogger(GenericContactEntry.class); private static final Logger s_log = Logger.getLogger(GenericContactEntry.class);

View File

@ -0,0 +1,97 @@
/*
* GenericContactType.java
*
*/
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 quasi
*/
public class GenericContactType extends ACSObject {
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericContactType";
private static final Logger s_log = Logger.getLogger(GenericContactType.class);
/** PDL property names */
public static final String KEY = "key";
public static final String LANGUAGE = "language";
public static final String NAME = "name";
/**
* Creates a new instance of GenericContactEntry
*/
public GenericContactType() {
this(BASE_DATA_OBJECT_TYPE);
}
public GenericContactType(String typeName) {
super(typeName);
}
public GenericContactType(OID oid) {
super(oid);
}
public GenericContactType(DataObject object) {
super(object);
}
/**
* Constructor. Retrieves an object instance with the given id.
* @param id the id of the object to retrieve
*/
public GenericContactType(BigDecimal id) throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
public GenericContactType(String key, String language, String name, int order) {
this();
setKey(key);
setLanguage(language);
setName(name);
save();
}
/////////////////////////////////////////////////
// accessors
// Get key
public String getKey() {
return (String) get(KEY);
}
// Set key
public void setKey(String key) {
set(KEY, key);
}
// Get language
public String getLanguage() {
return (String) get(LANGUAGE);
}
public void setLanguage(String language) {
set(LANGUAGE, language);
}
// Get name
public String getName() {
return (String) get(NAME);
}
// Set name
public void setName(String name) {
set(NAME, name);
}
}

View File

@ -0,0 +1,95 @@
/*
* GenericContactEntryCollection.java
*
* Created on 13. Mai 2009, 12:32
*
*
*/
package com.arsdigita.cms.contenttypes;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.Filter;
import com.arsdigita.persistence.SessionManager;
/**
*
* @author quasi
*/
public class GenericContactTypeCollection extends DomainCollection {
/**
* Creates a new instance of GenericContactEntryCollection
*/
public GenericContactTypeCollection() {
this((DataCollection) SessionManager.getSession().retrieve(GenericContactType.BASE_DATA_OBJECT_TYPE));
this.addOrder("key, language");
}
public GenericContactTypeCollection(String key) {
this();
this.addEqualsFilter("key", key);
}
public GenericContactTypeCollection(DataCollection dataCollection) {
super(dataCollection);
}
public final String getKey() {
return (String) getContactType().getKey();
}
public final String getLanguage() {
return (String) getContactType().getLanguage();
}
public final String getName() {
return (String) getContactType().getName();
}
public GenericContactType getContactType() {
return new GenericContactType(m_dataCollection.getDataObject());
}
// Get ContactType in desired language
public GenericContactType getContactType(String key, String language) {
// First, test the current element
if(this.getKey().equals(key) && this.getLanguage().equals(language)) {
return this.getContactType();
} else {
// Rewind the collection and search for a matching element
this.rewind();
while(this.next()) {
if(this.getKey().equals(key) && this.getLanguage().equals(language)){
return this.getContactType();
}
}
}
// Nothing found
return null;
}
public void filterLanguage(String language) {
this.addEqualsFilter("language", language);
}
public boolean hasLanguage(String language) {
boolean retVal = false;
Filter languageFilter = this.getFilterFactory().equals("language", language);
this.addFilter(languageFilter);
if(this.size() > 0) {
retVal = true;
}
this.removeFilter(languageFilter);
return retVal;
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009 Jens Pelzetter, for the Center of Social Politics of the University of Bremen * Copyright (C) 2010 Sören Bernstein, for the Center of Social Politics of the 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
@ -19,10 +19,10 @@
package com.arsdigita.cms.contenttypes; package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.contenttypes.*;
import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentPage;
import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
@ -40,6 +40,10 @@ public class GenericPerson extends ContentPage {
public static final String GIVENNAME = "givenname"; public static final String GIVENNAME = "givenname";
public static final String TITLEPRE = "titlepre"; public static final String TITLEPRE = "titlepre";
public static final String TITLEPOST = "titlepost"; public static final String TITLEPOST = "titlepost";
public static final String BIRTHDATE = "birthdate";
public static final String CONTACTS = "contacts";
public static final String CONTACT_TYPE = "contact_type";
public static final String CONTACT_ORDER = "contact_order";
/** Data object type for this domain object */ /** Data object type for this domain object */
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericPerson"; public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericPerson";
@ -67,6 +71,7 @@ public class GenericPerson extends ContentPage {
super(type); super(type);
} }
@Override
public void beforeSave() { public void beforeSave() {
super.beforeSave(); super.beforeSave();
@ -101,4 +106,37 @@ public class GenericPerson extends ContentPage {
public void setTitlePost(String titlePost) { public void setTitlePost(String titlePost) {
set(TITLEPOST, titlePost); set(TITLEPOST, titlePost);
} }
public String getBirthdate() {
return (String)get(BIRTHDATE);
}
public void setBirthdate(String birthdate) {
set(BIRTHDATE, birthdate);
}
// Get all contacts for this person
public GenericPersonContactCollection getContacts() {
return new GenericPersonContactCollection((DataCollection) get(CONTACTS));
}
// Add a contact for this person
public void addContact(GenericContact contact, String contactType) {
Assert.exists(contact, GenericContact.class);
DataObject link = add(CONTACTS, contact);
link.set(CONTACT_TYPE, contactType);
link.set(CONTACT_ORDER, BigDecimal.valueOf(getContacts().size()));
}
// Remove a contact for this person
public void removeContact(GenericContact contact) {
Assert.exists(contact, GenericContact.class);
remove(CONTACTS, contact);
}
public boolean hasContacts() {
return !this.getContacts().isEmpty();
}
} }

View File

@ -0,0 +1,55 @@
/*
* HealthCareFacilityContactCollection.java
*
* Created on 26. Juli 2009, 15:30
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.arsdigita.cms.contenttypes;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.persistence.DataCollection;
import java.math.BigDecimal;
/**
*
* @author quasi
*/
public class GenericPersonContactCollection extends DomainCollection {
public static final String ORDER = "link.contact_order asc";
public static final String CONTACT_TYPE = "link.contact_type";
public static final String CONTACT_ORDER = "link.contact_order";
/**
* Creates a new instance of GenericPersonContactCollection
*/
public GenericPersonContactCollection(DataCollection dataCollection) {
super(dataCollection);
m_dataCollection.addOrder(ORDER);
}
// Get the contact type of the link
public String getContactType() {
return (String) m_dataCollection.get(CONTACT_TYPE);
}
// Get the contact order of the link
public String getContactOrder() {
String retVal = ((BigDecimal) m_dataCollection.get(CONTACT_ORDER)).toString();
if(retVal == null || retVal.isEmpty()) {
retVal = String.valueOf(this.getPosition());
}
return retVal;
}
public GenericContact getContact() {
return new GenericContact(m_dataCollection.getDataObject());
}
}

View File

@ -20,14 +20,23 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.PrintEvent; import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener; 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.form.Submit;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.contenttypes.GenericPerson; import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.GenericContact; import com.arsdigita.cms.contenttypes.GenericContact;
import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.contenttypes.GenericContactType;
import com.arsdigita.cms.contenttypes.GenericContactTypeCollection;
import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -81,6 +90,24 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
add(new Label((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_person").localize())); add(new Label((String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.select_person").localize()));
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.GenericPerson")); this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.GenericPerson"));
add(this.m_itemSearch); add(this.m_itemSearch);
// GenericContact type field
add(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.type")));
ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACT_TYPE);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
// Add the Options to the SingleSelect widget
GenericContactTypeCollection contacttypes = new GenericContactTypeCollection();
contacttypes.filterLanguage(DispatcherHelper.getNegotiatedLocale().getLanguage());
while (contacttypes.next()) {
GenericContactType ct = contacttypes.getContactType();
contactType.addOption(new Option(ct.getKey(), ct.getName()));
}
add(contactType);
} }
public void init(FormSectionEvent fse) { public void init(FormSectionEvent fse) {

View File

@ -0,0 +1,144 @@
/*
* Copyright (C) 2010 Sören Bernstein All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SaveCancelSection;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.contenttypes.GenericContactType;
import com.arsdigita.cms.contenttypes.GenericContactTypeCollection;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.KernelConfig;
import java.util.Locale;
import java.util.StringTokenizer;
import org.apache.log4j.Logger;
/**
* Generates a form for creating new localisations for the given category.
*
* This class is part of the admin GUI of CCM and extends the standard form
* in order to present forms for managing the multi-language categories.
*
* @author Sören Bernstein (quasimodo) quasi@zes.uni-bremen.de
*/
public class GenericContactTypeAddForm extends BasicItemForm {
public final static String KEY = GenericContactType.KEY;
public final static String LANGUAGE = GenericContactType.LANGUAGE;
public final static String NAME = GenericContactType.NAME;
private static final Logger s_log = Logger.getLogger(GenericContactTypeAddForm.class);
private GenericPersonPropertiesStep m_step;
private SaveCancelSection m_saveCancelSection;
private ItemSelectionModel m_itemModel;
private SingleSelect language;
/** Creates a new instance of CategoryLocalizationAddForm */
public GenericContactTypeAddForm(ItemSelectionModel itemModel) {
super("ContactEntryAddForm", itemModel);
m_itemModel = itemModel;
}
@Override
protected void addWidgets() {
// Key
add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contacttypes.key").localize()));
ParameterModel keyParam = new StringParameter(KEY);
keyParam.addParameterListener(new NotNullValidationListener());
keyParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField key = new TextField(keyParam);
add(key);
// Language
add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contacttypes.language").localize()));
ParameterModel languageParam = new StringParameter(LANGUAGE);
language = new SingleSelect(languageParam);
language.addValidationListener(new NotNullValidationListener());
language.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
// Name
add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contacttypes.name").localize()));
ParameterModel nameParam = new StringParameter(NAME);
nameParam.addParameterListener(new NotNullValidationListener());
nameParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField name = new TextField(nameParam);
add(name);
}
public void init(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
GenericContactType contacttype = (GenericContactType) getItemSelectionModel().getSelectedObject(state);
GenericContactTypeCollection contacttypeCollection = new GenericContactTypeCollection(contacttype.getKey());
// all supported languages (by registry entry)
KernelConfig kernelConfig = Kernel.getConfig();
StringTokenizer strTok = kernelConfig.getSupportedLanguagesTokenizer();
while (strTok.hasMoreTokens()) {
String code = strTok.nextToken();
// If lanuage exists, remove it from the selection list
if (!contacttypeCollection.hasLanguage(code)) {
language.addOption(new Option(code, new Locale(code).getDisplayLanguage()), state);
}
}
data.put(KEY, contacttype.getKey());
data.put(LANGUAGE, contacttype.getLanguage());
data.put(NAME, contacttype.getName());
setVisible(state, true);
}
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
GenericContactType contacttype = (GenericContactType) getItemSelectionModel().getSelectedObject(state);
//
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
contacttype.setKey((String) data.get(KEY));
contacttype.setLanguage((String) data.get(LANGUAGE));
contacttype.setName((String) data.get(NAME));
}
init(fse);
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
/**
* @author Sören Bernstein
*/
public class GenericContactTypePropertiesStep extends SimpleEditStep {
/** The name of the editing sheet added to this step */
private static String ADD_CONTACT_SHEET_NAME = "addContactType";
public GenericContactTypePropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
this(itemModel, parent, null);
}
public GenericContactTypePropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) {
super(itemModel, parent, prefix);
BasicItemForm addContactTypeSheet = new GenericContactTypeAddForm(itemModel);
add(ADD_CONTACT_SHEET_NAME,
(String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.add_contacttype").localize(),
new WorkflowLockedComponentAccess(addContactTypeSheet, itemModel),
addContactTypeSheet.getSaveCancelSection().getCancelButton());
GenericContactTypeTable contacttypesTable = new GenericContactTypeTable(itemModel);
setDisplayComponent(contacttypesTable);
}
}

View File

@ -0,0 +1,250 @@
/*
* Copyright (C) 2010 Sören Bernstein All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
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.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.SecurityManager;
import com.arsdigita.cms.contenttypes.GenericContactType;
import com.arsdigita.cms.contenttypes.GenericContactTypeCollection;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.util.LockableImpl;
import java.math.BigDecimal;
/**
*
*
* @author Sören Bernstein (quasimodo) quasi@barkhof.uni-bremen.de
*/
public class GenericContactTypeTable extends Table implements TableActionListener {
private final String TABLE_COL_EDIT = "table_col_edit";
private final String TABLE_COL_DEL = "table_col_del";
private ItemSelectionModel m_itemModel;
/**
* Creates a new instance of GenericContactTypeTable
*/
public GenericContactTypeTable(final ItemSelectionModel itemModel) {
super();
this.m_itemModel = itemModel;
// if table is empty:
setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contacttypes.none")));
TableColumnModel tab_model = getColumnModel();
// define columns
tab_model.add(new TableColumn(0, ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contacttypes.key").localize(), TABLE_COL_EDIT));
tab_model.add(new TableColumn(1, ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contacttypes.title").localize()));
tab_model.add(new TableColumn(2, ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contacttypes.action").localize(), TABLE_COL_DEL));
setModelBuilder(new GenericContactTypeTableModelBuilder(itemModel));
tab_model.get(0).setCellRenderer(new EditCellRenderer());
tab_model.get(2).setCellRenderer(new DeleteCellRenderer());
addTableActionListener(this);
}
/**
* XXXX
*
*/
private class GenericContactTypeTableModelBuilder extends LockableImpl implements TableModelBuilder {
private ItemSelectionModel m_itemModel;
public GenericContactTypeTableModelBuilder(ItemSelectionModel itemModel) {
m_itemModel = itemModel;
}
public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state);
GenericContactType contacttype = (GenericContactType) m_itemModel.getSelectedObject(state);
return new GenericContactTypeTableModel(table, state, contacttype);
}
}
/**
* XXX
*
*/
private class GenericContactTypeTableModel implements TableModel {
final private int MAX_DESC_LENGTH = 25;
private Table m_table;
private GenericContactType m_contacttype;
private GenericContactTypeCollection m_contacttypeCollection = new GenericContactTypeCollection();
private GenericContactTypeTableModel(Table t, PageState ps, GenericContactType contacttype) {
m_table = t;
m_contacttype = contacttype;
// m_contacttypeCollection.filterLanguage(DispatcherHelper.getNegotiatedLocale().getLanguage());
}
public int getColumnCount() {
return m_table.getColumnModel().size();
}
/**
* Check collection for the existence of another row.
*
* If exists, fetch the value of current GenericPersonEntryCollection object
* into m_comntact class variable.
*/
public boolean nextRow() {
if (m_contacttypeCollection != null && m_contacttypeCollection.next()) {
m_contacttype = m_contacttypeCollection.getContactType();
return true;
} else {
return false;
}
}
/**
* Return the
* @see com.arsdigita.bebop.table.TableModel#getElementAt(int)
*/
public Object getElementAt(int columnIndex) {
switch (columnIndex) {
case 0:
return m_contacttypeCollection.getKey();
case 1:
return m_contacttypeCollection.getName();
case 2:
return GlobalizationUtil.globalize("cms.ui.delete").localize();
default:
return null;
}
}
/**
*
* @see com.arsdigita.bebop.table.TableModel#getKeyAt(int)
*/
public Object getKeyAt(int columnIndex) {
return m_contacttype.getID();
}
}
/**
* Check for the permissions to edit item and put either a Label or
* a ControlLink accordingly.
*/
private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key,
int row, int column) {
SecurityManager sm = Utilities.getSecurityManager(state);
GenericContactType contacttype = (GenericContactType) m_itemModel.getSelectedObject(state);
// boolean canEdit = sm.canAccess(state.getRequest(),
// SecurityManager.EDIT_ITEM,
// contacttype);
// if (canEdit) {
ControlLink link = new ControlLink(value.toString());
return link;
// } else {
// return new Label(value.toString());
// }
}
}
/**
* Check for the permissions to delete item and put either a Label or
* a ControlLink accordingly.
*/
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key,
int row, int column) {
SecurityManager sm = Utilities.getSecurityManager(state);
GenericContactType contacttype = (GenericContactType) m_itemModel.getSelectedObject(state);
// boolean canDelete = sm.canAccess(state.getRequest(),
// SecurityManager.DELETE_ITEM,
// contacttype);
// if (canDelete) {
ControlLink link = new ControlLink(value.toString());
link.setConfirmation((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contacttype.confirm_delete").localize());
return link;
// } else {
// return new Label(value.toString());
// }
}
}
/**
* Provide implementation to TableActionListener method.
* Code that comes into picture when a link on the table is clicked.
* Handles edit and delete event.
*/
public void cellSelected(TableActionEvent evt) {
PageState state = evt.getPageState();
// Get selected GenericContactType
GenericContactType contacttype = new GenericContactType(new BigDecimal(evt.getRowKey().toString()));
// Get selected column
TableColumn col = getColumnModel().get(evt.getColumn().intValue());
// Edit
if (col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
}
// Delete
if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
contacttype.delete();
}
}
/**
* provide Implementation to TableActionListener method.
* Does nothing in our case.
*/
public void headSelected(TableActionEvent e) {
throw new UnsupportedOperationException("Not Implemented");
}
}

View File

@ -0,0 +1,117 @@
/*
* Copyright (C) 2010 Sören Bernstein All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SaveCancelSection;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.contenttypes.GenericContact;
import com.arsdigita.cms.contenttypes.GenericContactType;
import com.arsdigita.cms.contenttypes.GenericContactTypeCollection;
import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.dispatcher.DispatcherHelper;
import org.apache.log4j.Logger;
/**
* Generates a form for creating new localisations for the given category.
*
* This class is part of the admin GUI of CCM and extends the standard form
* in order to present forms for managing the multi-language categories.
*
* @author Sören Bernstein (quasimodo) quasi@zes.uni-bremen.de
*/
public class GenericPersonContactAddForm extends BasicItemForm {
private static final Logger s_log = Logger.getLogger(GenericPersonContactAddForm.class);
private GenericPersonPropertiesStep m_step;
private ItemSearchWidget m_itemSearch;
private SaveCancelSection m_saveCancelSection;
private final String ITEM_SEARCH = "personAddress";
private ItemSelectionModel m_itemModel;
/** Creates a new instance of CategoryLocalizationAddForm */
public GenericPersonContactAddForm(ItemSelectionModel itemModel) {
super("ContactEntryAddForm", itemModel);
m_itemModel = itemModel;
}
@Override
protected void addWidgets() {
// Attach a GenericContact object
add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.select_contact").localize()));
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.contenttypes.GenericContact"));
add(this.m_itemSearch);
// GenericContact type field
add(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.type")));
ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACT_TYPE);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
// Add the Options to the SingleSelect widget
GenericContactTypeCollection contacttypes = new GenericContactTypeCollection();
contacttypes.filterLanguage(DispatcherHelper.getNegotiatedLocale().getLanguage());
while (contacttypes.next()) {
GenericContactType ct = contacttypes.getContactType();
contactType.addOption(new Option(ct.getKey(), ct.getName()));
}
add(contactType);
}
public void init(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
// GenericPerson person = (GenericPerson) getItemSelectionModel().getSelectedObject(state);
setVisible(state, true);
}
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
GenericPerson person = (GenericPerson) getItemSelectionModel().getSelectedObject(state);
//
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
person.addContact((GenericContact) data.get(ITEM_SEARCH), (String) data.get(GenericPersonContactCollection.CONTACT_TYPE));
}
init(fse);
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
/**
* @author Sören Bernstein
*/
public class GenericPersonContactPropertiesStep extends SimpleEditStep {
/** The name of the editing sheet added to this step */
private static String ADD_CONTACT_SHEET_NAME = "addContact";
public GenericPersonContactPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
this(itemModel, parent, null);
}
public GenericPersonContactPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) {
super(itemModel, parent, prefix);
BasicItemForm addContactSheet = new GenericPersonContactAddForm(itemModel);
add(ADD_CONTACT_SHEET_NAME,
(String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.add_contact").localize(),
new WorkflowLockedComponentAccess(addContactSheet, itemModel),
addContactSheet.getSaveCancelSection().getCancelButton());
GenericPersonContactTable contactsTable = new GenericPersonContactTable(itemModel);
setDisplayComponent(contactsTable);
}
}

View File

@ -0,0 +1,264 @@
/*
* Copyright (C) 2010 Sören Bernstein All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
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.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.SecurityManager;
import com.arsdigita.cms.contenttypes.GenericContact;
import com.arsdigita.cms.contenttypes.GenericContactTypeCollection;
import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.util.LockableImpl;
import java.math.BigDecimal;
/**
* Lists all existing contact entries for a selected contact.
*
* @author Sören Bernstein (quasimodo) quasi@barkhof.uni-bremen.de
*/
public class GenericPersonContactTable extends Table implements TableActionListener {
private final String TABLE_COL_EDIT = "table_col_edit";
private final String TABLE_COL_DEL = "table_col_del";
private ItemSelectionModel m_itemModel;
/**
* Creates a new instance of GenericPersonGenericPersonTable
*/
public GenericPersonContactTable(final ItemSelectionModel itemModel) {
super();
this.m_itemModel = itemModel;
// if table is empty:
setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contacts.none")));
TableColumnModel tab_model = getColumnModel();
// define columns
tab_model.add(new TableColumn(0, ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.order").localize(), TABLE_COL_EDIT));
tab_model.add(new TableColumn(1, ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.type").localize()));
tab_model.add(new TableColumn(2, ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.title").localize()));
tab_model.add(new TableColumn(3, ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.action").localize(), TABLE_COL_DEL));
setModelBuilder(new GenericPersonTableModelBuilder(itemModel));
tab_model.get(0).setCellRenderer(new EditCellRenderer());
tab_model.get(3).setCellRenderer(new DeleteCellRenderer());
addTableActionListener(this);
}
/**
* XXXX
*
*/
private class GenericPersonTableModelBuilder extends LockableImpl implements TableModelBuilder {
private ItemSelectionModel m_itemModel;
public GenericPersonTableModelBuilder(ItemSelectionModel itemModel) {
m_itemModel = itemModel;
}
public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state);
GenericPerson person = (GenericPerson) m_itemModel.getSelectedObject(state);
return new GenericPersonTableModel(table, state, person);
}
}
/**
* XXX
*
*/
private class GenericPersonTableModel implements TableModel {
final private int MAX_DESC_LENGTH = 25;
private Table m_table;
private GenericPersonContactCollection m_contactCollection;
private GenericContact m_contact;
private GenericContactTypeCollection contacttypes = new GenericContactTypeCollection();
private GenericPersonTableModel(Table t, PageState ps, GenericPerson person) {
m_table = t;
m_contactCollection = person.getContacts();
}
public int getColumnCount() {
return m_table.getColumnModel().size();
}
/**
* Check collection for the existence of another row.
*
* If exists, fetch the value of current GenericPersonEntryCollection object
* into m_comntact class variable.
*/
public boolean nextRow() {
if (m_contactCollection != null && m_contactCollection.next()) {
m_contact = m_contactCollection.getContact();
return true;
} else {
return false;
}
}
/**
* Return the
* @see com.arsdigita.bebop.table.TableModel#getElementAt(int)
*/
public Object getElementAt(int columnIndex) {
switch (columnIndex) {
case 0:
return m_contactCollection.getContactOrder();
case 1:
return contacttypes.getContactType(m_contactCollection.getContactType(),
DispatcherHelper.getNegotiatedLocale().getLanguage());
case 2:
return m_contact.getTitle();
// case 2:
// return (m_personEntry.getDescription() != null && m_personEntry.getDescription().length() > MAX_DESC_LENGTH)
// ? m_personEntry.getDescription().substring(0, MAX_DESC_LENGTH)
// : m_personEntry.getDescription();
case 3:
return GlobalizationUtil.globalize("cms.ui.delete").localize();
default:
return null;
}
}
/**
*
* @see com.arsdigita.bebop.table.TableModel#getKeyAt(int)
*/
public Object getKeyAt(int columnIndex) {
return m_contact.getID();
}
}
/**
* Check for the permissions to edit item and put either a Label or
* a ControlLink accordingly.
*/
private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key,
int row, int column) {
SecurityManager sm = Utilities.getSecurityManager(state);
GenericPerson person = (GenericPerson) m_itemModel.getSelectedObject(state);
boolean canEdit = sm.canAccess(state.getRequest(),
SecurityManager.EDIT_ITEM,
person);
if (canEdit) {
ControlLink link = new ControlLink(value.toString());
return link;
} else {
return new Label(value.toString());
}
}
}
/**
* Check for the permissions to delete item and put either a Label or
* a ControlLink accordingly.
*/
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key,
int row, int column) {
SecurityManager sm = Utilities.getSecurityManager(state);
GenericPerson person = (GenericPerson) m_itemModel.getSelectedObject(state);
boolean canDelete = sm.canAccess(state.getRequest(),
SecurityManager.DELETE_ITEM,
person);
if (canDelete) {
ControlLink link = new ControlLink(value.toString());
link.setConfirmation((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.confirm_delete").localize());
return link;
} else {
return new Label(value.toString());
}
}
}
/**
* Provide implementation to TableActionListener method.
* Code that comes into picture when a link on the table is clicked.
* Handles edit and delete event.
*/
public void cellSelected(TableActionEvent evt) {
PageState state = evt.getPageState();
// Get selected GenericContact
GenericContact contact = new GenericContact(new BigDecimal(evt.getRowKey().toString()));
// Get GenericPerson
GenericPerson person = (GenericPerson) m_itemModel.getSelectedObject(state);
// Get selected column
TableColumn col = getColumnModel().get(evt.getColumn().intValue());
// Edit
if (col.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
}
// Delete
if (col.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
person.removeContact(contact);
}
}
/**
* provide Implementation to TableActionListener method.
* Does nothing in our case.
*/
public void headSelected(TableActionEvent e) {
throw new UnsupportedOperationException("Not Implemented");
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009 Jens Pelzetter, for the Center of Social Politics of the University of Bremen * Copyright (C) 2009 Sören, for the Center of Social Politics of the 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
@ -19,7 +19,9 @@
package com.arsdigita.cms.contenttypes.ui; package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
@ -38,29 +40,58 @@ public class GenericPersonPropertiesStep extends SimpleEditStep {
public static final String EDIT_SHEET_NAME = "edit"; public static final String EDIT_SHEET_NAME = "edit";
public GenericPersonPropertiesStep(ItemSelectionModel itemModel, public GenericPersonPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
AuthoringKitWizard parent) {
super(itemModel, parent); super(itemModel, parent);
/* Use a Segmented Panel for the multiple parts of data */
SegmentedPanel segmentedPanel = new SegmentedPanel();
setDefaultEditKey(EDIT_SHEET_NAME); setDefaultEditKey(EDIT_SHEET_NAME);
createEditSheet(itemModel);
setDisplayComponent(getPersonPropertySheet(itemModel)); /* A new SimpleEditStep */
SimpleEditStep basicProperties = new SimpleEditStep(itemModel, parent, EDIT_SHEET_NAME);
/* Create the edit component for this SimpleEditStep and the corresponding link */
BasicPageForm editBasicSheet = new GenericPersonPropertyForm(itemModel, this);
basicProperties.add(EDIT_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.edit_basic_properties").localize(), new WorkflowLockedComponentAccess(editBasicSheet, itemModel), editBasicSheet.getSaveCancelSection().getCancelButton());
/* Set the displayComponent for this step */
basicProperties.setDisplayComponent(getGenericPersonPropertySheet(itemModel));
/* Add the SimpleEditStep to the segmented panel */
segmentedPanel.addSegment(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.basic_properties").localize()), basicProperties);
// GenericPersonContactPropertiesStep contactProperties = new GenericPersonContactPropertiesStep(itemModel, parent);
// segmentedPanel.addSegment(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact").localize()), contactProperties);
/* Sets the composed segmentedPanel as display component */
setDisplayComponent(segmentedPanel);
} }
protected void createEditSheet(ItemSelectionModel itemModel) { public static Component getGenericPersonPropertySheet(ItemSelectionModel itemModel) {
BasicPageForm editSheet;
editSheet = new GenericPersonPropertyForm(itemModel, this);
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel), editSheet.getSaveCancelSection().getCancelButton());
}
public static Component getPersonPropertySheet(ItemSelectionModel itemModel) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname").localize(), GenericPerson.SURNAME); sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname").localize(), GenericPerson.SURNAME);
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.givenname").localize(), GenericPerson.GIVENNAME); sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.givenname").localize(), GenericPerson.GIVENNAME);
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepre").localize(), GenericPerson.TITLEPRE); sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepre").localize(), GenericPerson.TITLEPRE);
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepost").localize(), GenericPerson.TITLEPOST); sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.titlepost").localize(), GenericPerson.TITLEPOST);
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.birthdate").localize(),
GenericPerson.BIRTHDATE,
new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject item,
String attribute,
PageState state) {
ContentPage page = (ContentPage) item;
if (page.getLaunchDate() != null) {
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
} else {
return (String) ContenttypesGlobalizationUtil.globalize("cms.ui.unknown").localize();
}
}
});
if (!ContentSection.getConfig().getHideLaunchDate()) { if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.ui.authoring.page_launch_date").localize(), sheet.add((String) ContenttypesGlobalizationUtil.globalize("cms.ui.authoring.page_launch_date").localize(),

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009 Jens Pelzetter, for the Center of Social Politics of the University of Bremen * Copyright (C) 2010 Sören Bernstein, for the Center of Social Politics of the 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
@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
package com.arsdigita.cms.contenttypes.ui; package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
@ -26,6 +25,7 @@ import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.DateParameter;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
@ -40,16 +40,15 @@ import org.apache.log4j.Logger;
* @author: Jens Pelzetter * @author: Jens Pelzetter
*/ */
public class GenericPersonPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener { public class GenericPersonPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
private static final Logger s_log = Logger.getLogger(GenericPersonPropertyForm.class); private static final Logger s_log = Logger.getLogger(GenericPersonPropertyForm.class);
private GenericPersonPropertiesStep m_step; private GenericPersonPropertiesStep m_step;
public static final String PERSON = GenericPerson.PERSON; public static final String PERSON = GenericPerson.PERSON;
public static final String SURNAME = GenericPerson.SURNAME; public static final String SURNAME = GenericPerson.SURNAME;
public static final String GIVENNAME = GenericPerson.GIVENNAME; public static final String GIVENNAME = GenericPerson.GIVENNAME;
public static final String TITLEPRE = GenericPerson.TITLEPRE; public static final String TITLEPRE = GenericPerson.TITLEPRE;
public static final String TITLEPOST = GenericPerson.TITLEPOST; public static final String TITLEPOST = GenericPerson.TITLEPOST;
public static final String BIRTHDATE = GenericPerson.BIRTHDATE;
public static final String ID = "Person_edit"; public static final String ID = "Person_edit";
public GenericPersonPropertyForm(ItemSelectionModel itemModel) { public GenericPersonPropertyForm(ItemSelectionModel itemModel) {
@ -85,6 +84,12 @@ public class GenericPersonPropertyForm extends BasicPageForm implements FormProc
ParameterModel titlepostParam = new StringParameter(TITLEPOST); ParameterModel titlepostParam = new StringParameter(TITLEPOST);
TextField titlepost = new TextField(titlepostParam); TextField titlepost = new TextField(titlepostParam);
add(titlepost); add(titlepost);
add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.birthdate").localize()));
ParameterModel birthdateParam = new DateParameter(BIRTHDATE);
com.arsdigita.bebop.form.Date birthdate = new com.arsdigita.bebop.form.Date(birthdateParam);
add(birthdate);
} }
public void init(FormSectionEvent fse) { public void init(FormSectionEvent fse) {
@ -95,11 +100,12 @@ public class GenericPersonPropertyForm extends BasicPageForm implements FormProc
data.put(GIVENNAME, person.getGivenName()); data.put(GIVENNAME, person.getGivenName());
data.put(TITLEPRE, person.getTitlePre()); data.put(TITLEPRE, person.getTitlePre());
data.put(TITLEPOST, person.getTitlePost()); data.put(TITLEPOST, person.getTitlePost());
data.put(BIRTHDATE, person.getBirthdate());
} }
public void submitted(FormSectionEvent fse) { public void submitted(FormSectionEvent fse) {
if (m_step != null && if (m_step != null
getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) { && getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
m_step.cancelStreamlinedCreation(fse.getPageState()); m_step.cancelStreamlinedCreation(fse.getPageState());
} }
} }
@ -109,12 +115,13 @@ public class GenericPersonPropertyForm extends BasicPageForm implements FormProc
GenericPerson person = (GenericPerson) super.processBasicWidgets(fse); GenericPerson person = (GenericPerson) super.processBasicWidgets(fse);
if (person != null && if (person != null
getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) { && getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
person.setSurname((String) data.get(SURNAME)); person.setSurname((String) data.get(SURNAME));
person.setGivenName((String) data.get(GIVENNAME)); person.setGivenName((String) data.get(GIVENNAME));
person.setTitlePre((String) data.get(TITLEPRE)); person.setTitlePre((String) data.get(TITLEPRE));
person.setTitlePost((String) data.get(TITLEPOST)); person.setTitlePost((String) data.get(TITLEPOST));
person.setBirthdate((String) data.get(BIRTHDATE));
person.save(); person.save();
} }

View File

@ -23,7 +23,7 @@ import com.arsdigita.globalization.GlobalizedMessage;
public class ContenttypesGlobalizationUtil { public class ContenttypesGlobalizationUtil {
final public static String BUNDLE_NAME = final public static String BUNDLE_NAME =
"com.arsdigita.cms.contenttypes.util.BasetypesResourceBundle"; "com.arsdigita.cms.contenttypes.util.ContenttypesResourceBundle";
public static GlobalizedMessage globalize (String key) { public static GlobalizedMessage globalize (String key) {
return new GlobalizedMessage(key, BUNDLE_NAME); return new GlobalizedMessage(key, BUNDLE_NAME);

View File

@ -25,7 +25,7 @@ import com.arsdigita.cms.CMSGlobalized;
public class ContenttypesResourceBundle extends ChainedResourceBundle implements CMSGlobalized { public class ContenttypesResourceBundle extends ChainedResourceBundle implements CMSGlobalized {
public static final String MEMBER_BUNDLE_NAME = public static final String MEMBER_BUNDLE_NAME =
"com.arsdigita.cms.contenttypes.BasetypesResources"; "com.arsdigita.cms.contenttypes.ContenttypesResources";
public ContenttypesResourceBundle() { public ContenttypesResourceBundle() {
super(); super();