Enhanced globalization for the options of several SingleSelect fields using RelationAttributes (Database driven enums).
git-svn-id: https://svn.libreccm.org/ccm/trunk@2748 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
52d8a5285e
commit
96770a673d
|
|
@ -33,8 +33,8 @@ import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.cms.ContentSection;
|
import com.arsdigita.cms.ContentSection;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.RelationAttribute;
|
|
||||||
import com.arsdigita.cms.RelationAttributeCollection;
|
import com.arsdigita.cms.RelationAttributeCollection;
|
||||||
|
import com.arsdigita.cms.RelationAttributeResourceBundleControl;
|
||||||
import com.arsdigita.cms.contentassets.GenericOrgaUnitTextAsset;
|
import com.arsdigita.cms.contentassets.GenericOrgaUnitTextAsset;
|
||||||
import com.arsdigita.cms.contentassets.GenericOrgaUnitTextAssetGlobalizationUtil;
|
import com.arsdigita.cms.contentassets.GenericOrgaUnitTextAssetGlobalizationUtil;
|
||||||
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
|
||||||
|
|
@ -42,7 +42,7 @@ import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import java.util.TooManyListenersException;
|
import java.util.TooManyListenersException;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -80,9 +80,15 @@ public class GenericOrgaUnitTextAssetEdit extends BasicItemForm implements FormS
|
||||||
|
|
||||||
final RelationAttributeCollection names = new RelationAttributeCollection(
|
final RelationAttributeCollection names = new RelationAttributeCollection(
|
||||||
"GenericOrgaUnitTextAssetName");
|
"GenericOrgaUnitTextAssetName");
|
||||||
names.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().getLanguage());
|
//names.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().getLanguage());
|
||||||
while (names.next()) {
|
while (names.next()) {
|
||||||
target.addOption(new Option(names.getKey(), names.getName()));
|
//target.addOption(new Option(names.getKey(), names.getName()));
|
||||||
|
target.addOption(new Option(
|
||||||
|
names.getKey(),
|
||||||
|
new Label(new GlobalizedMessage(
|
||||||
|
names.getKey(),
|
||||||
|
"GenericOrgaUnitTextAssetName",
|
||||||
|
new RelationAttributeResourceBundleControl()))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.RelationAttributeResourceBundleControl;
|
||||||
import com.arsdigita.cms.contenttypes.GenericContact;
|
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||||
import com.arsdigita.cms.contenttypes.GenericContactEntry;
|
import com.arsdigita.cms.contenttypes.GenericContactEntry;
|
||||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||||
|
|
@ -37,10 +38,9 @@ import com.arsdigita.cms.contenttypes.GenericContactEntryKeys;
|
||||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import java.util.TooManyListenersException;
|
import java.util.TooManyListenersException;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class GenericContactEntryAddForm extends BasicItemForm {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of CategoryLocalizationAddForm.
|
* Creates a new instance of CategoryLocalizationAddForm.
|
||||||
*
|
*
|
||||||
* @param itemModel
|
* @param itemModel
|
||||||
*/
|
*/
|
||||||
public GenericContactEntryAddForm(ItemSelectionModel itemModel) {
|
public GenericContactEntryAddForm(ItemSelectionModel itemModel) {
|
||||||
|
|
@ -72,7 +72,7 @@ public class GenericContactEntryAddForm extends BasicItemForm {
|
||||||
ParameterModel contactEntryKeyParam = new StringParameter(GenericContactEntry.KEY);
|
ParameterModel contactEntryKeyParam = new StringParameter(GenericContactEntry.KEY);
|
||||||
SingleSelect contactEntryKey = new SingleSelect(contactEntryKeyParam);
|
SingleSelect contactEntryKey = new SingleSelect(contactEntryKeyParam);
|
||||||
contactEntryKey.setLabel(ContenttypesGlobalizationUtil.globalize(
|
contactEntryKey.setLabel(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericcontact.contactEntry.key"));
|
"cms.contenttypes.ui.genericcontact.contactEntry.key"));
|
||||||
contactEntryKey.addValidationListener(new NotNullValidationListener());
|
contactEntryKey.addValidationListener(new NotNullValidationListener());
|
||||||
contactEntryKey.addOption(new Option("", new Label(GlobalizationUtil.globalize(
|
contactEntryKey.addOption(new Option("", new Label(GlobalizationUtil.globalize(
|
||||||
"cms.ui.select_one"))));
|
"cms.ui.select_one"))));
|
||||||
|
|
@ -84,11 +84,17 @@ public class GenericContactEntryAddForm extends BasicItemForm {
|
||||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||||
|
|
||||||
final GenericContactEntryKeys keyList = new GenericContactEntryKeys();
|
final GenericContactEntryKeys keyList = new GenericContactEntryKeys();
|
||||||
keyList.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale()
|
// keyList.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale()
|
||||||
.getLanguage());
|
// .getLanguage());
|
||||||
while (keyList.next()) {
|
while (keyList.next()) {
|
||||||
String currentKey = keyList.getKey();
|
String currentKey = keyList.getKey();
|
||||||
target.addOption(new Option(currentKey, keyList.getName()));
|
//target.addOption(new Option(currentKey, keyList.getName()));
|
||||||
|
target.addOption(new Option(
|
||||||
|
currentKey,
|
||||||
|
new Label(new GlobalizedMessage(
|
||||||
|
currentKey,
|
||||||
|
GenericContactEntryKeys.ATTRIBUTE_NAME,
|
||||||
|
new RelationAttributeResourceBundleControl()))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,16 +110,16 @@ public class GenericContactEntryAddForm extends BasicItemForm {
|
||||||
ParameterModel contactEntryValueParam = new StringParameter(GenericContactEntry.VALUE);
|
ParameterModel contactEntryValueParam = new StringParameter(GenericContactEntry.VALUE);
|
||||||
TextField contactEntryValue = new TextField(contactEntryValueParam);
|
TextField contactEntryValue = new TextField(contactEntryValueParam);
|
||||||
contactEntryValue.setLabel(ContenttypesGlobalizationUtil.globalize(
|
contactEntryValue.setLabel(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericcontact.contactEntry.value"));
|
"cms.contenttypes.ui.genericcontact.contactEntry.value"));
|
||||||
contactEntryValue.addValidationListener(new NotNullValidationListener());
|
contactEntryValue.addValidationListener(new NotNullValidationListener());
|
||||||
add(contactEntryValue);
|
add(contactEntryValue);
|
||||||
|
|
||||||
// Description field, only for internal usage
|
// Description field, only for internal usage
|
||||||
ParameterModel contactEntryDescriptionParam = new StringParameter(
|
ParameterModel contactEntryDescriptionParam = new StringParameter(
|
||||||
GenericContactEntry.DESCRIPTION);
|
GenericContactEntry.DESCRIPTION);
|
||||||
TextField contactEntryDescription = new TextField(contactEntryDescriptionParam);
|
TextField contactEntryDescription = new TextField(contactEntryDescriptionParam);
|
||||||
contactEntryDescription.setLabel(ContenttypesGlobalizationUtil.globalize(
|
contactEntryDescription.setLabel(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericcontact.contactEntry.description"));
|
"cms.contenttypes.ui.genericcontact.contactEntry.description"));
|
||||||
add(contactEntryDescription);
|
add(contactEntryDescription);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -139,14 +145,14 @@ public class GenericContactEntryAddForm extends BasicItemForm {
|
||||||
|
|
||||||
// save only if save button was pressed
|
// save only if save button was pressed
|
||||||
if (contact != null
|
if (contact != null
|
||||||
&& getSaveCancelSection().getSaveButton()
|
&& getSaveCancelSection().getSaveButton()
|
||||||
.isSelected(fse.getPageState())) {
|
.isSelected(fse.getPageState())) {
|
||||||
|
|
||||||
GenericContactEntry contactEntry = new GenericContactEntry(
|
GenericContactEntry contactEntry = new GenericContactEntry(
|
||||||
contact,
|
contact,
|
||||||
(String) data.get(GenericContactEntry.KEY),
|
(String) data.get(GenericContactEntry.KEY),
|
||||||
(String) data.get(GenericContactEntry.VALUE),
|
(String) data.get(GenericContactEntry.VALUE),
|
||||||
(String) data.get(GenericContactEntry.DESCRIPTION));
|
(String) data.get(GenericContactEntry.DESCRIPTION));
|
||||||
|
|
||||||
contact.addContactEntry(contactEntry);
|
contact.addContactEntry(contactEntry);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,17 +113,18 @@ public class GenericOrganizationalUnitPersonAddForm
|
||||||
|
|
||||||
final RelationAttributeCollection roles = new RelationAttributeCollection(
|
final RelationAttributeCollection roles = new RelationAttributeCollection(
|
||||||
getRoleAttributeName());
|
getRoleAttributeName());
|
||||||
roles.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
// roles.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||||
getLanguage());
|
// getLanguage());
|
||||||
while (roles.next()) {
|
while (roles.next()) {
|
||||||
RelationAttribute role;
|
RelationAttribute role;
|
||||||
role = roles.getRelationAttribute();
|
role = roles.getRelationAttribute();
|
||||||
//target.addOption(new Option(role.getKey(), role.getName()));
|
//target.addOption(new Option(role.getKey(), role.getName()));
|
||||||
target.addOption(new Option(role.getKey(),
|
target.addOption(new Option(
|
||||||
new Label(new GlobalizedMessage(
|
role.getKey(),
|
||||||
role.getKey(),
|
new Label(new GlobalizedMessage(
|
||||||
getRoleAttributeName(),
|
role.getKey(),
|
||||||
new RelationAttributeResourceBundleControl()))));
|
getRoleAttributeName(),
|
||||||
|
new RelationAttributeResourceBundleControl()))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,16 +151,18 @@ public class GenericOrganizationalUnitPersonAddForm
|
||||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||||
RelationAttributeCollection statusColl = new RelationAttributeCollection(
|
RelationAttributeCollection statusColl = new RelationAttributeCollection(
|
||||||
getStatusAttributeName());
|
getStatusAttributeName());
|
||||||
statusColl.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
// statusColl.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||||
getLanguage());
|
// getLanguage());
|
||||||
while (statusColl.next()) {
|
while (statusColl.next()) {
|
||||||
RelationAttribute status;
|
RelationAttribute status;
|
||||||
status = statusColl.getRelationAttribute();
|
status = statusColl.getRelationAttribute();
|
||||||
//target.addOption(new Option(status.getKey(), status.getName()));
|
//target.addOption(new Option(status.getKey(), status.getName()));
|
||||||
target.addOption(new Option(status.getKey(),
|
target.addOption(new Option(
|
||||||
new Label(new GlobalizedMessage(status.getKey(),
|
status.getKey(),
|
||||||
getStatusAttributeName(),
|
new Label(new GlobalizedMessage(
|
||||||
new RelationAttributeResourceBundleControl()))));
|
status.getKey(),
|
||||||
|
getStatusAttributeName(),
|
||||||
|
new RelationAttributeResourceBundleControl()))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.cms.ContentType;
|
import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.cms.RelationAttribute;
|
import com.arsdigita.cms.RelationAttribute;
|
||||||
|
import com.arsdigita.cms.RelationAttributeResourceBundleControl;
|
||||||
import com.arsdigita.cms.contenttypes.GenericContact;
|
import com.arsdigita.cms.contenttypes.GenericContact;
|
||||||
import com.arsdigita.cms.contenttypes.GenericContactTypeCollection;
|
import com.arsdigita.cms.contenttypes.GenericContactTypeCollection;
|
||||||
import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
|
import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
|
||||||
|
|
@ -43,7 +44,7 @@ import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
|
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
import com.arsdigita.kernel.Kernel;
|
import com.arsdigita.kernel.Kernel;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
|
@ -61,7 +62,7 @@ import org.apache.log4j.Logger;
|
||||||
public class GenericPersonContactAddForm extends BasicItemForm {
|
public class GenericPersonContactAddForm extends BasicItemForm {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(
|
private static final Logger s_log = Logger.getLogger(
|
||||||
GenericPersonContactAddForm.class);
|
GenericPersonContactAddForm.class);
|
||||||
private GenericPersonPropertiesStep m_step;
|
private GenericPersonPropertiesStep m_step;
|
||||||
private ItemSearchWidget m_itemSearch;
|
private ItemSearchWidget m_itemSearch;
|
||||||
private SaveCancelSection m_saveCancelSection;
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
|
@ -86,22 +87,22 @@ public class GenericPersonContactAddForm extends BasicItemForm {
|
||||||
|
|
||||||
// Attach a GenericContact object
|
// Attach a GenericContact object
|
||||||
add(new Label(ContenttypesGlobalizationUtil.globalize(
|
add(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericperson.select_contact")));
|
"cms.contenttypes.ui.genericperson.select_contact")));
|
||||||
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
|
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
|
||||||
findByAssociatedObjectType(
|
findByAssociatedObjectType(
|
||||||
"com.arsdigita.cms.contenttypes.GenericContact"));
|
"com.arsdigita.cms.contenttypes.GenericContact"));
|
||||||
add(this.m_itemSearch);
|
add(this.m_itemSearch);
|
||||||
|
|
||||||
// GenericContact type field
|
// GenericContact type field
|
||||||
ParameterModel contactTypeParam = new StringParameter(
|
ParameterModel contactTypeParam = new StringParameter(
|
||||||
GenericPersonContactCollection.CONTACTS_KEY);
|
GenericPersonContactCollection.CONTACTS_KEY);
|
||||||
SingleSelect contactType = new SingleSelect(contactTypeParam);
|
SingleSelect contactType = new SingleSelect(contactTypeParam);
|
||||||
contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
|
contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericperson.contact.type"));
|
"cms.contenttypes.ui.genericperson.contact.type"));
|
||||||
contactType.addValidationListener(new NotNullValidationListener());
|
contactType.addValidationListener(new NotNullValidationListener());
|
||||||
contactType.addOption(new Option("",
|
contactType.addOption(new Option("",
|
||||||
new Label(GlobalizationUtil.
|
new Label(GlobalizationUtil.
|
||||||
globalize("cms.ui.select_one"))));
|
globalize("cms.ui.select_one"))));
|
||||||
try {
|
try {
|
||||||
contactType.addPrintListener(new PrintListener() {
|
contactType.addPrintListener(new PrintListener() {
|
||||||
|
|
||||||
|
|
@ -111,12 +112,18 @@ public class GenericPersonContactAddForm extends BasicItemForm {
|
||||||
// Add the Options to the SingleSelect widget
|
// Add the Options to the SingleSelect widget
|
||||||
final GenericContactTypeCollection contacttypes
|
final GenericContactTypeCollection contacttypes
|
||||||
= new GenericContactTypeCollection();
|
= new GenericContactTypeCollection();
|
||||||
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
// contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||||
getLanguage());
|
// getLanguage());
|
||||||
|
|
||||||
while (contacttypes.next()) {
|
while (contacttypes.next()) {
|
||||||
RelationAttribute ct = contacttypes.getRelationAttribute();
|
RelationAttribute ct = contacttypes.getRelationAttribute();
|
||||||
target.addOption(new Option(ct.getKey(), ct.getName()));
|
//target.addOption(new Option(ct.getKey(), ct.getName()));
|
||||||
|
target.addOption(new Option(
|
||||||
|
ct.getKey(),
|
||||||
|
new Label(new GlobalizedMessage(
|
||||||
|
ct.getKey(),
|
||||||
|
GenericContactTypeCollection.ATTRIBUTE_NAME,
|
||||||
|
new RelationAttributeResourceBundleControl()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -143,17 +150,17 @@ public class GenericPersonContactAddForm extends BasicItemForm {
|
||||||
final FormData data = fse.getFormData();
|
final FormData data = fse.getFormData();
|
||||||
final PageState state = fse.getPageState();
|
final PageState state = fse.getPageState();
|
||||||
GenericPerson person = (GenericPerson) getItemSelectionModel().
|
GenericPerson person = (GenericPerson) getItemSelectionModel().
|
||||||
getSelectedObject(state);
|
getSelectedObject(state);
|
||||||
|
|
||||||
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
|
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
|
||||||
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
|
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
|
||||||
|
|
||||||
contact = (GenericContact) contact.getContentBundle().getInstance(
|
contact = (GenericContact) contact.getContentBundle().getInstance(
|
||||||
person.getLanguage());
|
person.getLanguage());
|
||||||
|
|
||||||
person.addContact(contact,
|
person.addContact(contact,
|
||||||
(String) data.get(
|
(String) data.get(
|
||||||
GenericPersonContactCollection.CONTACTS_KEY));
|
GenericPersonContactCollection.CONTACTS_KEY));
|
||||||
m_itemSearch.publishCreatedItem(data, contact);
|
m_itemSearch.publishCreatedItem(data, contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,14 +174,14 @@ public class GenericPersonContactAddForm extends BasicItemForm {
|
||||||
|
|
||||||
if (data.get(ITEM_SEARCH) == null) {
|
if (data.get(ITEM_SEARCH) == null) {
|
||||||
data.addError(
|
data.addError(
|
||||||
ContenttypesGlobalizationUtil.globalize(
|
ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericperson.select_contact.none_selected"));
|
"cms.contenttypes.ui.genericperson.select_contact.none_selected"));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericPerson person = (GenericPerson) getItemSelectionModel().
|
GenericPerson person = (GenericPerson) getItemSelectionModel().
|
||||||
getSelectedObject(state);
|
getSelectedObject(state);
|
||||||
|
|
||||||
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
|
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
|
||||||
|
|
||||||
|
|
@ -182,21 +189,21 @@ public class GenericPersonContactAddForm extends BasicItemForm {
|
||||||
Kernel.getConfig().
|
Kernel.getConfig().
|
||||||
languageIndependentItems()))) {
|
languageIndependentItems()))) {
|
||||||
data.addError(
|
data.addError(
|
||||||
ContenttypesGlobalizationUtil.globalize(
|
ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericperson.select_contact.no_suitable_language_variant"));
|
"cms.contenttypes.ui.genericperson.select_contact.no_suitable_language_variant"));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
contact = (GenericContact) contact.getContentBundle().getInstance(person.
|
contact = (GenericContact) contact.getContentBundle().getInstance(person.
|
||||||
getLanguage());
|
getLanguage());
|
||||||
GenericPersonContactCollection contacts = person.getContacts();
|
GenericPersonContactCollection contacts = person.getContacts();
|
||||||
|
|
||||||
contacts.addFilter(String.format("id = %s", contact.getID().toString()));
|
contacts.addFilter(String.format("id = %s", contact.getID().toString()));
|
||||||
if (contacts.size() > 0) {
|
if (contacts.size() > 0) {
|
||||||
data.addError(
|
data.addError(
|
||||||
ContenttypesGlobalizationUtil.globalize(
|
ContenttypesGlobalizationUtil.globalize(
|
||||||
"cms.contenttypes.ui.genericperson.select_contact.already_added"));
|
"cms.contenttypes.ui.genericperson.select_contact.already_added"));
|
||||||
}
|
}
|
||||||
|
|
||||||
contacts.close();
|
contacts.close();
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,14 @@ import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.RelationAttribute;
|
import com.arsdigita.cms.RelationAttribute;
|
||||||
import com.arsdigita.cms.RelationAttributeCollection;
|
import com.arsdigita.cms.RelationAttributeCollection;
|
||||||
|
import com.arsdigita.cms.RelationAttributeResourceBundleControl;
|
||||||
import com.arsdigita.cms.contentassets.SciPublicationsPersonsService;
|
import com.arsdigita.cms.contentassets.SciPublicationsPersonsService;
|
||||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
import com.arsdigita.cms.contenttypes.Publication;
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
import com.arsdigita.toolbox.GlobalisationUtil;
|
import com.arsdigita.toolbox.GlobalisationUtil;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import java.util.TooManyListenersException;
|
import java.util.TooManyListenersException;
|
||||||
|
|
@ -72,10 +73,10 @@ public class SciPublicationsPersonsPersonForm extends BasicItemForm {
|
||||||
// add(new Label(globalisationUtil.globalize(
|
// add(new Label(globalisationUtil.globalize(
|
||||||
// "com.arsdigita.cms.contentassets.publicationspersons.select_person")));
|
// "com.arsdigita.cms.contentassets.publicationspersons.select_person")));
|
||||||
itemSearch = new ItemSearchWidget(
|
itemSearch = new ItemSearchWidget(
|
||||||
ITEM_SEARCH,
|
ITEM_SEARCH,
|
||||||
ContentType.findByAssociatedObjectType(GenericPerson.class.getName()));
|
ContentType.findByAssociatedObjectType(GenericPerson.class.getName()));
|
||||||
itemSearch.setLabel(globalisationUtil.globalize(
|
itemSearch.setLabel(globalisationUtil.globalize(
|
||||||
"com.arsdigita.cms.contentassets.publicationspersons.select_person"));
|
"com.arsdigita.cms.contentassets.publicationspersons.select_person"));
|
||||||
itemSearch.setDisableCreatePane(true);
|
itemSearch.setDisableCreatePane(true);
|
||||||
add(itemSearch);
|
add(itemSearch);
|
||||||
|
|
||||||
|
|
@ -93,13 +94,19 @@ public class SciPublicationsPersonsPersonForm extends BasicItemForm {
|
||||||
public void prepare(final PrintEvent event) {
|
public void prepare(final PrintEvent event) {
|
||||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||||
final RelationAttributeCollection relations = new RelationAttributeCollection(
|
final RelationAttributeCollection relations = new RelationAttributeCollection(
|
||||||
SciPublicationsPersonsService.RELATION_ATTRIBUTE);
|
SciPublicationsPersonsService.RELATION_ATTRIBUTE);
|
||||||
relations.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale()
|
// relations.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale()
|
||||||
.getLanguage());
|
// .getLanguage());
|
||||||
while (relations.next()) {
|
while (relations.next()) {
|
||||||
RelationAttribute relation;
|
RelationAttribute relation;
|
||||||
relation = relations.getRelationAttribute();
|
relation = relations.getRelationAttribute();
|
||||||
target.addOption(new Option(relation.getKey(), relation.getName()));
|
//target.addOption(new Option(relation.getKey(), relation.getName()));
|
||||||
|
target.addOption(new Option(
|
||||||
|
relation.getKey(),
|
||||||
|
new Label(new GlobalizedMessage(
|
||||||
|
relation.getKey(),
|
||||||
|
SciPublicationsPersonsService.RELATION_ATTRIBUTE,
|
||||||
|
new RelationAttributeResourceBundleControl()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +116,7 @@ public class SciPublicationsPersonsPersonForm extends BasicItemForm {
|
||||||
throw new UncheckedWrapperException(ex);
|
throw new UncheckedWrapperException(ex);
|
||||||
}
|
}
|
||||||
relationSelect.setLabel(globalisationUtil.globalize(
|
relationSelect.setLabel(globalisationUtil.globalize(
|
||||||
"com.arsdigita.cms.contentassets.publicationspersons.select_person_relation"));
|
"com.arsdigita.cms.contentassets.publicationspersons.select_person_relation"));
|
||||||
add(relationSelect);
|
add(relationSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,12 +149,12 @@ public class SciPublicationsPersonsPersonForm extends BasicItemForm {
|
||||||
final GlobalisationUtil globalisationUtil = new SciPublicationsPersonsGlobalisationUtil();
|
final GlobalisationUtil globalisationUtil = new SciPublicationsPersonsGlobalisationUtil();
|
||||||
if (data.get(ITEM_SEARCH) == null) {
|
if (data.get(ITEM_SEARCH) == null) {
|
||||||
data.addError(globalisationUtil.globalize(
|
data.addError(globalisationUtil.globalize(
|
||||||
"com.arsdigita.cms.contentasset.publications_persons.none_selected"));
|
"com.arsdigita.cms.contentasset.publications_persons.none_selected"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data.get(RELATION) == null) || ((String) data.get(RELATION)).isEmpty()) {
|
if ((data.get(RELATION) == null) || ((String) data.get(RELATION)).isEmpty()) {
|
||||||
data.addError(globalisationUtil.globalize(
|
data.addError(globalisationUtil.globalize(
|
||||||
"com.arsdigita.cms.contentasset.publications_persons.none_relation_selected"));
|
"com.arsdigita.cms.contentasset.publications_persons.none_relation_selected"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,12 @@ import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
|
||||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.RelationAttribute;
|
import com.arsdigita.cms.RelationAttribute;
|
||||||
|
import com.arsdigita.cms.RelationAttributeResourceBundleControl;
|
||||||
import com.arsdigita.cms.contentassets.PublicationTypeAsset;
|
import com.arsdigita.cms.contentassets.PublicationTypeAsset;
|
||||||
import com.arsdigita.cms.contentassets.PublicationTypeValuesCollection;
|
import com.arsdigita.cms.contentassets.PublicationTypeValuesCollection;
|
||||||
import com.arsdigita.cms.contenttypes.Publication;
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
import com.arsdigita.globalization.GlobalizationHelper;
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -51,7 +52,8 @@ public class PublicationTypeAssetAddForm extends BasicItemForm {
|
||||||
private final ItemSelectionModel itemModel;
|
private final ItemSelectionModel itemModel;
|
||||||
private final ACSObjectSelectionModel typeModel;
|
private final ACSObjectSelectionModel typeModel;
|
||||||
|
|
||||||
public PublicationTypeAssetAddForm(final ItemSelectionModel itemModel, final ACSObjectSelectionModel typeModel) {
|
public PublicationTypeAssetAddForm(final ItemSelectionModel itemModel,
|
||||||
|
final ACSObjectSelectionModel typeModel) {
|
||||||
super("PublicationTypeAssetAddForm", itemModel);
|
super("PublicationTypeAssetAddForm", itemModel);
|
||||||
|
|
||||||
this.itemModel = itemModel;
|
this.itemModel = itemModel;
|
||||||
|
|
@ -67,13 +69,19 @@ public class PublicationTypeAssetAddForm extends BasicItemForm {
|
||||||
type.addValidationListener(new NotNullValidationListener());
|
type.addValidationListener(new NotNullValidationListener());
|
||||||
type.addValidationListener(new NotEmptyValidationListener());
|
type.addValidationListener(new NotEmptyValidationListener());
|
||||||
type.addOption(new Option("", new Label(PublicationTypeAssetGlobalizationUtil.globalize(
|
type.addOption(new Option("", new Label(PublicationTypeAssetGlobalizationUtil.globalize(
|
||||||
"scipublications.publication_type_asset.form.type.select_one"))));
|
"scipublications.publication_type_asset.form.type.select_one"))));
|
||||||
final PublicationTypeValuesCollection values = new PublicationTypeValuesCollection();
|
final PublicationTypeValuesCollection values = new PublicationTypeValuesCollection();
|
||||||
values.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().getLanguage());
|
//values.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().getLanguage());
|
||||||
|
|
||||||
while (values.next()) {
|
while (values.next()) {
|
||||||
final RelationAttribute value = values.getRelationAttribute();
|
final RelationAttribute value = values.getRelationAttribute();
|
||||||
type.addOption(new Option(value.getKey(), value.getName()));
|
//type.addOption(new Option(value.getKey(), value.getName()));
|
||||||
|
type.addOption(new Option(
|
||||||
|
value.getKey(),
|
||||||
|
new Label(new GlobalizedMessage(
|
||||||
|
value.getKey(),
|
||||||
|
PublicationTypeValuesCollection.ATTRIBUTE_NAME,
|
||||||
|
new RelationAttributeResourceBundleControl()))));
|
||||||
}
|
}
|
||||||
type.setLabel(PublicationTypeAssetGlobalizationUtil.
|
type.setLabel(PublicationTypeAssetGlobalizationUtil.
|
||||||
globalize("scipublications.publication_type_asset.form.type"));
|
globalize("scipublications.publication_type_asset.form.type"));
|
||||||
|
|
@ -101,7 +109,8 @@ public class PublicationTypeAssetAddForm extends BasicItemForm {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
if (typeModel.getSelectedObject(state) != null) {
|
if (typeModel.getSelectedObject(state) != null) {
|
||||||
final PublicationTypeAsset typeAsset = (PublicationTypeAsset) typeModel.getSelectedObject(state);
|
final PublicationTypeAsset typeAsset = (PublicationTypeAsset) typeModel.
|
||||||
|
getSelectedObject(state);
|
||||||
final FormData data = event.getFormData();
|
final FormData data = event.getFormData();
|
||||||
|
|
||||||
data.put(PUB_TYPE, typeAsset.getPublicationType());
|
data.put(PUB_TYPE, typeAsset.getPublicationType());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue