RelationAttribute

* angepasste Spaltennamen zum Debuggen. Es gab einfach zuviele Spalten mit der Bezeichnung key

RelatedLink

 * linkListName hinzufügt. Ist noch nicht vollständig... denke ich.

GenericPerson

 * NullPointer Exception im PageCreate gelöst
 * NotNullValidationListener zum Feld Nachname hinzugefügt

git-svn-id: https://svn.libreccm.org/ccm/trunk@581 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2010-10-18 06:53:53 +00:00
parent 6dd53b0920
commit 8d7857ade5
20 changed files with 166 additions and 100 deletions

View File

@ -21,6 +21,7 @@ import com.arsdigita.cms.MimeType;
object type RelatedLink extends Link {
String[0..1] linkListName = cms_related_links.link_list_name VARCHAR(100);
String[0..1] resourceSize = cms_related_links.resource_size VARCHAR(50);
MimeType[0..1] resourceType = join cms_related_links.resource_type
to cms_mime_types.mime_type;
@ -56,7 +57,7 @@ query allRelatedLinkOrderForItem {
do {
select l.link_order from cms_links l, cms_related_links r
where r.owner_id = :ownerID and l.link_id = r.related_link_id
where r.owner_id = :ownerID and l.link_id = r.related_link_id and r.link_list_name = :linkListName
} map {
linkOrder = l.link_order;
}
@ -68,7 +69,7 @@ query getReferringRelatedLinks {
do {
select l.link_id
from cms_links l, cms_related_links r
where l.target_item_id = :itemID and l.link_id=r.related_link_id
where l.target_item_id = :itemID and l.link_id=r.related_link_id and r.link_list_name = :linkListName
} map {
id = l.link_id;
}

View File

@ -44,6 +44,7 @@ public class RelatedLink extends Link {
private static final Logger s_log = Logger.getLogger(RelatedLink.class);
/** PDL properties */
public static final String LINK_LIST_NAME = "linkListName";
public static final String RESOURCE_SIZE = "resourceSize";
public static final String RESOURCE_TYPE = "resourceType";
public static final String LINK_OWNER = "linkOwner";
@ -108,6 +109,16 @@ public class RelatedLink extends Link {
super( type );
}
/** get the name of the named link list. */
public String getLinkListName(){
return (String) get(LINK_LIST_NAME);
}
/** Set the name of the named link list. */
public void setLinkListName(String name){
set(LINK_LIST_NAME , name);
}
/**
* Get the MimeType of the target resource to which this link points.
*
@ -171,11 +182,12 @@ public class RelatedLink extends Link {
*
* @param item The item to return links for
*/
public static DataCollection getRelatedLinks(ContentItem item) {
public static DataCollection getRelatedLinks(ContentItem item, String name) {
s_log.debug("Getting related links for a content item");
Session session = SessionManager.getSession();
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
links.addEqualsFilter(LINK_OWNER + ".id", item.getID());
links.addEqualsFilter(LINK_LIST_NAME, name);
links.addOrder(ORDER);
return links;
}
@ -261,6 +273,7 @@ public class RelatedLink extends Link {
Session session = SessionManager.getSession();
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
links.addEqualsFilter(LINK_OWNER + ".id", getLinkOwner().getID());
links.addEqualsFilter(LINK_LIST_NAME, getLinkListName());
links.addOrder(TITLE);
int sortKey = 0;
while (links.next()) {
@ -287,6 +300,7 @@ public class RelatedLink extends Link {
DataQuery query = SessionManager.getSession().retrieveQuery
("com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem");
query.setParameter("ownerID", getLinkOwner().getID());
query.setParameter("linkListName", getLinkListName());
query.addOrder("linkOrder DESC");
if (query.next()) {
Integer linkOrder = ((Integer)query.get("linkOrder"));

View File

@ -28,6 +28,8 @@ import com.arsdigita.cms.contenttypes.ui.LinkTable;
*/
public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
protected String m_linkListName = "";
/**
* Constructor. Creates a <code>RelatedLinkPropertiesStep</code> given an
* <code>ItemSelectionModel</code> and an
@ -63,10 +65,9 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
LinkTable table;
if (ContentSection.getConfig().isHideAdditionalResourceFields()) {
table = new LinkTable(getItemSelectionModel(), getLinkSelectionModel());
table.setModelBuilder(new RelatedLinkTableModelBuilder(getItemSelectionModel()));
table.setModelBuilder(new RelatedLinkTableModelBuilder(getItemSelectionModel(), m_linkListName));
} else {
table = new RelatedLinkTable(getItemSelectionModel(),
getLinkSelectionModel());
table = new RelatedLinkTable(getItemSelectionModel(), getLinkSelectionModel(), m_linkListName);
}
container.add(table);
@ -81,7 +82,8 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
@Override
protected FormSection getEditSheet() {
return new RelatedLinkPropertyForm(getItemSelectionModel(),
getLinkSelectionModel());
getLinkSelectionModel(),
m_linkListName);
}
}

View File

@ -19,6 +19,7 @@ import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.Hidden;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextField;
@ -49,6 +50,7 @@ import com.arsdigita.util.Assert;
public class RelatedLinkPropertyForm extends LinkPropertyForm {
private static boolean isHideAdditionalResourceFields;
private String m_linkListName = "";
static {
isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields();
@ -63,7 +65,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
* Link to work on
*/
public RelatedLinkPropertyForm(ItemSelectionModel itemModel,
LinkSelectionModel link) {
LinkSelectionModel link, String linkListName) {
super(itemModel, link);
}
@ -99,6 +101,9 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
addMimeOptions(resType);
add(resType);
}
Hidden linkListName = new Hidden(new StringParameter(RelatedLink.LINK_LIST_NAME));
add(linkListName);
}
/**
@ -124,6 +129,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
* @param s the PageState
* @return the newly-created RelatedLink
*/
@Override
protected Link createLink(PageState s) {
ContentItem item = getContentItem(s);
Assert.exists(item, ContentItem.class);
@ -141,6 +147,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
* Over-ride super class method to initialize addtional fields specific
* to <code>RelatedLink</code> content asset.
*/
@Override
public void init(FormSectionEvent fse) throws FormProcessException {
super.init(fse);
FormData data = fse.getFormData();
@ -156,10 +163,12 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
if (rl.getResourceType() != null) {
data.put(RelatedLink.RESOURCE_TYPE, rl.getResourceType().getMimeType());
}
data.put(RelatedLink.LINK_LIST_NAME, rl.getLinkListName());
} else {
// New Link creation , clear the fields.
data.put(RelatedLink.RESOURCE_SIZE, null);
data.put(RelatedLink.RESOURCE_TYPE, null);
data.put(RelatedLink.LINK_LIST_NAME, m_linkListName);
}
}
}
@ -168,6 +177,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
* over-ride super class method to set extended properties for
* <code>RelatedLink</code>.
*/
@Override
protected void setLinkProperties(Link link, FormSectionEvent fse) {
RelatedLink rl = (RelatedLink) (link);
FormData data = fse.getFormData();
@ -181,6 +191,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
MimeType mType = MimeType.loadMimeType(typeName);
rl.setResourceType(mType);
}
rl.setLinkListName(data.getString(RelatedLink.LINK_LIST_NAME));
super.setLinkProperties(link, fse);
}
}

View File

@ -48,10 +48,10 @@ public class RelatedLinkTable extends LinkTable {
* @param link The <code>LinkSelectionModel</code> to track the
* current link
*/
public RelatedLinkTable(ItemSelectionModel item, LinkSelectionModel link) {
public RelatedLinkTable(ItemSelectionModel item, LinkSelectionModel link, String linkListName) {
super(item, link);
setModelBuilder(new RelatedLinkTableModelBuilder(item));
setModelBuilder(new RelatedLinkTableModelBuilder(item, linkListName));
RelatedLinkRenderer rlcr = new RelatedLinkRenderer();
m_typeCol.setCellRenderer(rlcr);

View File

@ -31,12 +31,12 @@ import org.apache.log4j.Logger;
* @author Scott Seago (sseago@redhat.com)
*/
public class RelatedLinkTableModelBuilder
extends LinkTableModelBuilder {
public class RelatedLinkTableModelBuilder extends LinkTableModelBuilder {
private static final Logger s_log =
Logger.getLogger(RelatedLinkTableModelBuilder.class);
private ItemSelectionModel m_itemModel;
private String m_linkListName = "";
/**
* Constructor. Creates a <code>LinkTableModelBuilder</code> given an
@ -45,8 +45,9 @@ public class RelatedLinkTableModelBuilder
* @param item The <code>ItemSelectionModel</code> for the current page.
* current link
*/
public RelatedLinkTableModelBuilder(ItemSelectionModel item) {
public RelatedLinkTableModelBuilder(ItemSelectionModel item, String name) {
m_itemModel = item;
m_linkListName = name;
s_log.debug("RelatedLinkTableModelBuilder");
}
@ -61,7 +62,7 @@ public class RelatedLinkTableModelBuilder
Assert.isTrue(m_itemModel.isSelected(s), "item selected");
ContentItem item = m_itemModel.getSelectedItem(s);
s_log.debug("Getting related links for " + item.getName());
return RelatedLink.getRelatedLinks(item);
return RelatedLink.getRelatedLinks(item, m_linkListName);
}
}

View File

@ -25,12 +25,12 @@ object type RelationAttribute {
BigDecimal[1..1] id = cms_relation_attribute.object_id INTEGER;
String[1..1] attribute = cms_relation_attribute.attribute VARCHAR(100);
String[1..1] key = cms_relation_attribute.key VARCHAR(100);
String[1..1] attr_key = cms_relation_attribute.attr_key VARCHAR(100);
String[1..1] lang = cms_relation_attribute.lang VARCHAR(2);
String[1..1] name = cms_relation_attribute.name VARCHAR(100);
String[0..1] description = cms_relation_attribute.description VARCHAR(500);
unique (attribute, key, lang);
unique (attribute, attr_key, lang);
object key (id);
}

View File

@ -57,7 +57,7 @@ association {
to cms_contacts.contact_id;
// Link Attribute
BigDecimal[0..1] contact_order = cms_person_contact_map.contact_order INTEGER;
String[0..1] contact_type = cms_person_contact_map.key VARCHAR(100);
BigDecimal[0..1] link_order = cms_person_contact_map.link_order INTEGER;
String[0..1] link_key = cms_person_contact_map.link_key VARCHAR(100);
}

View File

@ -19,7 +19,7 @@ public class RelationAttribute extends DomainObject {
public static final String ID = "id";
public static final String ATTRIBUTE = "attribute";
public static final String KEY = "key";
public static final String KEY = "attr_key";
public static final String LANGUAGE = "lang";
public static final String NAME = "name";
public static final String DESCRIPTION = "description";

View File

@ -39,6 +39,7 @@ public class GenericContact extends ContentPage implements RelationAttributeInte
/** PDL property names */
public static final String PERSON = "person";
// public static final String CONTACT_TYPE = "";
public static final String ADDRESS = "address";
public static final String CONTACT_ENTRIES = "contactentries";
@ -104,6 +105,16 @@ public class GenericContact extends ContentPage implements RelationAttributeInte
set(PERSON, person);
}
// // Get the type for this contact
// public String getContactType() {
// return get(CONTACT_TYPE));
// }
//
// // Set the type for this contact
// public void setContactType(String type) {
// set(CONTACT_TYPE, type);
// }
// Unset the address for this contact
public void unsetPerson() {
set(PERSON, null);
@ -141,6 +152,14 @@ public class GenericContact extends ContentPage implements RelationAttributeInte
remove(CONTACT_ENTRIES, contactEntry);
}
public boolean hasPerson() {
return !(this.getPerson() == null);
}
public boolean hasAddress() {
return !(this.getAddress() == null);
}
public boolean hasContactEntries() {
return !this.getContactEntries().isEmpty();
}

View File

@ -16,17 +16,19 @@ import com.arsdigita.persistence.DataCollection;
*/
public class GenericContactTypeCollection extends RelationAttributeCollection {
public static final String CONTACT_ORDER = "contact_order";
public static final String CONTACTS_KEY = GenericPerson.CONTACTS_KEY;
public static final String CONTACTS_ORDER = GenericPerson.CONTACTS_ORDER;
public static final String ATTRIBUTE_NAME = "person";
/**
* Creates a new instance of GenericContactEntryCollection
*/
public GenericContactTypeCollection() {
super("person");
super(ATTRIBUTE_NAME);
}
public GenericContactTypeCollection(String key) {
super("person", key);
super(ATTRIBUTE_NAME, CONTACTS_KEY);
}
public GenericContactTypeCollection(DataCollection dataCollection) {
@ -38,6 +40,6 @@ public class GenericContactTypeCollection extends RelationAttributeCollection {
// }
public String getContactOrder() {
return (String) get(CONTACT_ORDER);
return (String) get(CONTACTS_ORDER);
}
}

View File

@ -46,8 +46,8 @@ public class GenericPerson extends ContentPage implements RelationAttributeInter
public static final String BIRTHDATE = "birthdate";
public static final String GENDER = "gender";
public static final String CONTACTS = "contacts";
public static final String CONTACT_TYPE = "contact_type";
public static final String CONTACT_ORDER = "contact_order";
public static final String CONTACTS_KEY = "link_key";
public static final String CONTACTS_ORDER = "link_order";
private static final String RELATION_ATTRIBUTES = "GenericContactType";
/** Data object type for this domain object */
public static final String BASE_DATA_OBJECT_TYPE =
@ -166,9 +166,11 @@ public class GenericPerson extends ContentPage implements RelationAttributeInter
private void updateNameAndTitle() {
// Sync title and name with CI data
setTitle(getFullName());
setName(GenericPerson.urlSave(getTitle()));
String fullname = getFullName();
if (fullname != null && !fullname.isEmpty()) {
setTitle(fullname);
setName(GenericPerson.urlSave(fullname));
}
}
// Get all contacts for this person
@ -183,8 +185,8 @@ public class GenericPerson extends ContentPage implements RelationAttributeInter
DataObject link = add(CONTACTS, contact);
link.set(CONTACT_TYPE, contactType);
link.set(CONTACT_ORDER, BigDecimal.valueOf(getContacts().size()));
link.set(CONTACTS_KEY, contactType);
link.set(CONTACTS_ORDER, BigDecimal.valueOf(getContacts().size()));
}
// Remove a contact for this person
@ -210,6 +212,8 @@ public class GenericPerson extends ContentPage implements RelationAttributeInter
// Create a ulr save version of the full name
public static String urlSave(String in) {
if (in != null && !in.isEmpty()) {
// Replacement map
String[][] replacements = {{"ä", "ae"}, {"Ä", "Ae"}, {"ö", "oe"}, {"Ö", "Oe"}, {"ü", "ue"}, {"Ü", "Ue"}, {"ß", "ss"}, {".", ""}};
@ -224,4 +228,8 @@ public class GenericPerson extends ContentPage implements RelationAttributeInter
// Replace all special chars that are not yet replaced with a dash
return out.replaceAll("[^A-Za-z0-9-]", "_");
}
return in;
}
}

View File

@ -19,9 +19,9 @@ import java.math.BigDecimal;
*/
public class GenericPersonContactCollection extends DomainCollection {
public static final String ORDER = "link.contact_order asc";
public static final String CONTACT_TYPE = "link.contact_type";
public static final String CONTACT_ORDER = "link.contact_order";
public static final String ORDER = "link." + GenericPerson.CONTACTS_ORDER + " asc";
public static final String CONTACTS_KEY = "link." + GenericPerson.CONTACTS_KEY;
public static final String CONTACTS_ORDER = "link." + GenericPerson.CONTACTS_ORDER;
/**
* Creates a new instance of GenericPersonContactCollection
@ -34,12 +34,12 @@ public class GenericPersonContactCollection extends DomainCollection {
// Get the contact type of the link
public String getContactType() {
return (String) m_dataCollection.get(CONTACT_TYPE);
return (String) m_dataCollection.get(CONTACTS_KEY);
}
// Get the contact order of the link
public String getContactOrder() {
String retVal = ((BigDecimal) m_dataCollection.get(CONTACT_ORDER)).toString();
String retVal = ((BigDecimal) m_dataCollection.get(CONTACTS_ORDER)).toString();
if(retVal == null || retVal.isEmpty()) {
retVal = String.valueOf(this.getPosition());

View File

@ -51,6 +51,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
private ItemSearchWidget m_itemSearch;
private SaveCancelSection m_saveCancelSection;
private final String ITEM_SEARCH = "contactPerson";
private final String CONTACTS_KEY = GenericPersonContactCollection.CONTACTS_KEY;
/**
* ID of the form
*/
@ -90,7 +91,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
// GenericContact type field
add(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.type")));
ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACT_TYPE);
ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACTS_KEY);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
@ -116,6 +117,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
if (contact != null) {
data.put(ITEM_SEARCH, contact.getPerson());
// data.put(CONTACTS_KEY, contact.getContactType());
}
}
@ -126,6 +128,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm implem
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
contact.setPerson((GenericPerson) data.get(ITEM_SEARCH));
// contact.setContactType(data.get(CONTACTS_KEY));
}
init(fse);
}

View File

@ -168,11 +168,11 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm impleme
GenericContact contact = (GenericContact) getItemSelectionModel().getSelectedObject(state);
if (getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
if (contact.getAddress() == null) {
contact.setAddress(new GenericAddress());
contact.getAddress().setName("Address for " + contact.getName() + "(" + contact.getID() + ")");
contact.getAddress().setTitle("Address for " + contact.getName() + "(" + contact.getID() + ")");
}
// if (contact.getAddress() == null) {
// contact.setAddress(new GenericAddress());
// contact.getAddress().setName("Address for " + contact.getName() + "(" + contact.getID() + ")");
// contact.getAddress().setTitle("Address for " + contact.getName() + "(" + contact.getID() + ")");
// }
contact.getAddress().setAddress((String) data.get(ADDRESS));
contact.getAddress().setPostalCode((String) data.get(POSTAL_CODE));

View File

@ -6,7 +6,6 @@
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.cms.ItemSelectionModel;
@ -17,6 +16,8 @@ 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.bebop.PageState;
import com.arsdigita.cms.contenttypes.GenericContact;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
@ -30,6 +31,9 @@ public class GenericContactPersonPropertiesStep extends SimpleEditStep {
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";
private WorkflowLockedComponentAccess addPerson;
private WorkflowLockedComponentAccess editPerson;
private WorkflowLockedComponentAccess delPerson;
/**
* Creates a new instance of GenericContactPersonPropertiesStep
@ -41,29 +45,20 @@ public class GenericContactPersonPropertiesStep extends SimpleEditStep {
public GenericContactPersonPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) {
super(itemModel, parent, prefix);
//XXX
// if(false/*EMPTY*/) {
BasicPageForm addPersonSheet = new GenericContactAttachPersonPropertyForm(itemModel, this);
add(ADD_PERSON_SHEET_NAME, (String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.attach_person").localize(), new WorkflowLockedComponentAccess(addPersonSheet, itemModel), addPersonSheet.getSaveCancelSection().getCancelButton());
/* Set the displayComponent for this step */
// setDisplayComponent(getEmptyPersonPropertySheet(itemModel));
// } else {
addPerson = new WorkflowLockedComponentAccess(addPersonSheet, itemModel);
add(ADD_PERSON_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.attach_person").localize(), addPerson, addPersonSheet.getSaveCancelSection().getCancelButton());
BasicPageForm editPersonSheet = new GenericContactEditPersonPropertyForm(itemModel, this);
add(EDIT_PERSON_SHEET_NAME, (String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.edit_person").localize(), new WorkflowLockedComponentAccess(editPersonSheet, itemModel), editPersonSheet.getSaveCancelSection().getCancelButton());
// BasicPageForm changePersonSheet = new GenericContactEditPersonPropertyForm(itemModel, this);
// add(CHANGE_PERSON_SHEET_NAME, (String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.reattach_person").localize(), new WorkflowLockedComponentAccess(changePersonSheet, itemModel), changePersonSheet.getSaveCancelSection().getCancelButton());
editPerson = new WorkflowLockedComponentAccess(editPersonSheet, itemModel);
add(EDIT_PERSON_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.edit_person").localize(), editPerson, editPersonSheet.getSaveCancelSection().getCancelButton());
BasicPageForm deletePersonSheet = new GenericContactDeletePersonForm(itemModel, this);
add(DELETE_PERSON_SHEET_NAME, (String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.delete_person").localize(), new WorkflowLockedComponentAccess(deletePersonSheet, itemModel), deletePersonSheet.getSaveCancelSection().getCancelButton());
delPerson = new WorkflowLockedComponentAccess(deletePersonSheet, itemModel);
add(DELETE_PERSON_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.delete_person").localize(), delPerson, deletePersonSheet.getSaveCancelSection().getCancelButton());
/* Set the displayComponent for this step */
setDisplayComponent(getPersonPropertySheet(itemModel));
// }
}
@ -81,4 +76,20 @@ public class GenericContactPersonPropertiesStep extends SimpleEditStep {
public static Component getEmptyPersonPropertySheet(ItemSelectionModel itemModel) {
return new Label(((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.emptyPerson").localize()));
}
@Override
public boolean isVisible(PageState ps) {
if(((GenericContact) getItemSelectionModel().getSelectedItem(ps)).hasPerson() == false) {
addPerson.getComponent().setVisible(ps, true);
editPerson.getComponent().setVisible(ps, false);
delPerson.getComponent().setVisible(ps, false);
} else {
addPerson.getComponent().setVisible(ps, false);
editPerson.getComponent().setVisible(ps, true);
delPerson.getComponent().setVisible(ps, true);
}
return super.isVisible(ps);
}
}

View File

@ -77,7 +77,7 @@ public class GenericPersonContactAddForm extends BasicItemForm {
// GenericContact type field
add(new Label(ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.contact.type")));
ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACT_TYPE);
ParameterModel contactTypeParam = new StringParameter(GenericPersonContactCollection.CONTACTS_KEY);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
@ -109,7 +109,7 @@ public class GenericPersonContactAddForm extends BasicItemForm {
//
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
person.addContact((GenericContact) data.get(ITEM_SEARCH), (String) data.get(GenericPersonContactCollection.CONTACT_TYPE));
person.addContact((GenericContact) data.get(ITEM_SEARCH), (String) data.get(GenericPersonContactCollection.CONTACTS_KEY));
}
init(fse);

View File

@ -74,7 +74,7 @@ public class GenericPersonContactTable extends Table implements TableActionListe
setModelBuilder(new GenericPersonTableModelBuilder(itemModel));
tab_model.get(0).setCellRenderer(new EditCellRenderer());
tab_model.get(2).setCellRenderer(new EditCellRenderer());
tab_model.get(3).setCellRenderer(new DeleteCellRenderer());
addTableActionListener(this);
@ -150,18 +150,10 @@ public class GenericPersonContactTable extends Table implements TableActionListe
case 0:
return m_contactCollection.getContactOrder();
case 1:
String lang = DispatcherHelper.getNegotiatedLocale().getLanguage();
String key = m_contactCollection.getContactType();
return contacttypes.getRelationAttribute(m_contactCollection.getContactType(),
DispatcherHelper.getNegotiatedLocale().getLanguage());
// return contacttypes.getRelationAttribute(m_contactCollection.getContactType(),
// DispatcherHelper.getNegotiatedLocale().getLanguage());
DispatcherHelper.getNegotiatedLocale().getLanguage()).getName();
case 2:
return m_contact.getTitle();
// case 2:
// return (m_personEntry.getDescription() != null && m_personEntry.getDescription().length() > MAX_DESC_LENGTH)
// ? m_personEntry.getDescription().substring(0, MAX_DESC_LENGTH)
// : m_personEntry.getDescription();
case 3:
return GlobalizationUtil.globalize("cms.ui.delete").localize();
default:

View File

@ -30,6 +30,7 @@ import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.DateParameter;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
@ -107,6 +108,7 @@ public class GenericPersonPropertyForm extends BasicPageForm implements FormProc
form.add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.person.surname").localize()));
ParameterModel surnameParam = new StringParameter(SURNAME);
surnameParam.addParameterListener(new NotNullValidationListener());
TextField surname = new TextField(surnameParam);
form.add(surname);

View File

@ -173,7 +173,7 @@ public class LinkPropertyForm extends FormSection
add(m_targetURI);
add(new Label("Content Item:"));
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, m_contentType);
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, m_itemModel.getContentType());
m_itemSearch.getSearchButton().setOnFocus("toggle_link_fields(true)");
m_itemSearch.getClearButton().setOnFocus("toggle_link_fields(true)");
add(m_itemSearch);