CT GenericContact

* Links zum Bearbeiten / Löschen einer Adresse werden nun entsprechend dem Status ein- bzw. ausgeblendet
 * Fehlerhafte GlobalizationString korrigiert

IncompleteDateParameter

 * Monate beginnen in der Java Date-Klasse mit 0 nicht mit 1

CT Image

 * Fehlerhaften Traversal-adapter korrigiert

CCM allgemein

 * diverse kleine Änderungen / Schönheitskorrekturen, usw.
 * cms-item Traversal-Adapter angepaßt

git-svn-id: https://svn.libreccm.org/ccm/trunk@816 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2011-04-03 12:54:10 +00:00
parent 3f6e7f6f5e
commit 56121d8707
17 changed files with 165 additions and 114 deletions

View File

@ -13,25 +13,4 @@
</xrd:associations> </xrd:associations>
</xrd:adapter> </xrd:adapter>
</xrd:context> </xrd:context>
<!-- Next the metadata for search -->
<xrd:context name="com.arsdigita.cms.search.ContentPageMetadataProvider">
<!-- Content item is the simplest type -->
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.Image" extends="com.arsdigita.cms.ContentItem" traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
<xrd:attributes rule="exclude">
<xrd:property name="/object/textAsset/id"/>
<xrd:property name="/object/textAsset/defaultDomainClass"/>
<xrd:property name="/object/textAsset/objectType"/>
<xrd:property name="/object/textAsset/displayName"/>
<xrd:property name="/object/textAsset/ancestors"/>
<xrd:property name="/object/textAsset/version"/>
<xrd:property name="/object/textAsset/name"/>
<xrd:property name="/object/textAsset/language"/>
<xrd:property name="/object/textAsset/isDeleted"/>
</xrd:attributes>
<xrd:associations rule="include">
<xrd:property name="/object/textAsset"/>
</xrd:associations>
</xrd:adapter>
</xrd:context>
</xrd:adapters> </xrd:adapters>

View File

@ -85,6 +85,8 @@
</xrd:adapter> </xrd:adapter>
<!-- Adds several image assets --> <!-- Adds several image assets -->
<!-- Quasimodo: Ich denke, das ist jetzt unnötig -->
<!--
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.GenericArticle" extends="com.arsdigita.cms.contenttypes.GenericArticle" traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter"> <xrd:adapter objectType="com.arsdigita.cms.contenttypes.GenericArticle" extends="com.arsdigita.cms.contenttypes.GenericArticle" traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
<xrd:attributes rule="exclude"> <xrd:attributes rule="exclude">
<xrd:property name="/object/imageCaptions/id"/> <xrd:property name="/object/imageCaptions/id"/>
@ -98,8 +100,10 @@
<xrd:property name="/object/imageCaptions/language"/> <xrd:property name="/object/imageCaptions/language"/>
<xrd:property name="/object/imageCaptions/imageId"/> <xrd:property name="/object/imageCaptions/imageId"/>
<xrd:property name="/object/imageCaptions/articleId"/> <xrd:property name="/object/imageCaptions/articleId"/>
-->
<!-- XXX change /cms-service to take OID --> <!-- XXX change /cms-service to take OID -->
<!--<xrd:property name="/object/imageCaptions/imageAsset/id"/>--> <!--<xrd:property name="/object/imageCaptions/imageAsset/id"/>-->
<!--
<xrd:property name="/object/imageCaptions/imageAsset/defaultDomainClass"/> <xrd:property name="/object/imageCaptions/imageAsset/defaultDomainClass"/>
<xrd:property name="/object/imageCaptions/imageAsset/objectType"/> <xrd:property name="/object/imageCaptions/imageAsset/objectType"/>
<xrd:property name="/object/imageCaptions/imageAsset/displayName"/> <xrd:property name="/object/imageCaptions/imageAsset/displayName"/>
@ -118,6 +122,7 @@
<xrd:property name="/object/imageCaptions/imageAsset/mimeType"/> <xrd:property name="/object/imageCaptions/imageAsset/mimeType"/>
</xrd:associations> </xrd:associations>
</xrd:adapter> </xrd:adapter>
-->
</xrd:context> </xrd:context>

View File

