- Added new style labels to the forms of the generic contenttypes in ccm-cms

- Added PrintListeners to various select fields ins these forms. For the database driven fields this means that a restart is not 
  longer required to see new values (for example for contact types)


git-svn-id: https://svn.libreccm.org/ccm/trunk@2716 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-06-24 08:44:08 +00:00
parent 4b7ff4f902
commit 06bfe7c709
21 changed files with 1039 additions and 893 deletions

View File

@ -44,20 +44,20 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
/**
* Form to edit the basic properties of a Content Group. This form can be
* extended to create forms for Brand subclasses.
* Form to edit the basic properties of a Content Group. This form can be extended to create forms
* for Brand subclasses.
*/
public class ContentGroupPropertyForm extends BasicItemForm {
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
* and set com.arsdigita.cms.contenttypes.ui.ContentGroupPropertyForm=DEBUG
* by uncommenting or adding the line. */
private final static org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(ContentGroupPropertyForm.class);
/**
* Internal logger instance to faciliate debugging. Enable logging output by editing
* /WEB-INF/conf/log4j.properties int hte runtime environment and set
* com.arsdigita.cms.contenttypes.ui.ContentGroupPropertyForm=DEBUG by uncommenting or adding
* the line.
*/
private final static org.apache.log4j.Logger s_log = org.apache.log4j.Logger.getLogger(
ContentGroupPropertyForm.class);
public final static String ASSOCIATED_ITEMS = "associatedItems";
public final static String RELATED_ITEM = "relatedItem";
@ -66,12 +66,12 @@ public class ContentGroupPropertyForm extends BasicItemForm {
private CheckboxGroup m_checkboxGroup;
/**
* Creates a new form to edit the Brand object specified
* by the item selection model passed in.
* @param itemModel The ItemSelectionModel to use to obtain the
* ContentGroupContainer to work on
* @param attributeName The name of the content group to use during
* the process stage of this form.
* Creates a new form to edit the Brand object specified by the item selection model passed in.
*
* @param itemModel The ItemSelectionModel to use to obtain the ContentGroupContainer to
* work on
* @param attributeName The name of the content group to use during the process stage of this
* form.
*/
public ContentGroupPropertyForm(ItemSelectionModel itemModel,
String attributeName) {
@ -84,35 +84,34 @@ public class ContentGroupPropertyForm extends BasicItemForm {
*/
@Override
protected void addWidgets() {
add(new Label(GlobalizationUtil
.globalize("cms.contenttypes.ui.content_group_name")));
TextField nameWidget =
new TextField(new TrimmedStringParameter(ContentGroup.NAME));
TextField nameWidget = new TextField(new TrimmedStringParameter(ContentGroup.NAME));
nameWidget.setLabel(GlobalizationUtil
.globalize("cms.contenttypes.ui.content_group_name"));
nameWidget.addValidationListener(new NotNullValidationListener());
add(nameWidget);
add(new Label(GlobalizationUtil
.globalize("cms.contenttypes.ui.content_group_current_items")) {
@Override
public boolean isVisible(PageState state) {
ContentGroupContainer item =
(ContentGroupContainer) getItemSelectionModel()
ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel()
.getSelectedObject(state);
ContentGroup group =
getCurrentGroup(item, m_attributeName);
ContentGroup group = getCurrentGroup(item, m_attributeName);
return group != null && group.getContentItems().size() > 0;
}
});
m_checkboxGroup = new CheckboxGroup(ASSOCIATED_ITEMS) {
@Override
public boolean isVisible(PageState state) {
ContentGroupContainer item =
(ContentGroupContainer) getItemSelectionModel()
ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel()
.getSelectedObject(state);
ContentGroup group =
getCurrentGroup(item, m_attributeName);
ContentGroup group = getCurrentGroup(item, m_attributeName);
return group != null && group.getContentItems().size() > 0;
}
};
add(m_checkboxGroup);
@ -125,11 +124,9 @@ public class ContentGroupPropertyForm extends BasicItemForm {
}
}
/**
* Perform form initialization. Children should override this
* this method to pre-fill the widgets with data, instantiate
* the content item, etc.
* Perform form initialization. Children should override this this method to pre-fill the
* widgets with data, instantiate the content item, etc.
*
* @throws com.arsdigita.bebop.FormProcessException
*/
@ -138,8 +135,8 @@ public class ContentGroupPropertyForm extends BasicItemForm {
s_log.debug("here in init");
FormData data = e.getFormData();
PageState state = e.getPageState();
ContentGroupContainer item =
(ContentGroupContainer) getItemSelectionModel().getSelectedObject(state);
ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel()
.getSelectedObject(state);
ContentGroup group = getCurrentGroup(item, m_attributeName);
if (group != null) {
data.put(ContentGroup.NAME, group.getName());
@ -149,11 +146,9 @@ public class ContentGroupPropertyForm extends BasicItemForm {
ItemCollection collection = group.getContentItems();
Collection selected = new ArrayList();
while (collection.next()) {
s_log.debug("NAME = " +
collection.getContentItem().getName());
s_log.debug("NAME = " + collection.getContentItem().getName());
s_log.debug("ID = " + collection.getID());
m_checkboxGroup.addOption
(new Option(collection.getID().toString(),
m_checkboxGroup.addOption(new Option(collection.getID().toString(),
collection.getContentItem().getName()), state);
selected.add(collection.getID().toString());
}
@ -161,18 +156,16 @@ public class ContentGroupPropertyForm extends BasicItemForm {
}
}
/**
* Process the form. Children should override this method to save
* the user's changes to the database.
* Process the form. Children should override this method to save the user's changes to the
* database.
*
* @throws com.arsdigita.bebop.FormProcessException
*/
@Override
public void process(FormSectionEvent e) throws FormProcessException {
s_log.debug("here in process");
ContentGroupContainer item =
(ContentGroupContainer) getItemSelectionModel()
ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel()
.getSelectedObject(e.getPageState());
FormData data = e.getFormData();
@ -201,8 +194,7 @@ public class ContentGroupPropertyForm extends BasicItemForm {
s_log.debug("XXXX adding " + id);
s_log.debug("XXXX isDeleted? " + collection.getContentItem().isDeleted());
}
String[] values =
(String[])m_checkboxGroup.getValue(e.getPageState());
String[] values = (String[]) m_checkboxGroup.getValue(e.getPageState());
if (values != null) {
for (String value : values) {
ids.remove(value);
@ -213,8 +205,7 @@ public class ContentGroupPropertyForm extends BasicItemForm {
Iterator iterator = ids.iterator();
while (iterator.hasNext()) {
s_log.debug("Removing item");
group.removeContentItem
((ContentItem)itemMap.get((String)iterator.next()));
group.removeContentItem((ContentItem) itemMap.get((String) iterator.next()));
}
ContentItem newItem = (ContentItem) data.get(RELATED_ITEM);
@ -227,7 +218,6 @@ public class ContentGroupPropertyForm extends BasicItemForm {
}
}
/**
* This returns the correct group for the attribute name
*/
@ -235,7 +225,6 @@ public class ContentGroupPropertyForm extends BasicItemForm {
return item.getContentGroup(attributeName);
}
/**
* This sets the group for the given attribute name
*/
@ -245,13 +234,13 @@ public class ContentGroupPropertyForm extends BasicItemForm {
}
/**
* The name of the Content Type to restrict the ItemSearchWidget to.
* To allow the user to search for any content type, this should
* return null.
* The name of the Content Type to restrict the ItemSearchWidget to. To allow the user to search
* for any content type, this should return null.
*
* @return
*/
protected String getSearchContentType() {
return null;
}
}

View File

@ -27,6 +27,8 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.ParameterEvent;
import com.arsdigita.bebop.event.ParameterListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextArea;
@ -41,8 +43,11 @@ import com.arsdigita.cms.contenttypes.GenericAddress;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.Iterator;
import java.util.Map;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger;
/**
@ -81,53 +86,67 @@ public class GenericAddressPropertyForm extends BasicPageForm
protected void addWidgets() {
super.addWidgets();
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.address")));
ParameterModel addressParam = new StringParameter(ADDRESS);
addressParam.addParameterListener(new NotNullValidationListener());
addressParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextArea address = new TextArea(addressParam);
address.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.address"));
address.setRows(5);
address.setCols(30);
add(address);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.postal_code")));
add(new Label());
ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE);
TextField postalCode = new TextField(postalCodeParam);
postalCode.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.postal_code"));
add(postalCode);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.city")));
ParameterModel cityParam = new StringParameter(CITY);
TextField city = new TextField(cityParam);
city.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.city"));
add(city);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.state")));
ParameterModel stateParam = new StringParameter(STATE);
TextField state = new TextField(stateParam);
state.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.state"));
add(state);
if (!GenericAddress.getConfig().getHideCountryCodeSelection()) {
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.iso_country_code")));
ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE);
countryParam.addParameterListener(new StringInRangeValidationListener(0, 2));
SingleSelect country = new SingleSelect(countryParam);
country.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.iso_country_code"));
country.addOption(new Option("",
new Label(GlobalizationUtil
.globalize("cms.ui.select_one"))));
Iterator countries = GenericAddress.getSortedListOfCountries(null)
try {
country.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
final Iterator countries = GenericAddress.getSortedListOfCountries(null)
.entrySet().iterator();
while (countries.hasNext()) {
Map.Entry<String, String> elem =
(Map.Entry<String, String>) countries.next();
country.addOption(new Option(elem.getValue().toString(),
Map.Entry<String, String> elem = (Map.Entry<String, String>) countries
.next();
target.addOption(new Option(elem.getValue().toString(),
elem.getKey().toString()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
}
country.addValidationListener(new ParameterListener() {
@ -142,6 +161,7 @@ public class GenericAddressPropertyForm extends BasicPageForm
.localize());
}
}
});
add(country);
@ -201,4 +221,5 @@ public class GenericAddressPropertyForm extends BasicPageForm
m_step.maybeForwardToNextStep(fse.getPageState());
}
}
}

View File

@ -31,6 +31,8 @@ import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger;
/**
@ -46,8 +48,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
private ItemSearchWidget m_itemSearch;
private SaveCancelSection m_saveCancelSection;
private final String ITEM_SEARCH = "contactPerson";
private final String CONTACTS_KEY =
GenericPersonContactCollection.CONTACTS_KEY;
private final String CONTACTS_KEY = GenericPersonContactCollection.CONTACTS_KEY;
/**
* ID of the form
*/
@ -63,8 +64,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
}
/**
* Constructor taking an ItemSelectionModel and an instance of
* ContactPropertiesStep.
* Constructor taking an ItemSelectionModel and an instance of ContactPropertiesStep.
*
* @param itemModel
* @param step
@ -93,26 +93,38 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
add(this.m_itemSearch);
// GenericContact type field
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.contact.type")));
ParameterModel contactTypeParam = new StringParameter(CONTACTS_KEY);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.contact.type"));
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("",
new Label(GlobalizationUtil
.globalize("cms.ui.select_one"))));
try {
contactType.addPrintListener(new PrintListener() {
// Add the Options to the SingleSelect widget
GenericContactTypeCollection contacttypes =
new GenericContactTypeCollection();
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
final GenericContactTypeCollection contacttypes
= new GenericContactTypeCollection();
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
while (contacttypes.next()) {
RelationAttribute ct = contacttypes.getRelationAttribute();
contactType.addOption(new Option(ct.getKey(), ct.getName()));
target.addOption(new Option(ct.getKey(), ct.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
}
// Add the Options to the SingleSelect widget
add(contactType);
}
@ -156,8 +168,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
GenericContact contact =
(GenericContact) getItemSelectionModel().
GenericContact contact = (GenericContact) getItemSelectionModel().
getSelectedObject(e.getPageState());
Submit target = (Submit) e.getTarget();
@ -171,6 +182,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
"cms.contenttypes.ui.contact.select_person.add"));
}
}
});
} catch (Exception ex) {
throw new UncheckedWrapperException("this cannot happen", ex);
@ -214,4 +226,5 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
localize());
}
}
}

View File

@ -28,6 +28,8 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.ParameterEvent;
import com.arsdigita.bebop.event.ParameterListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextArea;
@ -44,6 +46,9 @@ import java.util.Map;
import com.arsdigita.cms.contenttypes.GenericAddress;
import com.arsdigita.cms.contenttypes.GenericContact;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger;
@ -67,7 +72,9 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
private GenericContactAddressPropertiesStep m_step;
/** ID of the form */
/**
* ID of the form
*/
public static final String ID = "ContactEditAddress";
/**
@ -94,61 +101,72 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
@Override
public void addWidgets() {
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.address")));
ParameterModel addressParam = new StringParameter(ADDRESS);
addressParam.addParameterListener(new NotNullValidationListener());
addressParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextArea address = new TextArea(addressParam);
address.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.address"));
address.setRows(5);
address.setCols(30);
add(address);
if (!GenericContact.getConfig().getHideAddressPostalCode()) {
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.postal_code")));
ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE);
TextField postalCode = new TextField(postalCodeParam);
postalCode.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.postal_code"));
/* XXX NumberListener ?*/
add(postalCode);
}
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.city")));
ParameterModel cityParam = new StringParameter(CITY);
TextField city = new TextField(cityParam);
city.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.city"));
add(city);
if (!GenericContact.getConfig().getHideAddressState()) {
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.state")));
ParameterModel stateParam = new StringParameter(STATE);
TextField state = new TextField(stateParam);
state.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.state"));
add(state);
}
if (!GenericContact.getConfig().getHideAddressCountry()) {
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.address.iso_country_code")));
ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE);
countryParam.addParameterListener(new
StringInRangeValidationListener(0, 2));
countryParam.addParameterListener(new StringInRangeValidationListener(0, 2));
SingleSelect country = new SingleSelect(countryParam);
country.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.address.iso_country_code"));
country.addOption(new
Option("",
country.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil
.globalize("cms.ui.select_one"))));
Iterator countries = GenericAddress.getSortedListOfCountries(null)
try {
country.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
final Iterator countries = GenericAddress.getSortedListOfCountries(null)
.entrySet().iterator();
while (countries.hasNext()) {
Map.Entry<String, String> elem = (Map.Entry<String, String>)
countries.next();
country.addOption(new Option(elem.getValue().toString(),
Map.Entry<String, String> elem = (Map.Entry<String, String>) countries
.next();
target.addOption(new Option(elem.getValue().toString(),
elem.getKey().toString()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
}
country.addValidationListener(
new ParameterListener() {
@ -164,6 +182,7 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
.localize());
}
}
});
add(country);
@ -216,4 +235,5 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
m_step.maybeForwardToNextStep(fse.getPageState());
}
}
}

View File

@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData;
@ -26,6 +25,8 @@ import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextField;
@ -44,6 +45,9 @@ import com.arsdigita.cms.contenttypes.GenericPersonContactCollection;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger;
@ -80,8 +84,7 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
}
/**
* Constructor taking an ItemSelectionModel and an instance of
* ContactPropertiesStep.
* Constructor taking an ItemSelectionModel and an instance of ContactPropertiesStep.
*
* @param itemModel
* @param step
@ -98,56 +101,68 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
*/
@Override
public void addWidgets() {
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.surname")));
ParameterModel surnameParam = new StringParameter(SURNAME);
surnameParam.addParameterListener(new NotNullValidationListener());
surnameParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField surname = new TextField(surnameParam);
surname.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.surname"));
add(surname);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.givenname")));
ParameterModel givennameParam = new StringParameter(GIVENNAME);
givennameParam.addParameterListener(new NotNullValidationListener());
givennameParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField givenname = new TextField(givennameParam);
givenname.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.givenname"));
add(givenname);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.titlepre")));
ParameterModel titlepreParam = new StringParameter(TITLEPRE);
titlepreParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField titlepre = new TextField(titlepreParam);
titlepre.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.titlepre"));
add(titlepre);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.titlepost")));
ParameterModel titlepostParam = new StringParameter(TITLEPOST);
titlepostParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField titlepost = new TextField(titlepostParam);
titlepost.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.titlepost"));
add(titlepost);
// GenericContact type field
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.contact.type")));
ParameterModel contactTypeParam = new StringParameter(CONTACTS_KEY);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.contact.type"));
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new
Option("",
contactType.addOption(new Option("",
new Label(GlobalizationUtil
.globalize("cms.ui.select_one"))));
try {
contactType.addPrintListener(new PrintListener() {
// Add the Options to the SingleSelect widget
GenericContactTypeCollection contacttypes = new GenericContactTypeCollection();
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
final GenericContactTypeCollection contacttypes
= new GenericContactTypeCollection();
contacttypes.addLanguageFilter(GlobalizationHelper
.getNegotiatedLocale().getLanguage());
while (contacttypes.next()) {
RelationAttribute ct = contacttypes.getRelationAttribute();
contactType.addOption(new Option(ct.getKey(), ct.getName()));
target.addOption(new Option(ct.getKey(), ct.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
}
// Add the Options to the SingleSelect widget
add(contactType);
}
@ -187,7 +202,6 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
// contact.getPerson().setName("Person for " + contact.getName() + "(" + contact.getID() + ")");
// contact.getPerson().setTitle("Person for " + contact.getName() + "(" + contact.getID() + ")");
// }
contact.getPerson().setSurname((String) data.get(SURNAME));
contact.getPerson().setGivenName((String) data.get(GIVENNAME));
contact.getPerson().setTitlePre((String) data.get(TITLEPRE));
@ -201,4 +215,5 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
m_step.maybeForwardToNextStep(fse.getPageState());
}
}
}

View File

@ -21,6 +21,8 @@ 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.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.form.TextField;
@ -36,6 +38,9 @@ import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger;
@ -43,11 +48,14 @@ import org.apache.log4j.Logger;
* @author Sören Bernstein <quasi@quasiweb.de>
*/
public class GenericContactEntryAddForm extends BasicItemForm {
private static final Logger s_log = Logger.getLogger(GenericContactEntryAddForm.class);
private ItemSelectionModel m_itemModel;
/** Creates a new instance of CategoryLocalizationAddForm */
/**
* Creates a new instance of CategoryLocalizationAddForm
*/
public GenericContactEntryAddForm(ItemSelectionModel itemModel) {
super("ContactEntryAddForm", itemModel);
@ -59,48 +67,58 @@ public class GenericContactEntryAddForm extends BasicItemForm {
protected void addWidgets() {
// Key field
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.contactEntry.key")));
ParameterModel contactEntryKeyParam = new
StringParameter(GenericContactEntry.KEY);
ParameterModel contactEntryKeyParam = new StringParameter(GenericContactEntry.KEY);
SingleSelect contactEntryKey = new SingleSelect(contactEntryKeyParam);
contactEntryKey.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.contactEntry.key"));
contactEntryKey.addValidationListener(new NotNullValidationListener());
contactEntryKey.addOption(new
Option("", new Label(GlobalizationUtil.globalize(
contactEntryKey.addOption(new Option("", new Label(GlobalizationUtil.globalize(
"cms.ui.select_one"))));
try {
contactEntryKey.addPrintListener(new PrintListener() {
// Add the Options to the SingleSelect widget
GenericContactEntryKeys keyList = new GenericContactEntryKeys();
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
final GenericContactEntryKeys keyList = new GenericContactEntryKeys();
keyList.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale()
.getLanguage());
while (keyList.next()) {
String currentKey = keyList.getKey();
contactEntryKey.addOption(new Option(currentKey, keyList.getName()));
target.addOption(new Option(currentKey, keyList.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
}
// Add the Options to the SingleSelect widget
add(contactEntryKey);
// Value field
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.contactEntry.value")));
ParameterModel contactEntryValueParam = new
StringParameter(GenericContactEntry.VALUE);
ParameterModel contactEntryValueParam = new StringParameter(GenericContactEntry.VALUE);
TextField contactEntryValue = new TextField(contactEntryValueParam);
contactEntryValue.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.contactEntry.value"));
contactEntryValue.addValidationListener(new NotNullValidationListener());
add(contactEntryValue);
// Description field, only for internal usage
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.contactEntry.description")));
ParameterModel contactEntryDescriptionParam = new
StringParameter(GenericContactEntry.DESCRIPTION);
ParameterModel contactEntryDescriptionParam = new StringParameter(
GenericContactEntry.DESCRIPTION);
TextField contactEntryDescription = new TextField(contactEntryDescriptionParam);
contactEntryDescription.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.contactEntry.description"));
add(contactEntryDescription);
}
/**
* Does nothing here.
*
* @param fse
*/
public void init(FormSectionEvent fse) {
@ -113,8 +131,7 @@ public class GenericContactEntryAddForm extends BasicItemForm {
*/
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
GenericContact contact = (GenericContact)
m_itemModel.getSelectedObject(fse.getPageState());
GenericContact contact = (GenericContact) m_itemModel.getSelectedObject(fse.getPageState());
// save only if save button was pressed
if (contact != null
@ -130,4 +147,5 @@ public class GenericContactEntryAddForm extends BasicItemForm {
contact.addContactEntry(contactEntry);
}
}
}

View File

@ -84,16 +84,6 @@ public class GenericContactPropertyForm extends BasicPageForm
@Override
public void addWidgets() {
super.addWidgets();
/*
add(new Label(BaseContactGlobalizationUtil.globalize(
"cms.contenttypes.ui.contact.basic_properties.description")
)));
TextArea description = new TextArea(DESCRIPTION);
description.setRows(5);
description.setCols(30);
add(description);
*/
}
@Override

View File

@ -74,29 +74,29 @@ public class GenericContactTypeAddForm extends BasicItemForm {
@Override
protected void addWidgets() {
// Key
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.key")));
ParameterModel keyParam = new StringParameter(KEY);
keyParam.addParameterListener(new NotNullValidationListener());
keyParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField key = new TextField(keyParam);
key.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.key"));
add(key);
// Language
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.language")));
ParameterModel languageParam = new StringParameter(LANGUAGE);
language = new SingleSelect(languageParam);
language.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.language"));
language.addValidationListener(new NotNullValidationListener());
language.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize())));
// Name
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.name")));
ParameterModel nameParam = new StringParameter(NAME);
nameParam.addParameterListener(new NotNullValidationListener());
nameParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField name = new TextField(nameParam);
name.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.name"));
add(name);

View File

@ -25,6 +25,8 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SaveCancelSection;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
@ -43,6 +45,9 @@ import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import org.apache.log4j.Logger;
/**
@ -77,33 +82,45 @@ public class GenericOrganizationalUnitContactAddForm
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_contact")));
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType(GenericContact.class.getName()));
findByAssociatedObjectType(GenericContact.class
.getName()));
m_itemSearch.setDisableCreatePane(false);
add(m_itemSearch);
selectedContactLabel = new Label("");
add(selectedContactLabel);
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.contact.type")));
ParameterModel contactTypeParam = new StringParameter(
GenericOrganizationalUnitContactCollection.CONTACT_TYPE);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.contact.type"));
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one"))));
try {
contactType.addPrintListener(new PrintListener() {
GenericOrganizationContactTypeCollection contacttypes =
new GenericOrganizationContactTypeCollection();
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
final GenericOrganizationContactTypeCollection contacttypes
= new GenericOrganizationContactTypeCollection();
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
while (contacttypes.next()) {
RelationAttribute ct = contacttypes.getRelationAttribute();
contactType.addOption(new Option(ct.getKey(), ct.getName()));
target.addOption(new Option(ct.getKey(), ct.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
}
add(contactType);
}
@ -134,8 +151,7 @@ public class GenericOrganizationalUnitContactAddForm
public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
GenericOrganizationalUnit orgaunit =
(GenericOrganizationalUnit) getItemSelectionModel().
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel().
getSelectedObject(state);
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
@ -204,9 +220,8 @@ public class GenericOrganizationalUnitContactAddForm
}
if (editStep.getSelectedContact() == null) {
GenericOrganizationalUnit orgaunit =
(GenericOrganizationalUnit) getItemSelectionModel().
getSelectedObject(state);
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel()
.getSelectedObject(state);
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
@ -224,7 +239,6 @@ public class GenericOrganizationalUnitContactAddForm
}
}
if (orgaunit.getLanguage().equals(
GlobalizationHelper.LANG_INDEPENDENT)) {
contact = (GenericContact) contact.getContentBundle().
@ -247,4 +261,5 @@ public class GenericOrganizationalUnitContactAddForm
contacts.close();
}
}
}

View File

@ -26,6 +26,8 @@ import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
@ -43,6 +45,8 @@ import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
import org.apache.log4j.Logger;
/**
@ -86,47 +90,69 @@ public class GenericOrganizationalUnitPersonAddForm
selectedPersonNameLabel = new Label("");
add(selectedPersonNameLabel);
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.role")));
ParameterModel roleParam =
new StringParameter(
ParameterModel roleParam = new StringParameter(
GenericOrganizationalUnitPersonCollection.PERSON_ROLE);
SingleSelect roleSelect = new SingleSelect(roleParam);
roleSelect.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.role"));
roleSelect.addValidationListener(new NotNullValidationListener());
roleSelect.addOption(
new Option("",
new Label(ContenttypesGlobalizationUtil
.globalize("cms.ui.select_one"))));
RelationAttributeCollection roles = new RelationAttributeCollection(
try {
roleSelect.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
final RelationAttributeCollection roles = new RelationAttributeCollection(
getRoleAttributeName());
roles.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
while (roles.next()) {
RelationAttribute role;
role = roles.getRelationAttribute();
roleSelect.addOption(new Option(role.getKey(), role.getName()));
target.addOption(new Option(role.getKey(), role.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong...", ex);
}
add(roleSelect);
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.status")));
ParameterModel statusModel =
new StringParameter(
final ParameterModel statusModel = new StringParameter(
GenericOrganizationalUnitPersonCollection.STATUS);
SingleSelect statusSelect = new SingleSelect(statusModel);
final SingleSelect statusSelect = new SingleSelect(statusModel);
statusSelect.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.status"));
statusSelect.addValidationListener(new NotNullValidationListener());
statusSelect.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one"))));
RelationAttributeCollection statusColl =
new RelationAttributeCollection(
try {
statusSelect.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
RelationAttributeCollection statusColl = new RelationAttributeCollection(
getStatusAttributeName());
statusColl.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
while (statusColl.next()) {
RelationAttribute status;
status = statusColl.getRelationAttribute();
statusSelect.addOption(new Option(status.getKey(), status.getName()));
target.addOption(new Option(status.getKey(), status.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Somethin has gone terribly wrong", ex);
}
add(statusSelect);
@ -167,8 +193,7 @@ public class GenericOrganizationalUnitPersonAddForm
public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
GenericOrganizationalUnit orga =
(GenericOrganizationalUnit) getItemSelectionModel().
GenericOrganizationalUnit orga = (GenericOrganizationalUnit) getItemSelectionModel().
getSelectedObject(state);
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
@ -177,8 +202,7 @@ public class GenericOrganizationalUnitPersonAddForm
person = selector.getSelectedPerson();
if (person == null) {
GenericPerson personToAdd =
(GenericPerson) data.get(ITEM_SEARCH);
GenericPerson personToAdd = (GenericPerson) data.get(ITEM_SEARCH);
logger.debug(String.format("Adding person %s",
personToAdd.getFullName()));
@ -240,8 +264,7 @@ public class GenericOrganizationalUnitPersonAddForm
}
if (selector.getSelectedPerson() == null) {
GenericOrganizationalUnit orga =
(GenericOrganizationalUnit) getItemSelectionModel().
GenericOrganizationalUnit orga = (GenericOrganizationalUnit) getItemSelectionModel().
getSelectedObject(state);
GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH);
@ -255,10 +278,8 @@ public class GenericOrganizationalUnitPersonAddForm
return;
}*/
final ContentBundle bundle = person.getContentBundle();
final GenericOrganizationalUnitPersonCollection persons =
orga.getPersons();
final GenericOrganizationalUnitPersonCollection persons = orga.getPersons();
persons.addFilter(String.format("id = %s",
bundle.getID().toString()));
@ -290,4 +311,5 @@ public class GenericOrganizationalUnitPersonAddForm
protected String getStatusAttributeName() {
return "GenericOrganizationalUnitMemberStatus";
}
}

View File

@ -68,18 +68,10 @@ public class GenericOrganizationalUnitPropertyForm
protected void addWidgets() {
super.addWidgets();
/*add(new Label(
(String) ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorganunit.name").localize()));
ParameterModel nameParam = new StringParameter(NAME);
TextField name = new TextField(nameParam);
add(name);*/
add(new Label(
ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.addendum")));
ParameterModel addendumParam = new StringParameter(ADDENDUM);
TextField addendum = new TextField(addendumParam);
addendum.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.addendum"));
add(addendum);
}
@ -96,8 +88,7 @@ public class GenericOrganizationalUnitPropertyForm
@Override
public void init(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
GenericOrganizationalUnit orgaunit =
(GenericOrganizationalUnit) super.
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) super.
initBasicWidgets(fse);
//data.put(NAME, orgaunit.getName());
@ -108,8 +99,7 @@ public class GenericOrganizationalUnitPropertyForm
public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
GenericOrganizationalUnit orgaunit =
(GenericOrganizationalUnit) super.
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) super.
processBasicWidgets(fse);
if ((orgaunit != null)
@ -121,4 +111,5 @@ public class GenericOrganizationalUnitPropertyForm
orgaunit.save();
}
}
}

View File

@ -24,6 +24,8 @@ import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SaveCancelSection;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
@ -44,13 +46,15 @@ import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.TooManyListenersException;
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.
* 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 <quasi@quasiweb.de>
*/
@ -64,7 +68,9 @@ public class GenericPersonContactAddForm extends BasicItemForm {
private final String ITEM_SEARCH = "personAddress";
private ItemSelectionModel m_itemModel;
/** Creates a new instance of CategoryLocalizationAddForm */
/**
* Creates a new instance of CategoryLocalizationAddForm
*/
public GenericPersonContactAddForm(ItemSelectionModel itemModel) {
super("ContactEntryAddForm", itemModel);
@ -87,26 +93,37 @@ public class GenericPersonContactAddForm extends BasicItemForm {
add(this.m_itemSearch);
// GenericContact type field
add(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.contact.type")));
ParameterModel contactTypeParam =
new StringParameter(
ParameterModel contactTypeParam = new StringParameter(
GenericPersonContactCollection.CONTACTS_KEY);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.contact.type"));
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("",
new Label(GlobalizationUtil.
globalize("cms.ui.select_one"))));
try {
contactType.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget();
// Add the Options to the SingleSelect widget
GenericContactTypeCollection contacttypes =
new GenericContactTypeCollection();
final GenericContactTypeCollection contacttypes
= new GenericContactTypeCollection();
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
while (contacttypes.next()) {
RelationAttribute ct = contacttypes.getRelationAttribute();
contactType.addOption(new Option(ct.getKey(), ct.getName()));
target.addOption(new Option(ct.getKey(), ct.getName()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
}
add(contactType);
@ -184,4 +201,5 @@ public class GenericPersonContactAddForm extends BasicItemForm {
contacts.close();
}
}

View File

@ -64,18 +64,22 @@ public class GenericPersonCreate extends PageCreate {
add(m_workflowSection, ColumnPanel.INSERT);
add(new Label(GlobalizationUtil.globalize("cms.ui.authoring.content_type")));
add(new Label(type.getLabel()));
add(new Label(GlobalizationUtil.globalize("cms.ui.language.field")));
add(new LanguageWidget(LANGUAGE));
//add(new Label(GlobalizationUtil.globalize("cms.ui.language.field")));
//add(new LanguageWidget(LANGUAGE));
final LanguageWidget languageWidget = new LanguageWidget(LANGUAGE);
languageWidget.setLabel(GlobalizationUtil.globalize("cms.ui.language.field"));
add(languageWidget);
// Set all mandatory field widgets which will be used to generat the title and name
GenericPersonPropertyForm.mandatoryFieldWidgets(this);
if (!ContentSection.getConfig().getHideLaunchDate()) {
add(new Label(GlobalizationUtil.globalize(
"cms.ui.authoring.page_launch_date")));
//add(new Label(GlobalizationUtil.globalize(
// "cms.ui.authoring.page_launch_date")));
ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE);
com.arsdigita.bebop.form.Date launchDate = new com.arsdigita.bebop.form.Date(
launchDateParam);
launchDate.setLabel(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"));
if (ContentSection.getConfig().getRequireLaunchDate()) {
launchDate.addValidationListener(
new LaunchDateValidationListener());
@ -88,8 +92,9 @@ public class GenericPersonCreate extends PageCreate {
/**
* Ensure name uniqueness. Note: We can't call {@code super.validate(FormSectionEvent)} here
* because the super method {@link BasicPageForm#validate(com.arsdigita.bebop.event.FormSectionEvent)} tries
* to access things which on existing yet.
* because the super method
* {@link BasicPageForm#validate(com.arsdigita.bebop.event.FormSectionEvent)} tries to access
* things which on existing yet.
*/
@Override
public void validate(FormSectionEvent e) throws FormProcessException {
@ -142,4 +147,5 @@ public class GenericPersonCreate extends PageCreate {
return String.format("%s %s", surname, givenName);
}
}

View File

@ -53,8 +53,7 @@ public class GenericPersonPropertyForm extends BasicPageForm
FormInitListener,
FormSubmissionListener {
private static final Logger s_log =
Logger.getLogger(GenericPersonPropertyForm.class);
private static final Logger s_log = Logger.getLogger(GenericPersonPropertyForm.class);
private GenericPersonPropertiesStep m_step;
public static final String PERSON = GenericPerson.PERSON;
public static final String SURNAME = GenericPerson.SURNAME;
@ -71,17 +70,18 @@ public class GenericPersonPropertyForm extends BasicPageForm
*
* @param itemModel
*/
public GenericPersonPropertyForm(ItemSelectionModel itemModel) {
public GenericPersonPropertyForm(final ItemSelectionModel itemModel) {
this(itemModel, null);
}
/**
* Constructor, creates an empty form.
*
* @param itemModel
* @param step
*/
public GenericPersonPropertyForm(ItemSelectionModel itemModel,
GenericPersonPropertiesStep step) {
public GenericPersonPropertyForm(final ItemSelectionModel itemModel,
final GenericPersonPropertiesStep step) {
super(ID, itemModel);
m_step = step;
addSubmissionListener(this);
@ -98,19 +98,18 @@ public class GenericPersonPropertyForm extends BasicPageForm
// Add mandatory widgets title/Surname/giben name/name appendix
mandatoryFieldWidgets(this);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.birthdate")));
ParameterModel birthdateParam = new DateParameter(BIRTHDATE);
com.arsdigita.bebop.form.Date birthdate = new
com.arsdigita.bebop.form.Date(birthdateParam);
Calendar today = new GregorianCalendar();
final ParameterModel birthdateParam = new DateParameter(BIRTHDATE);
final com.arsdigita.bebop.form.Date birthdate = new com.arsdigita.bebop.form.Date(birthdateParam);
birthdate.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.birthdate"));
final Calendar today = new GregorianCalendar();
birthdate.setYearRange(1900, today.get(Calendar.YEAR));
add(birthdate);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.gender")));
ParameterModel genderParam = new StringParameter(GENDER);
SingleSelect gender = new SingleSelect(genderParam);
final ParameterModel genderParam = new StringParameter(GENDER);
final SingleSelect gender = new SingleSelect(genderParam);
gender.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.gender"));
gender.addOption(new Option(
"",
new Label(GlobalizationUtil.globalize("cms.ui.select_one"))));
@ -124,46 +123,47 @@ public class GenericPersonPropertyForm extends BasicPageForm
"cms.contenttypes.ui.genericperson.gender.m"))));
add(gender);
add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.description")));
ParameterModel descriptionParam = new StringParameter(DESCRIPTION);
TextArea description = new TextArea(descriptionParam);
final ParameterModel descriptionParam = new StringParameter(DESCRIPTION);
final TextArea description = new TextArea(descriptionParam);
description.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.description"));
description.setCols(50);
description.setRows(5);
add(description);
}
public static void mandatoryFieldWidgets(FormSection form) {
form.add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.titlepre")));
ParameterModel titlepreParam = new StringParameter(TITLEPRE);
TextField titlepre = new TextField(titlepreParam);
public static void mandatoryFieldWidgets(final FormSection form) {
final ParameterModel titlepreParam = new StringParameter(TITLEPRE);
final TextField titlepre = new TextField(titlepreParam);
titlepre.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.titlepre"));
form.add(titlepre);
form.add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.surname")));
ParameterModel surnameParam = new StringParameter(SURNAME);
final ParameterModel surnameParam = new StringParameter(SURNAME);
surnameParam.addParameterListener(new NotNullValidationListener());
TextField surname = new TextField(surnameParam);
final TextField surname = new TextField(surnameParam);
surname.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.surname"));
form.add(surname);
form.add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.givenname")));
ParameterModel givennameParam = new StringParameter(GIVENNAME);
TextField givenname = new TextField(givennameParam);
final ParameterModel givennameParam = new StringParameter(GIVENNAME);
final TextField givenname = new TextField(givennameParam);
givenname.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.givenname"));
form.add(givenname);
form.add(new Label(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.titlepost")));
ParameterModel titlepostParam = new StringParameter(TITLEPOST);
TextField titlepost = new TextField(titlepostParam);
final ParameterModel titlepostParam = new StringParameter(TITLEPOST);
final TextField titlepost = new TextField(titlepostParam);
titlepost.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.genericperson.titlepost"));
form.add(titlepost);
}
public void init(FormSectionEvent fse) {
FormData data = fse.getFormData();
GenericPerson person = (GenericPerson) super.initBasicWidgets(fse);
@Override
public void init(final FormSectionEvent fse) {
final FormData data = fse.getFormData();
final GenericPerson person = (GenericPerson) super.initBasicWidgets(fse);
data.put(TITLEPRE, person.getTitlePre());
data.put(SURNAME, person.getSurname());
@ -174,7 +174,8 @@ public class GenericPersonPropertyForm extends BasicPageForm
data.put(DESCRIPTION, person.getDescription());
}
public void submitted(FormSectionEvent fse) {
@Override
public void submitted(final FormSectionEvent fse) {
if (m_step != null
&& getSaveCancelSection().getCancelButton()
.isSelected(fse.getPageState())) {
@ -182,10 +183,10 @@ public class GenericPersonPropertyForm extends BasicPageForm
}
}
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
GenericPerson person = (GenericPerson) super.processBasicWidgets(fse);
@Override
public void process(final FormSectionEvent fse) {
final FormData data = fse.getFormData();
final GenericPerson person = (GenericPerson) super.processBasicWidgets(fse);
if (person != null
&& getSaveCancelSection().getSaveButton()
@ -205,5 +206,5 @@ public class GenericPersonPropertyForm extends BasicPageForm
m_step.maybeForwardToNextStep(fse.getPageState());
}
}
}
}

View File

@ -95,3 +95,5 @@ bebop.save=Save
bebop.cancel=Cancel
bebop.cancel.msg=Submission Cancelled
bebop.parameter.unexpected_value_type=Unexpected value type: {0}
bebop.date.year.hint=Year
bebop.date.year.label=Year

View File

@ -95,3 +95,5 @@ bebop.save=Speichern
bebop.cancel=Abbrechen
bebop.cancel.msg=Bearbeitung abgebrochen
bebop.parameter.unexpected_value_type=Unerwarteter Typ des Wertes: {0}
bebop.date.year.hint=Jahr
bebop.date.year.label=Jahr

View File

@ -95,3 +95,5 @@ bebop.save=TRANSLATE THIS: Previous (bebop.save)
bebop.cancel=TRANSLATE THIS: Previous (bebop.cancel)
bebop.cancel.msg=TRANSLATE THIS: Previous (bebop.cancel.submission.msg)
bebop.parameter.unexpected_value_type=Unexpected value type: {0}
bebop.date.year.hint=
bebop.date.year.label=

View File

@ -23,7 +23,6 @@ import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.GregorianCalendar;
import com.arsdigita.util.Assert;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.DateParameter;
@ -37,6 +36,7 @@ import com.arsdigita.bebop.parameters.*;
import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.bebop.util.GlobalizationUtil;
import com.arsdigita.xml.Element;
import java.text.SimpleDateFormat;
@ -69,6 +69,7 @@ public class Date extends Widget implements BebopConstants {
public YearFragment(String name, Date parent) {
super(name);
this.parent = parent;
setHint(GlobalizationUtil.globalize("bebop.date.year.hint"));
}
@Override
@ -100,6 +101,7 @@ public class Date extends Widget implements BebopConstants {
}
return value;
}
}
protected class MonthFragment extends SingleSelect {
@ -130,6 +132,7 @@ public class Date extends Widget implements BebopConstants {
}
return parent.getFragmentValue(ps, Calendar.MONTH);
}
}
protected class DayFragment extends TextField {
@ -160,6 +163,7 @@ public class Date extends Widget implements BebopConstants {
}
return parent.getFragmentValue(ps, Calendar.DATE);
}
}
/**
@ -214,9 +218,9 @@ public class Date extends Widget implements BebopConstants {
// Create an empty year entry to unset a date, if either
// a) skipYearAllowed is true
// b) skipDayAllowed is true and skipMonthAllowed is true, to unset a date
if (((IncompleteDateParameter) this.getParameterModel()).isSkipYearAllowed() ||
(((IncompleteDateParameter) this.getParameterModel()).isSkipDayAllowed() &&
((IncompleteDateParameter) this.getParameterModel()).isSkipMonthAllowed())) {
if (((IncompleteDateParameter) this.getParameterModel()).isSkipYearAllowed()
|| (((IncompleteDateParameter) this.getParameterModel()).isSkipDayAllowed()
&& ((IncompleteDateParameter) this.getParameterModel()).isSkipMonthAllowed())) {
m_year.addOption(new Option("", ""));
}
}
@ -247,8 +251,8 @@ public class Date extends Widget implements BebopConstants {
}
/**
* Sets the <tt>MAXLENGTH</tt> attribute for the <tt>INPUT</tt> tag
* used to render this form element.
* Sets the <tt>MAXLENGTH</tt> attribute for the <tt>INPUT</tt> tag used to render this form
* element.
*/
public void setMaxLength(int length) {
setAttribute("MAXLENGTH", String.valueOf(length));
@ -258,7 +262,8 @@ public class Date extends Widget implements BebopConstants {
return true;
}
/** The XML tag for this derived class of Widget.
/**
* The XML tag for this derived class of Widget.
*/
@Override
protected String getElementTag() {
@ -274,6 +279,9 @@ public class Date extends Widget implements BebopConstants {
Element date = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
date.addAttribute("name", getParameterModel().getName());
if (getLabel() != null) {
date.addAttribute("label", (String) getLabel().localize(ps.getRequest()));
}
exportAttributes(date);
generateLocalizedWidget(ps, date);
@ -345,12 +353,12 @@ public class Date extends Widget implements BebopConstants {
}
/**
* Sets the Form Object for this Widget. This method will throw an
* exception if the _form pointer is already set. To explicity
* change the _form pointer the developer must first call
* Sets the Form Object for this Widget. This method will throw an exception if the _form
* pointer is already set. To explicity change the _form pointer the developer must first call
* setForm(null)
*
* @param the <code>Form</code> Object for this Widget.
*
* @exception IllegalStateException if form already set.
*/
@Override
@ -410,4 +418,5 @@ public class Date extends Widget implements BebopConstants {
m_locale = GlobalizationHelper.getNegotiatedLocale();
}
}
}

View File

@ -50,10 +50,9 @@ public abstract class OptionGroup extends Widget
private static final Logger s_log = Logger.getLogger(OptionGroup.class);
/**
* The XML element to be used by individual options belonging to this group.
* This variable has to be initialized by every subclass of OptionGroup.
* LEGACY: An abstract method would be the better design, but changing it
* would break the API.
* The XML element to be used by individual options belonging to this group. This variable has
* to be initialized by every subclass of OptionGroup. LEGACY: An abstract method would be the
* better design, but changing it would break the API.
*/
protected String m_xmlElement;
// this only needs to be an ArrayList for multiple selection option groups
@ -66,18 +65,22 @@ public abstract class OptionGroup extends Widget
public static final String OTHER_OPTION = "__other__";
// request-local copy of selected elements, options
private RequestLocal m_requestOptions = new RequestLocal() {
@Override
public Object initialValue(PageState ps) {
return new ArrayList();
}
};
public final boolean isCompound() {
return true;
}
// this is only used for single selection option groups
private final static String TOO_MANY_OPTIONS_SELECTED =
"Only one option may be selected by default on this option group.";
private final static String TOO_MANY_OPTIONS_SELECTED
= "Only one option may be selected by default on this option group.";
/**
* The ParameterModel for mutliple OptionGroups is always an array parameter
@ -96,8 +99,8 @@ public abstract class OptionGroup extends Widget
}
/**
* Returns an Iterator of all the default Options in this group, plus any
* request-specific options.
* Returns an Iterator of all the default Options in this group, plus any request-specific
* options.
*/
public Iterator getOptions(PageState ps) {
ArrayList allOptions = new ArrayList();
@ -120,8 +123,8 @@ public abstract class OptionGroup extends Widget
/**
* Adds a new option.
*
* @param opt The {@link Option} to be added. Note: the argument is modified
* and associated with this OptionGroup, regardless of what its group was.
* @param opt The {@link Option} to be added. Note: the argument is modified and associated with
* this OptionGroup, regardless of what its group was.
*/
public void addOption(Option opt) {
addOption(opt, null, false);
@ -134,8 +137,8 @@ public abstract class OptionGroup extends Widget
/**
* Adds a new option.at the beginning of the list
*
* @param opt The {@link Option} to be added. Note: the argument is modified
* and associated with this OptionGroup, regardless of what its group was.
* @param opt The {@link Option} to be added. Note: the argument is modified and associated with
* this OptionGroup, regardless of what its group was.
*/
public void prependOption(Option opt) {
addOption(opt, null, true);
@ -150,15 +153,13 @@ public abstract class OptionGroup extends Widget
}
/**
* Adds a new option for the scope of the current request, or to the page as
* a whole if there is no current request.
* Adds a new option for the scope of the current request, or to the page as a whole if there is
* no current request.
*
* @param opt The {@link Option} to be added. Note: the argument is modified
* and associated with this OptionGroup, regardless of what its group was.
* @param ps the current page state. if ps is null, adds option to the
* default option list.
* @param prepend If true, prepend option to the list instead of appending
* it
* @param opt The {@link Option} to be added. Note: the argument is modified and associated
* with this OptionGroup, regardless of what its group was.
* @param ps the current page state. if ps is null, adds option to the default option list.
* @param prepend If true, prepend option to the list instead of appending it
*/
public void addOption(Option opt, PageState ps, boolean prepend) {
ArrayList list = m_options;
@ -191,8 +192,7 @@ public abstract class OptionGroup extends Widget
}
/**
* Removes the first option whose key is isEqual to the key that is passed
* in.
* Removes the first option whose key is isEqual to the key that is passed in.
*/
public void removeOption(String key, PageState ps) {
// This is not an entirely efficient technique. A more
@ -221,8 +221,8 @@ public abstract class OptionGroup extends Widget
*
* @param hasOtherOption true is the widget has an "Other" option
* @param width The width, in characters, of the "Other" entry area
* @param height The height, in characters, of the "Other" entry area. If
* this is 1 then a TextField is used. Otherwise a TextArea is used.
* @param height The height, in characters, of the "Other" entry area. If this is 1 then
* a TextField is used. Otherwise a TextArea is used.
*/
public void addOtherOption(String label, int width, int height) {
Assert.isUnlocked(this);
@ -233,14 +233,12 @@ public abstract class OptionGroup extends Widget
final ParameterModel model = getParameterModel();
if (1 == height) {
TextField field =
new TextField(model.getName() + ".other");
TextField field = new TextField(model.getName() + ".other");
field.setSize(width);
m_otherOption = field;
} else {
TextArea area =
new TextArea(model.getName() + ".other");
TextArea area = new TextArea(model.getName() + ".other");
area.setCols(width);
area.setRows(height);
@ -259,15 +257,14 @@ public abstract class OptionGroup extends Widget
}
setParameterModel(new ParameterModelWrapper(model) {
@Override
public ParameterData createParameterData(final HttpServletRequest request,
Object defaultValue,
boolean isSubmission) {
final String[] values =
request.getParameterValues(getName());
String[] otherValues =
request.getParameterValues(getName() + ".other");
final String[] values = request.getParameterValues(getName());
String[] otherValues = request.getParameterValues(getName() + ".other");
String other = (null == otherValues) ? null : otherValues[0];
@ -282,6 +279,7 @@ public abstract class OptionGroup extends Widget
s_log.debug("createParameterData in OptionGroup");
return super.createParameterData(new HttpServletRequestWrapper(request) {
@Override
public String[] getParameterValues(String key) {
if (s_log.isDebugEnabled()) {
@ -293,20 +291,21 @@ public abstract class OptionGroup extends Widget
}
return super.getParameterValues(key);
}
}, defaultValue, isSubmission);
}
private void replaceOther(String[] values, String other) {
}
});
}
/**
* Make an option selected by default. Updates the parameter model for the
* option group accordingly.
* Make an option selected by default. Updates the parameter model for the option group
* accordingly.
*
* @param value the value of the option to be added to the
* by-default-selected set.
* @param value the value of the option to be added to the by-default-selected set.
*/
public void setOptionSelected(String value) {
Assert.isUnlocked(this);
@ -335,20 +334,17 @@ public abstract class OptionGroup extends Widget
public Object clone() throws CloneNotSupportedException {
OptionGroup cloned = (OptionGroup) super.clone();
cloned.m_options = (ArrayList) m_options.clone();
cloned.m_selected =
(ArrayList) m_selected.clone();
cloned.m_selected = (ArrayList) m_selected.clone();
return cloned;
}
/**
* Is this a multiple (and not single) selection option group? Note that
* this should really be declared abstract, but we can't because it used to
* be in the direct subclass Select and making it abstract could break other
* subclasses that don't declare isMultiple. So we have a trivial
* implementation instead.
* Is this a multiple (and not single) selection option group? Note that this should really be
* declared abstract, but we can't because it used to be in the direct subclass Select and
* making it abstract could break other subclasses that don't declare isMultiple. So we have a
* trivial implementation instead.
*
* @return true if this OptionGroup can have more than one selected option;
* false otherwise.
* @return true if this OptionGroup can have more than one selected option; false otherwise.
*/
public boolean isMultiple() {
return true;
@ -387,17 +383,23 @@ public abstract class OptionGroup extends Widget
}
/**
* Generates the DOM for the select widget <p>Generates DOM fragment: <p><pre><code>&lt;bebop:* name=... [onXXX=...]&gt;
* Generates the DOM for the select widget
* <p>
* Generates DOM fragment:
* <p>
* <pre><code>&lt;bebop:* name=... [onXXX=...]&gt;
* &lt;bebop:option name=... [selected]&gt; option value &lt;/bebop:option%gt;
* ...
* &lt;/bebop:*select&gt;</code></pre>
*/
@Override
public void generateWidget(PageState state, Element parent) {
Element optionGroup =
parent.newChildElement(getElementTag(), BEBOP_XML_NS);
Element optionGroup = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
optionGroup.addAttribute("name", getName());
optionGroup.addAttribute("class", getName().replace(".", " "));
if (getLabel() != null) {
optionGroup.addAttribute("label", (String) getLabel().localize(state.getRequest()));
}
if (isMultiple()) {
optionGroup.addAttribute("multiple", "multiple");
}
@ -412,4 +414,5 @@ public abstract class OptionGroup extends Widget
m_otherOption.generateXML(state, optionGroup);
}
}
}

View File

@ -115,6 +115,9 @@
<!-- EN Create a select or multiselect widget. If wanted, creates a label instead for
a selection length of 1. -->
<xsl:template match="bebop:select | bebop:multiSelect">
<xsl:call-template name="processLabel">
<xsl:with-param name="widget" select="."/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="@class = 'displayOneOptionAsLabel' and count(bebop:option) = 1">
<xsl:choose>
@ -199,9 +202,15 @@
</xsl:template>
<xsl:template match="bebop:date">
<span class="date">
<!--<span class="date">
<xsl:apply-templates/>
</span>
</span>-->
<fieldset class="date">
<legend>
<xsl:value-of select="@label"/>
</legend>
<xsl:apply-templates/>
</fieldset>
</xsl:template>
<xsl:template match="bebop:time">