- 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-94f89814c4dfmaster
parent
4b7ff4f902
commit
06bfe7c709
|
|
@ -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,14 +66,14 @@ 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,
|
||||
public ContentGroupPropertyForm(ItemSelectionModel itemModel,
|
||||
String attributeName) {
|
||||
super("contentGroupProperty", itemModel);
|
||||
m_attributeName = attributeName;
|
||||
|
|
@ -84,40 +84,39 @@ 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")) {
|
||||
.globalize("cms.contenttypes.ui.content_group_current_items")) {
|
||||
|
||||
@Override
|
||||
public boolean isVisible(PageState state) {
|
||||
ContentGroupContainer item =
|
||||
(ContentGroupContainer) getItemSelectionModel()
|
||||
.getSelectedObject(state);
|
||||
ContentGroup group =
|
||||
getCurrentGroup(item, m_attributeName);
|
||||
ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel()
|
||||
.getSelectedObject(state);
|
||||
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()
|
||||
.getSelectedObject(state);
|
||||
ContentGroup group =
|
||||
getCurrentGroup(item, m_attributeName);
|
||||
return group != null && group.getContentItems().size() > 0;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean isVisible(PageState state) {
|
||||
ContentGroupContainer item = (ContentGroupContainer) getItemSelectionModel()
|
||||
.getSelectedObject(state);
|
||||
ContentGroup group = getCurrentGroup(item, m_attributeName);
|
||||
return group != null && group.getContentItems().size() > 0;
|
||||
}
|
||||
|
||||
};
|
||||
add(m_checkboxGroup);
|
||||
|
||||
add(new Label(GlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.content_group_new_item")));
|
||||
.globalize("cms.contenttypes.ui.content_group_new_item")));
|
||||
try {
|
||||
add(new ItemSearchWidget(RELATED_ITEM, getSearchContentType()));
|
||||
} catch (DataObjectNotFoundException de) {
|
||||
|
|
@ -125,12 +124,10 @@ 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
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -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,46 +146,42 @@ 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(),
|
||||
collection.getContentItem().getName()), state);
|
||||
m_checkboxGroup.addOption(new Option(collection.getID().toString(),
|
||||
collection.getContentItem().getName()), state);
|
||||
selected.add(collection.getID().toString());
|
||||
}
|
||||
data.put(ASSOCIATED_ITEMS, selected.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
if ( item != null && !getSaveCancelSection().getCancelButton()
|
||||
.isSelected( e.getPageState() ) ) {
|
||||
|
||||
if (item != null && !getSaveCancelSection().getCancelButton()
|
||||
.isSelected(e.getPageState())) {
|
||||
|
||||
ContentGroup group = getCurrentGroup(item, m_attributeName);
|
||||
if (group == null) {
|
||||
group = new ContentGroup();
|
||||
group.setMaster((ContentItem) item);
|
||||
setContentGroup(item, group, m_attributeName);
|
||||
}
|
||||
group.setName((String)data.get(ContentGroup.NAME));
|
||||
group.save ();
|
||||
|
||||
group.setName((String) data.get(ContentGroup.NAME));
|
||||
group.save();
|
||||
|
||||
// iterate through the values so that we only remove items
|
||||
// that have been unchecked.
|
||||
ItemCollection collection = group.getContentItems();
|
||||
|
|
@ -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,11 +205,10 @@ 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);
|
||||
|
||||
ContentItem newItem = (ContentItem) data.get(RELATED_ITEM);
|
||||
if (newItem != null) {
|
||||
group.addContentItem(newItem);
|
||||
}
|
||||
|
|
@ -227,31 +218,29 @@ public class ContentGroupPropertyForm extends BasicItemForm {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This returns the correct group for the attribute name
|
||||
* This returns the correct group for the attribute name
|
||||
*/
|
||||
private ContentGroup getCurrentGroup(ContentGroupContainer item, String attributeName) {
|
||||
return item.getContentGroup(attributeName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This sets the group for the given attribute name
|
||||
* This sets the group for the given attribute name
|
||||
*/
|
||||
private void setContentGroup(ContentGroupContainer item, ContentGroup group,
|
||||
private void setContentGroup(ContentGroupContainer item, ContentGroup group,
|
||||
String attributeName) {
|
||||
item.setContentGroup(attributeName, group);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
@ -51,10 +56,10 @@ import org.apache.log4j.Logger;
|
|||
* @author: Jens Pelzetter
|
||||
* @author Sören Bernstein <quasi@quasiweb.de>
|
||||
*/
|
||||
public class GenericAddressPropertyForm extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
public class GenericAddressPropertyForm extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(GenericAddressPropertyForm.class);
|
||||
|
||||
|
|
@ -70,7 +75,7 @@ public class GenericAddressPropertyForm extends BasicPageForm
|
|||
this(itemModel, null);
|
||||
}
|
||||
|
||||
public GenericAddressPropertyForm(ItemSelectionModel itemModel,
|
||||
public GenericAddressPropertyForm(ItemSelectionModel itemModel,
|
||||
GenericAddressPropertiesStep step) {
|
||||
super(ID, itemModel);
|
||||
m_step = step;
|
||||
|
|
@ -81,67 +86,82 @@ 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.addOption(new Option("",
|
||||
country.setLabel(ContenttypesGlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.address.iso_country_code"));
|
||||
country.addOption(new Option("",
|
||||
new Label(GlobalizationUtil
|
||||
.globalize("cms.ui.select_one"))));
|
||||
.globalize("cms.ui.select_one"))));
|
||||
|
||||
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(),
|
||||
elem.getKey().toString()));
|
||||
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();
|
||||
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() {
|
||||
|
||||
public void validate(ParameterEvent e)
|
||||
throws FormProcessException {
|
||||
public void validate(ParameterEvent e)
|
||||
throws FormProcessException {
|
||||
ParameterData data = e.getParameterData();
|
||||
String isoCode = (String) data.getValue();
|
||||
s_log.debug("ISO code is : " + isoCode);
|
||||
if (isoCode == null || isoCode.length() == 0) {
|
||||
data.addError((String) ContenttypesGlobalizationUtil
|
||||
.globalize("cms.contenttypes.ui.address.error_iso_country")
|
||||
.localize());
|
||||
.globalize("cms.contenttypes.ui.address.error_iso_country")
|
||||
.localize());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
add(country);
|
||||
|
|
@ -150,8 +170,8 @@ public class GenericAddressPropertyForm extends BasicPageForm
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fse
|
||||
*
|
||||
* @param fse
|
||||
*/
|
||||
public void init(FormSectionEvent fse) {
|
||||
FormData data = fse.getFormData();
|
||||
|
|
@ -167,8 +187,8 @@ public class GenericAddressPropertyForm extends BasicPageForm
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fse
|
||||
*
|
||||
* @param fse
|
||||
*/
|
||||
public void submitted(FormSectionEvent fse) {
|
||||
if (m_step != null
|
||||
|
|
@ -178,8 +198,8 @@ public class GenericAddressPropertyForm extends BasicPageForm
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fse
|
||||
*
|
||||
* @param fse
|
||||
*/
|
||||
public void process(FormSectionEvent fse) {
|
||||
FormData data = fse.getFormData();
|
||||
|
|
@ -201,4 +221,5 @@ public class GenericAddressPropertyForm extends BasicPageForm
|
|||
m_step.maybeForwardToNextStep(fse.getPageState());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
@ -38,16 +40,15 @@ import org.apache.log4j.Logger;
|
|||
* @author quasi
|
||||
*/
|
||||
public class GenericContactAttachPersonPropertyForm extends BasicPageForm
|
||||
implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
||||
implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(
|
||||
GenericContactPropertyForm.class);
|
||||
GenericContactPropertyForm.class);
|
||||
private GenericContactPersonPropertiesStep m_step;
|
||||
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,9 +64,8 @@ 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
|
||||
*/
|
||||
|
|
@ -85,34 +85,46 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
|
|||
public void addWidgets() {
|
||||
|
||||
add(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.contact.select_person")));
|
||||
"cms.contenttypes.ui.contact.select_person")));
|
||||
this.m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
|
||||
findByAssociatedObjectType(
|
||||
"com.arsdigita.cms.contenttypes.GenericPerson"));
|
||||
findByAssociatedObjectType(
|
||||
"com.arsdigita.cms.contenttypes.GenericPerson"));
|
||||
m_itemSearch.setDisableCreatePane(true);
|
||||
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"))));
|
||||
.globalize("cms.ui.select_one"))));
|
||||
try {
|
||||
contactType.addPrintListener(new PrintListener() {
|
||||
|
||||
// Add the Options to the SingleSelect widget
|
||||
GenericContactTypeCollection contacttypes =
|
||||
new GenericContactTypeCollection();
|
||||
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
@Override
|
||||
public void prepare(final PrintEvent event) {
|
||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||
|
||||
while (contacttypes.next()) {
|
||||
RelationAttribute ct = contacttypes.getRelationAttribute();
|
||||
contactType.addOption(new Option(ct.getKey(), ct.getName()));
|
||||
final GenericContactTypeCollection contacttypes
|
||||
= new GenericContactTypeCollection();
|
||||
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
|
||||
while (contacttypes.next()) {
|
||||
RelationAttribute ct = contacttypes.getRelationAttribute();
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +132,7 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
|
|||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
GenericContact contact = (GenericContact) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
getSelectedObject(state);
|
||||
|
||||
setVisible(state, true);
|
||||
|
||||
|
|
@ -134,13 +146,13 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
|
|||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
GenericContact contact = (GenericContact) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
getSelectedObject(state);
|
||||
|
||||
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
|
||||
GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH);
|
||||
|
||||
person = (GenericPerson) person.getContentBundle().getInstance(contact.
|
||||
getLanguage());
|
||||
getLanguage());
|
||||
|
||||
contact.setPerson(person, (String) data.get(CONTACTS_KEY));
|
||||
}
|
||||
|
|
@ -156,21 +168,21 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
|
|||
getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() {
|
||||
|
||||
public void prepare(PrintEvent e) {
|
||||
GenericContact contact =
|
||||
(GenericContact) getItemSelectionModel().
|
||||
getSelectedObject(e.getPageState());
|
||||
GenericContact contact = (GenericContact) getItemSelectionModel().
|
||||
getSelectedObject(e.getPageState());
|
||||
Submit target = (Submit) e.getTarget();
|
||||
|
||||
if (contact.getPerson() != null) {
|
||||
target.setButtonLabel(ContenttypesGlobalizationUtil.
|
||||
globalize(
|
||||
globalize(
|
||||
"cms.contenttypes.ui.contact.select_person.change"));
|
||||
} else {
|
||||
target.setButtonLabel(ContenttypesGlobalizationUtil.
|
||||
globalize(
|
||||
globalize(
|
||||
"cms.contenttypes.ui.contact.select_person.add"));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
throw new UncheckedWrapperException("this cannot happen", ex);
|
||||
|
|
@ -181,26 +193,26 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
|
|||
public void validate(FormSectionEvent e) throws FormProcessException {
|
||||
//Calling super.validate(e) here causes an exception because the super method checks things which not available
|
||||
//here.
|
||||
|
||||
|
||||
final PageState state = e.getPageState();
|
||||
final FormData data = e.getFormData();
|
||||
|
||||
if (data.get(ITEM_SEARCH) == null) {
|
||||
throw new FormProcessException((String) ContenttypesGlobalizationUtil.
|
||||
globalize(
|
||||
globalize(
|
||||
"cms.contenttypes.ui.contact.select_person.wrong_type").
|
||||
localize());
|
||||
localize());
|
||||
}
|
||||
|
||||
GenericContact contact = (GenericContact) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
getSelectedObject(state);
|
||||
GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH);
|
||||
|
||||
if (!(person.getContentBundle().hasInstance(contact.getLanguage(),
|
||||
Kernel.getConfig().
|
||||
languageIndependentItems()))) {
|
||||
languageIndependentItems()))) {
|
||||
data.addError(
|
||||
"cms.contenttypes.ui.contact.select_person.no_suitable_language_variant");
|
||||
"cms.contenttypes.ui.contact.select_person.no_suitable_language_variant");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -209,9 +221,10 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
|
|||
if (getSaveCancelSection().getCancelButton().isSelected(e.getPageState())) {
|
||||
init(e);
|
||||
throw new FormProcessException((String) ContenttypesGlobalizationUtil.
|
||||
globalize(
|
||||
globalize(
|
||||
"cms.contenttypes.ui.contact.select_person.cancelled").
|
||||
localize());
|
||||
localize());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,20 +46,23 @@ 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author quasi, Created on 8. Juli 2009, 10:27
|
||||
* @author quasi, Created on 8. Juli 2009, 10:27
|
||||
*/
|
||||
public class GenericContactEditAddressPropertyForm extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
public class GenericContactEditAddressPropertyForm extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(
|
||||
GenericContactPropertyForm.class);
|
||||
GenericContactPropertyForm.class);
|
||||
|
||||
public static final String ADDRESS = GenericAddress.ADDRESS;
|
||||
public static final String POSTAL_CODE = GenericAddress.POSTAL_CODE;
|
||||
|
|
@ -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";
|
||||
|
||||
/**
|
||||
|
|
@ -81,11 +88,11 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
|
|||
|
||||
/**
|
||||
* Constrctor taking an ItemSelectionModel and an instance of ContactPropertiesStep.
|
||||
*
|
||||
*
|
||||
* @param itemModel
|
||||
* @param step
|
||||
*/
|
||||
public GenericContactEditAddressPropertyForm(ItemSelectionModel itemModel,
|
||||
public GenericContactEditAddressPropertyForm(ItemSelectionModel itemModel,
|
||||
GenericContactAddressPropertiesStep step) {
|
||||
super(ID, itemModel);
|
||||
m_step = step;
|
||||
|
|
@ -94,77 +101,89 @@ 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("",
|
||||
new Label(ContenttypesGlobalizationUtil
|
||||
.globalize("cms.ui.select_one"))));
|
||||
country.addOption(new Option("",
|
||||
new Label(ContenttypesGlobalizationUtil
|
||||
.globalize("cms.ui.select_one"))));
|
||||
|
||||
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(),
|
||||
elem.getKey().toString()));
|
||||
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();
|
||||
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() {
|
||||
new ParameterListener() {
|
||||
|
||||
@Override
|
||||
public void validate(ParameterEvent e) throws FormProcessException {
|
||||
ParameterData data = e.getParameterData();
|
||||
String isoCode = (String) data.getValue();
|
||||
if (isoCode == null || isoCode.length() == 0) {
|
||||
data.addError((String) ContenttypesGlobalizationUtil
|
||||
@Override
|
||||
public void validate(ParameterEvent e) throws FormProcessException {
|
||||
ParameterData data = e.getParameterData();
|
||||
String isoCode = (String) data.getValue();
|
||||
if (isoCode == null || isoCode.length() == 0) {
|
||||
data.addError((String) ContenttypesGlobalizationUtil
|
||||
.globalize(
|
||||
"cms.contenttypes.ui.address.error_iso_country")
|
||||
"cms.contenttypes.ui.address.error_iso_country")
|
||||
.localize());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
add(country);
|
||||
}
|
||||
|
|
@ -216,4 +235,5 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
|
|||
m_step.maybeForwardToNextStep(fse.getPageState());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -51,14 +55,14 @@ import org.apache.log4j.Logger;
|
|||
*
|
||||
* @author quasi
|
||||
*/
|
||||
public class GenericContactEditPersonPropertyForm extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
public class GenericContactEditPersonPropertyForm extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(GenericContactPropertyForm.class);
|
||||
private GenericContactPersonPropertiesStep m_step;
|
||||
|
||||
|
||||
public static final String SURNAME = GenericPerson.SURNAME;
|
||||
public static final String GIVENNAME = GenericPerson.GIVENNAME;
|
||||
public static final String TITLEPRE = GenericPerson.TITLEPRE;
|
||||
|
|
@ -80,13 +84,12 @@ 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
|
||||
*/
|
||||
public GenericContactEditPersonPropertyForm(ItemSelectionModel itemModel,
|
||||
public GenericContactEditPersonPropertyForm(ItemSelectionModel itemModel,
|
||||
GenericContactPersonPropertiesStep step) {
|
||||
super(ID, itemModel);
|
||||
m_step = step;
|
||||
|
|
@ -94,60 +97,72 @@ 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("",
|
||||
new Label(GlobalizationUtil
|
||||
.globalize("cms.ui.select_one"))));
|
||||
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();
|
||||
contacttypes.addLanguageFilter(GlobalizationHelper
|
||||
.getNegotiatedLocale().getLanguage());
|
||||
@Override
|
||||
public void prepare(final PrintEvent event) {
|
||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||
|
||||
while (contacttypes.next()) {
|
||||
RelationAttribute ct = contacttypes.getRelationAttribute();
|
||||
contactType.addOption(new Option(ct.getKey(), ct.getName()));
|
||||
final GenericContactTypeCollection contacttypes
|
||||
= new GenericContactTypeCollection();
|
||||
contacttypes.addLanguageFilter(GlobalizationHelper
|
||||
.getNegotiatedLocale().getLanguage());
|
||||
|
||||
while (contacttypes.next()) {
|
||||
RelationAttribute ct = contacttypes.getRelationAttribute();
|
||||
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,7 +171,7 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
|
|||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
GenericContact contact = (GenericContact) getItemSelectionModel()
|
||||
.getSelectedObject(state);
|
||||
.getSelectedObject(state);
|
||||
|
||||
if (contact.getPerson() != null) {
|
||||
data.put(SURNAME, contact.getPerson().getSurname());
|
||||
|
|
@ -178,7 +193,7 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
|
|||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
GenericContact contact = (GenericContact) getItemSelectionModel()
|
||||
.getSelectedObject(state);
|
||||
.getSelectedObject(state);
|
||||
|
||||
if (getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
|
||||
|
||||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,91 +48,104 @@ 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);
|
||||
|
||||
super("ContactEntryAddForm", itemModel);
|
||||
m_itemModel = itemModel;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
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(
|
||||
"cms.ui.select_one")) ));
|
||||
|
||||
// Add the Options to the SingleSelect widget
|
||||
GenericContactEntryKeys keyList = new GenericContactEntryKeys();
|
||||
keyList.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale()
|
||||
.getLanguage());
|
||||
while(keyList.next()) {
|
||||
String currentKey = keyList.getKey();
|
||||
contactEntryKey.addOption(new Option(currentKey, keyList.getName()));
|
||||
contactEntryKey.addOption(new Option("", new Label(GlobalizationUtil.globalize(
|
||||
"cms.ui.select_one"))));
|
||||
try {
|
||||
contactEntryKey.addPrintListener(new PrintListener() {
|
||||
|
||||
@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();
|
||||
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
|
||||
*
|
||||
* @param fse
|
||||
*/
|
||||
public void init(FormSectionEvent fse) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fse
|
||||
*
|
||||
* @param fse
|
||||
*/
|
||||
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
|
||||
&& getSaveCancelSection().getSaveButton()
|
||||
.isSelected(fse.getPageState())) {
|
||||
|
||||
&& getSaveCancelSection().getSaveButton()
|
||||
.isSelected(fse.getPageState())) {
|
||||
|
||||
GenericContactEntry contactEntry = new GenericContactEntry(
|
||||
contact,
|
||||
(String)data.get(GenericContactEntry.KEY),
|
||||
(String)data.get(GenericContactEntry.VALUE),
|
||||
(String)data.get(GenericContactEntry.DESCRIPTION));
|
||||
|
||||
contact,
|
||||
(String) data.get(GenericContactEntry.KEY),
|
||||
(String) data.get(GenericContactEntry.VALUE),
|
||||
(String) data.get(GenericContactEntry.DESCRIPTION));
|
||||
|
||||
contact.addContactEntry(contactEntry);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
@ -51,11 +56,11 @@ import org.apache.log4j.Logger;
|
|||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class GenericOrganizationalUnitContactAddForm
|
||||
extends BasicItemForm
|
||||
implements FormSubmissionListener {
|
||||
extends BasicItemForm
|
||||
implements FormSubmissionListener {
|
||||
|
||||
private final static Logger s_log = Logger.getLogger(
|
||||
GenericOrganizationalUnitContactAddForm.class);
|
||||
GenericOrganizationalUnitContactAddForm.class);
|
||||
private GenericOrganizationalUnitPropertiesStep m_step;
|
||||
private ItemSearchWidget m_itemSearch;
|
||||
private SaveCancelSection m_saveCancelSection;
|
||||
|
|
@ -75,35 +80,47 @@ public class GenericOrganizationalUnitContactAddForm
|
|||
@Override
|
||||
protected void addWidgets() {
|
||||
add(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.select_contact")));
|
||||
"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);
|
||||
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();
|
||||
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
@Override
|
||||
public void prepare(final PrintEvent event) {
|
||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||
|
||||
while (contacttypes.next()) {
|
||||
RelationAttribute ct = contacttypes.getRelationAttribute();
|
||||
contactType.addOption(new Option(ct.getKey(), ct.getName()));
|
||||
final GenericOrganizationContactTypeCollection contacttypes
|
||||
= new GenericOrganizationContactTypeCollection();
|
||||
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
|
||||
while (contacttypes.next()) {
|
||||
RelationAttribute ct = contacttypes.getRelationAttribute();
|
||||
target.addOption(new Option(ct.getKey(), ct.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
|
||||
}
|
||||
|
||||
add(contactType);
|
||||
}
|
||||
|
||||
|
|
@ -134,9 +151,8 @@ public class GenericOrganizationalUnitContactAddForm
|
|||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
GenericContact selectedContact;
|
||||
|
|
@ -146,17 +162,17 @@ public class GenericOrganizationalUnitContactAddForm
|
|||
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
|
||||
|
||||
if (orgaunit.getLanguage().equals(
|
||||
GlobalizationHelper.LANG_INDEPENDENT)) {
|
||||
GlobalizationHelper.LANG_INDEPENDENT)) {
|
||||
contact = (GenericContact) contact.getContentBundle().
|
||||
getPrimaryInstance();
|
||||
getPrimaryInstance();
|
||||
} else {
|
||||
contact = (GenericContact) contact.getContentBundle().
|
||||
getInstance(orgaunit.getLanguage());
|
||||
getInstance(orgaunit.getLanguage());
|
||||
}
|
||||
|
||||
orgaunit.addContact(contact,
|
||||
(String) data.get(
|
||||
GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
|
||||
GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
|
||||
} else {
|
||||
GenericOrganizationalUnitContactCollection contacts;
|
||||
|
||||
|
|
@ -169,7 +185,7 @@ public class GenericOrganizationalUnitContactAddForm
|
|||
}
|
||||
|
||||
contacts.setContactType((String) data.get(
|
||||
GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
|
||||
GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
|
||||
|
||||
editStep.setSelectedContact(null);
|
||||
editStep.setSelectedContactType(null);
|
||||
|
|
@ -182,7 +198,7 @@ public class GenericOrganizationalUnitContactAddForm
|
|||
|
||||
public void submitted(FormSectionEvent fse) throws FormProcessException {
|
||||
if (getSaveCancelSection().getCancelButton().isSelected(
|
||||
fse.getPageState())) {
|
||||
fse.getPageState())) {
|
||||
editStep.setSelectedContact(null);
|
||||
editStep.setSelectedContactType(null);
|
||||
|
||||
|
|
@ -196,17 +212,16 @@ public class GenericOrganizationalUnitContactAddForm
|
|||
final FormData data = fse.getFormData();
|
||||
|
||||
if ((editStep.getSelectedContact() == null)
|
||||
&& (data.get(ITEM_SEARCH) == null)) {
|
||||
&& (data.get(ITEM_SEARCH) == null)) {
|
||||
data.addError(
|
||||
"cms.contenttypes.ui.genericorgaunit.select_contact.no_contact_selected");
|
||||
"cms.contenttypes.ui.genericorgaunit.select_contact.no_contact_selected");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (editStep.getSelectedContact() == null) {
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel()
|
||||
.getSelectedObject(state);
|
||||
|
||||
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
|
||||
|
||||
|
|
@ -215,36 +230,36 @@ public class GenericOrganizationalUnitContactAddForm
|
|||
if (!(contact.getContentBundle().hasInstance(orgaunit.
|
||||
getLanguage(),
|
||||
Kernel.getConfig().
|
||||
languageIndependentItems()))) {
|
||||
languageIndependentItems()))) {
|
||||
data.addError(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.select_contact.no_suitable_language_variant"));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (orgaunit.getLanguage().equals(
|
||||
GlobalizationHelper.LANG_INDEPENDENT)) {
|
||||
GlobalizationHelper.LANG_INDEPENDENT)) {
|
||||
contact = (GenericContact) contact.getContentBundle().
|
||||
getPrimaryInstance();
|
||||
getPrimaryInstance();
|
||||
} else {
|
||||
contact = (GenericContact) contact.getContentBundle().
|
||||
getInstance(orgaunit.getLanguage());
|
||||
getInstance(orgaunit.getLanguage());
|
||||
}
|
||||
GenericOrganizationalUnitContactCollection contacts = orgaunit.
|
||||
getContacts();
|
||||
getContacts();
|
||||
|
||||
contacts.addFilter(String.format("id = %s",
|
||||
contact.getID().toString()));
|
||||
if (contacts.size() > 0) {
|
||||
data.addError(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.select_contact.already_added"));
|
||||
}
|
||||
|
||||
contacts.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,41 +38,41 @@ import java.util.Date;
|
|||
* @version $Id$
|
||||
*/
|
||||
public class GenericOrganizationalUnitCreate extends PageCreate {
|
||||
|
||||
|
||||
public GenericOrganizationalUnitCreate(final ItemSelectionModel itemModel,
|
||||
final CreationSelector parent) {
|
||||
super(itemModel, parent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent fse) throws FormProcessException {
|
||||
final FormData data = fse.getFormData();
|
||||
final PageState state = fse.getPageState();
|
||||
final ContentSection section = m_parent.getContentSection(state);
|
||||
final Folder folder = m_parent.getFolder(state);
|
||||
|
||||
|
||||
final ContentPage item = createContentPage(state);
|
||||
item.setLanguage((String) data.get(LANGUAGE));
|
||||
item.setName((String) data.get(NAME));
|
||||
item.setTitle((String) data.get(TITLE));
|
||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
item.setLaunchDate((Date) data.get(LAUNCH_DATE));
|
||||
item.setLaunchDate((Date) data.get(LAUNCH_DATE));
|
||||
}
|
||||
|
||||
|
||||
final GenericOrganizationalUnitBundle bundle = createBundle(item);
|
||||
//new GenericOrganizationalUnitBundle(item);
|
||||
bundle.setParent(folder);
|
||||
bundle.setContentSection(section);
|
||||
bundle.save();
|
||||
|
||||
|
||||
m_workflowSection.applyWorkflow(state, item);
|
||||
|
||||
|
||||
m_parent.editItem(state, item);
|
||||
}
|
||||
|
||||
|
||||
protected GenericOrganizationalUnitBundle createBundle(
|
||||
final ContentItem primary) {
|
||||
final ContentItem primary) {
|
||||
return new GenericOrganizationalUnitBundle(primary);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
@ -52,13 +56,13 @@ import org.apache.log4j.Logger;
|
|||
* @version $Id$
|
||||
*/
|
||||
public class GenericOrganizationalUnitPersonAddForm
|
||||
extends BasicItemForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
extends BasicItemForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(
|
||||
GenericOrganizationalUnitPersonAddForm.class);
|
||||
GenericOrganizationalUnitPersonAddForm.class);
|
||||
private GenericOrganizationalUnitPersonPropertiesStep m_step;
|
||||
private ItemSearchWidget m_itemSearch;
|
||||
private final String ITEM_SEARCH = "orgaunitPerson";
|
||||
|
|
@ -75,58 +79,80 @@ public class GenericOrganizationalUnitPersonAddForm
|
|||
@Override
|
||||
protected void addWidgets() {
|
||||
add(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.select_person")));
|
||||
"cms.contenttypes.ui.genericorgaunit.select_person")));
|
||||
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
|
||||
findByAssociatedObjectType(getPersonType()));
|
||||
findByAssociatedObjectType(getPersonType()));
|
||||
/*m_itemSearch.getItemField().addValidationListener(
|
||||
new NotNullValidationListener());*/
|
||||
new NotNullValidationListener());*/
|
||||
m_itemSearch.setDisableCreatePane(false);
|
||||
add(this.m_itemSearch);
|
||||
|
||||
selectedPersonNameLabel = new Label("");
|
||||
add(selectedPersonNameLabel);
|
||||
|
||||
add(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.person.role")));
|
||||
ParameterModel roleParam =
|
||||
new StringParameter(
|
||||
GenericOrganizationalUnitPersonCollection.PERSON_ROLE);
|
||||
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(
|
||||
getRoleAttributeName());
|
||||
roles.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
while (roles.next()) {
|
||||
RelationAttribute role;
|
||||
role = roles.getRelationAttribute();
|
||||
roleSelect.addOption(new Option(role.getKey(), role.getName()));
|
||||
new Option("",
|
||||
new Label(ContenttypesGlobalizationUtil
|
||||
.globalize("cms.ui.select_one"))));
|
||||
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();
|
||||
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(
|
||||
GenericOrganizationalUnitPersonCollection.STATUS);
|
||||
SingleSelect statusSelect = new SingleSelect(statusModel);
|
||||
final ParameterModel statusModel = new StringParameter(
|
||||
GenericOrganizationalUnitPersonCollection.STATUS);
|
||||
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(
|
||||
getStatusAttributeName());
|
||||
statusColl.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
while (statusColl.next()) {
|
||||
RelationAttribute status;
|
||||
status = statusColl.getRelationAttribute();
|
||||
statusSelect.addOption(new Option(status.getKey(), status.getName()));
|
||||
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();
|
||||
target.addOption(new Option(status.getKey(), status.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UncheckedWrapperException("Somethin has gone terribly wrong", ex);
|
||||
}
|
||||
add(statusSelect);
|
||||
|
||||
|
|
@ -167,9 +193,8 @@ public class GenericOrganizationalUnitPersonAddForm
|
|||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
GenericOrganizationalUnit orga =
|
||||
(GenericOrganizationalUnit) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
GenericOrganizationalUnit orga = (GenericOrganizationalUnit) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
|
||||
|
|
@ -177,16 +202,15 @@ 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()));
|
||||
|
||||
orga.addPerson(personToAdd,
|
||||
(String) data.get(
|
||||
GenericOrganizationalUnitPersonCollection.PERSON_ROLE),
|
||||
GenericOrganizationalUnitPersonCollection.PERSON_ROLE),
|
||||
(String) data.get(
|
||||
GenericOrganizationalUnitPersonCollection.STATUS));
|
||||
GenericOrganizationalUnitPersonCollection.STATUS));
|
||||
m_itemSearch.publishCreatedItem(data, personToAdd);
|
||||
} else {
|
||||
GenericOrganizationalUnitPersonCollection persons;
|
||||
|
|
@ -200,9 +224,9 @@ public class GenericOrganizationalUnitPersonAddForm
|
|||
}
|
||||
|
||||
persons.setRoleName((String) data.get(
|
||||
GenericOrganizationalUnitPersonCollection.PERSON_ROLE));
|
||||
GenericOrganizationalUnitPersonCollection.PERSON_ROLE));
|
||||
persons.setStatus((String) data.get(
|
||||
GenericOrganizationalUnitPersonCollection.STATUS));
|
||||
GenericOrganizationalUnitPersonCollection.STATUS));
|
||||
|
||||
selector.setSelectedPerson(null);
|
||||
selector.setSelectedPersonRole(null);
|
||||
|
|
@ -217,7 +241,7 @@ public class GenericOrganizationalUnitPersonAddForm
|
|||
|
||||
public void submitted(FormSectionEvent fse) throws FormProcessException {
|
||||
if (this.getSaveCancelSection().getCancelButton().isSelected(
|
||||
fse.getPageState())) {
|
||||
fse.getPageState())) {
|
||||
selector.setSelectedPerson(null);
|
||||
selector.setSelectedPersonRole(null);
|
||||
selector.setSelectedPersonStatus(null);
|
||||
|
|
@ -232,46 +256,43 @@ public class GenericOrganizationalUnitPersonAddForm
|
|||
final FormData data = fse.getFormData();
|
||||
|
||||
if ((selector.getSelectedPerson() == null)
|
||||
&& (data.get(ITEM_SEARCH) == null)) {
|
||||
&& (data.get(ITEM_SEARCH) == null)) {
|
||||
data.addError(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.person.no_person_selected"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (selector.getSelectedPerson() == null) {
|
||||
GenericOrganizationalUnit orga =
|
||||
(GenericOrganizationalUnit) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
GenericOrganizationalUnit orga = (GenericOrganizationalUnit) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
GenericPerson person = (GenericPerson) data.get(ITEM_SEARCH);
|
||||
|
||||
/*if (!(person.getContentBundle().hasInstance(orga.getLanguage(),
|
||||
Kernel.getConfig().
|
||||
languageIndependentItems()))) {
|
||||
data.addError(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.person.no_suitable_language_variant"));
|
||||
|
||||
return;
|
||||
}*/
|
||||
Kernel.getConfig().
|
||||
languageIndependentItems()))) {
|
||||
data.addError(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.person.no_suitable_language_variant"));
|
||||
|
||||
return;
|
||||
}*/
|
||||
final ContentBundle bundle = person.getContentBundle();
|
||||
final GenericOrganizationalUnitPersonCollection persons =
|
||||
orga.getPersons();
|
||||
persons.addFilter(String.format("id = %s",
|
||||
bundle.getID().toString()));
|
||||
|
||||
/*person = (GenericPerson) person.getContentBundle().getInstance(orga.
|
||||
getLanguage());
|
||||
GenericOrganizationalUnitPersonCollection persons =
|
||||
orga.getPersons();
|
||||
|
||||
final GenericOrganizationalUnitPersonCollection persons = orga.getPersons();
|
||||
persons.addFilter(String.format("id = %s",
|
||||
person.getID().toString()));*/
|
||||
bundle.getID().toString()));
|
||||
|
||||
/*person = (GenericPerson) person.getContentBundle().getInstance(orga.
|
||||
getLanguage());
|
||||
GenericOrganizationalUnitPersonCollection persons =
|
||||
orga.getPersons();
|
||||
|
||||
persons.addFilter(String.format("id = %s",
|
||||
person.getID().toString()));*/
|
||||
if (persons.size() > 0) {
|
||||
data.addError(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.person.already_added"));
|
||||
}
|
||||
|
||||
|
|
@ -290,4 +311,5 @@ public class GenericOrganizationalUnitPersonAddForm
|
|||
protected String getStatusAttributeName() {
|
||||
return "GenericOrganizationalUnitMemberStatus";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@ import org.apache.log4j.Logger;
|
|||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class GenericOrganizationalUnitPropertyForm
|
||||
extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
|
||||
private final static Logger s_log = Logger.getLogger(
|
||||
GenericOrganizationalUnitPropertyForm.class);
|
||||
GenericOrganizationalUnitPropertyForm.class);
|
||||
private GenericOrganizationalUnitPropertiesStep m_step;
|
||||
//public static final String NAME = GenericOrganizationalUnit.NAME;
|
||||
//public static final String ORGAUNIT_NAME = GenericOrganizationalUnit.ORGAUNIT_NAME;
|
||||
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
@ -87,7 +79,7 @@ public class GenericOrganizationalUnitPropertyForm
|
|||
@Override
|
||||
public void submitted(FormSectionEvent fse) throws FormProcessException {
|
||||
if ((m_step != null)
|
||||
&& getSaveCancelSection().getCancelButton().isSelected(fse.
|
||||
&& getSaveCancelSection().getCancelButton().isSelected(fse.
|
||||
getPageState())) {
|
||||
m_step.cancelStreamlinedCreation(fse.getPageState());
|
||||
}
|
||||
|
|
@ -96,9 +88,8 @@ public class GenericOrganizationalUnitPropertyForm
|
|||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) super.
|
||||
initBasicWidgets(fse);
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) super.
|
||||
initBasicWidgets(fse);
|
||||
|
||||
//data.put(NAME, orgaunit.getName());
|
||||
data.put(ADDENDUM, orgaunit.getAddendum());
|
||||
|
|
@ -108,17 +99,17 @@ public class GenericOrganizationalUnitPropertyForm
|
|||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
|
||||
GenericOrganizationalUnit orgaunit =
|
||||
(GenericOrganizationalUnit) super.
|
||||
processBasicWidgets(fse);
|
||||
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) super.
|
||||
processBasicWidgets(fse);
|
||||
|
||||
if ((orgaunit != null)
|
||||
&& getSaveCancelSection().getSaveButton().isSelected(fse.
|
||||
&& getSaveCancelSection().getSaveButton().isSelected(fse.
|
||||
getPageState())) {
|
||||
//orgaunit.setName((String) data.get(NAME));
|
||||
orgaunit.setAddendum((String) data.get(ADDENDUM));
|
||||
|
||||
orgaunit.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,27 +46,31 @@ 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>
|
||||
*/
|
||||
public class GenericPersonContactAddForm extends BasicItemForm {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
GenericPersonContactAddForm.class);
|
||||
GenericPersonContactAddForm.class);
|
||||
private GenericPersonPropertiesStep m_step;
|
||||
private ItemSearchWidget m_itemSearch;
|
||||
private SaveCancelSection m_saveCancelSection;
|
||||
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);
|
||||
|
|
@ -80,33 +86,44 @@ public class GenericPersonContactAddForm extends BasicItemForm {
|
|||
|
||||
// Attach a GenericContact object
|
||||
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.
|
||||
findByAssociatedObjectType(
|
||||
"com.arsdigita.cms.contenttypes.GenericContact"));
|
||||
findByAssociatedObjectType(
|
||||
"com.arsdigita.cms.contenttypes.GenericContact"));
|
||||
add(this.m_itemSearch);
|
||||
|
||||
// GenericContact type field
|
||||
add(new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericperson.contact.type")));
|
||||
ParameterModel contactTypeParam =
|
||||
new StringParameter(
|
||||
GenericPersonContactCollection.CONTACTS_KEY);
|
||||
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() {
|
||||
|
||||
// Add the Options to the SingleSelect widget
|
||||
GenericContactTypeCollection contacttypes =
|
||||
new GenericContactTypeCollection();
|
||||
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
|
||||
getLanguage());
|
||||
@Override
|
||||
public void prepare(final PrintEvent event) {
|
||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||
// Add the Options to the SingleSelect widget
|
||||
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()));
|
||||
while (contacttypes.next()) {
|
||||
RelationAttribute ct = contacttypes.getRelationAttribute();
|
||||
target.addOption(new Option(ct.getKey(), ct.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UncheckedWrapperException("Something has gone terribly wrong", ex);
|
||||
}
|
||||
|
||||
add(contactType);
|
||||
|
|
@ -126,17 +143,17 @@ public class GenericPersonContactAddForm extends BasicItemForm {
|
|||
final FormData data = fse.getFormData();
|
||||
final PageState state = fse.getPageState();
|
||||
GenericPerson person = (GenericPerson) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
getSelectedObject(state);
|
||||
|
||||
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {
|
||||
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
|
||||
|
||||
contact = (GenericContact) contact.getContentBundle().getInstance(
|
||||
person.getLanguage());
|
||||
person.getLanguage());
|
||||
|
||||
person.addContact(contact,
|
||||
(String) data.get(
|
||||
GenericPersonContactCollection.CONTACTS_KEY));
|
||||
GenericPersonContactCollection.CONTACTS_KEY));
|
||||
m_itemSearch.publishCreatedItem(data, contact);
|
||||
}
|
||||
|
||||
|
|
@ -150,38 +167,39 @@ public class GenericPersonContactAddForm extends BasicItemForm {
|
|||
|
||||
if (data.get(ITEM_SEARCH) == null) {
|
||||
data.addError(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericperson.select_contact.none_selected"));
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericperson.select_contact.none_selected"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
GenericPerson person = (GenericPerson) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
getSelectedObject(state);
|
||||
|
||||
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
|
||||
|
||||
if (!(contact.getContentBundle().hasInstance(person.getLanguage(),
|
||||
Kernel.getConfig().
|
||||
languageIndependentItems()))) {
|
||||
languageIndependentItems()))) {
|
||||
data.addError(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericperson.select_contact.no_suitable_language_variant"));
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericperson.select_contact.no_suitable_language_variant"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
contact = (GenericContact) contact.getContentBundle().getInstance(person.
|
||||
getLanguage());
|
||||
getLanguage());
|
||||
GenericPersonContactCollection contacts = person.getContacts();
|
||||
|
||||
contacts.addFilter(String.format("id = %s", contact.getID().toString()));
|
||||
if (contacts.size() > 0) {
|
||||
data.addError(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericperson.select_contact.already_added"));
|
||||
}
|
||||
|
||||
contacts.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,17 +46,17 @@ import java.util.Date;
|
|||
* @author Sören Bernstein <quasi@quasiweb.de>
|
||||
*/
|
||||
public class GenericPersonCreate extends PageCreate {
|
||||
|
||||
|
||||
private static final String SURNAME = GenericPerson.SURNAME;
|
||||
private static final String GIVENNAME = GenericPerson.GIVENNAME;
|
||||
private static final String TITLEPRE = GenericPerson.TITLEPRE;
|
||||
private static final String TITLEPOST = GenericPerson.TITLEPOST;
|
||||
|
||||
|
||||
public GenericPersonCreate(final ItemSelectionModel itemModel,
|
||||
final CreationSelector parent) {
|
||||
super(itemModel, parent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
ContentType type = getItemSelectionModel().getContentType();
|
||||
|
|
@ -64,21 +64,25 @@ 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);
|
||||
launchDateParam);
|
||||
launchDate.setLabel(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"));
|
||||
if (ContentSection.getConfig().getRequireLaunchDate()) {
|
||||
launchDate.addValidationListener(
|
||||
new LaunchDateValidationListener());
|
||||
new LaunchDateValidationListener());
|
||||
// if launch date is required, help user by suggesting today's date
|
||||
launchDateParam.setDefaultValue(new Date());
|
||||
}
|
||||
|
|
@ -88,11 +92,12 @@ 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 {
|
||||
public void validate(FormSectionEvent e) throws FormProcessException {
|
||||
Folder f = m_parent.getFolder(e.getPageState());
|
||||
Assert.exists(f);
|
||||
validateNameUniqueness(f, e, GenericPerson.urlSave(getItemName(e)));
|
||||
|
|
@ -105,10 +110,10 @@ public class GenericPersonCreate extends PageCreate {
|
|||
final PageState state = e.getPageState();
|
||||
final ContentSection section = m_parent.getContentSection(state);
|
||||
Folder folder = m_parent.getFolder(state);
|
||||
|
||||
|
||||
String fullName = getItemName(e);
|
||||
Assert.exists(section, ContentSection.class);
|
||||
|
||||
|
||||
final ContentPage item = createContentPage(state);
|
||||
item.setLanguage((String) data.get(LANGUAGE));
|
||||
item.setName(GenericPerson.urlSave(fullName));
|
||||
|
|
@ -116,21 +121,21 @@ public class GenericPersonCreate extends PageCreate {
|
|||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
item.setLaunchDate((Date) data.get(LAUNCH_DATE));
|
||||
}
|
||||
|
||||
|
||||
final GenericPersonBundle bundle = new GenericPersonBundle(item);
|
||||
bundle.setParent(folder);
|
||||
bundle.setContentSection(m_parent.getContentSection(state));
|
||||
bundle.save();
|
||||
|
||||
|
||||
m_workflowSection.applyWorkflow(state, item);
|
||||
|
||||
|
||||
GenericPerson person = new GenericPerson(item.getOID());
|
||||
person.setTitlePre(data.getString(TITLEPRE));
|
||||
person.setGivenName(data.getString(GIVENNAME));
|
||||
person.setSurname(data.getString(SURNAME));
|
||||
person.setTitlePost(data.getString(TITLEPOST));
|
||||
person.save();
|
||||
|
||||
|
||||
m_parent.editItem(state, item);
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +144,8 @@ public class GenericPersonCreate extends PageCreate {
|
|||
final FormData data = e.getFormData();
|
||||
String givenName = data.getString(GIVENNAME);
|
||||
String surname = data.getString(SURNAME);
|
||||
|
||||
|
||||
return String.format("%s %s", surname, givenName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,13 +48,12 @@ import org.apache.log4j.Logger;
|
|||
*
|
||||
* @author: Jens Pelzetter
|
||||
*/
|
||||
public class GenericPersonPropertyForm extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
public class GenericPersonPropertyForm extends BasicPageForm
|
||||
implements FormProcessListener,
|
||||
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;
|
||||
|
|
@ -68,20 +67,21 @@ public class GenericPersonPropertyForm extends BasicPageForm
|
|||
|
||||
/**
|
||||
* Constructor, creates an empty form.
|
||||
*
|
||||
* @param itemModel
|
||||
*
|
||||
* @param itemModel
|
||||
*/
|
||||
public GenericPersonPropertyForm(ItemSelectionModel itemModel) {
|
||||
public GenericPersonPropertyForm(final ItemSelectionModel itemModel) {
|
||||
this(itemModel, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor, creates an empty form.
|
||||
*
|
||||
* @param itemModel
|
||||
* @param step
|
||||
* @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,72 +98,72 @@ 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"))));
|
||||
"",
|
||||
new Label(GlobalizationUtil.globalize("cms.ui.select_one"))));
|
||||
gender.addOption(new Option(
|
||||
"f",
|
||||
new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericperson.gender.f"))));
|
||||
"f",
|
||||
new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericperson.gender.f"))));
|
||||
gender.addOption(new Option(
|
||||
"m",
|
||||
new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericperson.gender.m"))));
|
||||
"m",
|
||||
new Label(ContenttypesGlobalizationUtil.globalize(
|
||||
"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,29 +174,30 @@ 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())) {
|
||||
&& getSaveCancelSection().getCancelButton()
|
||||
.isSelected(fse.getPageState())) {
|
||||
m_step.cancelStreamlinedCreation(fse.getPageState());
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
.isSelected(fse.getPageState())) {
|
||||
.isSelected(fse.getPageState())) {
|
||||
person.setTitlePre((String) data.get(TITLEPRE));
|
||||
person.setSurname((String) data.get(SURNAME));
|
||||
person.setGivenName((String) data.get(GIVENNAME));
|
||||
person.setTitlePost((String) data.get(TITLEPOST));
|
||||
person.setBirthdate((Date) data.get(BIRTHDATE));
|
||||
person.setGender((String) data.get(GENDER));
|
||||
person.setDescription((String)data.get(DESCRIPTION));
|
||||
person.setDescription((String) data.get(DESCRIPTION));
|
||||
|
||||
person.save();
|
||||
}
|
||||
|
|
@ -205,5 +206,5 @@ public class GenericPersonPropertyForm extends BasicPageForm
|
|||
m_step.maybeForwardToNextStep(fse.getPageState());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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=
|
||||
|
|
|
|||
|
|
@ -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,19 +36,20 @@ 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;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A class representing a date field in an HTML form.
|
||||
* A class representing a date field in an HTML form.
|
||||
*
|
||||
* @author Karl Goldstein
|
||||
* @author Uday Mathur
|
||||
* @author Michael Pih
|
||||
* @author Sören Bernstein <quasi@quasiweb.de>
|
||||
* @version $Id: Date.java 288 2010-02-20 07:29:00Z sbernstein $
|
||||
* @author Karl Goldstein
|
||||
* @author Uday Mathur
|
||||
* @author Michael Pih
|
||||
* @author Sören Bernstein <quasi@quasiweb.de>
|
||||
* @version $Id: Date.java 288 2010-02-20 07:29:00Z sbernstein $
|
||||
*/
|
||||
public class Date extends Widget implements BebopConstants {
|
||||
|
||||
|
|
@ -58,19 +58,20 @@ public class Date extends Widget implements BebopConstants {
|
|||
protected TextField m_day;
|
||||
private int m_year_begin;
|
||||
private int m_year_end;
|
||||
private Locale m_locale;
|
||||
private Locale m_locale;
|
||||
|
||||
// Inner classes for the fragment widgets
|
||||
protected class YearFragment extends SingleSelect {
|
||||
|
||||
protected Date parent;
|
||||
private boolean autoCurrentYear; //Decide wether to set the current year if year is null
|
||||
|
||||
|
||||
public YearFragment(String name, Date parent) {
|
||||
super(name);
|
||||
this.parent = parent;
|
||||
setHint(GlobalizationUtil.globalize("bebop.date.year.hint"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ParameterData getParameterData(PageState ps) {
|
||||
Object value = getValue(ps);
|
||||
|
|
@ -79,7 +80,7 @@ public class Date extends Widget implements BebopConstants {
|
|||
}
|
||||
return new ParameterData(getParameterModel(), value);
|
||||
}
|
||||
|
||||
|
||||
public void setAutoCurrentYear(final boolean autoCurrentYear) {
|
||||
this.autoCurrentYear = autoCurrentYear;
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -170,7 +174,7 @@ public class Date extends Widget implements BebopConstants {
|
|||
|
||||
if (!(model instanceof DateParameter || model instanceof DateTimeParameter)) {
|
||||
throw new IllegalArgumentException(
|
||||
"The Date widget " + model.getName()
|
||||
"The Date widget " + model.getName()
|
||||
+ " must be backed by a DateParameter parmeter model");
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +206,7 @@ public class Date extends Widget implements BebopConstants {
|
|||
public void setAutoCurrentYear(final boolean autoCurrentYear) {
|
||||
((YearFragment) m_year).setAutoCurrentYear(autoCurrentYear);
|
||||
}
|
||||
|
||||
|
||||
public void setYearRange(int yearBegin, int yearEnd) {
|
||||
Assert.isUnlocked(this);
|
||||
if (yearBegin != m_year_begin || yearEnd != m_year_end) {
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,370 +46,373 @@ import org.apache.log4j.Logger;
|
|||
* @version $Id: OptionGroup.java 738 2005-09-01 12:36:52Z sskracic $
|
||||
*/
|
||||
public abstract class OptionGroup extends Widget
|
||||
implements BebopConstants {
|
||||
implements BebopConstants {
|
||||
|
||||
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.
|
||||
*/
|
||||
protected String m_xmlElement;
|
||||
// this only needs to be an ArrayList for multiple selection option groups
|
||||
private ArrayList m_selected;
|
||||
private ArrayList m_options;
|
||||
private Widget m_otherOption = null;
|
||||
private Form m_form = null;
|
||||
private boolean m_isDisabled = false;
|
||||
private boolean m_isReadOnly = false;
|
||||
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();
|
||||
}
|
||||
};
|
||||
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.
|
||||
*/
|
||||
protected String m_xmlElement;
|
||||
// this only needs to be an ArrayList for multiple selection option groups
|
||||
private ArrayList m_selected;
|
||||
private ArrayList m_options;
|
||||
private Widget m_otherOption = null;
|
||||
private Form m_form = null;
|
||||
private boolean m_isDisabled = false;
|
||||
private boolean m_isReadOnly = false;
|
||||
public static final String OTHER_OPTION = "__other__";
|
||||
// request-local copy of selected elements, options
|
||||
private RequestLocal m_requestOptions = new RequestLocal() {
|
||||
|
||||
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.";
|
||||
@Override
|
||||
public Object initialValue(PageState ps) {
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* The ParameterModel for mutliple OptionGroups is always an array parameter
|
||||
*/
|
||||
protected OptionGroup(ParameterModel model) {
|
||||
super(model);
|
||||
m_options = new ArrayList();
|
||||
m_selected = new ArrayList();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an Iterator of all the default Options in this group.
|
||||
*/
|
||||
public Iterator getOptions() {
|
||||
return m_options.iterator();
|
||||
}
|
||||
public final boolean isCompound() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
allOptions.addAll(m_options);
|
||||
ArrayList requestOptions = (ArrayList) m_requestOptions.get(ps);
|
||||
for (Iterator i = requestOptions.iterator(); i.hasNext();) {
|
||||
Object obj = i.next();
|
||||
if (!allOptions.contains(obj)) {
|
||||
allOptions.add(obj);
|
||||
}
|
||||
}
|
||||
return allOptions.iterator();
|
||||
}
|
||||
// this is only used for single selection option groups
|
||||
|
||||
public void clearOptions() {
|
||||
Assert.isUnlocked(this);
|
||||
m_options = new ArrayList();
|
||||
}
|
||||
private final static String TOO_MANY_OPTIONS_SELECTED
|
||||
= "Only one option may be selected by default on this option group.";
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void addOption(Option opt) {
|
||||
addOption(opt, null, false);
|
||||
}
|
||||
/**
|
||||
* The ParameterModel for mutliple OptionGroups is always an array parameter
|
||||
*/
|
||||
protected OptionGroup(ParameterModel model) {
|
||||
super(model);
|
||||
m_options = new ArrayList();
|
||||
m_selected = new ArrayList();
|
||||
}
|
||||
|
||||
public void addOption(Option opt, PageState ps) {
|
||||
addOption(opt, ps, false);
|
||||
}
|
||||
/**
|
||||
* Returns an Iterator of all the default Options in this group.
|
||||
*/
|
||||
public Iterator getOptions() {
|
||||
return m_options.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void prependOption(Option opt) {
|
||||
addOption(opt, null, true);
|
||||
}
|
||||
/**
|
||||
* 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();
|
||||
allOptions.addAll(m_options);
|
||||
ArrayList requestOptions = (ArrayList) m_requestOptions.get(ps);
|
||||
for (Iterator i = requestOptions.iterator(); i.hasNext();) {
|
||||
Object obj = i.next();
|
||||
if (!allOptions.contains(obj)) {
|
||||
allOptions.add(obj);
|
||||
}
|
||||
}
|
||||
return allOptions.iterator();
|
||||
}
|
||||
|
||||
public void prependOption(Option opt, PageState ps) {
|
||||
addOption(opt, ps, true);
|
||||
}
|
||||
public void clearOptions() {
|
||||
Assert.isUnlocked(this);
|
||||
m_options = new ArrayList();
|
||||
}
|
||||
|
||||
public void removeOption(Option opt) {
|
||||
removeOption(opt, null);
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void addOption(Option opt) {
|
||||
addOption(opt, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public void addOption(Option opt, PageState ps, boolean prepend) {
|
||||
ArrayList list = m_options;
|
||||
if (ps == null) {
|
||||
Assert.isUnlocked(this);
|
||||
} else {
|
||||
list = (ArrayList) m_requestOptions.get(ps);
|
||||
}
|
||||
opt.setGroup(this);
|
||||
public void addOption(Option opt, PageState ps) {
|
||||
addOption(opt, ps, false);
|
||||
}
|
||||
|
||||
if (prepend == true) {
|
||||
list.add(0, opt);
|
||||
} else {
|
||||
list.add(opt);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void prependOption(Option opt) {
|
||||
addOption(opt, null, true);
|
||||
}
|
||||
|
||||
public void removeOption(Option opt, PageState ps) {
|
||||
ArrayList list = m_options;
|
||||
if (ps == null) {
|
||||
Assert.isUnlocked(this);
|
||||
} else {
|
||||
list = (ArrayList) m_requestOptions.get(ps);
|
||||
}
|
||||
list.remove(opt);
|
||||
}
|
||||
public void prependOption(Option opt, PageState ps) {
|
||||
addOption(opt, ps, true);
|
||||
}
|
||||
|
||||
public void removeOption(String key) {
|
||||
removeOption(key, null);
|
||||
}
|
||||
public void removeOption(Option opt) {
|
||||
removeOption(opt, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first option whose key is isEqual to the key that is passed
|
||||
* in.
|
||||
*/
|
||||
public void removeOption(String key, PageState ps) {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public void addOption(Option opt, PageState ps, boolean prepend) {
|
||||
ArrayList list = m_options;
|
||||
if (ps == null) {
|
||||
Assert.isUnlocked(this);
|
||||
} else {
|
||||
list = (ArrayList) m_requestOptions.get(ps);
|
||||
}
|
||||
opt.setGroup(this);
|
||||
|
||||
if (prepend == true) {
|
||||
list.add(0, opt);
|
||||
} else {
|
||||
list.add(opt);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeOption(Option opt, PageState ps) {
|
||||
ArrayList list = m_options;
|
||||
if (ps == null) {
|
||||
Assert.isUnlocked(this);
|
||||
} else {
|
||||
list = (ArrayList) m_requestOptions.get(ps);
|
||||
}
|
||||
list.remove(opt);
|
||||
}
|
||||
|
||||
public void removeOption(String key) {
|
||||
removeOption(key, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
// efficient solution is to switch to using a HashMap.
|
||||
ArrayList list = m_options;
|
||||
if (ps == null) {
|
||||
Assert.isUnlocked(this);
|
||||
} else {
|
||||
list = (ArrayList) m_requestOptions.get(ps);
|
||||
}
|
||||
// efficient solution is to switch to using a HashMap.
|
||||
ArrayList list = m_options;
|
||||
if (ps == null) {
|
||||
Assert.isUnlocked(this);
|
||||
} else {
|
||||
list = (ArrayList) m_requestOptions.get(ps);
|
||||
}
|
||||
|
||||
Iterator i = list.iterator();
|
||||
Option o = null;
|
||||
while (i.hasNext()) {
|
||||
o = (Option) i.next();
|
||||
if (o.getValue().equals(key)) {
|
||||
list.remove(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Iterator i = list.iterator();
|
||||
Option o = null;
|
||||
while (i.hasNext()) {
|
||||
o = (Option) i.next();
|
||||
if (o.getValue().equals(key)) {
|
||||
list.remove(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an "Other (please specify)" type option to the 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.
|
||||
*/
|
||||
public void addOtherOption(String label, int width, int height) {
|
||||
Assert.isUnlocked(this);
|
||||
/**
|
||||
* Add an "Other (please specify)" type option to the 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.
|
||||
*/
|
||||
public void addOtherOption(String label, int width, int height) {
|
||||
Assert.isUnlocked(this);
|
||||
|
||||
Option otherOption = new Option(OTHER_OPTION, label);
|
||||
addOption(otherOption);
|
||||
Option otherOption = new Option(OTHER_OPTION, label);
|
||||
addOption(otherOption);
|
||||
|
||||
final ParameterModel model = getParameterModel();
|
||||
final ParameterModel model = getParameterModel();
|
||||
|
||||
if (1 == height) {
|
||||
TextField field =
|
||||
new TextField(model.getName() + ".other");
|
||||
field.setSize(width);
|
||||
if (1 == height) {
|
||||
TextField field = new TextField(model.getName() + ".other");
|
||||
field.setSize(width);
|
||||
|
||||
m_otherOption = field;
|
||||
} else {
|
||||
TextArea area =
|
||||
new TextArea(model.getName() + ".other");
|
||||
area.setCols(width);
|
||||
area.setRows(height);
|
||||
m_otherOption = field;
|
||||
} else {
|
||||
TextArea area = new TextArea(model.getName() + ".other");
|
||||
area.setCols(width);
|
||||
area.setRows(height);
|
||||
|
||||
m_otherOption = area;
|
||||
}
|
||||
m_otherOption = area;
|
||||
}
|
||||
|
||||
if (null != m_form) {
|
||||
m_otherOption.setForm(m_form);
|
||||
if (null != m_form) {
|
||||
m_otherOption.setForm(m_form);
|
||||
|
||||
if (m_isDisabled) {
|
||||
m_otherOption.setDisabled();
|
||||
}
|
||||
if (m_isReadOnly) {
|
||||
m_otherOption.setReadOnly();
|
||||
}
|
||||
}
|
||||
if (m_isDisabled) {
|
||||
m_otherOption.setDisabled();
|
||||
}
|
||||
if (m_isReadOnly) {
|
||||
m_otherOption.setReadOnly();
|
||||
}
|
||||
}
|
||||
|
||||
setParameterModel(new ParameterModelWrapper(model) {
|
||||
@Override
|
||||
public ParameterData createParameterData(final HttpServletRequest request,
|
||||
Object defaultValue,
|
||||
boolean isSubmission) {
|
||||
setParameterModel(new ParameterModelWrapper(model) {
|
||||
|
||||
final String[] values =
|
||||
request.getParameterValues(getName());
|
||||
String[] otherValues =
|
||||
request.getParameterValues(getName() + ".other");
|
||||
@Override
|
||||
public ParameterData createParameterData(final HttpServletRequest request,
|
||||
Object defaultValue,
|
||||
boolean isSubmission) {
|
||||
|
||||
String other = (null == otherValues) ? null : otherValues[0];
|
||||
final String[] values = request.getParameterValues(getName());
|
||||
String[] otherValues = request.getParameterValues(getName() + ".other");
|
||||
|
||||
if (null != values) {
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (OTHER_OPTION.equals(values[i])) {
|
||||
values[i] = other;
|
||||
}
|
||||
}
|
||||
}
|
||||
String other = (null == otherValues) ? null : otherValues[0];
|
||||
|
||||
s_log.debug("createParameterData in OptionGroup");
|
||||
if (null != values) {
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (OTHER_OPTION.equals(values[i])) {
|
||||
values[i] = other;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.createParameterData(new HttpServletRequestWrapper(request) {
|
||||
@Override
|
||||
public String[] getParameterValues(String key) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Getting values for " + key);
|
||||
}
|
||||
s_log.debug("createParameterData in OptionGroup");
|
||||
|
||||
if (model.getName().equals(key)) {
|
||||
return values;
|
||||
}
|
||||
return super.getParameterValues(key);
|
||||
}
|
||||
}, defaultValue, isSubmission);
|
||||
}
|
||||
return super.createParameterData(new HttpServletRequestWrapper(request) {
|
||||
|
||||
private void replaceOther(String[] values, String other) {
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public String[] getParameterValues(String key) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Getting values for " + key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void setOptionSelected(String value) {
|
||||
Assert.isUnlocked(this);
|
||||
if (!isMultiple()) {
|
||||
if (model.getName().equals(key)) {
|
||||
return values;
|
||||
}
|
||||
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.
|
||||
*
|
||||
* @param value the value of the option to be added to the by-default-selected set.
|
||||
*/
|
||||
public void setOptionSelected(String value) {
|
||||
Assert.isUnlocked(this);
|
||||
if (!isMultiple()) {
|
||||
// only one option may be selected
|
||||
// to this selected list better be empty
|
||||
Assert.isTrue(m_selected.size() == 0, TOO_MANY_OPTIONS_SELECTED);
|
||||
m_selected.add(value);
|
||||
getParameterModel().setDefaultValue(value);
|
||||
} else {
|
||||
m_selected.add(value);
|
||||
getParameterModel().setDefaultValue(m_selected.toArray());
|
||||
}
|
||||
}
|
||||
// to this selected list better be empty
|
||||
Assert.isTrue(m_selected.size() == 0, TOO_MANY_OPTIONS_SELECTED);
|
||||
m_selected.add(value);
|
||||
getParameterModel().setDefaultValue(value);
|
||||
} else {
|
||||
m_selected.add(value);
|
||||
getParameterModel().setDefaultValue(m_selected.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* make an option selected by default
|
||||
*
|
||||
* @param option the option to be added to the by-default-selected set.
|
||||
*/
|
||||
public void setOptionSelected(Option option) {
|
||||
setOptionSelected(option.getValue());
|
||||
}
|
||||
/**
|
||||
* make an option selected by default
|
||||
*
|
||||
* @param option the option to be added to the by-default-selected set.
|
||||
*/
|
||||
public void setOptionSelected(Option option) {
|
||||
setOptionSelected(option.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
OptionGroup cloned = (OptionGroup) super.clone();
|
||||
cloned.m_options = (ArrayList) m_options.clone();
|
||||
cloned.m_selected =
|
||||
(ArrayList) m_selected.clone();
|
||||
return cloned;
|
||||
}
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
OptionGroup cloned = (OptionGroup) super.clone();
|
||||
cloned.m_options = (ArrayList) m_options.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.
|
||||
*
|
||||
* @return true if this OptionGroup can have more than one selected option;
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean isMultiple() {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public boolean isMultiple() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisabled() {
|
||||
m_isDisabled = true;
|
||||
@Override
|
||||
public void setDisabled() {
|
||||
m_isDisabled = true;
|
||||
|
||||
if (null != m_otherOption) {
|
||||
m_otherOption.setDisabled();
|
||||
}
|
||||
if (null != m_otherOption) {
|
||||
m_otherOption.setDisabled();
|
||||
}
|
||||
|
||||
super.setDisabled();
|
||||
}
|
||||
super.setDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadOnly() {
|
||||
m_isReadOnly = true;
|
||||
@Override
|
||||
public void setReadOnly() {
|
||||
m_isReadOnly = true;
|
||||
|
||||
if (null != m_otherOption) {
|
||||
m_otherOption.setReadOnly();
|
||||
}
|
||||
if (null != m_otherOption) {
|
||||
m_otherOption.setReadOnly();
|
||||
}
|
||||
|
||||
super.setReadOnly();
|
||||
}
|
||||
super.setReadOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForm(Form form) {
|
||||
m_form = form;
|
||||
if (null != m_otherOption) {
|
||||
m_otherOption.setForm(form);
|
||||
}
|
||||
@Override
|
||||
public void setForm(Form form) {
|
||||
m_form = form;
|
||||
if (null != m_otherOption) {
|
||||
m_otherOption.setForm(form);
|
||||
}
|
||||
|
||||
super.setForm(form);
|
||||
}
|
||||
super.setForm(form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the DOM for the select widget <p>Generates DOM fragment: <p><pre><code><bebop:* name=... [onXXX=...]>
|
||||
/**
|
||||
* Generates the DOM for the select widget
|
||||
* <p>
|
||||
* Generates DOM fragment:
|
||||
* <p>
|
||||
* <pre><code><bebop:* name=... [onXXX=...]>
|
||||
* <bebop:option name=... [selected]> option value </bebop:option%gt;
|
||||
* ...
|
||||
* </bebop:*select></code></pre>
|
||||
*/
|
||||
@Override
|
||||
public void generateWidget(PageState state, Element parent) {
|
||||
Element optionGroup =
|
||||
parent.newChildElement(getElementTag(), BEBOP_XML_NS);
|
||||
optionGroup.addAttribute("name", getName());
|
||||
optionGroup.addAttribute("class", getName().replace(".", " "));
|
||||
if (isMultiple()) {
|
||||
optionGroup.addAttribute("multiple", "multiple");
|
||||
}
|
||||
exportAttributes(optionGroup);
|
||||
* ...
|
||||
* </bebop:*select></code></pre>
|
||||
*/
|
||||
@Override
|
||||
public void generateWidget(PageState state, Element parent) {
|
||||
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");
|
||||
}
|
||||
exportAttributes(optionGroup);
|
||||
|
||||
for (Iterator i = getOptions(state); i.hasNext();) {
|
||||
Option o = (Option) i.next();
|
||||
o.generateXML(state, optionGroup);
|
||||
}
|
||||
for (Iterator i = getOptions(state); i.hasNext();) {
|
||||
Option o = (Option) i.next();
|
||||
o.generateXML(state, optionGroup);
|
||||
}
|
||||
|
||||
if (null != m_otherOption) {
|
||||
m_otherOption.generateXML(state, optionGroup);
|
||||
}
|
||||
}
|
||||
|
||||
if (null != m_otherOption) {
|
||||
m_otherOption.generateXML(state, optionGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
Loading…
Reference in New Issue