Weitere Verbesserung der Lokalisierung.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2226 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2013-06-24 20:55:42 +00:00
parent ede1f2036b
commit 04997be566
24 changed files with 359 additions and 230 deletions

View File

@ -86,12 +86,14 @@ public class PublicPersonalProfileCreate extends PageCreate {
add(m_workflowSection, ColumnPanel.INSERT); add(m_workflowSection, ColumnPanel.INSERT);
add(new Label(GlobalizationUtil.globalize( add(new Label(GlobalizationUtil.globalize(
"cms.ui.authoring.content_type"))); "cms.ui.authoring.content_type")));
add(new Label(type.getLabel())); add(new Label(type.getLabel())); // the title or name of the type
add(new Label(GlobalizationUtil.globalize("cms.ui.language.field"))); add(new Label(GlobalizationUtil.globalize("cms.ui.language.field")));
add(new LanguageWidget(LANGUAGE)); add(new LanguageWidget(LANGUAGE));
add(new Label(PublicPersonalProfileGlobalizationUtil.globalize("publicpersonalprofile.ui.create.select_person"))); add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
final ParameterModel ownerModel = new StringParameter(PublicPersonalProfileBundle.OWNER); "publicpersonalprofile.ui.create.select_person")));
final ParameterModel ownerModel = new
StringParameter(PublicPersonalProfileBundle.OWNER);
final SingleSelect ownerSelect = new SingleSelect(ownerModel); final SingleSelect ownerSelect = new SingleSelect(ownerModel);
ownerSelect.addValidationListener(new NotNullValidationListener()); ownerSelect.addValidationListener(new NotNullValidationListener());
@ -111,9 +113,11 @@ public class PublicPersonalProfileCreate extends PageCreate {
if (types.size() == 0) { if (types.size() == 0) {
personType = "com.arsdigita.cms.contenttypes.GenericPerson"; personType = "com.arsdigita.cms.contenttypes.GenericPerson";
} }
DataCollection persons = SessionManager.getSession().retrieve(personType); DataCollection persons = SessionManager.getSession()
.retrieve(personType);
//persons.addFilter("profile is null"); //persons.addFilter("profile is null");
persons.addFilter(String.format("version = '%s'", ContentItem.DRAFT)); persons.addFilter(String.format("version = '%s'",
ContentItem.DRAFT));
persons.addOrder("surname asc"); persons.addOrder("surname asc");
persons.addOrder("givenname asc"); persons.addOrder("givenname asc");
persons.addOrder("language asc"); persons.addOrder("language asc");

View File

@ -34,7 +34,7 @@ public class PublicPersonalProfileGlobalizationUtil {
/** Name of Java resource files to handle PPP's globalisation. */ /** Name of Java resource files to handle PPP's globalisation. */
public static final String BUNDLE_NAME = public static final String BUNDLE_NAME =
"com.arsdigita.cms.contenttypes.ui.PublicPersonalProfileResources"; "com.arsdigita.cms.contenttypes.PublicPersonalProfileResources";
/** /**
* This returns a globalized message using the package specific bundle, * This returns a globalized message using the package specific bundle,

View File

@ -49,8 +49,8 @@ public class PublicPersonalProfileMiscStep extends SimpleEditStep {
final BasicItemForm editPositionForm = new PublicPersonalProfileMiscEditForm( final BasicItemForm editPositionForm = new PublicPersonalProfileMiscEditForm(
itemModel); itemModel);
add(EDIT_MISC_SHEET_NAME, add(EDIT_MISC_SHEET_NAME,
(String) PublicPersonalProfileGlobalizationUtil.globalize( PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.misc.edit").localize(), "publicpersonalprofile.ui.misc.edit"),
new WorkflowLockedComponentAccess(editPositionForm, itemModel), new WorkflowLockedComponentAccess(editPositionForm, itemModel),
editPositionForm.getSaveCancelSection().getCancelButton()); editPositionForm.getSaveCancelSection().getCancelButton());

View File

@ -93,9 +93,8 @@ public class PublicPersonalProfileNavigationAddForm
@Override @Override
public void addWidgets() { public void addWidgets() {
add(new Label((String) PublicPersonalProfileGlobalizationUtil.globalize( add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.nav.select_nav_item"). "publicpersonalprofile.ui.nav.select_nav_item") ));
localize()));
ParameterModel navItemModel = ParameterModel navItemModel =
new StringParameter(PublicPersonalProfileNavItem.KEY); new StringParameter(PublicPersonalProfileNavItem.KEY);
SingleSelect navItemSelect = new SingleSelect(navItemModel); SingleSelect navItemSelect = new SingleSelect(navItemModel);
@ -109,7 +108,7 @@ public class PublicPersonalProfileNavigationAddForm
select.addOption(new Option("", "")); select.addOption(new Option("", ""));
PublicPersonalProfileNavItemCollection navItems = PublicPersonalProfileNavItemCollection navItems =
new PublicPersonalProfileNavItemCollection(); new PublicPersonalProfileNavItemCollection();
navItems.addLanguageFilter(GlobalizationHelper. navItems.addLanguageFilter(GlobalizationHelper.
getNegotiatedLocale(). getNegotiatedLocale().
getLanguage()); getLanguage());
@ -162,9 +161,8 @@ public class PublicPersonalProfileNavigationAddForm
add(navItemSelect); add(navItemSelect);
//if (!showGenerated()) { //if (!showGenerated()) {
add(new Label((String) PublicPersonalProfileGlobalizationUtil.globalize( add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.nav.select_target"). "publicpersonalprofile.ui.nav.select_target") ));
localize()));
itemSearch = new ItemSearchWidget(ITEM_SEARCH); itemSearch = new ItemSearchWidget(ITEM_SEARCH);
itemSearch.addValidationListener(this); itemSearch.addValidationListener(this);
add(this.itemSearch); add(this.itemSearch);

View File

@ -51,8 +51,8 @@ public class PublicPersonalProfileNavigationStep extends SimpleEditStep {
new PublicPersonalProfileNavigationAddForm(itemModel, new PublicPersonalProfileNavigationAddForm(itemModel,
this); this);
add(EDIT_NAV_ITEM_SHEET_NAME, add(EDIT_NAV_ITEM_SHEET_NAME,
(String) PublicPersonalProfileGlobalizationUtil.globalize( PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.profile.content.add").localize(), "publicpersonalprofile.ui.profile.content.add"),
new WorkflowLockedComponentAccess(editNavItemSheet, itemModel), new WorkflowLockedComponentAccess(editNavItemSheet, itemModel),
editNavItemSheet.getSaveCancelSection().getCancelButton()); editNavItemSheet.getSaveCancelSection().getCancelButton());

View File

@ -31,7 +31,6 @@ import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.bebop.table.TableColumnModel; import com.arsdigita.bebop.table.TableColumnModel;
import com.arsdigita.bebop.table.TableModel; import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder; import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
@ -55,9 +54,8 @@ import org.apache.log4j.Logger;
* @author Jens Pelzetter * @author Jens Pelzetter
* @version $Id$ * @version $Id$
*/ */
public class PublicPersonalProfileNavigationTable public class PublicPersonalProfileNavigationTable extends Table
extends Table implements TableActionListener {
implements TableActionListener {
private static final Logger logger = Logger.getLogger( private static final Logger logger = Logger.getLogger(
PublicPersonalProfileNavigationTable.class); PublicPersonalProfileNavigationTable.class);
@ -79,20 +77,20 @@ public class PublicPersonalProfileNavigationTable
TableColumnModel colModel = getColumnModel(); TableColumnModel colModel = getColumnModel();
colModel.add(new TableColumn( colModel.add(new TableColumn(
0, 0,
PublicPersonalProfileGlobalizationUtil.globalize( new Label(PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.nav.target").localize(), "publicpersonalprofile.ui.nav.target") ),
TABLE_COL_EDIT)); TABLE_COL_EDIT));
colModel.add(new TableColumn( colModel.add(new TableColumn(
1, 1,
PublicPersonalProfileGlobalizationUtil.globalize( new Label(PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.nav.targetitem").localize(), "publicpersonalprofile.ui.nav.targetitem")),
TABLE_COL_TARGET)); TABLE_COL_TARGET));
colModel.add(new TableColumn( colModel.add(new TableColumn(
2, 2,
PublicPersonalProfileGlobalizationUtil.globalize( new Label(PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.nav.remove").localize(), "publicpersonalprofile.ui.nav.remove")),
TABLE_COL_DEL)); TABLE_COL_DEL));
setModelBuilder(new PublicPersonalProfileNavigationTableModelBuilder( setModelBuilder(new PublicPersonalProfileNavigationTableModelBuilder(
@ -193,8 +191,11 @@ public class PublicPersonalProfileNavigationTable
return targetItem; return targetItem;
} }
case 2: case 2:
return PublicPersonalProfileGlobalizationUtil.globalize( // return PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.nav.remove").localize(); // "publicpersonalprofile.ui.nav.remove").localize();
return new Label(
PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.nav.remove"));
default: default:
return null; return null;
} }
@ -222,7 +223,8 @@ public class PublicPersonalProfileNavigationTable
int col) { int col) {
//com.arsdigita.cms.SecurityManager securityManager = Utilities.getSecurityManager(state); //com.arsdigita.cms.SecurityManager securityManager = Utilities.getSecurityManager(state);
return new Label((String) value); // return new Label((String) value);
return (Component)value;
} }
} }
@ -293,13 +295,14 @@ public class PublicPersonalProfileNavigationTable
if (canDelete) { if (canDelete) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink(value.toString());
link.setConfirmation((String) PublicPersonalProfileGlobalizationUtil. link.setConfirmation(PublicPersonalProfileGlobalizationUtil.
globalize("publicpersonalprofile.ui.nav.remove.confirm"). globalize("publicpersonalprofile.ui.nav.remove.confirm")
localize()); );
return link; return link;
} else { } else {
Label label = new Label(value.toString()); // Label label = new Label(value.toString());
return label; // return label;
return (Component)value;
} }
} }

View File

@ -20,7 +20,6 @@ package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.FormSection;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormInitListener;

View File

@ -50,8 +50,8 @@ public class PublicPersonalProfilePositionStep extends SimpleEditStep {
final BasicItemForm editPositionForm = new PublicPersonalProfilePositionEditForm( final BasicItemForm editPositionForm = new PublicPersonalProfilePositionEditForm(
itemModel); itemModel);
add(EDIT_POSITION_SHEET_NAME, add(EDIT_POSITION_SHEET_NAME,
(String) PublicPersonalProfileGlobalizationUtil.globalize( PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.position.edit").localize(), "publicpersonalprofile.ui.position.edit"),
new WorkflowLockedComponentAccess(editPositionForm, itemModel), new WorkflowLockedComponentAccess(editPositionForm, itemModel),
editPositionForm.getSaveCancelSection().getCancelButton()); editPositionForm.getSaveCancelSection().getCancelButton());

View File

@ -59,22 +59,19 @@ public class PublicPersonalProfilePropertiesStep extends SimpleEditStep {
BasicPageForm editBasicSheet = BasicPageForm editBasicSheet =
new PublicPersonalProfilePropertyForm(itemModel, new PublicPersonalProfilePropertyForm(itemModel,
this); this);
basicProperties.add(EDIT_SHEET_NAME, basicProperties.add(
(String) PublicPersonalProfileGlobalizationUtil. EDIT_SHEET_NAME,
globalize( PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.profile.edit_basic_properties"). "publicpersonalprofile.ui.profile.edit_basic_properties"),
localize(), new WorkflowLockedComponentAccess(editBasicSheet,itemModel),
new WorkflowLockedComponentAccess(editBasicSheet, editBasicSheet.getSaveCancelSection().getCancelButton());
itemModel),
editBasicSheet.getSaveCancelSection().
getCancelButton());
basicProperties.setDisplayComponent(getPublicPersonalProfilePropertySheet( basicProperties.setDisplayComponent(getPublicPersonalProfilePropertySheet(
itemModel)); itemModel));
segmentedPanel.addSegment(new Label((String) PublicPersonalProfileGlobalizationUtil. segmentedPanel.addSegment(new Label(PublicPersonalProfileGlobalizationUtil.
globalize("publicpersonalprofile.ui.profile.basic_properties"). globalize("publicpersonalprofile.ui.profile.basic_properties")),
localize()), basicProperties); basicProperties);
setDisplayComponent(segmentedPanel); setDisplayComponent(segmentedPanel);
} }

View File

@ -51,9 +51,9 @@ public class PublicPersonalProfileResearchInterestsStep extends SimpleEditStep {
final BasicItemForm editRiForm = final BasicItemForm editRiForm =
new PublicPersonalProfileResearchInterestsEditForm new PublicPersonalProfileResearchInterestsEditForm
(itemModel); (itemModel);
add(EDIT_RI_SHEET_NAME, (String) PublicPersonalProfileGlobalizationUtil. add(EDIT_RI_SHEET_NAME,
globalize("publicpersonalprofile.ui.research_interests.edit"). PublicPersonalProfileGlobalizationUtil.globalize(
localize(), "publicpersonalprofile.ui.research_interests.edit"),
new WorkflowLockedComponentAccess(editRiForm, itemModel), new WorkflowLockedComponentAccess(editRiForm, itemModel),
editRiForm.getSaveCancelSection().getCancelButton()); editRiForm.getSaveCancelSection().getCancelButton());
@ -66,7 +66,7 @@ public class PublicPersonalProfileResearchInterestsStep extends SimpleEditStep {
itemModel); itemModel);
sheet.add(PublicPersonalProfileGlobalizationUtil.globalize( sheet.add(PublicPersonalProfileGlobalizationUtil.globalize(
"publicpersonalprofile.ui.research_interests"), "publicpersonalprofile.ui.research_interests"),
PublicPersonalProfile.INTERESTS); PublicPersonalProfile.INTERESTS);
return sheet; return sheet;

View File

@ -60,10 +60,13 @@ import java.util.StringTokenizer;
public class ContentType extends ACSObject { public class ContentType extends ACSObject {
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.ContentType"; "com.arsdigita.cms.ContentType";
public static final String OBJECT_TYPE = "associatedObjectType"; public static final String OBJECT_TYPE = "associatedObjectType";
/** The name or title of the content type, e.g. "File Storage Item" */
public static final String LABEL = "label"; public static final String LABEL = "label";
/** A short description of the type, what is is meant to do / to use for. */
public static final String DESCRIPTION = "description"; public static final String DESCRIPTION = "description";
/** Fully qualified name of the (main) domain class (and main entry point)*/
public static final String CLASSNAME = "className"; public static final String CLASSNAME = "className";
public static final String MODE = "mode"; public static final String MODE = "mode";
public static final String AUTHORING_KIT = "authoringKit"; public static final String AUTHORING_KIT = "authoringKit";

View File

@ -39,7 +39,7 @@ import java.util.StringTokenizer;
/** /**
* Displays a list of label-value pairs, which represent the attributes * Displays a list of label-value pairs, which represent the attributes
* of a domain object. * of a domain object.
* <p> *
* Typical usage is * Typical usage is
* <blockquote><pre><code> * <blockquote><pre><code>
* DomainObjectPropertySheet mySheet = * DomainObjectPropertySheet mySheet =
@ -47,20 +47,22 @@ import java.util.StringTokenizer;
* mySheet.add("Name:", ContentPage.NAME); * mySheet.add("Name:", ContentPage.NAME);
* mySheet.add("Title:", ContentPage.TITLE); * mySheet.add("Title:", ContentPage.TITLE);
* </code></pre></blockquote> * </code></pre></blockquote>
*
* The first argument is the visible label for the property, and * The first argument is the visible label for the property, and
* the second argument is the name of the property as it appears in * the second argument is the name of the property as it appears in
* the PDL file. * the PDL file.
* <p> *
* Instead of specifying the property directly, you may specify the "path" * Instead of specifying the property directly, you may specify the "path"
* to the property. For example, * to the property. For example,
* <blockquote><pre><code> * <blockquote><pre><code>
* mySheet.add("Address Line 1:", "user.address.street"); * mySheet.add("Address Line 1:", "user.address.street");
* </code></pre></blockquote> * </code></pre></blockquote>
*
* The code above tells the <code>DomainObjectPropertySheet</code> to look for * The code above tells the <code>DomainObjectPropertySheet</code> to look for
* the child of the current object named "user"; then look for the child * the child of the current object named "user"; then look for the child
* of the user named "address", and finally to return the property of * of the user named "address", and finally to return the property of
* the address named "street". * the address named "street".
* <p> *
* Note that, by default, <code>DomainObjectPropertySheet</code> retrieves * Note that, by default, <code>DomainObjectPropertySheet</code> retrieves
* the values for its properties directly from the underlying {@link DataObject} * the values for its properties directly from the underlying {@link DataObject}
* of the {@link DomainObject}. This means that the Java <code>getXXX</code> * of the {@link DomainObject}. This means that the Java <code>getXXX</code>
@ -69,8 +71,8 @@ import java.util.StringTokenizer;
* will call the appropriate methods. * will call the appropriate methods.
* *
* @author Stanislav Freidin * @author Stanislav Freidin
* @author Peter Boy (localization)
* @version $Id: DomainObjectPropertySheet.java 287 2005-02-22 00:29:02Z sskracic $ * @version $Id: DomainObjectPropertySheet.java 287 2005-02-22 00:29:02Z sskracic $
*
*/ */
public class DomainObjectPropertySheet extends PropertySheet { public class DomainObjectPropertySheet extends PropertySheet {
@ -83,8 +85,7 @@ public class DomainObjectPropertySheet extends PropertySheet {
* Construct a new DomainObjectPropertySheet * Construct a new DomainObjectPropertySheet
* *
* @param objModel The selection model which feeds domain objects to this * @param objModel The selection model which feeds domain objects to this
* property sheet. * property sheet.
*
*/ */
public DomainObjectPropertySheet(DomainObjectSelectionModel objModel) { public DomainObjectPropertySheet(DomainObjectSelectionModel objModel) {
this(objModel, false); this(objModel, false);
@ -94,13 +95,13 @@ public class DomainObjectPropertySheet extends PropertySheet {
* Construct a new DomainObjectPropertySheet * Construct a new DomainObjectPropertySheet
* *
* @param objModel The selection model which feeds domain objects to this * @param objModel The selection model which feeds domain objects to this
* property sheet * property sheet
* @param valueOutputEscape The value of the label-value pair(i.e., * @param valueOutputEscape The value of the label-value pair(i.e.,
* column[1])'s output-escaping * column[1])'s output-escaping
*
*/ */
public DomainObjectPropertySheet( public DomainObjectPropertySheet( DomainObjectSelectionModel objModel,
DomainObjectSelectionModel objModel, boolean valueOutputEscape) { boolean valueOutputEscape) {
super(new DomainObjectModelBuilder(), valueOutputEscape); super(new DomainObjectModelBuilder(), valueOutputEscape);
m_objModel = objModel; m_objModel = objModel;
@ -177,7 +178,8 @@ public class DomainObjectPropertySheet extends PropertySheet {
* PDL property) * PDL property)
* @param formatter An instance of AttributeFormatter * @param formatter An instance of AttributeFormatter
*/ */
public void add(GlobalizedMessage label, String attribute, public void add(GlobalizedMessage label,
String attribute,
AttributeFormatter f) { AttributeFormatter f) {
m_props.add(new Property(label, attribute, f)); m_props.add(new Property(label, attribute, f));
} }
@ -234,6 +236,13 @@ public class DomainObjectPropertySheet extends PropertySheet {
private String m_attr; private String m_attr;
private AttributeFormatter m_formatter; private AttributeFormatter m_formatter;
/**
* Constructor, takes the set of parameter to create a new Property.
*
* @param l the lebael for the attribute
* @param a the attribute (as String, i.e name of the property)
* @param f the formatter to convert the attribute a into a String
*/
public Property(GlobalizedMessage l, String a, AttributeFormatter f) { public Property(GlobalizedMessage l, String a, AttributeFormatter f) {
m_label = l; m_label = l;
m_attr = a; m_attr = a;
@ -247,22 +256,38 @@ public class DomainObjectPropertySheet extends PropertySheet {
return m_label.getKey(); return m_label.getKey();
} }
/**
* Fetch the (globalizes) label of the property.
* @return
*/
public GlobalizedMessage getGlobalizedLabel() { public GlobalizedMessage getGlobalizedLabel() {
return m_label; return m_label;
} }
/**
* Fetch the attribute.
*
* @return name of the attribute (a String)
*/
public String getAttribute() { public String getAttribute() {
return m_attr; return m_attr;
} }
/**
* Fetch the formatter for the attribute
* @return
*/
public AttributeFormatter getFormatter() { public AttributeFormatter getFormatter() {
return m_formatter; return m_formatter;
} }
} }
// Build up the object properties model from the iterator over all properties /**
private static class DomainObjectPropertiesModel implements * Build up the object properties model from the iterator over all
PropertySheetModel { * properties.
*/
private static class DomainObjectPropertiesModel
implements PropertySheetModel {
private DomainObject m_obj; private DomainObject m_obj;
private PageState m_state; private PageState m_state;
@ -271,14 +296,25 @@ public class DomainObjectPropertySheet extends PropertySheet {
private static String ERROR = private static String ERROR =
"No current property. Make sure that nextRow() was called at least once."; "No current property. Make sure that nextRow() was called at least once.";
public DomainObjectPropertiesModel( /**
DomainObject obj, Iterator props, PageState state) { *
* @param obj
* @param props
* @param state
*/
public DomainObjectPropertiesModel( DomainObject obj,
Iterator props,
PageState state) {
m_obj = obj; m_obj = obj;
m_props = props; m_props = props;
m_state = state; m_state = state;
m_current = null; m_current = null;
} }
/**
*
* @return
*/
public boolean nextRow() { public boolean nextRow() {
if (!m_props.hasNext()) { if (!m_props.hasNext()) {
return false; return false;
@ -295,6 +331,10 @@ public class DomainObjectPropertySheet extends PropertySheet {
return getGlobalizedLabel().getKey(); return getGlobalizedLabel().getKey();
} }
/**
*
* @return
*/
public GlobalizedMessage getGlobalizedLabel() { public GlobalizedMessage getGlobalizedLabel() {
if (m_current == null) { if (m_current == null) {
throw new IllegalStateException(ERROR); throw new IllegalStateException(ERROR);
@ -302,6 +342,10 @@ public class DomainObjectPropertySheet extends PropertySheet {
return m_current.getGlobalizedLabel(); return m_current.getGlobalizedLabel();
} }
/**
*
* @return
*/
public String getValue() { public String getValue() {
if (m_current == null) { if (m_current == null) {
throw new IllegalStateException(ERROR); throw new IllegalStateException(ERROR);
@ -312,7 +356,9 @@ public class DomainObjectPropertySheet extends PropertySheet {
} }
} }
// Builds an DomainObjectPropertiesModel /**
* Builds an DomainObjectPropertiesModel.
*/
private static class DomainObjectModelBuilder extends LockableImpl private static class DomainObjectModelBuilder extends LockableImpl
implements PropertySheetModelBuilder { implements PropertySheetModelBuilder {
@ -325,72 +371,128 @@ public class DomainObjectPropertySheet extends PropertySheet {
} }
} }
// Abstract formatter which maintains a "default" string /**
* Abstract AttributeFormatter class which maintains a "default" value for
* the attribute. The default value is a GlobalizedMessage, which will be
* formatted to a String by the default format method.
*/
private static abstract class DefaultAttributeFormatter private static abstract class DefaultAttributeFormatter
extends DomainService extends DomainService
implements AttributeFormatter { implements AttributeFormatter {
private String m_default; private GlobalizedMessage m_default;
/**
* Default Constructor which creates a default GlobalizedMessage to
* be used as default value for an attribute.
*/
public DefaultAttributeFormatter() { public DefaultAttributeFormatter() {
this((String)GlobalizationUtil.globalize("cms.ui.unknown").localize()); m_default = new GlobalizedMessage(
"toolbox.ui.na",
"com.arsdigita.toolbox.ui.ToolboxResources");
} }
public DefaultAttributeFormatter(String def) { /**
* Constructor which takes a custom GlobalizedMessage to be used as a
* default value.
*
* @param def GlobalizedMessage used as default value
*/
public DefaultAttributeFormatter(GlobalizedMessage def) {
m_default = def; m_default = def;
} }
public String getDefaultString() { public GlobalizedMessage getDefaultValue() {
return m_default; return m_default;
} }
} }
// A simple attribute formatter that calls get on the object with the /**
// specified attribute * A simple attribute formatter that calls get on the object with the
* specified attribute.
*/
private static class SimpleAttributeFormatter private static class SimpleAttributeFormatter
extends DefaultAttributeFormatter { extends DefaultAttributeFormatter {
/**
* Constructor, simply calls the super class. Uses a default value for
* empty attributes.
*/
public SimpleAttributeFormatter() { public SimpleAttributeFormatter() {
super(); super();
} }
public SimpleAttributeFormatter(String def) { /**
* Constructor which takes a custom GlobalizedMessage to be used as a
* default value.
*
* @param def GlobalizedMessage used as default value
*/
public SimpleAttributeFormatter(GlobalizedMessage def) {
super(def); super(def);
} }
/**
* Formatter method, invoked at every page request!
*
* @param obj
* @param attribute
* @param state
* @return
*/
public String format(DomainObject obj, String attribute, PageState state) { public String format(DomainObject obj, String attribute, PageState state) {
if (obj == null) {
return getDefaultString(); /* Determine the default value */
} GlobalizedMessage defaultMsg = getDefaultValue();
Object value = get(obj, attribute); Object value = get(obj, attribute);
if (value == null) { if (value == null) {
return getDefaultString(); return (String)defaultMsg.localize();
} else { } else {
return value.toString(); return value.toString();
} }
} }
} }
// A more advanced attribute formatter. Folows the path to the value /**
// by following the names in the attribute string. For example, if * A more advanced attribute formatter. Follows the path to the value
// the string says "foo.bar.baz", the formatter will attempt to call * by following the names in the attribute string. For example, if
// obj.get("foo").get("bar").get("baz"); * the string says "foo.bar.baz", the formatter will attempt to call
* obj.get("foo").get("bar").get("baz");
*/
private static class RecursiveAttributeFormatter private static class RecursiveAttributeFormatter
extends DefaultAttributeFormatter { extends DefaultAttributeFormatter {
/**
* Constructor, simply calls the super class. Uses a default value for
* empty attributes.
*/
public RecursiveAttributeFormatter() { public RecursiveAttributeFormatter() {
super(); super();
} }
public RecursiveAttributeFormatter(String def) { /**
* Constructor which takes a custom GlobalizedMessage to be used as a
* default value.
*
* @param def GlobalizedMessage used as default value
*/
public RecursiveAttributeFormatter(GlobalizedMessage def) {
super(def); super(def);
} }
/**
* Formatter method, invoked at every page request!
*
* @param obj
* @param attribute
* @param state
* @return
*/
public String format(DomainObject obj, String attribute, PageState state) { public String format(DomainObject obj, String attribute, PageState state) {
if (obj == null) { if (obj == null) {
return getDefaultString(); return (String)getDefaultValue().localize();
} }
StringTokenizer tokenizer = new StringTokenizer(attribute, "."); StringTokenizer tokenizer = new StringTokenizer(attribute, ".");
@ -402,13 +504,13 @@ public class DomainObjectPropertySheet extends PropertySheet {
// Null check // Null check
value = ((DataObject) value).get(token); value = ((DataObject) value).get(token);
if (value == null) { if (value == null) {
return getDefaultString(); return (String)getDefaultValue().localize();
} }
} }
// Extract leaf value // Extract leaf value
if (token == null || value == null) { if (token == null || value == null) {
return getDefaultString(); return (String)getDefaultValue().localize();
} }
return value.toString(); return value.toString();

View File

@ -1,3 +1,2 @@
toolbox.ui.na=N/A toolbox.ui.na=N/A
toolbox.ui.no_results=No Results. toolbox.ui.no_results=No Results.
cms.ui.unknown=<em>unknown</em>

View File

@ -1,3 +1,2 @@
toolbox.ui.na=N/A toolbox.ui.na=(nicht eingetragen)
toolbox.ui.no_results=Keine Ergebnisse. toolbox.ui.no_results=Keine Ergebnisse.
cms.ui.unknown=<em>unbekannt</em>

View File

@ -1,3 +1,2 @@
toolbox.ui.na=N/A toolbox.ui.na=N/A
toolbox.ui.no_results=Pas de r\u00e9sultats toolbox.ui.no_results=Pas de r\u00e9sultats
cms.ui.unknown=

View File

@ -29,3 +29,7 @@ london.contenttypes.ui.contact.phonetable.header_delete=Delete
london.contenttypes.ui.contact.phonetable.confirm_delete=Delete this Phone? london.contenttypes.ui.contact.phonetable.confirm_delete=Delete this Phone?
london.contenttypes.ui.contact.phonetable.link_delete=delete london.contenttypes.ui.contact.phonetable.link_delete=delete
london.contenttypes.ui.contact.phonetable.delete_confirmation=Delete this Phone? london.contenttypes.ui.contact.phonetable.delete_confirmation=Delete this Phone?
london.contenttypes.ui.contact.remove_contact=Remove contact
london.contenttypes.ui.contact.search_contact_label=Search for Contact:
london.contenttypes.ui.contact.no_contacts_yet=This item does not have a contact.
london.contenttypes.ui.contact.add_contact=Add

View File

@ -21,7 +21,7 @@ london.contenttypes.ui.contact.emails=E-Mail
com.arsdigita.london.contenttypes.contact_authoring_step_description=Kontakteintrag com.arsdigita.london.contenttypes.contact_authoring_step_description=Kontakteintrag
com.arsdigita.london.contenttypes.contact_authoring_step_label=Kontakt com.arsdigita.london.contenttypes.contact_authoring_step_label=Kontakt
com.arsdigita.london.contenttypes.ui.contact.select_contact=Einen Kontakt ausw\u00e4hlen com.arsdigita.london.contenttypes.ui.contact.select_contact=Einen Kontakt ausw\u00e4hlen
london.contenttypes.ui.contact.add_phone_button=Telefonnummer hinzuf\u00fchren london.contenttypes.ui.contact.add_phone_button=Telefonnummer hinzuf\u00fcgen
london.contenttypes.ui.contact.phonetable.no_entries_msg=Es sind keine Telefonnummer mit diesem Kontakt verkn\u00fcpft. london.contenttypes.ui.contact.phonetable.no_entries_msg=Es sind keine Telefonnummer mit diesem Kontakt verkn\u00fcpft.
london.contenttypes.ui.contact.phonetable.header_type=Telefon Typ london.contenttypes.ui.contact.phonetable.header_type=Telefon Typ
london.contenttypes.ui.contact.phonetable.header_num=Telefonnummer london.contenttypes.ui.contact.phonetable.header_num=Telefonnummer
@ -29,3 +29,7 @@ london.contenttypes.ui.contact.phonetable.header_delete=L\u00f6schen
london.contenttypes.ui.contact.phonetable.confirm_delete=Delete this Phone? london.contenttypes.ui.contact.phonetable.confirm_delete=Delete this Phone?
london.contenttypes.ui.contact.phonetable.link_delete=l\u00f6schen london.contenttypes.ui.contact.phonetable.link_delete=l\u00f6schen
london.contenttypes.ui.contact.phonetable.delete_confirmation=Diesen Eintrag l\u00f6schen? london.contenttypes.ui.contact.phonetable.delete_confirmation=Diesen Eintrag l\u00f6schen?
london.contenttypes.ui.contact.remove_contact=Kontakt entfernen
london.contenttypes.ui.contact.search_contact_label=Nach Kontakt suchen:
london.contenttypes.ui.contact.no_contacts_yet=es ist kein Kontakt zugeordnet.
london.contenttypes.ui.contact.add_contact=Hinzuf\u00fcgen

View File

@ -29,3 +29,7 @@ london.contenttypes.ui.contact.phonetable.header_delete=Delete
london.contenttypes.ui.contact.phonetable.confirm_delete=Delete this Phone? london.contenttypes.ui.contact.phonetable.confirm_delete=Delete this Phone?
london.contenttypes.ui.contact.phonetable.link_delete=delete london.contenttypes.ui.contact.phonetable.link_delete=delete
london.contenttypes.ui.contact.phonetable.delete_confirmation=Delete this Phone? london.contenttypes.ui.contact.phonetable.delete_confirmation=Delete this Phone?
london.contenttypes.ui.contact.remove_contact=Remove contact
london.contenttypes.ui.contact.search_contact_label=Search for Contact:
london.contenttypes.ui.contact.no_contacts_yet=This item does not have a contact.
london.contenttypes.ui.contact.add_contact=Add

View File

@ -42,7 +42,7 @@ public class ContactAddressProperties extends SimpleEditStep {
public static String EDIT_SHEET_NAME = "edit-contact-address"; public static String EDIT_SHEET_NAME = "edit-contact-address";
public ContactAddressProperties(ItemSelectionModel itemModel, public ContactAddressProperties(ItemSelectionModel itemModel,
AuthoringKitWizard parent) { AuthoringKitWizard parent) {
super(itemModel, parent); super(itemModel, parent);
BasicItemForm form; BasicItemForm form;

View File

@ -109,7 +109,8 @@ public class ContactPropertiesAddStep extends ResettableContainer {
m_contact = new RequestLocal() { m_contact = new RequestLocal() {
@Override @Override
protected Object initialValue(PageState s) { protected Object initialValue(PageState s) {
ContentItem item = (ContentItem) ((ItemSelectionModel) getSingleSelectionModel()) ContentItem item = (ContentItem) (
(ItemSelectionModel) getSingleSelectionModel())
.getSelectedObject(s); .getSelectedObject(s);
Assert.exists(item); Assert.exists(item);
return Contact.getContactForItem(item); return Contact.getContactForItem(item);
@ -166,7 +167,8 @@ public class ContactPropertiesAddStep extends ResettableContainer {
private void addWidgets() { private void addWidgets() {
m_contactPropertySheet = getContactPropertySheet(m_contactSelectionModel); m_contactPropertySheet = getContactPropertySheet(m_contactSelectionModel);
m_noContact = new Label("This item does not have a contact."); m_noContact = new Label(ContactGlobalizationUtil.globalize(
"london.contenttypes.ui.contact.no_contacts_yet"));
m_noContact.setFontWeight(Label.ITALIC); m_noContact.setFontWeight(Label.ITALIC);
add(m_contactPropertySheet); add(m_contactPropertySheet);
add(m_noContact); add(m_noContact);
@ -188,61 +190,64 @@ public class ContactPropertiesAddStep extends ResettableContainer {
private Component getContactPropertySheet(ItemSelectionModel itemModel) { private Component getContactPropertySheet(ItemSelectionModel itemModel) {
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
itemModel); itemModel);
sheet.add(ContactGlobalizationUtil sheet.add(ContactGlobalizationUtil.globalize(
.globalize("com.arsdigita.london.contenttypes.ui.name"), "com.arsdigita.london.contenttypes.ui.name"),
Contact.NAME); Contact.NAME);
sheet.add(ContactGlobalizationUtil sheet.add(ContactGlobalizationUtil.globalize(
.globalize("com.arsdigita.london.contenttypes.ui.title"), "com.arsdigita.london.contenttypes.ui.title"),
Contact.TITLE); Contact.TITLE);
sheet.add(ContactGlobalizationUtil sheet.add(ContactGlobalizationUtil.globalize(
.globalize("com.arsdigita.london.contenttypes.ui.contact_givenname"), "com.arsdigita.london.contenttypes.ui.contact_givenname"),
Contact.GIVEN_NAME); Contact.GIVEN_NAME);
sheet.add(ContactGlobalizationUtil sheet.add(ContactGlobalizationUtil.globalize(
.globalize("com.arsdigita.london.contenttypes.ui.contact_familyname"), "com.arsdigita.london.contenttypes.ui.contact_familyname"),
Contact.FAMILY_NAME); Contact.FAMILY_NAME);
sheet.add(ContactGlobalizationUtil sheet.add(ContactGlobalizationUtil.globalize(
.globalize("com.arsdigita.london.contenttypes.ui.contact_type"), "com.arsdigita.london.contenttypes.ui.contact_type"),
Contact.CONTACT_TYPE, Contact.CONTACT_TYPE,
new DomainObjectPropertySheet.AttributeFormatter() { new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject item, public String format(DomainObject item,
String attribute, PageState state) { String attribute,
Contact contact = (Contact) item; PageState state) {
if (contact != null Contact contact = (Contact) item;
&& contact.getContactType() != null) { if (contact != null
return contact.getContactTypeName(); && contact.getContactType() != null) {
} else { return contact.getContactTypeName();
return "unknown"; } else {
} return (String)GlobalizationUtil
} .globalize("cms.ui.unknown")
}); .localize();
}
}
});
sheet.add(ContactGlobalizationUtil sheet.add(ContactGlobalizationUtil.globalize(
.globalize("com.arsdigita.london.contenttypes.ui.description"), "com.arsdigita.london.contenttypes.ui.description"),
Contact.DESCRIPTION); Contact.DESCRIPTION);
sheet.add(ContactGlobalizationUtil sheet.add(ContactGlobalizationUtil.globalize(
.globalize("com.arsdigita.london.contenttypes.ui.contact_emails"), "com.arsdigita.london.contenttypes.ui.contact_emails"),
Contact.EMAILS); Contact.EMAILS);
sheet.add(ContactGlobalizationUtil sheet.add(ContactGlobalizationUtil.globalize(
.globalize("com.arsdigita.london.contenttypes.ui.contact_suffix"), "com.arsdigita.london.contenttypes.ui.contact_suffix"),
Contact.SUFFIX); Contact.SUFFIX);
sheet.add(ContactGlobalizationUtil sheet.add(ContactGlobalizationUtil.globalize(
.globalize("com.arsdigita.london.contenttypes.ui.contact_orgname"), "com.arsdigita.london.contenttypes.ui.contact_orgname"),
Contact.ORG_NAME); Contact.ORG_NAME);
sheet.add(ContactGlobalizationUtil sheet.add(ContactGlobalizationUtil.globalize(
.globalize("com.arsdigita.london.contenttypes.ui.contact_deptname"), "com.arsdigita.london.contenttypes.ui.contact_deptname"),
Contact.DEPT_NAME); Contact.DEPT_NAME);
sheet.add(ContactGlobalizationUtil sheet.add(ContactGlobalizationUtil.globalize(
.globalize("com.arsdigita.london.contenttypes.ui.contact_role"), "com.arsdigita.london.contenttypes.ui.contact_role"),
Contact.ROLE); Contact.ROLE);
return sheet; return sheet;
} }

View File

@ -38,32 +38,37 @@ import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.util.GlobalizationUtil;
/** /**
* Form to edit basic properties of <code>Contact</code> object. Used by * Form to edit basic properties of
* <code>Contact</code> object. Used by
* <code>ContactPropertiesStep</code> authoring kit step. * <code>ContactPropertiesStep</code> authoring kit step.
* *
* @author Shashin Shinde <a href="mailto:sshinde@redhat.com">sshinde@redhat.com</a> * @author Shashin Shinde <a
* href="mailto:sshinde@redhat.com">sshinde@redhat.com</a>
* @version $Id: ContactPropertyForm.java 287 2005-02-22 00:29:02Z sskracic $ * @version $Id: ContactPropertyForm.java 287 2005-02-22 00:29:02Z sskracic $
*/ */
public class ContactPropertyForm extends BasicPageForm { public class ContactPropertyForm extends BasicPageForm {
/** Name of this form */ /**
public static final String ID = "Contact_edit"; * Name of this form
*/
/** public static final String ID = "Contact_edit";
* Creates a new form to edit the Contact object specified by the item
* selection model passed in.
*
* @param itemModel
* The ItemSelectionModel to use to obtain the Contact to work on
*/
public ContactPropertyForm(ItemSelectionModel itemModel) {
super(ID, itemModel);
}
/** /**
* Adds widgets to the form. This has been cut into small methods * Creates a new form to edit the Contact object specified by the item
* so that subclasses can pick and choose. * selection model passed in.
*
* @param itemModel The ItemSelectionModel to use to obtain the Contact to
* work on
*/ */
public ContactPropertyForm(ItemSelectionModel itemModel) {
super(ID, itemModel);
}
/**
* Adds widgets to the form. This has been cut into small methods so that
* subclasses can pick and choose.
*/
@Override
protected void addWidgets() { protected void addWidgets() {
addBasicPageFormWidgets(); addBasicPageFormWidgets();
addGivenNameWidget(); addGivenNameWidget();
@ -83,7 +88,7 @@ public class ContactPropertyForm extends BasicPageForm {
protected void addGivenNameWidget() { protected void addGivenNameWidget() {
add(new Label(ContactGlobalizationUtil.globalize( add(new Label(ContactGlobalizationUtil.globalize(
"london.contenttypes.ui.contact.givenname"))); "london.contenttypes.ui.contact.givenname")));
ParameterModel givenNameParam = new StringParameter(Contact.GIVEN_NAME); ParameterModel givenNameParam = new StringParameter(Contact.GIVEN_NAME);
TextField givenName = new TextField(givenNameParam); TextField givenName = new TextField(givenNameParam);
add(givenName); add(givenName);
@ -91,23 +96,23 @@ public class ContactPropertyForm extends BasicPageForm {
protected void addFamilyNameWidget() { protected void addFamilyNameWidget() {
add(new Label(ContactGlobalizationUtil.globalize( add(new Label(ContactGlobalizationUtil.globalize(
"london.contenttypes.ui.contact.familyname"))); "london.contenttypes.ui.contact.familyname")));
ParameterModel familyNameParam = new StringParameter(Contact.FAMILY_NAME); ParameterModel familyNameParam = new StringParameter(Contact.FAMILY_NAME);
TextField familyName = new TextField(familyNameParam); TextField familyName = new TextField(familyNameParam);
add(familyName); add(familyName);
} }
protected void addSuffixWidget() { protected void addSuffixWidget() {
add(new Label(ContactGlobalizationUtil.globalize( add(new Label(ContactGlobalizationUtil.globalize(
"london.contenttypes.ui.contact.suffix"))); "london.contenttypes.ui.contact.suffix")));
ParameterModel suffixParam = new StringParameter(Contact.SUFFIX); ParameterModel suffixParam = new StringParameter(Contact.SUFFIX);
TextField suffix = new TextField(suffixParam); TextField suffix = new TextField(suffixParam);
add(suffix); add(suffix);
} }
protected void addContactTypeWidget() { protected void addContactTypeWidget() {
add(new Label(ContactGlobalizationUtil.globalize( add(new Label(ContactGlobalizationUtil.globalize(
"london.contenttypes.ui.contact.type"))); "london.contenttypes.ui.contact.type")));
ParameterModel contactTypeParam = new StringParameter(Contact.CONTACT_TYPE); ParameterModel contactTypeParam = new StringParameter(Contact.CONTACT_TYPE);
SingleSelect contactType = new SingleSelect(contactTypeParam); SingleSelect contactType = new SingleSelect(contactTypeParam);
add(contactType); add(contactType);
@ -120,13 +125,13 @@ public class ContactPropertyForm extends BasicPageForm {
protected void addDescriptionWidget() { protected void addDescriptionWidget() {
add(new Label(GlobalizationUtil.globalize( add(new Label(GlobalizationUtil.globalize(
"cms.contenttypes.ui.description"))); "cms.contenttypes.ui.description")));
ParameterModel descParam = new StringParameter(Contact.DESCRIPTION); ParameterModel descParam = new StringParameter(Contact.DESCRIPTION);
TextArea desc = new TextArea(descParam); TextArea desc = new TextArea(descParam);
desc.setRows(5); desc.setRows(5);
add(desc); add(desc);
} }
protected void addEmailsWidget() { protected void addEmailsWidget() {
add(new Label(ContactGlobalizationUtil add(new Label(ContactGlobalizationUtil
.globalize("london.contenttypes.ui.contact.emails"))); .globalize("london.contenttypes.ui.contact.emails")));
@ -134,7 +139,7 @@ public class ContactPropertyForm extends BasicPageForm {
TextField emails = new TextField(emailsParam); TextField emails = new TextField(emailsParam);
add(emails); add(emails);
} }
protected void addOrganizationNameWidget() { protected void addOrganizationNameWidget() {
add(new Label(ContactGlobalizationUtil add(new Label(ContactGlobalizationUtil
.globalize("london.contenttypes.ui.contact.orgname"))); .globalize("london.contenttypes.ui.contact.orgname")));
@ -142,7 +147,7 @@ public class ContactPropertyForm extends BasicPageForm {
TextField orgName = new TextField(orgNameParam); TextField orgName = new TextField(orgNameParam);
add(orgName); add(orgName);
} }
protected void addDepartmentNameWidget() { protected void addDepartmentNameWidget() {
add(new Label(ContactGlobalizationUtil add(new Label(ContactGlobalizationUtil
.globalize("london.contenttypes.ui.contact.deptname"))); .globalize("london.contenttypes.ui.contact.deptname")));
@ -150,66 +155,66 @@ public class ContactPropertyForm extends BasicPageForm {
TextField deptName = new TextField(deptParam); TextField deptName = new TextField(deptParam);
add(deptName); add(deptName);
} }
protected void addRoleWidget() { protected void addRoleWidget() {
add(new Label(ContactGlobalizationUtil add(new Label(ContactGlobalizationUtil
.globalize("london.contenttypes.ui.contact.role"))); .globalize("london.contenttypes.ui.contact.role")));
ParameterModel roleParam = new StringParameter(Contact.ROLE); ParameterModel roleParam = new StringParameter(Contact.ROLE);
TextField role = new TextField(roleParam); TextField role = new TextField(roleParam);
add(role); add(role);
} }
/** /**
* Initialize Form values from Contact object. * Initialize Form values from Contact object.
*/ */
public void init(FormSectionEvent fse) { public void init(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
Contact contact = (Contact) super.initBasicWidgets(fse); Contact contact = (Contact) super.initBasicWidgets(fse);
if (contact.getContactType() != null) { if (contact.getContactType() != null) {
data.put(Contact.CONTACT_TYPE, contact.getContactType().getID()); data.put(Contact.CONTACT_TYPE, contact.getContactType().getID());
}
data.put(Contact.GIVEN_NAME, contact.getGivenName());
data.put(Contact.FAMILY_NAME, contact.getFamilyName());
data.put(Contact.SUFFIX, contact.getSuffix());
data.put(Contact.EMAILS, contact.getEmails());
data.put(Contact.DESCRIPTION, contact.getDescription());
data.put(Contact.ORG_NAME, contact.getOrganisationName());
data.put(Contact.DEPT_NAME, contact.getDeptName());
data.put(Contact.ROLE, contact.getRole());
} }
data.put(Contact.GIVEN_NAME, contact.getGivenName()); /**
data.put(Contact.FAMILY_NAME, contact.getFamilyName()); * Process the form submission event.
data.put(Contact.SUFFIX, contact.getSuffix()); */
data.put(Contact.EMAILS, contact.getEmails()); public void process(FormSectionEvent fse) {
data.put(Contact.DESCRIPTION, contact.getDescription());
data.put(Contact.ORG_NAME, contact.getOrganisationName());
data.put(Contact.DEPT_NAME, contact.getDeptName());
data.put(Contact.ROLE, contact.getRole());
}
/** FormData data = fse.getFormData();
* Process the form submission event. Contact contact = (Contact) super.processBasicWidgets(fse);
*/
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData(); // save only if save button was pressed
Contact contact = (Contact) super.processBasicWidgets(fse); if (contact != null
&& getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
// save only if save button was pressed contact.setGivenName((String) data.get(Contact.GIVEN_NAME));
if (contact != null contact.setFamilyName((String) data.get(Contact.FAMILY_NAME));
&& getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) { contact.setSuffix((String) data.get(Contact.SUFFIX));
contact.setEmails((String) data.get(Contact.EMAILS));
String contactTypeIDStr = (String) data.get(Contact.CONTACT_TYPE);
if (contactTypeIDStr != null) {
BigDecimal contactTypeID =
new BigDecimal(contactTypeIDStr);
ContactType ctType = new ContactType(contactTypeID);
contact.setContactType(ctType);
}
contact.setGivenName((String) data.get(Contact.GIVEN_NAME)); contact.setDescription((String) data.get(Contact.DESCRIPTION));
contact.setFamilyName((String) data.get(Contact.FAMILY_NAME)); contact.setOrganisationName((String) data.get(Contact.ORG_NAME));
contact.setSuffix((String) data.get(Contact.SUFFIX)); contact.setDeptName((String) data.get(Contact.DEPT_NAME));
contact.setEmails((String) data.get(Contact.EMAILS)); contact.setRole((String) data.get(Contact.ROLE));
String contactTypeIDStr = (String) data.get(Contact.CONTACT_TYPE); contact.save();
if (contactTypeIDStr != null) { }
BigDecimal contactTypeID =
new BigDecimal(contactTypeIDStr);
ContactType ctType = new ContactType(contactTypeID);
contact.setContactType(ctType);
}
contact.setDescription((String) data.get(Contact.DESCRIPTION));
contact.setOrganisationName((String) data.get(Contact.ORG_NAME));
contact.setDeptName((String) data.get(Contact.DEPT_NAME));
contact.setRole((String) data.get(Contact.ROLE));
contact.save();
} }
}
} }

View File

@ -21,6 +21,7 @@ import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.london.contenttypes.Contact; import com.arsdigita.london.contenttypes.Contact;
import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.london.contenttypes.util.ContactGlobalizationUtil;
public class ContactToItemAddForm extends FormSection implements public class ContactToItemAddForm extends FormSection implements
FormInitListener, FormValidationListener, FormProcessListener, FormInitListener, FormValidationListener, FormProcessListener,
@ -44,8 +45,8 @@ public class ContactToItemAddForm extends FormSection implements
private AuthoringKitWizard m_parent; private AuthoringKitWizard m_parent;
private Label m_removeLinkText = new Label(GlobalizationUtil private Label m_removeLinkText = new Label(ContactGlobalizationUtil
.globalize("Remove contact")); .globalize("london.contenttypes.ui.contact.remove_contact"));
private ActionLink m_removeLink; private ActionLink m_removeLink;
@ -87,10 +88,11 @@ public class ContactToItemAddForm extends FormSection implements
add(m_removeLink, ColumnPanel.FULL_WIDTH); add(m_removeLink, ColumnPanel.FULL_WIDTH);
m_searchFormLabel = new Label("Search for Contact:"); m_searchFormLabel = new Label(ContactGlobalizationUtil.globalize(
"london.contenttypes.ui.contact.search_contact_label"));
add(m_searchFormLabel); add(m_searchFormLabel);
m_itemSearch = new ItemSearchWidget(CONTACT_SEARCH, m_itemSearch = new ItemSearchWidget(CONTACT_SEARCH,
Contact.BASE_DATA_OBJECT_TYPE); Contact.BASE_DATA_OBJECT_TYPE);
add(m_itemSearch); add(m_itemSearch);
} }
@ -101,7 +103,9 @@ public class ContactToItemAddForm extends FormSection implements
/** Adds the saveCancelSection */ /** Adds the saveCancelSection */
public void addSaveCancelSection() { public void addSaveCancelSection() {
m_saveCancelSection = new SaveCancelSection(); m_saveCancelSection = new SaveCancelSection();
m_saveCancelSection.getSaveButton().setButtonLabel("Add"); m_saveCancelSection.getSaveButton()
.setButtonLabel(ContactGlobalizationUtil.globalize(
"london.contenttypes.ui.contact.add_contact"));
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH); add(m_saveCancelSection, ColumnPanel.FULL_WIDTH);
} }