Author: apevec Date: 2005-12-13 23:39:04 +0100 (Tue, 13 Dec 2005) New Revision: 1049 Added: trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/oracle-se/ trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/oracle-se/upgrade/ trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/oracle-se/upgrade/atoz-modification.sql trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/postgres/ trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/postgres/upgrade/ trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/postgres/upgrade/atoz-modification.sql trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/upgrade/ trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/upgrade/oracle-se-6.3.0-6.3.1.sql trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/upgrade/postgres-6.3.0-6.3.1.sql trunk/ccm-cms-types-siteproxy/src/ccm-cms-types-siteproxy.upgrade trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxyUpgrade630to631.java trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/Constants.java trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/SiteProxyAtoZPropertiesStep.java trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/SiteProxyAtoZPropertyForm.java Modified: trunk/ccm-cms-types-siteproxy/application.xml trunk/ccm-cms-types-siteproxy/pdl/com/arsdigita/cms/contenttypes/SiteProxy.pdl trunk/ccm-cms-types-siteproxy/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SiteProxy.xml trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxy.java trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxyResources.properties Log: SiteProxy content type modifications to enable its usage as a data source for AtoZ application NB data model change: ccm upgrade ccm-cms-types-siteproxy --from-version 6.3.0 --to-version 6.3.1 Modified: trunk/ccm-cms-types-siteproxy/application.xml =================================================================== --- trunk/ccm-cms-types-siteproxy/application.xml 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/application.xml 2005-12-13 22:39:04 UTC (rev 1049) @@ -2,8 +2,8 @@ <ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project" name="ccm-cms-types-siteproxy" prettyName="Red Hat CCM Content Types" - version="6.3.0" - release="3" + version="6.3.1" + release="1" webapp="ROOT"> <ccm:dependencies> <ccm:requires name="ccm-core" version="6.2.0" relation="ge"/> Modified: trunk/ccm-cms-types-siteproxy/pdl/com/arsdigita/cms/contenttypes/SiteProxy.pdl =================================================================== --- trunk/ccm-cms-types-siteproxy/pdl/com/arsdigita/cms/contenttypes/SiteProxy.pdl 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/pdl/com/arsdigita/cms/contenttypes/SiteProxy.pdl 2005-12-13 22:39:04 UTC (rev 1049) @@ -23,7 +23,8 @@ object type SiteProxy extends ContentPage { String [0..1] url = ct_siteproxy.url VARCHAR(250); - + String [0..1] titleAtoZ = ct_siteproxy.title_atoz VARCHAR(200); + Boolean[0..1] usedInAtoZ = ct_siteproxy.used_in_atoz BIT; reference key (ct_siteproxy.site_id); } Added: trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/oracle-se/upgrade/atoz-modification.sql =================================================================== --- trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/oracle-se/upgrade/atoz-modification.sql 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/oracle-se/upgrade/atoz-modification.sql 2005-12-13 22:39:04 UTC (rev 1049) @@ -0,0 +1,8 @@ +alter table ct_siteproxy add ( + title_atoz VARCHAR(200) +); +alter table ct_siteproxy add ( + used_in_atoz CHAR(1) + constraint ct_sitepro_use_in_atoz_c_fitem + check(used_in_atoz in ('0', '1')) +); Added: trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/postgres/upgrade/atoz-modification.sql =================================================================== --- trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/postgres/upgrade/atoz-modification.sql 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/postgres/upgrade/atoz-modification.sql 2005-12-13 22:39:04 UTC (rev 1049) @@ -0,0 +1,2 @@ +alter table ct_siteproxy add title_atoz VARCHAR(200); +alter table ct_siteproxy add used_in_atoz BOOLEAN; Added: trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/upgrade/oracle-se-6.3.0-6.3.1.sql =================================================================== --- trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/upgrade/oracle-se-6.3.0-6.3.1.sql 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/upgrade/oracle-se-6.3.0-6.3.1.sql 2005-12-13 22:39:04 UTC (rev 1049) @@ -0,0 +1 @@ +@@ ../oracle-se/upgrade/atoz-modification.sql Added: trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/upgrade/postgres-6.3.0-6.3.1.sql =================================================================== --- trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/upgrade/postgres-6.3.0-6.3.1.sql 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/sql/ccm-cms-types-siteproxy/upgrade/postgres-6.3.0-6.3.1.sql 2005-12-13 22:39:04 UTC (rev 1049) @@ -0,0 +1 @@ +\i ../postgres/upgrade/atoz-modification.sql Modified: trunk/ccm-cms-types-siteproxy/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SiteProxy.xml =================================================================== --- trunk/ccm-cms-types-siteproxy/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SiteProxy.xml 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SiteProxy.xml 2005-12-13 22:39:04 UTC (rev 1049) @@ -1,24 +1,33 @@ <?xml version="1.0" encoding="utf-8"?> -<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd"> +<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd"> <ctd:content-type label="Site Proxy" - description="A Proxy item for a page on an external site" - objectType="com.arsdigita.cms.contenttypes.SiteProxy" - classname="com.arsdigita.cms.contenttypes.SiteProxy"> + description="A Proxy item for a page on an external site" + objectType="com.arsdigita.cms.contenttypes.SiteProxy" + classname="com.arsdigita.cms.contenttypes.SiteProxy"> - <ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate"> + <ctd:authoring-kit + createComponent="com.arsdigita.cms.ui.authoring.PageCreate"> - <ctd:authoring-step label="Edit Basic Properties" - description="Edit basic properties" - component="com.arsdigita.cms.contenttypes.ui.SiteProxyPropertiesStep" - ordering="1"/> - - <ctd:authoring-step label="Assign categories" - description="Assign categories" - component="com.arsdigita.cms.ui.authoring.ItemCategoryStep" - ordering="2"/> - - </ctd:authoring-kit> + <ctd:authoring-step + labelKey="cms.contenttypes.shared.basic_properties.title" + labelBundle="com.arsdigita.cms.ui.CMSResources" + descriptionKey="cms.contenttypes.shared.basic_properties.description" + descriptionBundle="com.arsdigita.cms.ui.CMSResources" + component="com.arsdigita.cms.contenttypes.ui.SiteProxyPropertiesStep"/> + + <ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/> + + <ctd:authoring-step + labelKey="cms.contenttypes.ui.siteproxy.atozstep.label" + labelBundle="com.arsdigita.cms.contenttypes.SiteProxyResources" + descriptionKey="cms.contenttypes.ui.siteproxy.atozstep.description" + descriptionBundle="com.arsdigita.cms.contenttypes.SiteProxyResources" + component="com.arsdigita.cms.contenttypes.ui.SiteProxyAtoZPropertiesStep"/> + + </ctd:authoring-kit> </ctd:content-type> </ctd:content-types> Added: trunk/ccm-cms-types-siteproxy/src/ccm-cms-types-siteproxy.upgrade =================================================================== --- trunk/ccm-cms-types-siteproxy/src/ccm-cms-types-siteproxy.upgrade 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/src/ccm-cms-types-siteproxy.upgrade 2005-12-13 22:39:04 UTC (rev 1049) @@ -0,0 +1,6 @@ +<upgrade> + <version from="6.3.0" to="6.3.1"> + <script sql="ccm-cms-types-siteproxy/upgrade/::database::-6.3.0-6.3.1.sql"/> + <script class="com.arsdigita.cms.contenttypes.SiteProxyUpgrade630to631"/> + </version> +</upgrade> Modified: trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxy.java =================================================================== --- trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxy.java 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxy.java 2005-12-13 22:39:04 UTC (rev 1049) @@ -18,73 +18,94 @@ */ package com.arsdigita.cms.contenttypes; +import java.math.BigDecimal; + +import org.apache.log4j.Logger; + +import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentType; -import com.arsdigita.cms.ContentPage; -import com.arsdigita.cms.dispatcher.SiteProxyPanel; import com.arsdigita.domain.DataObjectNotFoundException; +import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; -import com.arsdigita.persistence.DataObject; -import java.math.BigDecimal; - -import org.apache.log4j.Logger; - /** * This content type represents a SiteProxy. - * - * @version $Revision: #4 $ $Date: 2004/08/17 $ + * + * Remote XML document defined by "url" property is retrieved and + * included in CMS XML output. */ public class SiteProxy extends ContentPage { - private static final Logger s_log = Logger.getLogger(SiteProxy.class); - /** PDL property name for definition */ public static final String URL = "url"; + /** PDL property name for definition titleAtoZ */ + public static final String TITLE_ATOZ = "titleAtoZ"; + + /** PDL property name for definition usedInAtoZ */ + public static final String USED_IN_ATOZ = "usedInAtoZ"; + /** Data object type for this domain object */ - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.cms.contenttypes.SiteProxy"; + public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.SiteProxy"; + /** Data object type for this domain object (for CMS compatibility) */ - public static final String TYPE - = BASE_DATA_OBJECT_TYPE; + public static final String TYPE = BASE_DATA_OBJECT_TYPE; public SiteProxy() { - this( BASE_DATA_OBJECT_TYPE ); + this(BASE_DATA_OBJECT_TYPE); try { - setContentType( - ContentType.findByAssociatedObjectType( - BASE_DATA_OBJECT_TYPE - ) - ); - } catch( DataObjectNotFoundException e ) { - throw new RuntimeException( "SiteProxy type not registered" ); + setContentType(ContentType + .findByAssociatedObjectType(BASE_DATA_OBJECT_TYPE)); + } catch (DataObjectNotFoundException e) { + throw new RuntimeException("SiteProxy type not registered"); } } - public SiteProxy( BigDecimal id ) - throws DataObjectNotFoundException { - this( new OID( BASE_DATA_OBJECT_TYPE, id ) ); + public SiteProxy(BigDecimal id) throws DataObjectNotFoundException { + this(new OID(BASE_DATA_OBJECT_TYPE, id)); } - public SiteProxy( OID id ) - throws DataObjectNotFoundException { - super( id ); + public SiteProxy(OID id) throws DataObjectNotFoundException { + super(id); } - public SiteProxy( DataObject obj ) { - super( obj ); + public SiteProxy(DataObject obj) { + super(obj); } - public SiteProxy( String type ) { - super( type ); + public SiteProxy(String type) { + super(type); } - public String getURL() { return (String) get(URL); } - public void setURL( String url ) { + public void setURL(String url) { set(URL, url); } + + public String getAtoZTitle() { + return (String) get(TITLE_ATOZ); + } + + public void setAtoZTitle(String atozTitle) { + set(TITLE_ATOZ, atozTitle); + } + + public boolean isUsedInAtoZ() { + return Boolean.TRUE.equals(get(USED_IN_ATOZ)); + } + + public void setUsedInAtoZ(boolean usedInAtoZ) { + set(USED_IN_ATOZ, new Boolean(usedInAtoZ)); + } + + protected void initialize() { + super.initialize(); + + if (isNew()) { + set(USED_IN_ATOZ, Boolean.FALSE); + } + } } Modified: trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxyResources.properties =================================================================== --- trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxyResources.properties 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxyResources.properties 2005-12-13 22:39:04 UTC (rev 1049) @@ -1,3 +1,12 @@ cms.contenttypes.siteproxy.error_fetching_url=Error fetching URL: {0} cms.contenttypes.siteproxy.exception_fetching_url=Error fetching URL: {0} with exception of type " {1} " and message " {2} " -cms.contenttypes.siteproxy.empty_page_returned=Empty Page Returned for URL: {0} \ No newline at end of file +cms.contenttypes.siteproxy.empty_page_returned=Empty Page Returned for URL: {0} +cms.contenttypes.ui.siteproxy.kit.label=Site Proxy +cms.contenttypes.ui.siteproxy.kit.description=A Proxy item for a page on an external site +cms.contenttypes.ui.siteproxy.atozstep.label=Edit AtoZ properties +cms.contenttypes.ui.siteproxy.atozstep.description=Edit AtoZ properties +cms.contenttypes.ui.siteproxy.label.atoztitle=AtoZ Title +cms.contenttypes.ui.siteproxy.label.usedinatoz=Used in AtoZ +cms.contenttypes.ui.siteproxy.option.usedinatoz.yes=Yes +cms.contenttypes.ui.siteproxy.option.usedinatoz.no=No +cms.contenttypes.ui.siteproxy.link.editatoz=Edit Added: trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxyUpgrade630to631.java =================================================================== --- trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxyUpgrade630to631.java 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/SiteProxyUpgrade630to631.java 2005-12-13 22:39:04 UTC (rev 1049) @@ -0,0 +1,41 @@ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.cms.installer.xml.XMLContentTypeHandler; +import com.arsdigita.kernel.Kernel; +import com.arsdigita.kernel.KernelExcursion; +import com.arsdigita.persistence.Session; +import com.arsdigita.persistence.SessionManager; +import com.arsdigita.persistence.TransactionContext; +import com.arsdigita.runtime.Startup; +import com.arsdigita.xml.XML; + +public class SiteProxyUpgrade630to631 { + + private final static String SITE_PROXY = "/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SiteProxy.xml"; + + public static void main(String[] args) { + new Startup().run(); + final Session session = SessionManager.getSession(); + final TransactionContext tc = session.getTransactionContext(); + try { + tc.beginTxn(); + new KernelExcursion() { + public void excurse() { + setEffectiveParty(Kernel.getSystemParty()); + /* + * reload SiteProxy content type definition from XML config + * to add new authoring kit step + */ + XMLContentTypeHandler handler = new XMLContentTypeHandler(); + XML.parseResource(SITE_PROXY, handler); + } + }.run(); + session.flushAll(); + tc.commitTxn(); + } finally { + if (tc.inTxn()) { + tc.abortTxn(); + } + } + } +} Added: trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/Constants.java =================================================================== --- trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/Constants.java 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/Constants.java 2005-12-13 22:39:04 UTC (rev 1049) @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.contenttypes.ui; + +interface Constants { + + /* Globalization constants */ + static final String LABEL_TITLE_ATOZ = "cms.contenttypes.ui.siteproxy.label.atoztitle"; + static final String LABEL_USED_IN_ATOZ = "cms.contenttypes.ui.siteproxy.label.usedinatoz"; + static final String OPTION_USED_IN_ATOZ_YES = "cms.contenttypes.ui.siteproxy.option.usedinatoz.yes"; + static final String OPTION_USED_IN_ATOZ_NO = "cms.contenttypes.ui.siteproxy.option.usedinatoz.no"; + +} Added: trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/SiteProxyAtoZPropertiesStep.java =================================================================== --- trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/SiteProxyAtoZPropertiesStep.java 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/SiteProxyAtoZPropertiesStep.java 2005-12-13 22:39:04 UTC (rev 1049) @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2005 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.PageState; +import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.SiteProxy; +import com.arsdigita.cms.contenttypes.util.SiteProxyGlobalizationUtil; +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; +import com.arsdigita.domain.DomainObject; +import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; + +/** + * Authoring step to edit the simple attributes for the SiteProxy content + * connection to new AtoZ + */ +public class SiteProxyAtoZPropertiesStep extends SimpleEditStep { + + /** The name of the editing sheet added to this step */ + public static final String EDIT_ATOZ_SHEET_NAME = "editAtoZ"; + + public static final String LINK_EDIT = "cms.contenttypes.ui.siteproxy.link.editatoz"; + + /** + * @param itemModel + * @param parent + */ + public SiteProxyAtoZPropertiesStep(ItemSelectionModel itemModel, + AuthoringKitWizard parent) { + super(itemModel, parent); + + BasicItemForm form; + + form = new SiteProxyAtoZPropertyForm(itemModel); + add(EDIT_ATOZ_SHEET_NAME, SiteProxyGlobalizationUtil.globalize( + LINK_EDIT).localize().toString(), + new WorkflowLockedComponentAccess(form, itemModel), form + .getSaveCancelSection().getCancelButton()); + + setDisplayComponent(getSiteProxyAtoZPropertySheet(itemModel)); + } + + /** + * Returns a component that displays AtoZ integration properties of the + * SiteProxy specified by the ItemSelectionModel passed in. + * + * @param itemModel + * The ItemSelectionModel to use + * @pre itemModel != null + * @return A component to display the state of the AtoZ integration + * properties of the release + */ + public static Component getSiteProxyAtoZPropertySheet( + ItemSelectionModel itemModel) { + DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( + itemModel); + + sheet.add(SiteProxyGlobalizationUtil + .globalize(Constants.LABEL_TITLE_ATOZ), SiteProxy.TITLE_ATOZ); + + sheet.add(SiteProxyGlobalizationUtil + .globalize(Constants.LABEL_USED_IN_ATOZ), + SiteProxy.USED_IN_ATOZ, new BooleanAttributeFormater( + (String) SiteProxyGlobalizationUtil.globalize( + Constants.OPTION_USED_IN_ATOZ_YES).localize(), + (String) SiteProxyGlobalizationUtil.globalize( + Constants.OPTION_USED_IN_ATOZ_NO).localize())); + + return sheet; + } + + private static class BooleanAttributeFormater implements + DomainObjectPropertySheet.AttributeFormatter { + + private static final String DEFAULT = "-"; + + private String trueValue; + + private String falseValue; + + public BooleanAttributeFormater(String trueValue, String falseValue) { + this.trueValue = trueValue; + this.falseValue = falseValue; + } + + public String format(DomainObject obj, String attribute, PageState state) { + if (obj == null) + return BooleanAttributeFormater.DEFAULT; + + if ((obj instanceof ContentItem)) { + ContentItem contentItem = (ContentItem) obj; + Object field = contentItem.get(attribute); + if (field == null) + return BooleanAttributeFormater.DEFAULT; + + if (field instanceof Boolean) { + Boolean value = (Boolean) contentItem.get(attribute); + if (value.booleanValue()) + return trueValue; + else + return falseValue; + } + } + return BooleanAttributeFormater.DEFAULT; + } + + } + +} Added: trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/SiteProxyAtoZPropertyForm.java =================================================================== --- trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/SiteProxyAtoZPropertyForm.java 2005-12-13 21:24:06 UTC (rev 1048) +++ trunk/ccm-cms-types-siteproxy/src/com/arsdigita/cms/contenttypes/ui/SiteProxyAtoZPropertyForm.java 2005-12-13 22:39:04 UTC (rev 1049) @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2005 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.form.Option; +import com.arsdigita.bebop.form.RadioGroup; +import com.arsdigita.bebop.form.TextField; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.SiteProxy; +import com.arsdigita.cms.contenttypes.util.SiteProxyGlobalizationUtil; +import com.arsdigita.cms.ui.authoring.BasicItemForm; + +/** + * Form to edit the basic properties of an SiteProxy. This form can be extended + * to create forms for SiteProxy subclasses. + */ +public class SiteProxyAtoZPropertyForm extends BasicItemForm { + + private TextField m_title_atoz; + + private RadioGroup m_radiogroupUsedInAtoZ; + + private ItemSelectionModel m_selectionModel; + + private SiteProxy siteProxy; + + /** + * Creates a new form to edit the SiteProxy object specified by the item + * selection model passed in. + * + * @param itemModel + * The ItemSelectionModel to use to obtain the SiteProxy to work + * on + */ + public SiteProxyAtoZPropertyForm(ItemSelectionModel itemModel) { + super("siteProxyAtoZEdit", itemModel); + m_selectionModel = itemModel; + } + + /** + * Adds widgets to the form. + */ + protected void addWidgets() { + add(new Label(SiteProxyGlobalizationUtil + .globalize(Constants.LABEL_TITLE_ATOZ))); + m_title_atoz = new TextField(SiteProxy.TITLE_ATOZ); + m_title_atoz.setSize(50); + add(m_title_atoz); + add(new Label(SiteProxyGlobalizationUtil + .globalize(Constants.LABEL_USED_IN_ATOZ))); + m_radiogroupUsedInAtoZ = new RadioGroup(SiteProxy.USED_IN_ATOZ); + m_radiogroupUsedInAtoZ.addOption(new Option(Boolean.TRUE.toString(), + SiteProxyGlobalizationUtil.globalize( + Constants.OPTION_USED_IN_ATOZ_YES).localize() + .toString())); + m_radiogroupUsedInAtoZ + .addOption(new Option(Boolean.FALSE.toString(), + SiteProxyGlobalizationUtil.globalize( + Constants.OPTION_USED_IN_ATOZ_NO).localize() + .toString())); + add(m_radiogroupUsedInAtoZ); + } + + /** Form initialisation hook. Fills widgets with data. */ + public void init(FormSectionEvent fse) { + PageState pageState = fse.getPageState(); + siteProxy = (SiteProxy) m_selectionModel.getSelectedObject(pageState); + if (siteProxy == null) + return; + + m_title_atoz.setValue(pageState, siteProxy.getAtoZTitle()); + m_radiogroupUsedInAtoZ.setValue(pageState, new Boolean(siteProxy + .isUsedInAtoZ()).toString()); + } + + /** Form processing hook. Saves SiteProxy object. */ + public void process(FormSectionEvent fse) { + PageState pageState = fse.getPageState(); + siteProxy = (SiteProxy) m_selectionModel.getSelectedObject(pageState); + /* proced only when siteProxy is present and save button was pressed */ + if ((siteProxy == null) + && !getSaveCancelSection().getSaveButton() + .isSelected(pageState)) + return; + + siteProxy.setAtoZTitle((String) m_title_atoz.getValue(pageState)); + siteProxy.setUsedInAtoZ(new Boolean((String) m_radiogroupUsedInAtoZ + .getValue(pageState)).booleanValue()); + siteProxy.save(); + } +} |