@ -17,6 +17,7 @@ import com.arsdigita.domain.DomainObject;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.cms.contenttypes.GenericAddress; import com.arsdigita.cms.contenttypes.GenericAddress;
import com.arsdigita.cms.contenttypes.GenericContact; import com.arsdigita.cms.contenttypes.GenericContact;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
@ -33,6 +34,8 @@ public class GenericContactAddressPropertiesStep extends SimpleEditStep {
public static final String CHANGE_ADDRESS_SHEET_NAME = "changeAddress"; public static final String CHANGE_ADDRESS_SHEET_NAME = "changeAddress";
public static final String DELETE_ADDRESS_SHEET_NAME = "deleteAddress"; public static final String DELETE_ADDRESS_SHEET_NAME = "deleteAddress";
private ItemSelectionModel itemModel;
/** Creates a new instance of GenericContactAddressPropertiesStep */ /** Creates a new instance of GenericContactAddressPropertiesStep */
public GenericContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { public GenericContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
this(itemModel, parent, ""); this(itemModel, parent, "");
@ -41,31 +44,20 @@ public class GenericContactAddressPropertiesStep extends SimpleEditStep {
public GenericContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) { public GenericContactAddressPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent, String prefix) {
super(itemModel, parent, prefix); super(itemModel, parent, prefix);
// GenericContact contact = (GenericContact)itemModel.getSelectedObject(state); this.itemModel = itemModel;
//XXX
// if(/*contact.getAddress() == null*/ true) {
BasicPageForm attachAddressSheet = new GenericContactAttachAddressPropertyForm(itemModel, this); BasicPageForm attachAddressSheet = new GenericContactAttachAddressPropertyForm(itemModel, this);
add(ADD_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.attach_address").localize(), new WorkflowLockedComponentAccess(attachAddressSheet, itemModel), attachAddressSheet.getSaveCancelSection().getCancelButton()); BasicPageForm reattachAddressSheet = new GenericContactAttachAddressPropertyForm(itemModel, this);
/* Set the displayComponent for this step */
// setDisplayComponent(getEmptyBaseAddressPropertySheet(itemModel));
// } else {
// editAddress
BasicPageForm editAddressSheet = new GenericContactEditAddressPropertyForm(itemModel, this); BasicPageForm editAddressSheet = new GenericContactEditAddressPropertyForm(itemModel, this);
add(EDIT_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.edit_address").localize(), new WorkflowLockedComponentAccess(editAddressSheet, itemModel), editAddressSheet.getSaveCancelSection().getCancelButton());
// BasicPageForm attachAddressSheet = new GenericContactAttachAddressPropertyForm(itemModel, this);
// add(CHANGE_ADDRESS_SHEET_NAME, (String)ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.reattach_address").localize(), new WorkflowLockedComponentAccess(attachAddressSheet, itemModel), attachAddressSheet.getSaveCancelSection().getCancelButton());
BasicPageForm deleteAddressSheet = new GenericContactDeleteAddressForm(itemModel, this); BasicPageForm deleteAddressSheet = new GenericContactDeleteAddressForm(itemModel, this);
add(DELETE_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.delete_address").localize(), new WorkflowLockedComponentAccess(deleteAddressSheet, itemModel), deleteAddressSheet.getSaveCancelSection().getCancelButton());
add(ADD_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.attach_address").localize(), new AttachAddressWorkflowLockedComponentAccess(attachAddressSheet, itemModel), attachAddressSheet.getSaveCancelSection().getCancelButton());
add(CHANGE_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.reattach_address").localize(), new EditAddressWorkflowLockedComponentAccess(reattachAddressSheet, itemModel), reattachAddressSheet.getSaveCancelSection().getCancelButton());
add(EDIT_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.edit_address").localize(), new EditAddressWorkflowLockedComponentAccess(editAddressSheet, itemModel), editAddressSheet.getSaveCancelSection().getCancelButton());
add(DELETE_ADDRESS_SHEET_NAME, (String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.delete_address").localize(), new EditAddressWorkflowLockedComponentAccess(deleteAddressSheet, itemModel), deleteAddressSheet.getSaveCancelSection().getCancelButton());
/* Set the displayComponent for this step */ /* Set the displayComponent for this step */
setDisplayComponent(getAddressPropertySheet(itemModel)); setDisplayComponent(getAddressPropertySheet(itemModel));
// }
} }
@ -87,12 +79,13 @@ public class GenericContactAddressPropertiesStep extends SimpleEditStep {
"address." + GenericAddress.ISO_COUNTRY_CODE, "address." + GenericAddress.ISO_COUNTRY_CODE,
new DomainObjectPropertySheet.AttributeFormatter() { new DomainObjectPropertySheet.AttributeFormatter() {
@Override
public String format(DomainObject item, public String format(DomainObject item,
String attribute, String attribute,
PageState state) { PageState state) {
GenericAddress Address = ((GenericContact) item).getAddress(); GenericAddress Address = ((GenericContact) item).getAddress();
if (Address != null && Address.getIsoCountryCode() != null) { if (Address != null && Address.getIsoCountryCode() != null) {
return Address.getCountryNameFromIsoCode(Address.getIsoCountryCode()); return GenericAddress.getCountryNameFromIsoCode(Address.getIsoCountryCode());
} else { } else {
return (String) ContenttypesGlobalizationUtil.globalize("cms.ui.unknown").localize(); return (String) ContenttypesGlobalizationUtil.globalize("cms.ui.unknown").localize();
} }
@ -107,4 +100,32 @@ public class GenericContactAddressPropertiesStep extends SimpleEditStep {
public static Component getEmptyBaseAddressPropertySheet(ItemSelectionModel itemModel) { public static Component getEmptyBaseAddressPropertySheet(ItemSelectionModel itemModel) {
return new Label(((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.emptyAddress").localize())); return new Label(((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.contact.emptyAddress").localize()));
} }
private class EditAddressWorkflowLockedComponentAccess extends WorkflowLockedComponentAccess {
public EditAddressWorkflowLockedComponentAccess(Component c, ItemSelectionModel i) {
super(c, i);
}
@Override
public boolean isVisible(PageState state) {
GenericContact contact = (GenericContact) itemModel.getSelectedObject(state);
return contact.hasAddress();
}
}
private class AttachAddressWorkflowLockedComponentAccess extends WorkflowLockedComponentAccess {
public AttachAddressWorkflowLockedComponentAccess(Component c, ItemSelectionModel i) {
super(c, i);
}
@Override
public boolean isVisible(PageState state) {
GenericContact contact = (GenericContact) itemModel.getSelectedObject(state);
return !contact.hasAddress();
}
}
} }

View File

@ -83,6 +83,7 @@ public class GenericContactAttachAddressPropertyForm extends BasicPageForm imple
add(this.m_itemSearch); add(this.m_itemSearch);
} }
@Override
public void init(FormSectionEvent fse) { public void init(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
@ -95,6 +96,7 @@ public class GenericContactAttachAddressPropertyForm extends BasicPageForm imple
} }
} }
@Override
public void process(FormSectionEvent fse) { public void process(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
@ -115,6 +117,7 @@ public class GenericContactAttachAddressPropertyForm extends BasicPageForm imple
try { try {
getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() { getSaveCancelSection().getSaveButton().addPrintListener(new PrintListener() {
@Override
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
GenericContact contact = (GenericContact)getItemSelectionModel().getSelectedObject(e.getPageState()); GenericContact contact = (GenericContact)getItemSelectionModel().getSelectedObject(e.getPageState());
Submit target = (Submit) e.getTarget(); Submit target = (Submit) e.getTarget();
@ -138,6 +141,7 @@ public class GenericContactAttachAddressPropertyForm extends BasicPageForm imple
} }
} }
@Override
public void submitted(FormSectionEvent e) throws FormProcessException { public void submitted(FormSectionEvent e) throws FormProcessException {
if (getSaveCancelSection().getCancelButton().isSelected(e.getPageState())) { if (getSaveCancelSection().getCancelButton().isSelected(e.getPageState())) {
init(e); init(e);

View File

@ -78,7 +78,7 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm impleme
@Override @Override
public void addWidgets() { public void addWidgets() {
add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.address").localize())); add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.address.address").localize()));
ParameterModel addressParam = new StringParameter(ADDRESS); ParameterModel addressParam = new StringParameter(ADDRESS);
addressParam.addParameterListener(new NotNullValidationListener()); addressParam.addParameterListener(new NotNullValidationListener());
addressParam.addParameterListener(new StringInRangeValidationListener(0, 1000)); addressParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
@ -88,27 +88,27 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm impleme
add(address); add(address);
if (!GenericContact.getConfig().getHideAddressPostalCode()) { if (!GenericContact.getConfig().getHideAddressPostalCode()) {
add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.postal_code").localize())); add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.address.postal_code").localize()));
ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE); ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE);
TextField postalCode = new TextField(postalCodeParam); TextField postalCode = new TextField(postalCodeParam);
/* XXX NumberListener ?*/ /* XXX NumberListener ?*/
add(postalCode); add(postalCode);
} }
add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.city").localize())); add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.address.city").localize()));
ParameterModel cityParam = new StringParameter(CITY); ParameterModel cityParam = new StringParameter(CITY);
TextField city = new TextField(cityParam); TextField city = new TextField(cityParam);
add(city); add(city);
if (!GenericContact.getConfig().getHideAddressState()) { if (!GenericContact.getConfig().getHideAddressState()) {
add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.state").localize())); add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.address.state").localize()));
ParameterModel stateParam = new StringParameter(STATE); ParameterModel stateParam = new StringParameter(STATE);
TextField state = new TextField(stateParam); TextField state = new TextField(stateParam);
add(state); add(state);
} }
if (!GenericContact.getConfig().getHideAddressCountry()) { if (!GenericContact.getConfig().getHideAddressCountry()) {
add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.baseAddress.iso_country_code").localize())); add(new Label((String) ContenttypesGlobalizationUtil.globalize("cms.contenttypes.ui.address.iso_country_code").localize()));
ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE); ParameterModel countryParam = new StringParameter(ISO_COUNTRY_CODE);
countryParam.addParameterListener(new StringInRangeValidationListener(0, 2)); countryParam.addParameterListener(new StringInRangeValidationListener(0, 2));
@ -125,6 +125,7 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm impleme
country.addValidationListener( country.addValidationListener(
new ParameterListener() { new ParameterListener() {
@Override
public void validate(ParameterEvent e) throws FormProcessException { public void validate(ParameterEvent e) throws FormProcessException {
ParameterData data = e.getParameterData(); ParameterData data = e.getParameterData();
String isoCode = (String) data.getValue(); String isoCode = (String) data.getValue();
@ -139,6 +140,7 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm impleme
} }
@Override
public void init(FormSectionEvent fse) { public void init(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
@ -155,6 +157,7 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm impleme
} }
} }
@Override
public void submitted(FormSectionEvent fse) { public void submitted(FormSectionEvent fse) {
if (m_step != null if (m_step != null
&& getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) { && getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
@ -162,18 +165,13 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm impleme
} }
} }
@Override
public void process(FormSectionEvent fse) { public void process(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
GenericContact contact = (GenericContact) getItemSelectionModel().getSelectedObject(state); GenericContact contact = (GenericContact) getItemSelectionModel().getSelectedObject(state);
if (getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) { if (getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
// if (contact.getAddress() == null) {
// contact.setAddress(new GenericAddress());
// contact.getAddress().setName("Address for " + contact.getName() + "(" + contact.getID() + ")");
// contact.getAddress().setTitle("Address for " + contact.getName() + "(" + contact.getID() + ")");
// }
contact.getAddress().setAddress((String) data.get(ADDRESS)); contact.getAddress().setAddress((String) data.get(ADDRESS));
contact.getAddress().setPostalCode((String) data.get(POSTAL_CODE)); contact.getAddress().setPostalCode((String) data.get(POSTAL_CODE));
contact.getAddress().setCity((String) data.get(CITY)); contact.getAddress().setCity((String) data.get(CITY));

View File

@ -140,6 +140,7 @@ public class ImageBrowser extends Table {
public static abstract class LinkActionListener public static abstract class LinkActionListener
extends TableActionAdapter { extends TableActionAdapter {
@Override
public void cellSelected(TableActionEvent e) { public void cellSelected(TableActionEvent e) {
int c = e.getColumn().intValue(); int c = e.getColumn().intValue();
if (c == LINK) { if (c == LINK) {
@ -157,6 +158,7 @@ public class ImageBrowser extends Table {
// Renders a static image for the current asset // Renders a static image for the current asset
private class ThumbnailCellRenderer implements TableCellRenderer { private class ThumbnailCellRenderer implements TableCellRenderer {
@Override
public Component getComponent(Table table, PageState state, Object value, public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key, boolean isSelected, Object key,
int row, int column) { int row, int column) {
@ -232,6 +234,7 @@ public class ImageBrowser extends Table {
m_builder = b; m_builder = b;
} }
@Override
public TableModel makeModel(Table t, PageState s) { public TableModel makeModel(Table t, PageState s) {
return new ImageModelAdapter( return new ImageModelAdapter(
m_builder.makeModel((ImageBrowser) t, s)); m_builder.makeModel((ImageBrowser) t, s));
@ -253,14 +256,17 @@ public class ImageBrowser extends Table {
m_model = m; m_model = m;
} }
@Override
public int getColumnCount() { public int getColumnCount() {
return ImageBrowser.NUM_COLUMNS; return ImageBrowser.NUM_COLUMNS;
} }
@Override
public boolean nextRow() { public boolean nextRow() {
return m_model.nextRow(); return m_model.nextRow();
} }
@Override
public Object getElementAt(int columnIndex) { public Object getElementAt(int columnIndex) {
ImageAsset a = m_model.getImageAsset(); ImageAsset a = m_model.getImageAsset();
@ -311,6 +317,7 @@ public class ImageBrowser extends Table {
} }
} }
@Override
public Object getKeyAt(int columnIndex) { public Object getKeyAt(int columnIndex) {
return m_model.getImageAsset().getID(); return m_model.getImageAsset().getID();
} }

View File

@ -28,11 +28,9 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.ParameterEvent; import com.arsdigita.bebop.event.ParameterEvent;
import com.arsdigita.bebop.event.ParameterListener; import com.arsdigita.bebop.event.ParameterListener;
//import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.parameters.DateParameter; import com.arsdigita.bebop.parameters.DateParameter;
import com.arsdigita.bebop.parameters.ParameterData; import com.arsdigita.bebop.parameters.ParameterData;
import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.ParameterModel;
//import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
@ -213,6 +211,7 @@ public abstract class BasicPageForm extends BasicItemForm {
*/ */
public class LaunchDateValidationListener implements ParameterListener { public class LaunchDateValidationListener implements ParameterListener {
@Override
public void validate(final ParameterEvent e) { public void validate(final ParameterEvent e) {
final ParameterData data = e.getParameterData(); final ParameterData data = e.getParameterData();

View File

@ -31,6 +31,7 @@ import com.arsdigita.categorization.Category;
import com.arsdigita.categorization.CategoryCollection; import com.arsdigita.categorization.CategoryCollection;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import java.util.Arrays;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
@ -54,13 +55,16 @@ public class CategoryWidget extends Widget {
m_mode = mode; m_mode = mode;
} }
@Override
protected String getType() { protected String getType() {
return "category"; return "category";
} }
@Override
public boolean isCompound() { public boolean isCompound() {
return false; return false;
} }
@Override
protected void generateWidget(PageState state, protected void generateWidget(PageState state,
Element parent) { Element parent) {
Element widget = parent.newChildElement("cms:categoryWidget", Element widget = parent.newChildElement("cms:categoryWidget",
@ -74,9 +78,7 @@ public class CategoryWidget extends Widget {
BigDecimal[] values = (BigDecimal[])getValue(state); BigDecimal[] values = (BigDecimal[])getValue(state);
if (values != null) { if (values != null) {
for (int i = 0 ; i < values.length ; i++) { ids.addAll(Arrays.asList(values));
ids.add(values[i]);
}
} }
Category root = (Category)DomainObjectFactory.newInstance( Category root = (Category)DomainObjectFactory.newInstance(
@ -132,8 +134,10 @@ public class CategoryWidget extends Widget {
String fullname = path == null ? "/" : path + " > " + cat.getName(); String fullname = path == null ? "/" : path + " > " + cat.getName();
el.addAttribute("fullname", fullname); el.addAttribute("fullname", fullname);
StringBuffer nodeID = new StringBuffer(parent.getAttribute("node-id")); StringBuilder nodeID = new StringBuilder(parent.getAttribute("node-id"));
if (nodeID.length() > 0) nodeID.append("-"); if (nodeID.length() > 0) {
nodeID.append("-");
}
nodeID.append(cat.getID()); nodeID.append(cat.getID());
el.addAttribute("node-id", nodeID.toString()); el.addAttribute("node-id", nodeID.toString());
parent.addContent(el); parent.addContent(el);

View File

@ -124,6 +124,7 @@ public class CreationSelector extends MetaForm {
} }
@Override
public Form buildForm(PageState state) { public Form buildForm(PageState state) {
BigDecimal typeID = (BigDecimal)m_typeSel.getSelectedKey(state); BigDecimal typeID = (BigDecimal)m_typeSel.getSelectedKey(state);
Component c = null; Component c = null;
@ -151,6 +152,7 @@ public class CreationSelector extends MetaForm {
} }
// Add the item_id parameter // Add the item_id parameter
@Override
public void register(Page p) { public void register(Page p) {
super.register(p); super.register(p);
p.addComponentStateParam(this, m_itemId); p.addComponentStateParam(this, m_itemId);

View File

@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionEvent;
@ -120,6 +119,7 @@ public class SimpleEditStep extends SecurityPropertyEditor
parent.getList().addActionListener(new ActionListener() { parent.getList().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
showDisplayPane(state); showDisplayPane(state);
@ -140,6 +140,7 @@ public class SimpleEditStep extends SecurityPropertyEditor
* Registers globa state param for cancelling streamlined * Registers globa state param for cancelling streamlined
* creation * creation
*/ */
@Override
public void register(Page p) { public void register(Page p) {
super.register(p); super.register(p);
p.addGlobalStateParam(m_streamlinedCreationParam); p.addGlobalStateParam(m_streamlinedCreationParam);
@ -200,6 +201,7 @@ public class SimpleEditStep extends SecurityPropertyEditor
* *
* @param state the PageState * @param state the PageState
*/ */
@Override
public void pageRequested(RequestEvent e) { public void pageRequested(RequestEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms.ui.category; package com.arsdigita.cms.ui.category;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
@ -47,8 +46,7 @@ import org.apache.log4j.Logger;
*/ */
public class CategoryLocalizationAddForm extends CategoryLocalizationForm { public class CategoryLocalizationAddForm extends CategoryLocalizationForm {
private static final Logger s_log = Logger.getLogger private static final Logger s_log = Logger.getLogger(CategoryAddForm.class);
(CategoryAddForm.class);
/** Creates a new instance of CategoryLocalizationAddForm */ /** Creates a new instance of CategoryLocalizationAddForm */
public CategoryLocalizationAddForm(final CategoryRequestLocal category) { public CategoryLocalizationAddForm(final CategoryRequestLocal category) {
@ -65,8 +63,8 @@ public class CategoryLocalizationAddForm extends CategoryLocalizationForm {
// public boolean isVisible(PageState state) { // public boolean isVisible(PageState state) {
// return !m_category.getCategory(state).isRoot(); // return !m_category.getCategory(state).isRoot();
// } // }
private class InitListener implements FormInitListener { private class InitListener implements FormInitListener {
public final void init(final FormSectionEvent e) public final void init(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
@ -82,12 +80,12 @@ public class CategoryLocalizationAddForm extends CategoryLocalizationForm {
KernelConfig kernelConfig = Kernel.getConfig(); KernelConfig kernelConfig = Kernel.getConfig();
StringTokenizer strTok = kernelConfig.getSupportedLanguagesTokenizer(); StringTokenizer strTok = kernelConfig.getSupportedLanguagesTokenizer();
while(strTok.hasMoreTokens()) { while (strTok.hasMoreTokens()) {
String code = strTok.nextToken(); String code = strTok.nextToken();
// If lanuage exists, remove it from the selection list // If lanuage exists, remove it from the selection list
if(!category.getCategoryLocalizationCollection(). if (!category.getCategoryLocalizationCollection().
localizationExists(code)) { localizationExists(code)) {
m_locale.addOption(new Option(code, m_locale.addOption(new Option(code,
new Locale(code).getDisplayLanguage()), state); new Locale(code).getDisplayLanguage()), state);
@ -96,8 +94,8 @@ public class CategoryLocalizationAddForm extends CategoryLocalizationForm {
} }
} }
private final class ProcessListener implements FormProcessListener { private final class ProcessListener implements FormProcessListener {
public final void process(final FormSectionEvent e) public final void process(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
s_log.debug("Adding a categoryLocalization to category " + m_category); s_log.debug("Adding a categoryLocalization to category " + m_category);
@ -115,8 +113,8 @@ public class CategoryLocalizationAddForm extends CategoryLocalizationForm {
//Assert.assertNotNull(parent, "Category parent"); //Assert.assertNotNull(parent, "Category parent");
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Adding localization for locale " + locale + s_log.debug("Adding localization for locale " + locale
" to category " + category); + " to category " + category);
} }
if (category.canEdit()) { if (category.canEdit()) {

View File

@ -229,6 +229,7 @@ public class FolderManipulator extends SimpleContainer
return m_itemView.getBrowser(); return m_itemView.getBrowser();
} }
@Override
public void process(FormSectionEvent e) { public void process(FormSectionEvent e) {
PageState s = e.getPageState(); PageState s = e.getPageState();
if ( e.getSource() == m_itemView ) { if ( e.getSource() == m_itemView ) {
@ -249,6 +250,7 @@ public class FolderManipulator extends SimpleContainer
} }
} }
@Override
public void validate(FormSectionEvent e) { public void validate(FormSectionEvent e) {
ContentItem item; ContentItem item;
String name; String name;
@ -308,6 +310,7 @@ public class FolderManipulator extends SimpleContainer
} }
} }
@Override
public void submitted(FormSectionEvent e) public void submitted(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
PageState s = e.getPageState(); PageState s = e.getPageState();
@ -317,6 +320,7 @@ public class FolderManipulator extends SimpleContainer
} }
} }
@Override
public void reset(PageState s) { public void reset(PageState s) {
m_itemView.setVisible(s, true); m_itemView.setVisible(s, true);
m_itemView.reset(s); m_itemView.reset(s);
@ -342,6 +346,7 @@ public class FolderManipulator extends SimpleContainer
m_folderTree.setCellRenderer (new FolderTreeCellRenderer()); m_folderTree.setCellRenderer (new FolderTreeCellRenderer());
Label l = new Label(new PrintListener() { Label l = new Label(new PrintListener() {
@Override
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
PageState s = e.getPageState(); PageState s = e.getPageState();
Label t = (Label) e.getTarget(); Label t = (Label) e.getTarget();
@ -389,6 +394,7 @@ public class FolderManipulator extends SimpleContainer
} }
} }
@Override
public void reset(PageState s) { public void reset(PageState s) {
m_folderTree.clearSelection(s); m_folderTree.clearSelection(s);
// FIXME: add a reset method to Tree and call that instead of this // FIXME: add a reset method to Tree and call that instead of this
@ -461,6 +467,7 @@ public class FolderManipulator extends SimpleContainer
return m_browser; return m_browser;
} }
@Override
public void reset(PageState s) { public void reset(PageState s) {
m_checkboxGroup.setValue(s, null); m_checkboxGroup.setValue(s, null);
m_actionSel.setValue(s, null); m_actionSel.setValue(s, null);
@ -469,6 +476,7 @@ public class FolderManipulator extends SimpleContainer
// The renderer for the first column in the itemView table // The renderer for the first column in the itemView table
private class CheckboxRenderer implements TableCellRenderer { private class CheckboxRenderer implements TableCellRenderer {
@Override
public Component getComponent(Table table, PageState state, Object value, public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key, boolean isSelected, Object key,
int row, int column) { int row, int column) {
@ -501,6 +509,7 @@ public class FolderManipulator extends SimpleContainer
* are control links. Invalid folders are: the parent folder of the * are control links. Invalid folders are: the parent folder of the
* sources, any of the sources, and any subfolders of the sources. * sources, any of the sources, and any subfolders of the sources.
*/ */
@Override
public Component getComponent (Tree tree, PageState state, Object value, public Component getComponent (Tree tree, PageState state, Object value,
boolean isSelected, boolean isExpanded, boolean isSelected, boolean isExpanded,
boolean isLeaf, Object key) { boolean isLeaf, Object key) {

View File

@ -39,8 +39,8 @@ public class WorkflowLockedComponentAccess extends ComponentAccess {
private static final Logger s_log = private static final Logger s_log =
Logger.getLogger(WorkflowLockedComponentAccess.class); Logger.getLogger(WorkflowLockedComponentAccess.class);
ItemSelectionModel m_itemModel; ItemSelectionModel m_itemModel;
/** /**
* @param c The component * @param c The component
*/ */
@ -54,7 +54,7 @@ public class WorkflowLockedComponentAccess extends ComponentAccess {
* @param check An access check * @param check An access check
*/ */
public WorkflowLockedComponentAccess(Component c, String check, ItemSelectionModel i) { public WorkflowLockedComponentAccess(Component c, String check, ItemSelectionModel i) {
super(c,check); super(c, check);
m_itemModel = i; m_itemModel = i;
} }
@ -68,22 +68,37 @@ public class WorkflowLockedComponentAccess extends ComponentAccess {
* the access checks * the access checks
* @return true if all the access checks pass, false otherwise * @return true if all the access checks pass, false otherwise
* */ * */
@Override
public boolean canAccess(PageState state, Security security) { public boolean canAccess(PageState state, Security security) {
SecurityManager sm = Utilities.getSecurityManager(state); SecurityManager sm = Utilities.getSecurityManager(state);
ContentItem item = (ContentItem)m_itemModel.getSelectedObject(state); ContentItem item = (ContentItem) m_itemModel.getSelectedObject(state);
if (isVisible(state) == true) {
if (super.canAccess(state, security)) { if (super.canAccess(state, security)) {
boolean smCheck = sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM, boolean smCheck = sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM,
item); item);
if ( s_log.isDebugEnabled() ) { if (s_log.isDebugEnabled()) {
s_log.debug("Superclass security check passed. SecurityManager check is " + s_log.debug("Superclass security check passed. SecurityManager check is "
smCheck); + smCheck);
} }
return smCheck; return smCheck;
} }
}
s_log.warn("Returning false");
return false; return false;
} }
/**
* Override this method to change visiblity of action link created by
* SecurityPropertyEditor add-method. If this method returns false, the
* link will be hidden, p.ex. to hide a delete link if the component is
* already empty.
*
* @param state The page state
* @return true for default behavior
*/
public boolean isVisible(PageState state) {
return true;
}
} }

View File

@ -73,6 +73,7 @@ public class ActionLink extends ControlLink {
* *
* @param s the current page state * @param s the current page state
*/ */
@Override
public void setControlEvent(PageState s) { public void setControlEvent(PageState s) {
s.setControlEvent(this); s.setControlEvent(this);
} }

View File

@ -137,8 +137,9 @@ public class ControlLink extends BaseLink {
*/ */
protected void fireActionEvent(PageState state) { protected void fireActionEvent(PageState state) {
ActionEvent e = null; ActionEvent e = null;
if (m_actionListeners == null) if (m_actionListeners == null) {
return; return;
}
for (int i=0; i < m_actionListeners.size(); i++ ) { for (int i=0; i < m_actionListeners.size(); i++ ) {
if ( e == null ) { if ( e == null ) {
e = new ActionEvent(this, state); e = new ActionEvent(this, state);
@ -151,6 +152,7 @@ public class ControlLink extends BaseLink {
* Responds to the incoming request. Fires the <code>ActionEvent</code>. * Responds to the incoming request. Fires the <code>ActionEvent</code>.
* @param state the current page state * @param state the current page state
*/ */
@Override
public void respond(PageState state) { public void respond(PageState state) {
fireActionEvent(state); fireActionEvent(state);
} }
@ -162,12 +164,13 @@ public class ControlLink extends BaseLink {
* @param state the current page state * @param state the current page state
* @param parent the parent element * @param parent the parent element
*/ */
@Override
protected void generateURL(PageState state, Element parent) { protected void generateURL(PageState state, Element parent) {
setControlEvent(state); setControlEvent(state);
try { try {
parent.addAttribute("href", state.stateAsURL()); parent.addAttribute("href", state.stateAsURL());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); // e.printStackTrace();
parent.addAttribute("href", ""); parent.addAttribute("href", "");
} }
exportAttributes(parent); exportAttributes(parent);

View File

@ -127,7 +127,9 @@ public class IncompleteDateParameter extends DateParameter {
c.set(Calendar.MONTH, Integer.parseInt(month)); c.set(Calendar.MONTH, Integer.parseInt(month));
} else { } else {
this.skippedMonth = true; this.skippedMonth = true;
c.set(Calendar.MONTH, 1); // BE AWARE: Java month counting is of by 1 because someone decided
// to start counting at 0, So january = 0 (not 1);
c.set(Calendar.MONTH, 0);
} }
if (day != null && day.length() > 0) { if (day != null && day.length() > 0) {
this.skippedDay = false; this.skippedDay = false;

View File

@ -168,6 +168,7 @@ public class SelectionPanel extends LayoutPanel implements Resettable {
this(new Label(title), builder); this(new Label(title), builder);
} }
@Override
public void reset(final PageState state) { public void reset(final PageState state) {
s_log.debug("Resetting to default initial state"); s_log.debug("Resetting to default initial state");
@ -317,6 +318,7 @@ public class SelectionPanel extends LayoutPanel implements Resettable {
} }
public class SelectionListener implements ChangeListener { public class SelectionListener implements ChangeListener {
@Override
public final void stateChanged(final ChangeEvent e) { public final void stateChanged(final ChangeEvent e) {
s_log.debug("Selection state changed; I may change " + s_log.debug("Selection state changed; I may change " +
"the body's visible pane"); "the body's visible pane");