diff --git a/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/Address.java b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/Address.java new file mode 100755 index 000000000..fbf08914f --- /dev/null +++ b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/Address.java @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.globalization.LocaleNegotiator; +import com.arsdigita.cms.ContentType; +import com.arsdigita.domain.DataObjectNotFoundException; +import com.arsdigita.persistence.DataObject; +import com.arsdigita.persistence.OID; +import com.arsdigita.util.Assert; +import java.math.BigDecimal; +import java.util.Locale; +import java.util.TreeMap; + +/** + *

DomainObject class to represent address ContentType + * objects. + *
+ * This content type represents a generic address which is not country specific. + * It provides methods for creating new address objects, retrieving existing + * objects from the persistent storage and retrieving and setting is properties.

+ *

This class extends {@link com.arsdigita.cms.ContentItem content item} and + * adds extended attributes specific for an not country specific address:

+ * + * @author Sören Bernstein + **/ +public class Address extends com.arsdigita.cms.basetypes.Address { + + /** Data object type for this domain object */ + public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Address"; + + /** + * Default constructor. This creates a new (empty) Address. + **/ + public Address() { + this(BASE_DATA_OBJECT_TYPE); + } + + /** + * Constructor. The contained DataObject is retrieved + * from the persistent storage mechanism with an OID + * specified by id and + * Address.BASE_DATA_OBJECT_TYPE. + * + * @param id The id for the retrieved + * DataObject. + **/ + public Address(BigDecimal id) throws DataObjectNotFoundException { + this(new OID(BASE_DATA_OBJECT_TYPE, id)); + } + + /** + * Constructor. The contained DataObject is retrieved + * from the persistent storage mechanism with an OID + * specified by id. + * + * @param id The OID for the retrieved + * DataObject. + **/ + public Address(OID id) throws DataObjectNotFoundException { + super(id); + } + + /** + * Constructor. Retrieves or creates a content item using the + * DataObject argument. + * + * @param obj The DataObject with which to create or + * load a content item + */ + public Address(DataObject obj) { + super(obj); + } + + /** + * Constructor. Creates a new content item using the given data + * object type. Such items are created as draft versions. + * + * @param type The String data object type of the + * item to create + */ + public Address(String type) { + super(type); + } + + /** + * For new content items, sets the associated content type if it + * has not been already set. + */ + @Override + public void beforeSave() { + super.beforeSave(); + + Assert.exists(getContentType(), ContentType.class); + } + + /* accessors *****************************************************/ +} diff --git a/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/AddressInitializer.java b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/AddressInitializer.java new file mode 100755 index 000000000..96e459dbc --- /dev/null +++ b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/AddressInitializer.java @@ -0,0 +1,25 @@ +package com.arsdigita.cms.contenttypes; + +import org.apache.log4j.Logger; + +/** + * The CMS initializer + * + */ +public class AddressInitializer extends ContentTypeInitializer { + + private static final Logger s_log = Logger.getLogger(AddressInitializer.class); + + public AddressInitializer() { + super("ccm-cms-types-address.pdl.mf", + Address.BASE_DATA_OBJECT_TYPE); + } + + @Override + public String[] getStylesheets() { + return new String[] { + "/static/content-types/com/arsdigita/cms/contenttypes/Address.xsl" + }; + } + +} diff --git a/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/AddressLoader.java b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/AddressLoader.java new file mode 100755 index 000000000..a95a3571a --- /dev/null +++ b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/AddressLoader.java @@ -0,0 +1,17 @@ +package com.arsdigita.cms.contenttypes; + +/** + * Loader + * + */ +public class AddressLoader extends AbstractContentTypeLoader { + + private static final String[] TYPES = { + "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/Address.xml" + }; + + public String[] getTypes() { + return TYPES; + } + +} diff --git a/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/BaseAddressInitializer.java b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/BaseAddressInitializer.java deleted file mode 100755 index 106b559c3..000000000 --- a/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/BaseAddressInitializer.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.arsdigita.cms.contenttypes; - -import org.apache.log4j.Logger; - -/** - * The CMS initializer - * - */ -public class BaseAddressInitializer extends ContentTypeInitializer { - public final static String versionId = - "$Id: BaseAddressInitializer.java $" + - "$Author: quasi $" + - "$DateTime: 2009/03/15 $"; - private static final Logger s_log = Logger.getLogger(BaseAddressInitializer.class); - - public BaseAddressInitializer() { - super("ccm-cms-types-baseAddress.pdl.mf", - BaseAddress.BASE_DATA_OBJECT_TYPE); - } - - public String[] getStylesheets() { - return new String[] { - "/static/content-types/com/arsdigita/cms/contenttypes/BaseAddress.xsl" - }; - } - -} diff --git a/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/BaseAddressLoader.java b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/BaseAddressLoader.java deleted file mode 100755 index 0afcd64cb..000000000 --- a/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/BaseAddressLoader.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.arsdigita.cms.contenttypes; - -import com.arsdigita.cms.contenttypes.AbstractContentTypeLoader; - - -/** - * Loader - * - */ -public class BaseAddressLoader extends AbstractContentTypeLoader { - public final static String versionId = - "$Id: BaseAddressLoader.java$" + - "$Author: quasi $" + - "$DateTime: 2009/03/15 $"; - - - private static final String[] TYPES = { - "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/BaseAddress.xml" - }; - - public String[] getTypes() { - return TYPES; - } - -} diff --git a/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/ui/AddressPropertiesStep.java b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/ui/AddressPropertiesStep.java new file mode 100644 index 000000000..9797bd4a4 --- /dev/null +++ b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/ui/AddressPropertiesStep.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Jens Pelzetter, for the Center of Social Politics of the University of Bremen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Component; +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; + + +public class AddressPropertiesStep extends com.arsdigita.cms.basetypes.ui.AddressPropertiesStep { + + public static final String EDIT_SHEET_NAME = "edit"; + + public AddressPropertiesStep(ItemSelectionModel itemModel, + AuthoringKitWizard parent) { + super(itemModel, parent); + } + + @Override + protected void createEditSheet(ItemSelectionModel itemModel) { + BasicPageForm editSheet; + editSheet = new AddressPropertyForm(itemModel, this); + add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel), editSheet.getSaveCancelSection().getCancelButton()); + } + + public static Component getAddressPropertySheet(ItemSelectionModel itemModel) { + Component sheet = AddressPropertiesStep.getAddressPropertySheet(itemModel); + return sheet; + } +} diff --git a/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/ui/AddressPropertyForm.java b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/ui/AddressPropertyForm.java new file mode 100644 index 000000000..23c5fe03f --- /dev/null +++ b/ccm-cms-types-address/src/com/arsdigita/cms/contenttypes/ui/AddressPropertyForm.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2009 Jens Pelzetter, for the Center of Social Politics of the University of Bremen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.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 org.apache.log4j.Logger; + +/** + * Form to edit the properties of an address. + * + * @author: Jens Pelzetter + * @author: Sören Bernstein + */ +public class AddressPropertyForm extends com.arsdigita.cms.basetypes.ui.AddressPropertyForm implements FormProcessListener, FormInitListener, FormSubmissionListener { + + private static final Logger s_log = Logger.getLogger(AddressPropertyForm.class); + private AddressPropertiesStep m_step; + public static final String ID = "Address_edit"; + + public AddressPropertyForm(ItemSelectionModel itemModel) { + this(itemModel, null); + } + + public AddressPropertyForm(ItemSelectionModel itemModel, AddressPropertiesStep step) { + super(itemModel, step); + m_step = step; + addSubmissionListener(this); + } + + @Override + protected void addWidgets() { + super.addWidgets(); + } + + @Override + public void init(FormSectionEvent fse) { + super.init(fse); + } + + @Override + public void process(FormSectionEvent fse) { + super.process(fse); + } +} diff --git a/ccm-cms-types-address/web/static/content-types/com/arsdigita/cms/contenttypes/BaseAddress.xsl b/ccm-cms-types-address/web/static/content-types/com/arsdigita/cms/contenttypes/Address.xsl similarity index 91% rename from ccm-cms-types-address/web/static/content-types/com/arsdigita/cms/contenttypes/BaseAddress.xsl rename to ccm-cms-types-address/web/static/content-types/com/arsdigita/cms/contenttypes/Address.xsl index 2215c9856..6a5061f77 100644 --- a/ccm-cms-types-address/web/static/content-types/com/arsdigita/cms/contenttypes/BaseAddress.xsl +++ b/ccm-cms-types-address/web/static/content-types/com/arsdigita/cms/contenttypes/Address.xsl @@ -6,8 +6,8 @@ xmlns:cms="http://www.arsdigita.com/cms/1.0" version="1.0"> - +
@@ -47,8 +47,8 @@
- +

Address @@ -68,4 +68,4 @@
- \ No newline at end of file +