Erste Version von basetypes.contact

Kompiliert und läßt laden und starten, alledings gibt es eine Exception beim Anlegen eines neuen BaseContacts

BaseContacts so angepaßt, daß es den basetype verwendet.

git-svn-id: https://svn.libreccm.org/ccm/trunk@436 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2010-05-21 10:07:53 +00:00
parent 153ac8a86b
commit 1f390ae868
48 changed files with 2420 additions and 194 deletions

View File

@ -42,7 +42,6 @@ public class AddressPropertiesStep extends com.arsdigita.cms.basetypes.ui.Addres
} }
public static Component getAddressPropertySheet(ItemSelectionModel itemModel) { public static Component getAddressPropertySheet(ItemSelectionModel itemModel) {
Component sheet = AddressPropertiesStep.getAddressPropertySheet(itemModel); return com.arsdigita.cms.basetypes.ui.AddressPropertiesStep.getAddressPropertySheet(itemModel);
return sheet;
} }
} }

View File

@ -8,8 +8,6 @@
<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-baseAddress" version="6.6.0" relation="ge"/>
</ccm:dependencies> </ccm:dependencies>
<ccm:directories> <ccm:directories>
<ccm:directory name="pdl"/> <ccm:directory name="pdl"/>

View File

@ -1,31 +1,10 @@
model com.arsdigita.cms.contenttypes; model com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.contenttypes.Person; import com.arsdigita.cms.basetypes.Contact;
import com.arsdigita.cms.contenttypes.BaseAddress;
import com.arsdigita.kernel.ACSObject; import com.arsdigita.kernel.ACSObject;
import com.arsdigita.cms.*; import com.arsdigita.cms.*;
// Contact Object // Contact Object
object type BaseContact extends ContentPage { object type BaseContact extends com.arsdigita.cms.basetypes.Contact {
Person [0..1] person = join ct_baseContacts.person_id
to ct_persons.person_id;
BaseAddress [0..1] address = join ct_baseContacts.address_id
to ct_baseAddresses.address_id;
component BaseContactEntry [0..n] contactentries = join ct_baseContacts.contact_id
to ct_baseContactEntries.contact_id;
reference key ( ct_baseContacts.contact_id ); reference key ( ct_baseContacts.contact_id );
} }
object type BaseContactEntry extends ContentItem {
String [1..1] key = ct_baseContactEntries.key VARCHAR(100);
String [0..1] description = ct_baseContactEntries.description VARCHAR(100);
String [1..1] value = ct_baseContactEntries.value VARCHAR(100);
reference key ( ct_baseContactEntries.contactentry_id );
}

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<registry> <registry>
<config class="com.arsdigita.cms.contenttypes.BaseContactConfig" storage="ccm-cms-types-baseContact/baseContact.properties"/> <!-- <config class="com.arsdigita.cms.contenttypes.BaseContactConfig" storage="ccm-cms-types-baseContact/baseContact.properties"/> -->
</registry> </registry>

View File

@ -3,13 +3,10 @@
<table name="inits"/> <table name="inits"/>
<table name="acs_objects"/> <table name="acs_objects"/>
<table name="cms_items"/> <table name="cms_items"/>
<table name="ct_baseAddresses"/>
<table name="ct_persons"/>
<initializer class="com.arsdigita.cms.Initializer"/> <initializer class="com.arsdigita.cms.Initializer"/>
</requires> </requires>
<provides> <provides>
<table name="ct_baseContacts"/> <table name="ct_baseContacts"/>
<table name="ct_baseContactEntries"/>
<initializer class="com.arsdigita.cms.contenttypes.BaseContactInitializer"/> <initializer class="com.arsdigita.cms.contenttypes.BaseContactInitializer"/>
</provides> </provides>
<scripts> <scripts>

View File

