BaseContact
Traversal-Adapter hinzugefügt. ContactEntries UI weistestgehend erstellt. Anzeige, Hinzufügen und Löschen funktioniert, es fehlt noch das Bearbeiten. Noch vorhandene Fehler: * Es fehlt zur Zeit noch eine Möglichkeit, die ActionLinks dem aktuelle Zustand der Verknüpfung anzupassen. Es soll eigentlich nur "Attach" angezeigt werden, wenn kein CT verknüpft ist. Sonst sollen "Change", "Edit" und "Delete" angezeigt werden. * Lokalisierung ist noch vollständig vorhanden * Aus einem mir noch nicht nachvollziehbaren Grund schließt sich das ItemSerachWidget nicht automatisch nach der Auswahl eines CTs * Der Versuch, ein nicht verknüpften CT zu editieren endet in einer Exception. Das Problem löst sich, sobald eine Möglichkeit zum bedarfsgerechten Ändern der Links gefunden wurde. * Bei nichtverknüpften CTs soll eigentlich nur angezeigt werden, daß keine Verknüpfung vorhanden ist. Das Problem löst sich, sobald eine Möglichkeit zum bedarfsgerechten Ändern der Links gefunden wurde. git-svn-id: https://svn.libreccm.org/ccm/trunk@216 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
7822403945
commit
4bad58d14b
|
|
@ -20,10 +20,10 @@ object type BaseContact extends ContentPage {
|
|||
reference key ( ct_baseContacts.contact_id );
|
||||
}
|
||||
|
||||
object type BaseContactEntry extends ACSObject {
|
||||
object type BaseContactEntry extends ContentItem {
|
||||
|
||||
String [1..1] key = ct_baseContactEntries.key VARCHAR(100);
|
||||
String [1..1] description = ct_baseContactEntries.description 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 );
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xrd:adapters
|
||||
xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
|
||||
<!--
|
||||
Extend adapter for ContentItemPanel to also output the associated objects.
|
||||
The default properties for BaseContact are left as is and are inherited from ContentPage
|
||||
-->
|
||||
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
|
||||
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.BaseContact" extends="com.arsdigita.cms.ContentPage">
|
||||
<xrd:attributes rule="exclude">
|
||||
<xrd:property name="/object/person/id"/>
|
||||
<xrd:property name="/object/person/defaultDomainClass"/>
|
||||
<xrd:property name="/object/person/objectType"/>
|
||||
<xrd:property name="/object/person/displayName"/>
|
||||
<xrd:property name="/object/person/ancestors"/>
|
||||
<xrd:property name="/object/person/version"/>
|
||||
<xrd:property name="/object/person/name"/>
|
||||
<xrd:property name="/object/person/language"/>
|
||||
<xrd:property name="/object/person/isDeleted"/>
|
||||
<xrd:property name="/object/address/id"/>
|
||||
<xrd:property name="/object/address/defaultDomainClass"/>
|
||||
<xrd:property name="/object/address/objectType"/>
|
||||
<xrd:property name="/object/address/displayName"/>
|
||||
<xrd:property name="/object/address/ancestors"/>
|
||||
<xrd:property name="/object/address/version"/>
|
||||
<xrd:property name="/object/address/name"/>
|
||||
<xrd:property name="/object/address/language"/>
|
||||
<xrd:property name="/object/address/isDeleted"/>
|
||||
<xrd:property name="/object/contactentries/id"/>
|
||||
<xrd:property name="/object/contactentries/defaultDomainClass"/>
|
||||
<xrd:property name="/object/contactentries/objectType"/>
|
||||
<xrd:property name="/object/contactentries/displayName"/>
|
||||
<xrd:property name="/object/contactentries/ancestors"/>
|
||||
<xrd:property name="/object/contactentries/version"/>
|
||||
<xrd:property name="/object/contactentries/name"/>
|
||||
<xrd:property name="/object/contactentries/language"/>
|
||||
<xrd:property name="/object/contactentries/isDeleted"/>
|
||||
</xrd:attributes>
|
||||
<xrd:associations rule="include">
|
||||
<xrd:property name="/object/person"/>
|
||||
<xrd:property name="/object/address"/>
|
||||
<xrd:property name="/object/contactentries"/>
|
||||
</xrd:associations>
|
||||
</xrd:adapter>
|
||||
</xrd:context>
|
||||
</xrd:adapters>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<registry>
|
||||
<!-- nothing yet -->
|
||||
<config class="com.arsdigita.cms.contenttypes.BaseContactConfig" storage="ccm-cms-types-baseContact/baseContact.properties"/>
|
||||
</registry>
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ public class BaseContact extends ContentPage {
|
|||
public static final String ADDRESS = "address";
|
||||
public static final String CONTACT_ENTRIES = "contactentries";
|
||||
|
||||
// Config
|
||||
private static BaseContactConfig s_config = new BaseContactConfig();
|
||||
|
||||
/** Data object type for tihs domain object */
|
||||
public static final String BASE_DATA_OBJECT_TYPE
|
||||
= "com.arsdigita.cms.contenttypes.BaseContact";
|
||||
|
|
@ -75,6 +78,13 @@ public class BaseContact extends ContentPage {
|
|||
Assert.exists(getContentType(), ContentType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current configuration
|
||||
*/
|
||||
public static BaseContactConfig getConfig() {
|
||||
return s_config;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// accessors
|
||||
|
|
|
|||
|
|
@ -20,64 +20,64 @@
|
|||
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.kernel.ACSObject;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.persistence.metadata.ObjectType;
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author quasi
|
||||
*/
|
||||
public class BaseContactEntry extends ACSObject {
|
||||
public class BaseContactEntry extends ContentItem {
|
||||
|
||||
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.BaseContactEntry";
|
||||
private static final String BASE_DATA_OBJECT_PACKAGE = "com.arsdigita.cms.contenttypes";
|
||||
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(BaseContactEntry.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 BaseContactEntry
|
||||
*/
|
||||
public BaseContactEntry(String typeName) {
|
||||
super(typeName);
|
||||
}
|
||||
|
||||
public BaseContactEntry(ObjectType type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public BaseContactEntry(OID oid) {
|
||||
super(oid);
|
||||
}
|
||||
|
||||
public BaseContactEntry(DataObject dataObject) {
|
||||
super(dataObject);
|
||||
}
|
||||
|
||||
public BaseContactEntry() {
|
||||
this(BASE_DATA_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
public BaseContactEntry(String key, String value, String description) {
|
||||
this();
|
||||
setKey(key);
|
||||
setValue(value);
|
||||
setDescription(description);
|
||||
public BaseContactEntry(String typeName) {
|
||||
super(typeName);
|
||||
}
|
||||
|
||||
public BaseContactEntry(OID oid, String key, String value, String description) {
|
||||
this(oid);
|
||||
public BaseContactEntry(OID oid) {
|
||||
super(oid);
|
||||
}
|
||||
|
||||
public BaseContactEntry(DataObject object) {
|
||||
super(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. Retrieves an object instance with the given id.
|
||||
* @param id the id of the object to retrieve
|
||||
*/
|
||||
public BaseContactEntry(BigDecimal id) throws DataObjectNotFoundException {
|
||||
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||
}
|
||||
|
||||
public BaseContactEntry(BaseContact contact, String key, String value, String description) {
|
||||
this();
|
||||
setName(key + " for " + contact.getName() + "(" + contact.getID() + ")");
|
||||
setKey(key);
|
||||
setValue(value);
|
||||
setDescription(description);
|
||||
save();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -8,15 +8,16 @@
|
|||
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.kernel.ACSObjectCollection;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author quasi
|
||||
*/
|
||||
public class BaseContactEntryCollection extends ACSObjectCollection {
|
||||
public class BaseContactEntryCollection extends DomainCollection {
|
||||
|
||||
/**
|
||||
* Creates a new instance of BaseContactEntryCollection
|
||||
|
|
@ -42,7 +43,7 @@ public class BaseContactEntryCollection extends ACSObjectCollection {
|
|||
}
|
||||
|
||||
public BaseContactEntry getBaseContactEntry() {
|
||||
return (BaseContactEntry) getDomainObject();
|
||||
return new BaseContactEntry(m_dataCollection.getDataObject());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,20 +28,24 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class BaseContactInitializer extends ContentTypeInitializer {
|
||||
public final static String versionId =
|
||||
"$Id: BaseContactInitializer.java $" +
|
||||
"$Author: quasi $" +
|
||||
"$DateTime: 2009/03/15 $";
|
||||
"$Id: BaseContactInitializer.java $" +
|
||||
"$Author: quasi $" +
|
||||
"$DateTime: 2009/03/15 $";
|
||||
private static final Logger s_log = Logger.getLogger(BaseContactInitializer.class);
|
||||
|
||||
|
||||
public BaseContactInitializer() {
|
||||
super("ccm-cms-types-baseContact.pdl.mf",
|
||||
BaseContact.BASE_DATA_OBJECT_TYPE);
|
||||
BaseContact.BASE_DATA_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
|
||||
public String[] getStylesheets() {
|
||||
return new String[] {
|
||||
"/static/content-types/com/arsdigita/cms/contenttypes/BaseContact.xsl"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public String getTraversalXML() {
|
||||
return "/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/BaseContact.xml";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ public class BaseContactAddressPropertiesStep extends SimpleEditStep {
|
|||
public static final String CHANGE_ADDRESS_SHEET_NAME = "changeAddress";
|
||||
public static final String DELETE_ADDRESS_SHEET_NAME = "deleteAddress";
|
||||
|
||||
|
||||
/** Creates a new instance of BaseContactAddressPropertiesStep */
|
||||
public BaseContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, "");
|
||||
|
|
@ -77,26 +76,29 @@ public class BaseContactAddressPropertiesStep extends SimpleEditStep {
|
|||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||
|
||||
sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.address").localize(), "address." + BaseAddress.ADDRESS);
|
||||
sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.postal_code").localize(), "address." + BaseAddress.POSTAL_CODE);
|
||||
if(!BaseContact.getConfig().getHideAddressPostalCode())
|
||||
sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.postal_code").localize(), "address." + BaseAddress.POSTAL_CODE);
|
||||
sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.city").localize(), "address." + BaseAddress.CITY);
|
||||
sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.state").localize(), "address." + BaseAddress.STATE);
|
||||
if(!BaseContact.getConfig().getHideAddressState())
|
||||
sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.state").localize(), "address." + BaseAddress.STATE);
|
||||
|
||||
sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.iso_country_code").localize(),
|
||||
"address." + BaseAddress.ISO_COUNTRY_CODE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
BaseAddress baseAddress = ((BaseContact)item).getAddress();
|
||||
if(baseAddress != null && baseAddress.getIsoCountryCode() != null) {
|
||||
return BaseAddress.getCountryNameFromIsoCode(baseAddress.getIsoCountryCode());
|
||||
} else {
|
||||
return (String)BaseAddressGlobalizationUtil.globalize
|
||||
("cms.ui.unknown").localize();
|
||||
if(!BaseContact.getConfig().getHideAddressCountry()) {
|
||||
sheet.add((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.iso_country_code").localize(),
|
||||
"address." + BaseAddress.ISO_COUNTRY_CODE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
BaseAddress baseAddress = ((BaseContact)item).getAddress();
|
||||
if(baseAddress != null && baseAddress.getIsoCountryCode() != null) {
|
||||
return BaseAddress.getCountryNameFromIsoCode(baseAddress.getIsoCountryCode());
|
||||
} else {
|
||||
return (String)BaseAddressGlobalizationUtil.globalize
|
||||
("cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return sheet;
|
||||
|
||||
|
|
|
|||
|
|
@ -91,23 +91,27 @@ public class BaseContactEditAddressPropertyForm extends BasicPageForm implements
|
|||
address.setCols(30);
|
||||
add(address);
|
||||
|
||||
add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.postal_code").localize()));
|
||||
ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE);
|
||||
TextField postalCode = new TextField(postalCodeParam);
|
||||
/* XXX NumberListener ?*/
|
||||
add(postalCode);
|
||||
if(!BaseContact.getConfig().getHideAddressPostalCode()) {
|
||||
add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.postal_code").localize()));
|
||||
ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE);
|
||||
TextField postalCode = new TextField(postalCodeParam);
|
||||
/* XXX NumberListener ?*/
|
||||
add(postalCode);
|
||||
}
|
||||
|
||||
add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.city").localize()));
|
||||
ParameterModel cityParam = new StringParameter(CITY);
|
||||
TextField city = new TextField(cityParam);
|
||||
add(city);
|
||||
|
||||
add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.state").localize()));
|
||||
ParameterModel stateParam = new StringParameter(STATE);
|
||||
TextField state = new TextField(stateParam);
|
||||
add(state);
|
||||
if(!BaseContact.getConfig().getHideAddressState()) {
|
||||
add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.state").localize()));
|
||||
ParameterModel stateParam = new StringParameter(STATE);
|
||||
TextField state = new TextField(stateParam);
|
||||
add(state);
|
||||
}
|
||||
|
||||
if (!BaseAddress.getConfig().getHideCountryCodeSelection()) {
|
||||
if (!BaseContact.getConfig().getHideAddressCountry()) {
|
||||
add(new Label((String)BaseAddressGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.iso_country_code").localize()));
|
||||
ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE);
|
||||
countryParam.addParameterListener(new StringInRangeValidationListener(0, 2));
|
||||
|
|
|
|||
|
|
@ -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.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
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 BaseContactEntriesPropertiesStep extends SimpleEditStep {
|
||||
|
||||
/** The name of the editing sheet added to this step */
|
||||
private static String ADD_CONTACT_ENTRY_SHEET_NAME = "addContactEntry";
|
||||
|
||||
public BaseContactEntriesPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, null);
|
||||
}
|
||||
|
||||
public BaseContactEntriesPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
//XXX
|
||||
BasicItemForm addContactEntrySheet = new BaseContactEntryAddForm(itemModel);
|
||||
add(ADD_CONTACT_ENTRY_SHEET_NAME, "Add Contact Entry", new WorkflowLockedComponentAccess(addContactEntrySheet, itemModel), addContactEntrySheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
BaseContactEntriesTable contactEntriesTable = new BaseContactEntriesTable(itemModel);
|
||||
setDisplayComponent(contactEntriesTable);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,273 @@
|
|||
/*
|
||||
* 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.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.contenttypes.BaseContact;
|
||||
import com.arsdigita.cms.contenttypes.BaseContactEntry;
|
||||
import com.arsdigita.cms.contenttypes.BaseContactEntryCollection;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
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 BaseContactEntriesTable 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 BaseContactEntriesTable
|
||||
*/
|
||||
public BaseContactEntriesTable(final ItemSelectionModel itemModel) {
|
||||
|
||||
super();
|
||||
this.m_itemModel = itemModel;
|
||||
|
||||
// if table is empty:
|
||||
setEmptyView(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.contactentries.none")));
|
||||
TableColumnModel tab_model = getColumnModel();
|
||||
|
||||
// define columns
|
||||
tab_model.add(new TableColumn(0, GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.contactentries.key").localize(), TABLE_COL_EDIT));
|
||||
tab_model.add(new TableColumn(1, GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.contactentries.value").localize()));
|
||||
tab_model.add(new TableColumn(2, GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.contactentries.description").localize()));
|
||||
tab_model.add(new TableColumn(3, GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.contactentries.delete").localize(), TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(new BaseContactTableModelBuilder(itemModel));
|
||||
|
||||
tab_model.get(0).setCellRenderer(new EditCellRenderer());
|
||||
tab_model.get(3).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* XXXX
|
||||
*
|
||||
*/
|
||||
private class BaseContactTableModelBuilder extends LockableImpl implements TableModelBuilder {
|
||||
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public BaseContactTableModelBuilder(ItemSelectionModel itemModel) {
|
||||
m_itemModel = itemModel;
|
||||
}
|
||||
|
||||
public TableModel makeModel(Table table, PageState state) {
|
||||
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
|
||||
BaseContact baseContact = (BaseContact) m_itemModel.getSelectedObject(state);
|
||||
|
||||
// if (baseContact != null && baseContact.hasContactEntries()) {
|
||||
return new BaseContactTableModel(table, state, baseContact);
|
||||
// } else {
|
||||
// return Table.EMPTY_MODEL;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* XXX
|
||||
*
|
||||
*/
|
||||
private class BaseContactTableModel implements TableModel {
|
||||
|
||||
final private int MAX_DESC_LENGTH = 25;
|
||||
|
||||
private Table m_table;
|
||||
private BaseContactEntryCollection m_baseContactEntryCollection;
|
||||
private BaseContactEntry m_baseContactEntry;
|
||||
|
||||
private BaseContactTableModel(Table t, PageState ps, BaseContact baseContact) {
|
||||
m_table = t;
|
||||
m_baseContactEntryCollection = baseContact.getContactEntries();
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return m_table.getColumnModel().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check collection for the existence of another row.
|
||||
*
|
||||
* If exists, fetch the value of current BaseContactEntryCollection object
|
||||
* into m_baseContactEntry class variable.
|
||||
*/
|
||||
public boolean nextRow() {
|
||||
|
||||
if(m_baseContactEntryCollection != null && m_baseContactEntryCollection.next()){
|
||||
m_baseContactEntry = m_baseContactEntryCollection.getBaseContactEntry();
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the
|
||||
* @see com.arsdigita.bebop.table.TableModel#getElementAt(int)
|
||||
*/
|
||||
public Object getElementAt(int columnIndex) {
|
||||
switch (columnIndex){
|
||||
case 0:
|
||||
return m_baseContactEntry.getKey();
|
||||
case 1:
|
||||
return m_baseContactEntry.getValue();
|
||||
case 2:
|
||||
return (m_baseContactEntry.getDescription() != null && m_baseContactEntry.getDescription().length() > MAX_DESC_LENGTH)
|
||||
? m_baseContactEntry.getDescription().substring(0, MAX_DESC_LENGTH)
|
||||
: m_baseContactEntry.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_baseContactEntry.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);
|
||||
BaseContact baseContact = (BaseContact) m_itemModel.getSelectedObject(state);
|
||||
|
||||
boolean canEdit = sm.canAccess(state.getRequest(),
|
||||
SecurityManager.EDIT_ITEM,
|
||||
baseContact);
|
||||
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);
|
||||
BaseContact baseContact = (BaseContact) m_itemModel.getSelectedObject(state);
|
||||
|
||||
boolean canDelete = sm.canAccess(state.getRequest(),
|
||||
SecurityManager.DELETE_ITEM,
|
||||
baseContact);
|
||||
if(canDelete) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) GlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.baseContact.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 BaseContactEntry
|
||||
BaseContactEntry baseContactEntry =
|
||||
new BaseContactEntry(new BigDecimal(evt.getRowKey().toString()));
|
||||
|
||||
// Get BaseContact
|
||||
BaseContact baseContact = (BaseContact) 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)) {
|
||||
baseContact.removeContactEntry(baseContactEntry);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* provide Implementation to TableActionListener method.
|
||||
* Does nothing in our case.
|
||||
*/
|
||||
public void headSelected(TableActionEvent e) {
|
||||
throw new UnsupportedOperationException("Not Implemented");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* 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.contenttypes.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.contenttypes.BaseContact;
|
||||
import com.arsdigita.cms.contenttypes.BaseContactEntry;
|
||||
import com.arsdigita.cms.contenttypes.util.BaseAddressGlobalizationUtil;
|
||||
import com.arsdigita.cms.contenttypes.util.BaseContactGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Generates a form for creating new localisations for the given category.
|
||||
*
|
||||
* This class is part of the admin GUI of CCM and extends the standard form
|
||||
* in order to present forms for managing the multi-language categories.
|
||||
*
|
||||
* @author Sören Bernstein (quasimodo) quasi@zes.uni-bremen.de
|
||||
*/
|
||||
public class BaseContactEntryAddForm extends BasicItemForm {
|
||||
private static final Logger s_log = Logger.getLogger(BaseContactEntryAddForm.class);
|
||||
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
/** Creates a new instance of CategoryLocalizationAddForm */
|
||||
public BaseContactEntryAddForm(ItemSelectionModel itemModel) {
|
||||
|
||||
super("BaseContactEntryAddForm",itemModel);
|
||||
m_itemModel = itemModel;
|
||||
|
||||
}
|
||||
|
||||
protected void addWidgets() {
|
||||
|
||||
// Key field
|
||||
add(new Label(BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.contactEntry.key")));
|
||||
ParameterModel contactEntryKeyParam = new StringParameter(BaseContactEntry.KEY);
|
||||
SingleSelect contactEntryKey = new SingleSelect(contactEntryKeyParam);
|
||||
contactEntryKey.addValidationListener(new NotNullValidationListener());
|
||||
contactEntryKey.addOption(new Option("", new Label((String)BaseAddressGlobalizationUtil.globalize("cms.ui.select_one" ).localize())));
|
||||
|
||||
// Add the Options to the SingleSelect widget
|
||||
StringTokenizer keyList = BaseContact.getConfig().getContactEntryKeys();
|
||||
while(keyList.hasMoreTokens()) {
|
||||
String currentKey = keyList.nextToken();
|
||||
contactEntryKey.addOption(new Option(currentKey, ((String)BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.contactEntry.key." + currentKey).localize())));
|
||||
}
|
||||
|
||||
add(contactEntryKey);
|
||||
|
||||
// Value field
|
||||
add(new Label(BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.contactEntry.value")));
|
||||
ParameterModel contactEntryValueParam = new StringParameter(BaseContactEntry.VALUE);
|
||||
TextField contactEntryValue = new TextField(contactEntryValueParam);
|
||||
contactEntryValue.addValidationListener(new NotNullValidationListener());
|
||||
add(contactEntryValue);
|
||||
|
||||
// Description field, only for internal usage
|
||||
add(new Label(BaseContactGlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.contactEntry.description")));
|
||||
ParameterModel contactEntryDescriptionParam = new StringParameter(BaseContactEntry.DESCRIPTION);
|
||||
TextField contactEntryDescription = new TextField(contactEntryDescriptionParam);
|
||||
add(contactEntryDescription);
|
||||
|
||||
}
|
||||
|
||||
public void init(FormSectionEvent fse) {
|
||||
|
||||
}
|
||||
|
||||
public void process(FormSectionEvent fse) {
|
||||
FormData data = fse.getFormData();
|
||||
BaseContact baseContact = (BaseContact)m_itemModel.getSelectedObject(fse.getPageState());
|
||||
|
||||
// save only if save button was pressed
|
||||
if (baseContact != null
|
||||
&& getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
|
||||
|
||||
BaseContactEntry contactEntry = new BaseContactEntry(baseContact,
|
||||
(String)data.get(BaseContactEntry.KEY),
|
||||
(String)data.get(BaseContactEntry.VALUE),
|
||||
(String)data.get(BaseContactEntry.DESCRIPTION));
|
||||
|
||||
baseContact.addContactEntry(contactEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ 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.contenttypes.BaseContact;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -24,7 +25,7 @@ import org.apache.log4j.Logger;
|
|||
public class BaseContactPropertiesStep extends SimpleEditStep {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(BaseContactPropertiesStep.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)
|
||||
|
|
@ -50,21 +51,31 @@ public class BaseContactPropertiesStep extends SimpleEditStep {
|
|||
|
||||
/* 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, "Edit Basic", new WorkflowLockedComponentAccess(editBasicSheet, itemModel), editBasicSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
/* Set the displayComponent for this step */
|
||||
basicProperties.setDisplayComponent(getBaseContactPropertySheet(itemModel));
|
||||
|
||||
BaseContactPersonPropertiesStep personProperties = new BaseContactPersonPropertiesStep(itemModel, parent);
|
||||
BaseContactAddressPropertiesStep addressProperties = new BaseContactAddressPropertiesStep(itemModel, parent);
|
||||
// BaseContactEntriesTable baseContactEntries = new BaseContactEntriesTable(itemModel, parent);
|
||||
|
||||
/* Add the SimpleEditStep to the segmented panel */
|
||||
segmentedPanel.addSegment(new Label("Basic"), basicProperties);
|
||||
segmentedPanel.addSegment(new Label((String)GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.person").localize()), personProperties);
|
||||
segmentedPanel.addSegment(new Label((String)GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.address").localize()), addressProperties);
|
||||
// segmentedPanel.addSegment(new Label((String)GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.baseContactEntries").localize()), baseContactEntries);
|
||||
|
||||
// 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)GlobalizationUtil.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)GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.address").localize()), addressProperties);
|
||||
}
|
||||
|
||||
BaseContactEntriesPropertiesStep baseContactEntries = new BaseContactEntriesPropertiesStep(itemModel, parent);
|
||||
segmentedPanel.addSegment(new Label((String)GlobalizationUtil.globalize("cms.contenttypes.ui.baseContact.baseContactEntries").localize()), baseContactEntries);
|
||||
|
||||
/* Sets the composed segmentedPanel as display component */
|
||||
setDisplayComponent(segmentedPanel);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE stylesheet [
|
||||
<!ENTITY nbsp " " ><!-- no-break space = non-breaking space, U+00A0 ISOnum -->
|
||||
]>
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:cms="http://www.arsdigita.com/cms/1.0"
|
||||
version="1.0">
|
||||
|
||||
<xsl:template match="cms:item[objectType='com.arsdigita.cms.contenttypes.BaseContact']" mode="cms:CT_graphics"
|
||||
name="cms:CT_graphics_com_arsdigita_cms_contenttypes_BaseContact">
|
||||
<table width="435" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td class="contentTitle" align="left" valign="top">
|
||||
<xsl:value-of select="./title"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<xsl:if test="./address">
|
||||
<tr>
|
||||
<th>Address:</th>
|
||||
<td class="contentText" valign="top" align="left"><xsl:value-of select="./address"/></td>
|
||||
</tr>
|
||||
</xsl:if>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="cms:item[objectType='com.arsdigita.cms.contenttypes.BaseContact']" mode="cms:CT_text"
|
||||
name="cms:CT_text_com_arsdigita_cms_contenttypes_BaseContact">
|
||||
<h1 class="title"><xsl:value-of select="./title"/></h1>
|
||||
<xsl:if test="./address">
|
||||
<span class="subtitle">Address</span>
|
||||
<span class="text"><xsl:value-of select="./address"/></span><br/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
Loading…
Reference in New Issue