@ -22,12 +22,6 @@ import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataObject;
import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataAssociation;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataOperation;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -36,18 +30,18 @@ import java.math.BigDecimal;
* This content type represents an BaseContact * This content type represents an BaseContact
* *
*/ */
public class BaseContact extends ContentPage { public class BaseContact extends com.arsdigita.cms.basetypes.Contact {
/** PDL property names */ /** PDL property names */
public static final String PERSON = "person"; // public static final String PERSON = "person";
public static final String ADDRESS = "address"; // public static final String ADDRESS = "address";
public static final String CONTACT_ENTRIES = "contactentries"; // public static final String CONTACT_ENTRIES = "contactentries";
// Config // Config
private static final BaseContactConfig s_config = new BaseContactConfig(); // private static final BaseContactConfig s_config = new BaseContactConfig();
static { // static {
s_config.load(); // s_config.load();
} // }
/** Data object type for tihs domain object */ /** Data object type for tihs domain object */
public static final String BASE_DATA_OBJECT_TYPE public static final String BASE_DATA_OBJECT_TYPE
@ -75,6 +69,7 @@ public class BaseContact extends ContentPage {
super(type); super(type);
} }
@Override
public void beforeSave() { public void beforeSave() {
super.beforeSave(); super.beforeSave();
@ -84,62 +79,62 @@ public class BaseContact extends ContentPage {
/** /**
* Retrieves the current configuration * Retrieves the current configuration
*/ */
public static final BaseContactConfig getConfig() { // public static final BaseContactConfig getConfig() {
return s_config; // return s_config;
} // }
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
// accessors // accessors
//
// Get the person for this contact // // Get the person for this contact
public Member getPerson() { // public Member getPerson() {
return (Member) DomainObjectFactory.newInstance((DataObject)get(PERSON)); // return (Member) DomainObjectFactory.newInstance((DataObject)get(PERSON));
} // }
//
// Set the person for this contact // // Set the person for this contact
public void setPerson(Member person) { // public void setPerson(Member person) {
set(PERSON, person); // set(PERSON, person);
} // }
//
// Unset the address for this contact // // Unset the address for this contact
public void unsetPerson() { // public void unsetPerson() {
set(PERSON, null); // set(PERSON, null);
} // }
//
// Get the address for this contact // // Get the address for this contact
public BaseAddress getAddress() { // public BaseAddress getAddress() {
return (BaseAddress)DomainObjectFactory.newInstance((DataObject)get(ADDRESS)); // return (BaseAddress)DomainObjectFactory.newInstance((DataObject)get(ADDRESS));
} // }
//
// Set the address for this contact // // Set the address for this contact
public void setAddress(BaseAddress address) { // public void setAddress(BaseAddress address) {
set(ADDRESS, address); // set(ADDRESS, address);
} // }
//
// Unset the address for this contact // // Unset the address for this contact
public void unsetAddress() { // public void unsetAddress() {
set(ADDRESS, null); // set(ADDRESS, null);
} // }
//
// Get all contact entries for this contact, p. ex. phone number, type of contact etc. // // Get all contact entries for this contact, p. ex. phone number, type of contact etc.
public BaseContactEntryCollection getContactEntries() { // public BaseContactEntryCollection getContactEntries() {
return new BaseContactEntryCollection ((DataCollection) get(CONTACT_ENTRIES)); // return new BaseContactEntryCollection ((DataCollection) get(CONTACT_ENTRIES));
} // }
//
// Add a contact entry for this contact // // Add a contact entry for this contact
public void addContactEntry(BaseContactEntry contactEntry) { // public void addContactEntry(BaseContactEntry contactEntry) {
Assert.exists(contactEntry, BaseContactEntry.class); // Assert.exists(contactEntry, BaseContactEntry.class);
add(CONTACT_ENTRIES, contactEntry); // add(CONTACT_ENTRIES, contactEntry);
} // }
//
// Remove a contect entry for this contact // // Remove a contect entry for this contact
public void removeContactEntry(BaseContactEntry contactEntry) { // public void removeContactEntry(BaseContactEntry contactEntry) {
Assert.exists(contactEntry, BaseContactEntry.class); // Assert.exists(contactEntry, BaseContactEntry.class);
remove(CONTACT_ENTRIES, contactEntry); // remove(CONTACT_ENTRIES, contactEntry);
} // }
//
public boolean hasContactEntries() { // public boolean hasContactEntries() {
return !this.getContactEntries().isEmpty(); // return !this.getContactEntries().isEmpty();
} // }
} }

View File

@ -8,10 +8,7 @@ import org.apache.log4j.Logger;
* @author Sören Bernstein; * @author Sören Bernstein;
*/ */
public class BaseContactInitializer extends ContentTypeInitializer { public class BaseContactInitializer extends ContentTypeInitializer {
public final static String versionId =
"$Id: BaseContactInitializer.java $" +
"$Author: quasi $" +
"$DateTime: 2009/03/15 $";
private static final Logger s_log = Logger.getLogger(BaseContactInitializer.class); private static final Logger s_log = Logger.getLogger(BaseContactInitializer.class);
public BaseContactInitializer() { public BaseContactInitializer() {

View File

@ -1,20 +1,12 @@
package com.arsdigita.cms.contenttypes; package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.contenttypes.AbstractContentTypeLoader;
/** /**
* Loader. * Loader.
* *
* @author Sören Bernstein * @author Sören Bernstein
*/ */
public class BaseContactLoader extends AbstractContentTypeLoader { public class BaseContactLoader extends AbstractContentTypeLoader {
public final static String versionId =
"$Id: BaseContactLoader.java $" +
"$Author: quasi $" +
"$DateTime: 2009/03/15 $";
private static final String[] TYPES = { private static final String[] TYPES = {
"/WEB-INF/content-types/com/arsdigita/cms/contenttypes/BaseContact.xml" "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/BaseContact.xml"

View File

@ -1,29 +1,15 @@
package com.arsdigita.cms.contenttypes.ui; package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.cms.contenttypes.BaseContact;
import com.arsdigita.cms.contenttypes.util.BaseContactGlobalizationUtil;
import java.text.DateFormat;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* AuthoringStep for the basic properties of a basic contact * AuthoringStep for the basic properties of a basic contact
*/ */
public class BaseContactPropertiesStep extends SimpleEditStep { public class BaseContactPropertiesStep extends com.arsdigita.cms.basetypes.ui.ContactPropertiesStep {
private static final Logger logger = Logger.getLogger(BaseContactPropertiesStep.class); private static final Logger logger = Logger.getLogger(BaseContactPropertiesStep.class);
@ -41,45 +27,6 @@ public class BaseContactPropertiesStep extends SimpleEditStep {
*/ */
public BaseContactPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { public BaseContactPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
super(itemModel, parent); super(itemModel, parent);
/* Use a Segmented Panel for the multiple parts of data */
SegmentedPanel segmentedPanel = new SegmentedPanel();
setDefaultEditKey(EDIT_BASIC_SHEET_NAME);
/* The different parts of information are displayed in seperated segments each containing a SimpleEditStep */
/* Well, not so simple anymore... */
/* A new SimpleEditStep */
SimpleEditStep basicProperties = new SimpleEditStep(itemModel, parent, EDIT_BASIC_SHEET_NAME);
/* Create the edit component for this SimpleEditStep and the corresponding link */
BasicPageForm editBasicSheet = new BaseContactPropertyForm(itemModel, this);
basicProperties.add(EDIT_BASIC_SHEET_NAME, (String)BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.edit_basic_properties").localize(), new WorkflowLockedComponentAccess(editBasicSheet, itemModel), editBasicSheet.getSaveCancelSection().getCancelButton());
/* Set the displayComponent for this step */
basicProperties.setDisplayComponent(getBaseContactPropertySheet(itemModel));
/* Add the SimpleEditStep to the segmented panel */
segmentedPanel.addSegment(new Label((String)BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.basic_properties").localize()), basicProperties);
// If not disabled via registry, add the ui for attaching a person
if(!BaseContact.getConfig().getHidePerson()) {
BaseContactPersonPropertiesStep personProperties = new BaseContactPersonPropertiesStep(itemModel, parent);
segmentedPanel.addSegment(new Label((String)BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.person").localize()), personProperties);
}
// If not disabled via registry, add the ui for attaching a baseAddress
if(!BaseContact.getConfig().getHideAddress()) {
BaseContactAddressPropertiesStep addressProperties = new BaseContactAddressPropertiesStep(itemModel, parent);
segmentedPanel.addSegment(new Label((String)BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.address").localize()), addressProperties);
}
BaseContactEntriesPropertiesStep baseContactEntries = new BaseContactEntriesPropertiesStep(itemModel, parent);
segmentedPanel.addSegment(new Label((String)BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.contactEntry").localize()), baseContactEntries);
/* Sets the composed segmentedPanel as display component */
setDisplayComponent(segmentedPanel);
} }
/** /**
@ -90,30 +37,7 @@ public class BaseContactPropertiesStep extends SimpleEditStep {
* @return The sheet for editing the properties of the organization. * @return The sheet for editing the properties of the organization.
*/ */
public static Component getBaseContactPropertySheet(ItemSelectionModel itemModel) { public static Component getBaseContactPropertySheet(ItemSelectionModel itemModel) {
return com.arsdigita.cms.basetypes.ui.ContactPropertiesStep.getContactPropertySheet(itemModel);
/* The DisplayComponent for the Basic Properties */
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"),"name");
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"),"title");
if(!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"), ContentPage.LAUNCH_DATE, new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject obj, String attribute, PageState state) {
ContentPage page = (ContentPage)obj;
if(page.getLaunchDate() != null) {
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
}
else {
return (String)GlobalizationUtil.globalize("cms.ui.unknown").localize();
}
}
});
}
return sheet;
} }
} }

View File

@ -0,0 +1,29 @@
model com.arsdigita.cms.basetypes;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.cms.*;
// Contact Object
object type Contact extends ContentPage {
Person [0..1] person = join cms_contacts.person_id
to cms_persons.person_id;
Address [0..1] address = join cms_contacts.address_id
to cms_addresses.address_id;
component ContactEntry [0..n] contactentries = join cms_contacts.contact_id
to cms_contactEntries.contact_id;
reference key ( cms_contacts.contact_id );
}
object type ContactEntry extends ContentItem {
String [1..1] key = cms_contactEntries.key VARCHAR(100);
String [0..1] description = cms_contactEntries.description VARCHAR(100);
String [1..1] value = cms_contactEntries.value VARCHAR(100);
reference key ( cms_contactEntries.contactentry_id );
}

View File

@ -8,4 +8,6 @@
storage="ccm-cms/publishToFile.properties"/> storage="ccm-cms/publishToFile.properties"/>
<config class="com.arsdigita.cms.basetypes.AddressConfig" <config class="com.arsdigita.cms.basetypes.AddressConfig"
storage="ccm-cms/basetypes.properties"/> storage="ccm-cms/basetypes.properties"/>
<config class="com.arsdigita.cms.basetypes.ContactConfig"
storage="ccm-cms/basetypes.properties"/>
</registry> </registry>

View File

@ -11,3 +11,54 @@ cms.basetypes.ui.person.titlepre=Title
cms.basetypes.ui.person.titlepost=Name appendix cms.basetypes.ui.person.titlepost=Name appendix
address.authoring.basic_properties.title=Basic Properties address.authoring.basic_properties.title=Basic Properties
cms.basetypes.ui.contact.basic_properties=Basic Properties
cms.basetypes.ui.contact.edit_basic_properties=Edit Basic Properties
cms.basetypes.ui.contact.edit_basic_properties.description=Description
cms.basetypes.ui.contact.confirm_delete=Sure?
cms.basetypes.ui.contact.person=Person
cms.basetypes.ui.contact.address=Address
cms.basetypes.ui.contact.attach_address=Attach Address
cms.basetypes.ui.contact.edit_address=Edit Address
cms.basetypes.ui.contact.reattach_address=Reattach Address
cms.basetypes.ui.contact.delete_address=Delete Address
cms.basetypes.ui.contact.emptyAddress=There is no Address attached
cms.basetypes.ui.contact.select_address=Please select a contact content type
cms.basetypes.ui.contact.select_address.add=Add
cms.basetypes.ui.contact.select_address.change=Change
cms.basetypes.ui.contact.select_address.wrong_type=BaseAddress selection is required
cms.basetypes.ui.contact.select_address.cancelled=cancelled
cms.basetypes.ui.contact.delete_address.label=Do you want to delete the link to the contact content type?
cms.basetypes.ui.contact.delete_address.button_label=Delete
cms.basetypes.ui.contact.attach_person=Attach Person
cms.basetypes.ui.contact.edit_person=Edit Person
cms.basetypes.ui.contact.reattach_person=Reattach Person
cms.basetypes.ui.contact.delete_person=Delete Person
cms.basetypes.ui.contact.emptyPerson=There is no Address attached
cms.basetypes.ui.contact.select_person=Please select a Person content type
cms.basetypes.ui.contact.select_person.add=Add
cms.basetypes.ui.contact.select_person.change=Change
cms.basetypes.ui.contact.select_person.wrong_type=Person selection is required
cms.basetypes.ui.contact.select_person.cancelled=cancelled
cms.basetypes.ui.contact.delete_person.label=Do you want to delete the link to the Person content type?
cms.basetypes.ui.contact.delete_person.button_label=Delete
cms.basetypes.ui.contact.add_contactEntry=Add Contact Entry
cms.basetypes.ui.contact.contactEntry=Contact Entries
cms.basetypes.ui.contact.contactEntry.key=Type
cms.basetypes.ui.contact.contactEntry.value=Value
cms.basetypes.ui.contact.contactEntry.description=Description (internal use only)
cms.basetypes.ui.contact.contactEntry.action=Action
cms.basetypes.ui.contact.contactEntry.key.contact_type=Type of Contact
cms.basetypes.ui.contact.contactEntry.key.office_hours=Office Hours
cms.basetypes.ui.contact.contactEntry.key.phone_office=Phone (office)
cms.basetypes.ui.contact.contactEntry.key.phone_private=Phone (private)
cms.basetypes.ui.contact.contactEntry.key.phone_mobile=Phone (mobile)
cms.basetypes.ui.contact.contactEntry.key.email=eMail
cms.basetypes.ui.contact.contactEntry.key.fax=Fax
cms.basetypes.ui.contact.contactEntry.key.im=Instant Messenger
cms.basetypes.ui.contact.contactEntry.key.www=Homepage

View File

@ -11,3 +11,56 @@ cms.basetypes.ui.person.titlepre=Titel
cms.basetypes.ui.person.titlepost=Namesanhang cms.basetypes.ui.person.titlepost=Namesanhang
address.authoring.basic_properties.title=Eigenschaften von Adresse address.authoring.basic_properties.title=Eigenschaften von Adresse
cms.basetypes.ui.contact.basic_properties=Eigenschaften von Contact
cms.basetypes.ui.contact.edit_basic_properties=Bearbeiten
cms.basetypes.ui.contact.edit_basic_properties.description=Description
cms.basetypes.ui.contact.confirm_delete=Sind Sie sicher?
cms.basetypes.ui.contact.person=Person
cms.basetypes.ui.contact.address=Adresse
cms.basetypes.ui.contact.attach_address=Adresse verkn\u00FCpfen
cms.basetypes.ui.contact.edit_address=Adresse bearbeiten
cms.basetypes.ui.contact.reattach_address=Adresse neu verkn\u00FCpfen
cms.basetypes.ui.contact.delete_address=Adresse l\u00F6schen
cms.basetypes.ui.contact.emptyAddress=Zur Zeit ist keine Adresse verkn\u00FCpft
cms.basetypes.ui.contact.select_address=Bitte w\u00E4hlen Sie eine Eintrag vom Typ BaseAddress
cms.basetypes.ui.contact.select_address.add=Verkn\u00FCpfen
cms.basetypes.ui.contact.select_address.change=Ver\u00E4ndern
cms.basetypes.ui.contact.select_address.wrong_type=Der gew\u00E4hlte Eintrag ist nicht vom Typ BaseAddress
cms.basetypes.ui.contact.select_address.cancelled=Abbruch
cms.basetypes.ui.contact.delete_address.label=Wollen Sie die Verkn\u00FCpfung zur Adresse entfernen?
cms.basetypes.ui.contact.delete_address.button_label=L\u00F6schen
cms.basetypes.ui.contact.attach_person=Person verkn\u00FCpfen
cms.basetypes.ui.contact.edit_person=Person bearbeiten
cms.basetypes.ui.contact.reattach_person=Person neu verkn\u00FCpfen
cms.basetypes.ui.contact.delete_person=Person l\u00F6schen
cms.basetypes.ui.contact.emptyPerson=Zur Zeit ist keine Person verkn\u00FCft
cms.basetypes.ui.contact.select_person=Bitte w\u00E4hlen Sie einen Eintrag vom Typ Person
cms.basetypes.ui.contact.select_person.add=Verkn\u00FCpfen
cms.basetypes.ui.contact.select_person.change=Ver\u00E4ndern
cms.basetypes.ui.contact.select_person.wrong_type=Der gew\u00E4hlte Eintrag ist nicht vom Typ Person
cms.basetypes.ui.contact.select_person.cancelled=Abbruch
cms.basetypes.ui.contact.delete_person.label=WollenSie die Verkn\u00FCfung zur Person entfernen?
cms.basetypes.ui.contact.delete_person.button_label=L\u00F6schen
cms.basetypes.ui.contact.add_contactEntry=Kontaktinformation hinzuf\u00FCgen
cms.basetypes.ui.contact.contactEntry=Kontaktinformationen
cms.basetypes.ui.contact.contactEntry.key=Art der Information
cms.basetypes.ui.contact.contactEntry.value=Inhalt
cms.basetypes.ui.contact.contactEntry.description=Beschreibung (wird nicht \u00F6ffentlich angezeigt)
cms.basetypes.ui.contact.contactEntry.action=Aktionen
cms.basetypes.ui.contact.contactEntry.key.contact_type=Kontaktart
cms.basetypes.ui.contact.contactEntry.key.office_hours=\u00D6ffnungszeiten
cms.basetypes.ui.contact.contactEntry.key.phone_office=Telefon (B\u00FCro)
cms.basetypes.ui.contact.contactEntry.key.phone_private=Telefon (Privat)
cms.basetypes.ui.contact.contactEntry.key.phone_mobile=Telefon (Mobil)
cms.basetypes.ui.contact.contactEntry.key.email=E-Mail
cms.basetypes.ui.contact.contactEntry.key.fax=Fax
cms.basetypes.ui.contact.contactEntry.key.im=Instant Messenger
cms.basetypes.ui.contact.contactEntry.key.www=Homepage
cms.basetypes.ui.contact.contactEntry.none=Zur Zeit sind keine Kontaktinformatioonen vorhanden

View File

@ -0,0 +1,143 @@
/*
* Copyright (C) 2003-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.basetypes;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.util.Assert;
import java.math.BigDecimal;
/**
* This content type represents an basic contact
*
*/
public class Contact extends ContentPage {
/** PDL property names */
public static final String PERSON = "person";
public static final String ADDRESS = "address";
public static final String CONTACT_ENTRIES = "contactentries";
// Config
private static final ContactConfig s_config = new ContactConfig();
static {
s_config.load();
}
/** Data object type for tihs domain object */
public static final String BASE_DATA_OBJECT_TYPE
= "com.arsdigita.cms.basetypes.Contact";
public Contact() {
super(BASE_DATA_OBJECT_TYPE);
}
public Contact(BigDecimal id)
throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
public Contact(OID id)
throws DataObjectNotFoundException {
super(id);
}
public Contact(DataObject obj) {
super(obj);
}
public Contact(String type) {
super(type);
}
@Override
public void beforeSave() {
super.beforeSave();
Assert.exists(getContentType(), ContentType.class);
}
/**
* Retrieves the current configuration
*/
public static final ContactConfig getConfig() {
return s_config;
}
///////////////////////////////////////////////////////////////
// accessors
// Get the person for this contact
public Person getPerson() {
return (Person) DomainObjectFactory.newInstance((DataObject)get(PERSON));
}
// Set the person for this contact
public void setPerson(Person person) {
set(PERSON, person);
}
// Unset the address for this contact
public void unsetPerson() {
set(PERSON, null);
}
// Get the address for this contact
public Address getAddress() {
return (Address)DomainObjectFactory.newInstance((DataObject)get(ADDRESS));
}
// Set the address for this contact
public void setAddress(Address address) {
set(ADDRESS, address);
}
// Unset the address for this contact
public void unsetAddress() {
set(ADDRESS, null);
}
// Get all contact entries for this contact, p. ex. phone number, type of contact etc.
public ContactEntryCollection getContactEntries() {
return new ContactEntryCollection ((DataCollection) get(CONTACT_ENTRIES));
}
// Add a contact entry for this contact
public void addContactEntry(ContactEntry contactEntry) {
Assert.exists(contactEntry, ContactEntry.class);
add(CONTACT_ENTRIES, contactEntry);
}
// Remove a contect entry for this contact
public void removeContactEntry(ContactEntry contactEntry) {
Assert.exists(contactEntry, ContactEntry.class);
remove(CONTACT_ENTRIES, contactEntry);
}
public boolean hasContactEntries() {
return !this.getContactEntries().isEmpty();
}
}

View File

@ -0,0 +1,151 @@
package com.arsdigita.cms.basetypes;
import com.arsdigita.runtime.AbstractConfig;
import com.arsdigita.util.parameter.Parameter;
import com.arsdigita.util.parameter.BooleanParameter;
import com.arsdigita.util.parameter.StringParameter;
import java.util.StringTokenizer;
import org.apache.log4j.Logger;
/**
* Stores the configuration record for the contact.
*
* @author Sören Bernstein (quasimodo) quasi@zes.uni-bremen.de
*/
public final class ContactConfig extends AbstractConfig {
private static Logger s_log = Logger.getLogger(ContactConfig.class);
private final Parameter m_hidePerson;
private final Parameter m_hideAddress;
private final Parameter m_hideAddressPostalCode;
private final Parameter m_hideAddressState;
private final Parameter m_hideAddressCountry;
private final Parameter m_contactEntryKeys;
/**
* Public Constructor
*/
public ContactConfig() {
/**
* If set to true disables the possibility to attach a person ct
*/
m_hidePerson = new BooleanParameter
("com.arsdigita.cms.basetypes.contact.hide_person",
Parameter.REQUIRED,
new Boolean(false));
/**
* If set to true disables the possibility to attach a baseAddress ct
*/
m_hideAddress = new BooleanParameter
("com.arsdigita.cms.basetypes.contact.hide_address",
Parameter.REQUIRED,
new Boolean(false));
/**
* If set to true hides the postal code entry field for the attached address ct
*/
m_hideAddressPostalCode = new BooleanParameter
("com.arsdigita.cms.basetypes.contact.address.hide_postal_code",
Parameter.REQUIRED,
new Boolean(false));
/**
* If set to true hides the state entry field for the attached address ct
*/
m_hideAddressState = new BooleanParameter
("com.arsdigita.cms.basetypes.contact.address.hide_state",
Parameter.REQUIRED,
new Boolean(false));
/**
* If set to true hides the country selection for the attaches address ct
*/
m_hideAddressCountry = new BooleanParameter
("com.arsdigita.cms.basetypes.contact.address.hide_country",
Parameter.REQUIRED,
new Boolean(false));
/**
*/
m_contactEntryKeys = new StringParameter
("com.arsdigita.cms.basetypes.contact.contact_entry_keys",
Parameter.REQUIRED,
"contact_type,office_hours,phone_office,phone_private,phone_mobile,email,fax,im,www");
register(m_hidePerson);
register(m_hideAddress);
register(m_hideAddressPostalCode);
register(m_hideAddressState);
register(m_hideAddressCountry);
register(m_contactEntryKeys);
loadInfo();
}
/**
*/
public final boolean getHidePerson() {
return ((Boolean) get(m_hidePerson)).booleanValue();
}
/**
*/
public final boolean getHideAddress() {
return ((Boolean) get(m_hideAddress)).booleanValue();
}
/**
*/
public final boolean getHideAddressPostalCode() {
return ((Boolean) get(m_hideAddressPostalCode)).booleanValue();
}
/**
*/
public final boolean getHideAddressState() {
return ((Boolean) get(m_hideAddressState)).booleanValue();
}
/**
*/
public final boolean getHideAddressCountry() {
return ((Boolean) get(m_hideAddressCountry)).booleanValue();
}
/**
* Returns the contactEntryKeys as StringTokenizer.
*/
public final StringTokenizer getContactEntryKeys() {
return new StringTokenizer((((String) get(m_contactEntryKeys)).replace(" ","")), ",", false);
}
/**
* Return true, if language lang is part of supported langs
*/
public final boolean hasKey(String key) {
return ((String) get(m_contactEntryKeys)).contains(key);
}
/**
* Return the index value for given key
*/
public final int getKeyIndex(String key) {
int index = -1;
if(hasKey(key)) {
StringTokenizer keys = getContactEntryKeys();
while(keys.hasMoreElements()) {
index++;
if(keys.nextToken().equals(key)) {
break;
}
}
}
return index;
}
}

View File

@ -0,0 +1,29 @@
com.arsdigita.cms.basetypes.contact.hide_person.title=Hide person attachment
com.arsdigita.cms.basetypes.contact.hide_person.purpose=Hide the part to attach a person CT
com.arsdigita.cms.basetypes.contact.hide_person.example=false
com.arsdigita.cms.basetypes.contact.hide_person.format=[boolean]
com.arsdigita.cms.basetypes.contact.hide_address.title=Hide address attachment
com.arsdigita.cms.basetypes.contact.hide_address.purpose=Hide the part to attach a baseAddress CT
com.arsdigita.cms.basetypes.contact.hide_address.example=false
com.arsdigita.cms.basetypes.contact.hide_address.format=[boolean]
com.arsdigita.cms.basetypes.contact.address.hide_postal_code.title=Hide postal code for attached adress
com.arsdigita.cms.basetypes.contact.address.hide_postal_code.purpose=Hide the postal code entry field for the attached baseAddress
com.arsdigita.cms.basetypes.contact.address.hide_postal_code.example=false
com.arsdigita.cms.basetypes.contact.address.hide_postal_code.format=[boolean]
com.arsdigita.cms.basetypes.contact.address.hide_state.title=Hide state for attached adress
com.arsdigita.cms.basetypes.contact.address.hide_state.purpose=Hide the state entry field for the attached baseAddress
com.arsdigita.cms.basetypes.contact.address.hide_state.example=false
com.arsdigita.cms.basetypes.contact.address.hide_state.format=[boolean]
com.arsdigita.cms.basetypes.contact.address.hide_country.title=Hide country for attached address
com.arsdigita.cms.basetypes.contact.address.hide_country.purpose=Hide the country selection box for the attached baseAddress
com.arsdigita.cms.basetypes.contact.address.hide_country.example=false
com.arsdigita.cms.basetypes.contact.address.hide_country.format=[boolean]
com.arsdigita.cms.basetypes.contact.contact_entry_keys.title=Select available contact entry types
com.arsdigita.cms.basetypes.contact.contact_entry_keys.purpose=Select available contact entry types and define display order
com.arsdigita.cms.basetypes.contact.contact_entry_keys.example=contact_type,office_hours,phone_office,phone_private,phone_mobile,email,fax,im,www
com.arsdigita.cms.basetypes.contact.contact_entry_keys.format=[string]

View File

@ -0,0 +1,114 @@
/*
* BaseContactEntry.java
*
* Created on 13. Mai 2009, 12:31
*
* This class is part of BaseContact and stores the contact informations.
* These informations is organized by a key, which possible values are set by a config param.
* In addition there is a description field to provide additional information for this entry
* which will be shown along with the entry value, if set. If there is no description set, the
* key will be used as a fallback label.
*
* For example:
* key = "phone"
* description = "office phone"
* value = "1234 / 123456"
*
* would be shown as
* office phone: 1234 / 123456
*/
package com.arsdigita.cms.basetypes;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
/**
*
* @author quasi
*/
public class ContactEntry extends ContentItem {
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.basetypes.ContactEntry";
private static final String BASE_DATA_OBJECT_PACKAGE = "com.arsdigita.cms.basetypes";
private static final Logger s_log = Logger.getLogger(ContactEntry.class);
/** PDL property names */
public static final String KEY = "key";
public static final String VALUE = "value";
public static final String DESCRIPTION = "description";
/**
* Creates a new instance of ContactEntry
*/
public ContactEntry() {
this(BASE_DATA_OBJECT_TYPE);
}
public ContactEntry(String typeName) {
super(typeName);
}
public ContactEntry(OID oid) {
super(oid);
}
public ContactEntry(DataObject object) {
super(object);
}
/**
* Constructor. Retrieves an object instance with the given id.
* @param id the id of the object to retrieve
*/
public ContactEntry(BigDecimal id) throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
public ContactEntry(Contact contact, String key, String value, String description) {
this();
setName(key + " for " + contact.getName() + "(" + contact.getID() + ")");
setKey(key);
setValue(value);
setDescription(description);
save();
}
/////////////////////////////////////////////////
// accessors
// Get key
public String getKey() {
return (String) get(KEY);
}
// Set key
public void setKey(String key) {
set(KEY, key);
}
// Get value
public String getValue() {
return (String) get(VALUE);
}
// Set value
public void setValue(String value) {
set(VALUE, value);
}
// Get description
public String getDescription() {
return (String) get(DESCRIPTION);
}
public void setDescription(String description) {
set(DESCRIPTION, description);
}
}

View File

@ -0,0 +1,140 @@
/*
* ContactEntryCollection.java
*
* Created on 13. Mai 2009, 12:32
*
*
*/
package com.arsdigita.cms.basetypes;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.persistence.DataCollection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.TreeSet;
/**
*
* @author quasi
*/
public class ContactEntryCollection extends DomainCollection {
private TreeSet m_sortedCollection = new TreeSet(new ContactEntryComparator());
private Iterator m_iterator;
private boolean m_firstElem;
private ContactEntry m_currentContactEntry;
/**
* Creates a new instance of ContactEntryCollection
*/
public ContactEntryCollection(Contact contact) {
this((DataCollection) contact.getContactEntries());
}
public ContactEntryCollection(DataCollection dataCollection) {
super(dataCollection);
// Now copy all objects from m_dataCollection to the sorting TreeSet
this.sortCollection();
}
@Override
public boolean next() {
boolean retVal = m_iterator.hasNext();
if (retVal) {
m_currentContactEntry = (ContactEntry) m_iterator.next();
m_firstElem = false;
}
return retVal;
}
@Override
public boolean isBeforeFirst() {
return false;
}
@Override
public boolean isAfterLast() {
return false;
}
@Override
public boolean isFirst() {
return m_firstElem;
}
@Override
public boolean isLast() {
return !m_iterator.hasNext();
}
@Override
public boolean isEmpty() {
return m_sortedCollection.isEmpty();
}
@Override
public long size() {
return m_sortedCollection.size();
}
@Override
public void reset() {
super.reset();
m_iterator = null;
m_currentContactEntry = null;
m_sortedCollection = new TreeSet(new ContactEntryComparator());
this.sortCollection();
}
@Override
public void rewind() {
m_iterator = m_sortedCollection.iterator();
}
public final String getKey() {
return (String) getContactEntry().getKey();
}
public final String getDescription() {
return (String) getContactEntry().getDescription();
}
public final String getValue() {
return (String) getContactEntry().getValue();
}
public ContactEntry getContactEntry() {
// return new ContactEntry(m_dataCollection.getDataObject());
return m_currentContactEntry;
}
private void sortCollection() {
m_dataCollection.rewind();
while (m_dataCollection.next()) {
m_sortedCollection.add(new ContactEntry(m_dataCollection.getDataObject()));
}
m_iterator = m_sortedCollection.iterator();
m_firstElem = true;
}
private class ContactEntryComparator implements Comparator {
public int compare(Object o1, Object o2) {
int retVal = 0;
if (o1 instanceof ContactEntry && o2 instanceof ContactEntry) {
ContactEntry bc1 = (ContactEntry) o1;
ContactEntry bc2 = (ContactEntry) o2;
retVal = Contact.getConfig().getKeyIndex(bc1.getKey())
- Contact.getConfig().getKeyIndex(bc2.getKey());
if (retVal == 0) {
retVal = -1;
}
}
return retVal;
}
}
}

View File

@ -0,0 +1,110 @@
/*
* ContactAddressPropertiesStep.java
*
* Created on 4. Juli 2009, 15:15
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.arsdigita.cms.basetypes.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
import com.arsdigita.cms.basetypes.Address;
import com.arsdigita.cms.basetypes.Contact;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
/**
*
* @author quasi
*/
public class ContactAddressPropertiesStep extends SimpleEditStep {
public static final String ADD_ADDRESS_SHEET_NAME = "addAddress";
public static final String EDIT_ADDRESS_SHEET_NAME = "editAddress";
public static final String CHANGE_ADDRESS_SHEET_NAME = "changeAddress";
public static final String DELETE_ADDRESS_SHEET_NAME = "deleteAddress";
/** Creates a new instance of ContactAddressPropertiesStep */
public ContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
this(itemModel, parent, "");
}
public ContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) {
super(itemModel, parent, prefix);
// Contact contact = (Contact)itemModel.getSelectedObject(state);
//XXX
// if(/*contact.getAddress() == null*/ true) {
BasicPageForm attachAddressSheet = new ContactAttachAddressPropertyForm(itemModel, this);
add(ADD_ADDRESS_SHEET_NAME, (String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.attach_address").localize(), new WorkflowLockedComponentAccess(attachAddressSheet, itemModel), attachAddressSheet.getSaveCancelSection().getCancelButton());
/* Set the displayComponent for this step */
// setDisplayComponent(getEmptyBaseAddressPropertySheet(itemModel));
// } else {
// editAddress
BasicPageForm editAddressSheet = new ContactEditAddressPropertyForm(itemModel, this);
add(EDIT_ADDRESS_SHEET_NAME, (String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.edit_address").localize(), new WorkflowLockedComponentAccess(editAddressSheet, itemModel), editAddressSheet.getSaveCancelSection().getCancelButton());
// BasicPageForm attachAddressSheet = new ContactAttachAddressPropertyForm(itemModel, this);
// add(CHANGE_ADDRESS_SHEET_NAME, (String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.reattach_address").localize(), new WorkflowLockedComponentAccess(attachAddressSheet, itemModel), attachAddressSheet.getSaveCancelSection().getCancelButton());
BasicPageForm deleteAddressSheet = new ContactDeleteAddressForm(itemModel, this);
add(DELETE_ADDRESS_SHEET_NAME, (String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.delete_address").localize(), new WorkflowLockedComponentAccess(deleteAddressSheet, itemModel), deleteAddressSheet.getSaveCancelSection().getCancelButton());
/* Set the displayComponent for this step */
setDisplayComponent(getAddressPropertySheet(itemModel));
// }
}
public static Component getAddressPropertySheet(ItemSelectionModel itemModel) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
sheet.add((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.baseAddress.address").localize(), "address." + Address.ADDRESS);
if (!Contact.getConfig().getHideAddressPostalCode()) {
sheet.add((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.baseAddress.postal_code").localize(), "address." + Address.POSTAL_CODE);
}
sheet.add((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.baseAddress.city").localize(), "address." + Address.CITY);
if (!Contact.getConfig().getHideAddressState()) {
sheet.add((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.baseAddress.state").localize(), "address." + Address.STATE);
}
if (!Contact.getConfig().getHideAddressCountry()) {
sheet.add((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.baseAddress.iso_country_code").localize(),
"address." + Address.ISO_COUNTRY_CODE,
new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject item,
String attribute,
PageState state) {
Address Address = ((Contact) item).getAddress();
if (Address != null && Address.getIsoCountryCode() != null) {
return Address.getCountryNameFromIsoCode(Address.getIsoCountryCode());
} else {
return (String) BasetypesGlobalizationUtil.globalize("cms.ui.unknown").localize();
}
}
});
}
return sheet;
}
public static Component getEmptyBaseAddressPropertySheet(ItemSelectionModel itemModel) {
return new Label(((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.emptyAddress").localize()));
}
}

View File

@ -0,0 +1,147 @@
/*
* ContactEditAddressPropertyForm.java
*
* Created on 8. Juli 2009, 10:27
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.arsdigita.cms.basetypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
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.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.basetypes.Address;
import com.arsdigita.cms.basetypes.Contact;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
import com.arsdigita.util.UncheckedWrapperException;
import org.apache.log4j.Logger;
/**
*
* @author quasi
*/
public class ContactAttachAddressPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
private static final Logger logger = Logger.getLogger(ContactPropertyForm.class);
private ContactAddressPropertiesStep m_step;
private ItemSearchWidget m_itemSearch;
private SaveCancelSection m_saveCancelSection;
private final String ITEM_SEARCH = "contactAddress";
/**
* ID of the form
*/
public static final String ID = "ContactAttachAddress";
/**
* Constrctor taking an ItemSelectionModel
*
* @param itemModel
*/
public ContactAttachAddressPropertyForm(ItemSelectionModel itemModel) {
this(itemModel, null);
}
/**
* Constrctor taking an ItemSelectionModel and an instance of ContactPropertiesStep.
*
* @param itemModel
* @param step
*/
public ContactAttachAddressPropertyForm(ItemSelectionModel itemModel, ContactAddressPropertiesStep step) {
super(ID, itemModel);
addSubmissionListener(this);
addSaveCancelSection();
addInitListener(this);
addSubmissionListener(this);
}
@Override
public void addWidgets() {
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.select_address").localize()));
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.basetypes.BaseAddress"));
add(this.m_itemSearch);
}
public void init(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
Contact contact = (Contact)getItemSelectionModel().getSelectedObject(state);
setVisible(state, true);
if (contact != null) {
data.put(ITEM_SEARCH, contact.getAddress());
}
}
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
Contact contact = (Contact)getItemSelectionModel().getSelectedObject(state);
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
contact.setAddress((Address)data.get(ITEM_SEARCH));
}
init(fse);
}
/**
* Creates the section with the save and the cancel button.
*/
@Override
public void addSaveCancelSection() {
try {
getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
Contact contact = (Contact)getItemSelectionModel().getSelectedObject(e.getPageState());
Submit target = (Submit) e.getTarget();
if (contact.getAddress() != null) {
target.setButtonLabel((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.select_address.change").localize());
} else {
target.setButtonLabel((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.select_address.add").localize());
}
}
});
} catch (Exception ex) {
throw new UncheckedWrapperException("this cannot happen", ex);
}
}
@Override
public void validate(FormSectionEvent e) throws FormProcessException {
if (e.getFormData().get(ITEM_SEARCH) == null) {
throw new FormProcessException((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.select_address.wrong_type").localize());
}
}
public void submitted(FormSectionEvent e) throws FormProcessException {
if (getSaveCancelSection().getCancelButton().isSelected(e.getPageState())) {
init(e);
throw new FormProcessException((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.select_address.cancelled").localize());
}
}
}

View File

@ -0,0 +1,147 @@
/*
* ContactEditPersonPropertyForm.java
*
* Created on 8. Juli 2009, 10:27
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.arsdigita.cms.basetypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
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.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.basetypes.Person;
import com.arsdigita.cms.basetypes.Contact;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
import com.arsdigita.util.UncheckedWrapperException;
import org.apache.log4j.Logger;
/**
*
* @author quasi
*/
public class ContactAttachPersonPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
private static final Logger logger = Logger.getLogger(ContactPropertyForm.class);
private ContactPersonPropertiesStep m_step;
private ItemSearchWidget m_itemSearch;
private SaveCancelSection m_saveCancelSection;
private final String ITEM_SEARCH = "contactPerson";
/**
* ID of the form
*/
public static final String ID = "ContactAttachPerson";
/**
* Constrctor taking an ItemSelectionModel
*
* @param itemModel
*/
public ContactAttachPersonPropertyForm(ItemSelectionModel itemModel) {
this(itemModel, null);
}
/**
* Constrctor taking an ItemSelectionModel and an instance of ContactPropertiesStep.
*
* @param itemModel
* @param step
*/
public ContactAttachPersonPropertyForm(ItemSelectionModel itemModel, ContactPersonPropertiesStep step) {
super(ID, itemModel);
addSubmissionListener(this);
addSaveCancelSection();
addInitListener(this);
addSubmissionListener(this);
}
@Override
public void addWidgets() {
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.select_person").localize()));
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.findByAssociatedObjectType("com.arsdigita.cms.basetypes.Person"));
add(this.m_itemSearch);
}
public void init(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
Contact contact = (Contact)getItemSelectionModel().getSelectedObject(state);
setVisible(state, true);
if (contact != null) {
data.put(ITEM_SEARCH, contact.getPerson());
}
}
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
Contact contact = (Contact)getItemSelectionModel().getSelectedObject(state);
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
contact.setPerson((Person)data.get(ITEM_SEARCH));
}
init(fse);
}
/**
* Creates the section with the save and the cancel button.
*/
@Override
public void addSaveCancelSection() {
try {
getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
Contact contact = (Contact)getItemSelectionModel().getSelectedObject(e.getPageState());
Submit target = (Submit) e.getTarget();
if (contact.getPerson() != null) {
target.setButtonLabel((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.select_person.change").localize());
} else {
target.setButtonLabel((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.select_person.add").localize());
}
}
});
} catch (Exception ex) {
throw new UncheckedWrapperException("this cannot happen", ex);
}
}
@Override
public void validate(FormSectionEvent e) throws FormProcessException {
if (e.getFormData().get(ITEM_SEARCH) == null) {
throw new FormProcessException((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.select_person.wrong_type").localize());
}
}
public void submitted(FormSectionEvent e) throws FormProcessException {
if (getSaveCancelSection().getCancelButton().isSelected(e.getPageState())) {
init(e);
throw new FormProcessException((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.select_person.cancelled").localize());
}
}
}

View File

@ -0,0 +1,77 @@
/*
* ContactDeleteAddressForm.java
*
* Created on 17. Juli 2009, 10:10
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.arsdigita.cms.basetypes.ui;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.basetypes.Contact;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.util.UncheckedWrapperException;
/**
*
* @author quasi
*/
public class ContactDeleteAddressForm extends BasicPageForm implements FormProcessListener {
/**
* ID of the form
*/
public static final String ID = "BaseContactDeleteAddress";
ContactDeleteAddressForm(ItemSelectionModel itemModel, ContactAddressPropertiesStep step) {
super(ID, itemModel);
addSaveCancelSection();
}
public void init(FormSectionEvent fse) {
}
@Override
public void addWidgets() {
add(new Label((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.delete_address.label").localize()));
}
/**
* Creates the section with the save and the cancel button.
*/
@Override
public void addSaveCancelSection() {
try {
getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
Contact contact = (Contact) getItemSelectionModel().getSelectedObject(e.getPageState());
Submit target = (Submit) e.getTarget();
target.setButtonLabel((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.delete_address.button_label").localize());
}
});
} catch (Exception ex) {
throw new UncheckedWrapperException("this cannot happen", ex);
}
}
public final void process(final FormSectionEvent fse) throws FormProcessException {
final PageState state = fse.getPageState();
final Contact contact = (Contact) getItemSelectionModel().getSelectedObject(state);
if (contact != null && contact.getAddress() != null) {
contact.unsetAddress();
}
}
}

View File

@ -0,0 +1,80 @@
/*
* ContactDeletePersonForm.java
*
* Created on 17. Juli 2009, 10:10
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.arsdigita.cms.basetypes.ui;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.basetypes.Contact;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.util.UncheckedWrapperException;
/**
*
* @author quasi
*/
public class ContactDeletePersonForm extends BasicPageForm implements FormProcessListener {
/**
* ID of the form
*/
public static final String ID = "ContactDeletePerson";
ContactDeletePersonForm(ItemSelectionModel itemModel, ContactPersonPropertiesStep step) {
super(ID, itemModel);
addSaveCancelSection();
}
public void init(FormSectionEvent fse) {
}
@Override
public void addWidgets() {
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.delete_person.label").localize()));
}
/**
* Creates the section with the save and the cancel button.
*/
@Override
public void addSaveCancelSection() {
try {
getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
Contact contact = (Contact)getItemSelectionModel().getSelectedObject(e.getPageState());
Submit target = (Submit) e.getTarget();
target.setButtonLabel((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.delete_person").localize());
}
});
} catch (Exception ex) {
throw new UncheckedWrapperException("this cannot happen", ex);
}
}
public final void process(final FormSectionEvent fse) throws FormProcessException {
final PageState state = fse.getPageState();
final Contact contact = (Contact)getItemSelectionModel().getSelectedObject(state);
if (contact != null && contact.getPerson() != null) {
contact.unsetPerson();
}
}
}

View File

@ -0,0 +1,189 @@
/*
* ContactEditAddressPropertyForm.java
*
* Created on 8. Juli 2009, 10:27
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.arsdigita.cms.basetypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.ParameterEvent;
import com.arsdigita.bebop.event.ParameterListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.parameters.ParameterData;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import java.util.Iterator;
import java.util.Map;
import com.arsdigita.cms.basetypes.Address;
import com.arsdigita.cms.basetypes.Contact;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
import org.apache.log4j.Logger;
/**
*
* @author quasi
*/
public class ContactEditAddressPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
private static final Logger logger = Logger.getLogger(ContactPropertyForm.class);
private ContactAddressPropertiesStep m_step;
public static final String ADDRESS = Address.ADDRESS;
public static final String POSTAL_CODE = Address.POSTAL_CODE;
public static final String CITY = Address.CITY;
public static final String STATE = Address.STATE;
public static final String ISO_COUNTRY_CODE = Address.ISO_COUNTRY_CODE;
/**
* ID of the form
*/
public static final String ID = "ContactEditAddress";
/**
* Constrctor taking an ItemSelectionModel
*
* @param itemModel
*/
public ContactEditAddressPropertyForm(ItemSelectionModel itemModel) {
this(itemModel, null);
}
/**
* Constrctor taking an ItemSelectionModel and an instance of ContactPropertiesStep.
*
* @param itemModel
* @param step
*/
public ContactEditAddressPropertyForm(ItemSelectionModel itemModel, ContactAddressPropertiesStep step) {
super(ID, itemModel);
m_step = step;
addSubmissionListener(this);
}
@Override
public void addWidgets() {
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.baseAddress.address").localize()));
ParameterModel addressParam = new StringParameter(ADDRESS);
addressParam.addParameterListener( new NotNullValidationListener( ) );
addressParam.addParameterListener( new StringInRangeValidationListener(0, 1000) );
TextArea address = new TextArea(addressParam);
address.setRows(5);
address.setCols(30);
add(address);
if(!Contact.getConfig().getHideAddressPostalCode()) {
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.baseAddress.postal_code").localize()));
ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE);
TextField postalCode = new TextField(postalCodeParam);
/* XXX NumberListener ?*/
add(postalCode);
}
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.baseAddress.city").localize()));
ParameterModel cityParam = new StringParameter(CITY);
TextField city = new TextField(cityParam);
add(city);
if(!Contact.getConfig().getHideAddressState()) {
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.baseAddress.state").localize()));
ParameterModel stateParam = new StringParameter(STATE);
TextField state = new TextField(stateParam);
add(state);
}
if (!Contact.getConfig().getHideAddressCountry()) {
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.baseAddress.iso_country_code").localize()));
ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE);
countryParam.addParameterListener(new StringInRangeValidationListener(0, 2));
SingleSelect country = new SingleSelect(countryParam);
country.addOption(new Option("", new Label((String)BasetypesGlobalizationUtil.globalize("cms.ui.select_one" ).localize())));
Iterator countries = Address.getSortedListOfCountries(null).entrySet().iterator();
while(countries.hasNext()) {
Map.Entry<String,String> elem = (Map.Entry<String,String>)countries.next();
country.addOption(new Option(elem.getValue().toString(), elem.getKey().toString()));
}
country.addValidationListener(
new ParameterListener() {
public void validate(ParameterEvent e) throws FormProcessException {
ParameterData data = e.getParameterData();
String isoCode = (String) data.getValue() ;
if (isoCode == null || isoCode.length() == 0) {
data.addError((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.address.error_iso_country").localize());
}
}
}
);
add(country);
}
}
public void init(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
Contact contact = (Contact)getItemSelectionModel().getSelectedObject(state);
if(contact.getAddress() != null) {
data.put(ADDRESS, contact.getAddress().getAddress());
data.put(POSTAL_CODE, contact.getAddress().getPostalCode());
data.put(CITY, contact.getAddress().getCity());
data.put(STATE, contact.getAddress().getState());
if(!Address.getConfig().getHideCountryCodeSelection()) {
data.put(ISO_COUNTRY_CODE, contact.getAddress().getIsoCountryCode());
}
}
}
public void submitted(FormSectionEvent fse) {
if (m_step != null &&
getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
m_step.cancelStreamlinedCreation(fse.getPageState());
}
}
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
Contact contact = (Contact)getItemSelectionModel().getSelectedObject(state);
if (contact.getAddress() != null &&
getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
contact.getAddress().setAddress((String)data.get(ADDRESS));
contact.getAddress().setPostalCode((String)data.get(POSTAL_CODE));
contact.getAddress().setCity((String)data.get(CITY));
contact.getAddress().setState((String)data.get(STATE));
contact.getAddress().setIsoCountryCode((String)data.get(ISO_COUNTRY_CODE));
contact.getAddress().save();
}
if (m_step != null) {
m_step.maybeForwardToNextStep(fse.getPageState());
}
}
}

View File

@ -0,0 +1,141 @@
/*
* ContactEditPersonPropertyForm.java
*
* Created on 8. Juli 2009, 10:27
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.arsdigita.cms.basetypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.basetypes.Contact;
import com.arsdigita.cms.basetypes.Person;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
import org.apache.log4j.Logger;
/**
*
* @author quasi
*/
public class ContactEditPersonPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
private static final Logger logger = Logger.getLogger(ContactPropertyForm.class);
private ContactPersonPropertiesStep m_step;
public static final String SURNAME = Person.SURNAME;
public static final String GIVENNAME = Person.GIVENNAME;
public static final String TITLEPRE = Person.TITLEPRE;
public static final String TITLEPOST = Person.TITLEPOST;
/**
* ID of the form
*/
public static final String ID = "ContactEditPerson";
/**
* Constrctor taking an ItemSelectionModel
*
* @param itemModel
*/
public ContactEditPersonPropertyForm(ItemSelectionModel itemModel) {
this(itemModel, null);
}
/**
* Constrctor taking an ItemSelectionModel and an instance of ContactPropertiesStep.
*
* @param itemModel
* @param step
*/
public ContactEditPersonPropertyForm(ItemSelectionModel itemModel, ContactPersonPropertiesStep step) {
super(ID, itemModel);
m_step = step;
addSubmissionListener(this);
}
@Override
public void addWidgets() {
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.person.surname").localize()));
ParameterModel surnameParam = new StringParameter(SURNAME);
surnameParam.addParameterListener( new NotNullValidationListener( ) );
surnameParam.addParameterListener( new StringInRangeValidationListener(0, 1000) );
TextField surname = new TextField(surnameParam);
add(surname);
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.person.givenname").localize()));
ParameterModel givennameParam = new StringParameter(GIVENNAME);
givennameParam.addParameterListener( new NotNullValidationListener( ) );
givennameParam.addParameterListener( new StringInRangeValidationListener(0, 1000) );
TextField givenname = new TextField(givennameParam);
add(givenname);
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.person.titlepre").localize()));
ParameterModel titlepreParam = new StringParameter(TITLEPRE);
titlepreParam.addParameterListener( new StringInRangeValidationListener(0, 1000) );
TextField titlepre = new TextField(titlepreParam);
add(titlepre);
add(new Label((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.person.titlepost").localize()));
ParameterModel titlepostParam = new StringParameter(TITLEPOST);
titlepostParam.addParameterListener( new StringInRangeValidationListener(0, 1000) );
TextField titlepost = new TextField(titlepostParam);
add(titlepost);
}
public void init(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
Contact contact = (Contact)getItemSelectionModel().getSelectedObject(state);
if(contact.getPerson() != null) {
data.put(SURNAME, contact.getPerson().getSurname());
data.put(GIVENNAME, contact.getPerson().getGivenName());
data.put(TITLEPRE, contact.getPerson().getTitlePre());
data.put(TITLEPOST, contact.getPerson().getTitlePost());
}
}
public void submitted(FormSectionEvent fse) {
if (m_step != null &&
getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
m_step.cancelStreamlinedCreation(fse.getPageState());
}
}
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
Contact contact = (Contact)getItemSelectionModel().getSelectedObject(state);
if (contact.getPerson() != null &&
getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
contact.getPerson().setSurname((String)data.get(SURNAME));
contact.getPerson().setGivenName((String)data.get(GIVENNAME));
contact.getPerson().setTitlePre((String)data.get(TITLEPRE));
contact.getPerson().setTitlePost((String)data.get(TITLEPOST));
contact.getPerson().save();
}
if (m_step != null) {
m_step.maybeForwardToNextStep(fse.getPageState());
}
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.basetypes.ui;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
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;
/**
* A UI step to manipulate <code>Phones </code> for the Contact object
* which is retrieved from the ItemSelectionModel.
*
*
* @author Shashin Shinde <a href="mailto:sshinde@redhat.com">sshinde@redhat.com</a>
* @version $Id: PhoBaseContactEntriesPropertiesStepva 287 2005-02-22 00:29:02Z sskracic $
*/
public class ContactEntriesPropertiesStep extends SimpleEditStep {
/** The name of the editing sheet added to this step */
private static String ADD_CONTACT_ENTRY_SHEET_NAME = "addContactEntry";
public ContactEntriesPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
this(itemModel, parent, null);
}
public ContactEntriesPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) {
super(itemModel, parent, prefix);
BasicItemForm addContactEntrySheet = new ContactEntryAddForm(itemModel);
add(ADD_CONTACT_ENTRY_SHEET_NAME, (String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.add_contactEntry").localize(), new WorkflowLockedComponentAccess(addContactEntrySheet, itemModel), addContactEntrySheet.getSaveCancelSection().getCancelButton());
ContactEntriesTable contactEntriesTable = new ContactEntriesTable(itemModel);
setDisplayComponent(contactEntriesTable);
}
}

View File

@ -0,0 +1,272 @@
/*
* Copyright (C) 2008 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.basetypes.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.basetypes.Contact;
import com.arsdigita.cms.basetypes.ContactEntry;
import com.arsdigita.cms.basetypes.ContactEntryCollection;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.cms.util.GlobalizationUtil;
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 ContactEntriesTable 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 ContactEntriesTable
*/
public ContactEntriesTable(final ItemSelectionModel itemModel) {
super();
this.m_itemModel = itemModel;
// if table is empty:
setEmptyView(new Label(BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.contactEntry.none")));
TableColumnModel tab_model = getColumnModel();
// define columns
tab_model.add(new TableColumn(0, BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.contactEntry.key").localize(), TABLE_COL_EDIT));
tab_model.add(new TableColumn(1, BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.contactEntry.value").localize()));
tab_model.add(new TableColumn(2, BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.contactEntry.description").localize()));
tab_model.add(new TableColumn(3, BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.contactEntry.action").localize(), TABLE_COL_DEL));
setModelBuilder(new ContactTableModelBuilder(itemModel));
tab_model.get(0).setCellRenderer(new EditCellRenderer());
tab_model.get(3).setCellRenderer(new DeleteCellRenderer());
addTableActionListener(this);
}
/**
* XXXX
*
*/
private class ContactTableModelBuilder extends LockableImpl implements TableModelBuilder {
private ItemSelectionModel m_itemModel;
public ContactTableModelBuilder(ItemSelectionModel itemModel) {
m_itemModel = itemModel;
}
public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state);
Contact contact = (Contact) m_itemModel.getSelectedObject(state);
// if (contact != null && contact.hasContactEntries()) {
return new ContactTableModel(table, state, contact);
// } else {
// return Table.EMPTY_MODEL;
// }
}
}
/**
* XXX
*
*/
private class ContactTableModel implements TableModel {
final private int MAX_DESC_LENGTH = 25;
private Table m_table;
private ContactEntryCollection m_contactEntryCollection;
private ContactEntry m_contactEntry;
private ContactTableModel(Table t, PageState ps, Contact contact) {
m_table = t;
m_contactEntryCollection = contact.getContactEntries();
}
public int getColumnCount() {
return m_table.getColumnModel().size();
}
/**
* Check collection for the existence of another row.
*
* If exists, fetch the value of current ContactEntryCollection object
* into m_contactEntry class variable.
*/
public boolean nextRow() {
if(m_contactEntryCollection != null && m_contactEntryCollection.next()){
m_contactEntry = m_contactEntryCollection.getContactEntry();
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 (String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.contactEntry.key." + m_contactEntry.getKey()).localize();
case 1:
return m_contactEntry.getValue();
case 2:
return (m_contactEntry.getDescription() != null && m_contactEntry.getDescription().length() > MAX_DESC_LENGTH)
? m_contactEntry.getDescription().substring(0, MAX_DESC_LENGTH)
: m_contactEntry.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_contactEntry.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);
Contact contact = (Contact) m_itemModel.getSelectedObject(state);
boolean canEdit = sm.canAccess(state.getRequest(),
SecurityManager.EDIT_ITEM,
contact);
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);
Contact contact = (Contact) m_itemModel.getSelectedObject(state);
boolean canDelete = sm.canAccess(state.getRequest(),
SecurityManager.DELETE_ITEM,
contact);
if(canDelete) {
ControlLink link = new ControlLink(value.toString());
link.setConfirmation((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.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 ContactEntry
ContactEntry contactEntry =
new ContactEntry(new BigDecimal(evt.getRowKey().toString()));
// Get Contact
Contact contact = (Contact) 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)) {
contact.removeContactEntry(contactEntry);
}
}
/**
* 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,109 @@
/*
* Copyright (C) 2008 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.basetypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.Label;
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.cms.ItemSelectionModel;
import com.arsdigita.cms.basetypes.Contact;
import com.arsdigita.cms.basetypes.ContactEntry;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.bebop.parameters.StringParameter;
import java.util.StringTokenizer;
import org.apache.log4j.Logger;
/**
* @author Sören Bernstein (quasimodo) quasi@barkhof.uni-bremen.de
*/
public class ContactEntryAddForm extends BasicItemForm {
private static final Logger s_log = Logger.getLogger(ContactEntryAddForm.class);
private ItemSelectionModel m_itemModel;
/** Creates a new instance of CategoryLocalizationAddForm */
public ContactEntryAddForm(ItemSelectionModel itemModel) {
super("ContactEntryAddForm",itemModel);
m_itemModel = itemModel;
}
@Override
protected void addWidgets() {
// Key field
add(new Label(BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.contactEntry.key")));
ParameterModel contactEntryKeyParam = new StringParameter(ContactEntry.KEY);
SingleSelect contactEntryKey = new SingleSelect(contactEntryKeyParam);
contactEntryKey.addValidationListener(new NotNullValidationListener());
contactEntryKey.addOption(new Option("", new Label((String)BasetypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
// Add the Options to the SingleSelect widget
StringTokenizer keyList = Contact.getConfig().getContactEntryKeys();
while(keyList.hasMoreElements()) {
String currentKey = keyList.nextToken();
contactEntryKey.addOption(new Option(currentKey, ((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.contactEntry.key." + currentKey).localize())));
}
add(contactEntryKey);
// Value field
add(new Label(BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.contactEntry.value")));
ParameterModel contactEntryValueParam = new StringParameter(ContactEntry.VALUE);
TextField contactEntryValue = new TextField(contactEntryValueParam);
contactEntryValue.addValidationListener(new NotNullValidationListener());
add(contactEntryValue);
// Description field, only for internal usage
add(new Label(BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.contactEntry.description")));
ParameterModel contactEntryDescriptionParam = new StringParameter(ContactEntry.DESCRIPTION);
TextField contactEntryDescription = new TextField(contactEntryDescriptionParam);
add(contactEntryDescription);
}
public void init(FormSectionEvent fse) {
}
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
Contact contact = (Contact)m_itemModel.getSelectedObject(fse.getPageState());
// save only if save button was pressed
if (contact != null
&& getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
ContactEntry contactEntry = new ContactEntry(contact,
(String)data.get(ContactEntry.KEY),
(String)data.get(ContactEntry.VALUE),
(String)data.get(ContactEntry.DESCRIPTION));
contact.addContactEntry(contactEntry);
}
}
}

View File

@ -0,0 +1,84 @@
/*
* ContactPersonPropertiesStep.java
*
* Created on 4. Juli 2009, 15:12
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.arsdigita.cms.basetypes.ui;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
import com.arsdigita.cms.basetypes.Person;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
/**
*
* @author quasi
*/
public class ContactPersonPropertiesStep extends SimpleEditStep {
public static final String ADD_PERSON_SHEET_NAME = "addPerson";
public static final String EDIT_PERSON_SHEET_NAME = "editPerson";
public static final String CHANGE_PERSON_SHEET_NAME = "changePerson";
public static final String DELETE_PERSON_SHEET_NAME = "deletePerson";
/**
* Creates a new instance of ContactPersonPropertiesStep
*/
public ContactPersonPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
this(itemModel, parent, "");
}
public ContactPersonPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) {
super(itemModel, parent, prefix);
//XXX
// if(false/*EMPTY*/) {
BasicPageForm addPersonSheet = new ContactAttachPersonPropertyForm(itemModel, this);
add(ADD_PERSON_SHEET_NAME, (String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.attach_person").localize(), new WorkflowLockedComponentAccess(addPersonSheet, itemModel), addPersonSheet.getSaveCancelSection().getCancelButton());
/* Set the displayComponent for this step */
// setDisplayComponent(getEmptyPersonPropertySheet(itemModel));
// } else {
BasicPageForm editPersonSheet = new ContactEditPersonPropertyForm(itemModel, this);
add(EDIT_PERSON_SHEET_NAME, (String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.edit_person").localize(), new WorkflowLockedComponentAccess(editPersonSheet, itemModel), editPersonSheet.getSaveCancelSection().getCancelButton());
// BasicPageForm changePersonSheet = new ContactEditPersonPropertyForm(itemModel, this);
// add(CHANGE_PERSON_SHEET_NAME, (String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.reattach_person").localize(), new WorkflowLockedComponentAccess(changePersonSheet, itemModel), changePersonSheet.getSaveCancelSection().getCancelButton());
BasicPageForm deletePersonSheet = new ContactDeletePersonForm(itemModel, this);
add(DELETE_PERSON_SHEET_NAME, (String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.delete_person").localize(), new WorkflowLockedComponentAccess(deletePersonSheet, itemModel), deletePersonSheet.getSaveCancelSection().getCancelButton());
/* Set the displayComponent for this step */
setDisplayComponent(getPersonPropertySheet(itemModel));
// }
}
public static Component getPersonPropertySheet(ItemSelectionModel itemModel) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
sheet.add((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.person.surname").localize(), "person." + Person.SURNAME);
sheet.add((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.person.givenname").localize(), "person." + Person.GIVENNAME);
sheet.add((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.person.titlepre").localize(), "person." + Person.TITLEPRE);
sheet.add((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.person.titlepost").localize(), "person." + Person.TITLEPOST);
return sheet;
}
public static Component getEmptyPersonPropertySheet(ItemSelectionModel itemModel) {
return new Label(((String)BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.emptyPerson").localize()));
}
}

View File

@ -0,0 +1,123 @@
package com.arsdigita.cms.basetypes.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.cms.basetypes.Contact;
import com.arsdigita.cms.basetypes.util.BasetypesGlobalizationUtil;
import java.text.DateFormat;
import org.apache.log4j.Logger;
/**
* AuthoringStep for the basic properties of a basic contact
*/
public class ContactPropertiesStep extends SimpleEditStep {
private static final Logger logger = Logger.getLogger(ContactPropertiesStep.class);
/**
* Name of the this edit sheet (Don't know if this this really needed.
* It has the same value in almost all PropertiesStep classes)
*/
public static final String EDIT_BASIC_SHEET_NAME = "editBasic";
/**
* Constructor for the PropertiesStep.
*
* @param itemModel
* @param parent
*/
public ContactPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
super(itemModel, parent);
setDefaultEditKey(EDIT_BASIC_SHEET_NAME);
SegmentedPanel segmentedPanel = createEditSheet(itemModel, parent);
/* Sets the composed segmentedPanel as display component */
setDisplayComponent(segmentedPanel);
}
protected SegmentedPanel createEditSheet(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
/* Use a Segmented Panel for the multiple parts of data */
SegmentedPanel segmentedPanel = new SegmentedPanel();
/* The different parts of information are displayed in seperated segments each containing a SimpleEditStep */
/* Well, not so simple anymore... */
/* A new SimpleEditStep */
SimpleEditStep basicProperties = new SimpleEditStep(itemModel, parent, EDIT_BASIC_SHEET_NAME);
/* Create the edit component for this SimpleEditStep and the corresponding link */
BasicPageForm editBasicSheet = new ContactPropertyForm(itemModel, this);
basicProperties.add(EDIT_BASIC_SHEET_NAME, (String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.edit_basic_properties").localize(), new WorkflowLockedComponentAccess(editBasicSheet, itemModel), editBasicSheet.getSaveCancelSection().getCancelButton());
/* Set the displayComponent for this step */
basicProperties.setDisplayComponent(getContactPropertySheet(itemModel));
/* Add the SimpleEditStep to the segmented panel */
segmentedPanel.addSegment(new Label((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.basic_properties").localize()), basicProperties);
// If not disabled via registry, add the ui for attaching a person
if (!Contact.getConfig().getHidePerson()) {
ContactPersonPropertiesStep personProperties = new ContactPersonPropertiesStep(itemModel, parent);
segmentedPanel.addSegment(new Label((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.person").localize()), personProperties);
}
if (!Contact.getConfig().getHideAddress()) {
ContactAddressPropertiesStep addressProperties = new ContactAddressPropertiesStep(itemModel, parent);
segmentedPanel.addSegment(new Label((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.address").localize()), addressProperties);
}
ContactEntriesPropertiesStep contactEntries = new ContactEntriesPropertiesStep(itemModel, parent);
segmentedPanel.addSegment(new Label((String) BasetypesGlobalizationUtil.globalize("cms.basetypes.ui.contact.contactEntry").localize()), contactEntries);
return segmentedPanel;
}
/**
* Creates and returns the sheet for editing the basic properties
* of a contact. (@see ContactPropertyForm).
*
* @param itemModel
* @return The sheet for editing the properties of the contact.
*/
public static Component getContactPropertySheet(ItemSelectionModel itemModel) {
/* The DisplayComponent for the Basic Properties */
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
sheet.add(GlobalizationUtil.globalize("cms.basetypes.ui.name"), "name");
sheet.add(GlobalizationUtil.globalize("cms.basetypes.ui.title"), "title");
if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"), ContentPage.LAUNCH_DATE, new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject obj, String attribute, PageState state) {
ContentPage page = (ContentPage) obj;
if (page.getLaunchDate() != null) {
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
} else {
return (String) GlobalizationUtil.globalize("cms.ui.unknown").localize();
}
}
});
}
return sheet;
}
}

View File

@ -0,0 +1,97 @@
package com.arsdigita.cms.basetypes.ui;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
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.cms.ItemSelectionModel;
import com.arsdigita.bebop.FormData;
import com.arsdigita.cms.basetypes.Contact;
import org.apache.log4j.Logger;
/**
* Form for editing the basic properties of a basic contact.
*/
public class ContactPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
private static final Logger logger = Logger.getLogger(ContactPropertyForm.class);
private ContactPropertiesStep m_step;
public static final String PERSON = Contact.PERSON;
public static final String ADRESS = Contact.ADDRESS;
public static final String CONTACT_ENTRIES= Contact.CONTACT_ENTRIES;
/**
* ID of the form
*/
public static final String ID = "Contact_edit";
/**
* Constrctor taking an ItemSelectionModel
*
* @param itemModel
*/
public ContactPropertyForm(ItemSelectionModel itemModel) {
this(itemModel, null);
}
/**
* Constrctor taking an ItemSelectionModel and an instance of BaseContactPropertiesStep.
*
* @param itemModel
* @param step
*/
public ContactPropertyForm(ItemSelectionModel itemModel, ContactPropertiesStep step) {
super(ID, itemModel);
m_step = step;
addSubmissionListener(this);
}
@Override
public void addWidgets() {
super.addWidgets();
/*
add(new Label((String)BaseContactGlobalizationUtil.globalize("cms.basetypes.ui.contact.basic_properties.description").localize())));
TextArea description = new TextArea(DESCRIPTION);
description.setRows(5);
description.setCols(30);
add(description);
*/
}
@Override
public void init(FormSectionEvent e) throws FormProcessException {
FormData data = e.getFormData();
Contact contact = (Contact)super.initBasicWidgets(e);
// data.put(DESCRIPTION, contact.getDescription());
}
@Override
public void process(FormSectionEvent e) throws FormProcessException {
FormData data = e.getFormData();
Contact contact = (Contact)super.processBasicWidgets(e);
if((contact != null) && (getSaveCancelSection().getSaveButton().isSelected(e.getPageState()))) {
// contact.setDescription((String)data.get(DESCRIPTION));
contact.save();
}
if(m_step != null) {
m_step.maybeForwardToNextStep(e.getPageState());
}
}
public void submitted(FormSectionEvent e) throws FormProcessException {
if((m_step != null) && (getSaveCancelSection().getCancelButton().isSelected(e.getPageState()))) {
m_step.cancelStreamlinedCreation(e.getPageState());
}
}
}

View File

@ -3,13 +3,14 @@
<head> <head>
<title>Auditing Service</title> <title>Auditing Service</title>
</head> </head>
<body bgcolor="white"> <body>
<p>
The Auditing Service provides a standard API The Auditing Service provides a standard API
and common mechanism for providing a Domain Object with auditing and common mechanism for providing a Domain Object with auditing
information. Developers of Domain Objects can use this standard information. Developers of Domain Objects can use this standard
mechanism with almost no overhead, significantly speeding up the mechanism with almost no overhead, significantly speeding up the
development process.</p> development process.
</p>
<p> <p>
For a more complete description, see the full For a more complete description, see the full
<a href="http://developer.arsdigita.com/acs-java/doc/core-platform/4.6/services/auditing/requirements.html"> <a href="http://developer.arsdigita.com/acs-java/doc/core-platform/4.6/services/auditing/requirements.html">