CCM NG/ccm-cms: Some progress for editing

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4822 8810af33-2d31-482b-a856-94f89814c4df

Former-commit-id: b1f2c7ff98
pull/2/head
jensp 2017-06-28 19:25:28 +00:00
parent ba5e114ffe
commit 82083d7608
15 changed files with 368 additions and 169 deletions

View File

@ -30,6 +30,8 @@ import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
import java.util.Objects;
/** /**
* Authoring step to edit the simple attributes of the Article content type (and * Authoring step to edit the simple attributes of the Article content type (and
* its subclasses). The attributes edited are 'name', 'title', 'article date', * its subclasses). The attributes edited are 'name', 'title', 'article date',
@ -43,18 +45,27 @@ public class ArticlePropertiesStep extends GenericArticlePropertiesStep {
*/ */
public final static String EDIT_SHEET_NAME = "edit"; public final static String EDIT_SHEET_NAME = "edit";
private StringParameter selectedLanuageParam; private final StringParameter selectedLanguageParam;
public ArticlePropertiesStep(final ItemSelectionModel itemModel, public ArticlePropertiesStep(final ItemSelectionModel itemModel,
final AuthoringKitWizard parent, final AuthoringKitWizard parent,
final StringParameter selectedLanguageParam) { final StringParameter selectedLanguageParam) {
super(itemModel, parent, selectedLanguageParam); super(itemModel, parent, selectedLanguageParam);
Objects.requireNonNull(selectedLanguageParam);
this.selectedLanguageParam = selectedLanguageParam;
} }
@Override @Override
protected void createEditSheet(final ItemSelectionModel itemModel) { protected void createEditSheet(final ItemSelectionModel itemModel,
BasicPageForm editSheet; final StringParameter selectedLanguageParam) {
editSheet = new ArticlePropertyForm(itemModel, this);
final BasicPageForm editSheet = new ArticlePropertyForm(
itemModel,
this,
selectedLanguageParam);
add(EDIT_SHEET_NAME, add(EDIT_SHEET_NAME,
new GlobalizedMessage("cms.ui.edit", CmsConstants.CMS_BUNDLE), new GlobalizedMessage("cms.ui.edit", CmsConstants.CMS_BUNDLE),
new WorkflowLockedComponentAccess(editSheet, itemModel), new WorkflowLockedComponentAccess(editSheet, itemModel),
@ -64,15 +75,16 @@ public class ArticlePropertiesStep extends GenericArticlePropertiesStep {
@Override @Override
protected void setDisplayComponent( protected void setDisplayComponent(
final ItemSelectionModel itemModel) { final ItemSelectionModel itemModel) {
setDisplayComponent(getArticlePropertySheet(itemModel, setDisplayComponent(getArticlePropertySheet(itemModel,
selectedLanuageParam)); selectedLanguageParam));
} }
/** /**
* Returns a component that displays the properties of the Article specified * Returns a component that displays the properties of the Article specified
* by the ItemSelectionModel passed in. * by the ItemSelectionModel passed in.
* *
* @param itemModel The ItemSelectionModel to use * @param itemModel The ItemSelectionModel to use
* @param selectedLanguageParam
* *
* @pre itemModel != null * @pre itemModel != null
* @return A component to display the state of the basic properties of the * @return A component to display the state of the basic properties of the

View File

@ -20,6 +20,7 @@ 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.PageState;
import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.event.FormSubmissionListener;
@ -30,7 +31,6 @@ import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener; import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
@ -41,6 +41,9 @@ import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItemRepository; import org.librecms.contentsection.ContentItemRepository;
import org.librecms.contenttypes.Article; import org.librecms.contenttypes.Article;
import java.util.Locale;
import java.util.Objects;
/** /**
* Form to edit the basic properties of an article. This form can be extended to * Form to edit the basic properties of an article. This form can be extended to
* create forms for Article subclasses. * create forms for Article subclasses.
@ -50,7 +53,8 @@ public class ArticlePropertyForm extends GenericArticlePropertyForm
public static final String LEAD = "lead"; public static final String LEAD = "lead";
private ArticlePropertiesStep propertyStep; private final ArticlePropertiesStep propertiesStep;
private final StringParameter selectedLanguageParam;
/** /**
* Creates a new form to edit the Article object specified by the item * Creates a new form to edit the Article object specified by the item
@ -58,23 +62,33 @@ public class ArticlePropertyForm extends GenericArticlePropertyForm
* *
* @param itemModel The ItemSelectionModel to use to obtain the Article to * @param itemModel The ItemSelectionModel to use to obtain the Article to
* work on * work on
* @param selectedLanguageParam
*/ */
public ArticlePropertyForm(final ItemSelectionModel itemModel) { public ArticlePropertyForm(final ItemSelectionModel itemModel,
this(itemModel, null); final StringParameter selectedLanguageParam) {
this(itemModel, null, selectedLanguageParam);
} }
/** /**
* Creates a new form to edit the Article object specified by the item * Creates a new form to edit the Article object specified by the item
* selection model passed in. * selection model passed in.
* *
* @param itemModel The ItemSelectionModel to use to obtain the Article to * @param itemModel The ItemSelectionModel to use to obtain the Article
* work on * to work on
* @param step The ArticlePropertiesStep which controls this form. * @param propertiesStep The ArticlePropertiesStep which controls this form.
* @param selectedLanguageParam
*/ */
public ArticlePropertyForm(final ItemSelectionModel itemModel, public ArticlePropertyForm(
final ArticlePropertiesStep step) { final ItemSelectionModel itemModel,
super(itemModel, step); final ArticlePropertiesStep propertiesStep,
propertyStep = step; final StringParameter selectedLanguageParam) {
super(itemModel, propertiesStep, selectedLanguageParam);
Objects.requireNonNull(selectedLanguageParam);
this.propertiesStep = propertiesStep;
this.selectedLanguageParam = selectedLanguageParam;
addSubmissionListener(this); addSubmissionListener(this);
} }
@ -119,11 +133,20 @@ public class ArticlePropertyForm extends GenericArticlePropertyForm
*/ */
@Override @Override
public void init(final FormSectionEvent event) { public void init(final FormSectionEvent event) {
// Do some initialization hook stuff final FormData data = event.getFormData();
FormData data = event.getFormData(); final PageState state = event.getPageState();
final Article article = (Article) super.initBasicWidgets(event); final Article article = (Article) super.initBasicWidgets(event);
data.put(LEAD, article.getDescription()); final String selectedLanguage = (String) state
.getValue(selectedLanguageParam);
final Locale selectedLocale;
if (selectedLanguage == null) {
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
} else {
selectedLocale = new Locale(selectedLanguage);
}
data.put(LEAD, article.getDescription().getValue(selectedLocale));
} }
/** /**
@ -131,9 +154,9 @@ public class ArticlePropertyForm extends GenericArticlePropertyForm
*/ */
@Override @Override
public void submitted(final FormSectionEvent event) { public void submitted(final FormSectionEvent event) {
if (propertyStep != null && getSaveCancelSection().getCancelButton() if (propertiesStep != null && getSaveCancelSection().getCancelButton()
.isSelected(event.getPageState())) { .isSelected(event.getPageState())) {
propertyStep.cancelStreamlinedCreation(event.getPageState()); propertiesStep.cancelStreamlinedCreation(event.getPageState());
} }
} }
@ -144,25 +167,36 @@ public class ArticlePropertyForm extends GenericArticlePropertyForm
*/ */
@Override @Override
public void process(final FormSectionEvent event) { public void process(final FormSectionEvent event) {
FormData data = event.getFormData(); final FormData data = event.getFormData();
final PageState state = event.getPageState();
Article article = (Article) super.processBasicWidgets(event); final Article article = (Article) super.processBasicWidgets(event);
// save only if save button was pressed // save only if save button was pressed
if (article != null if (article != null
&& getSaveCancelSection().getSaveButton() && getSaveCancelSection().getSaveButton()
.isSelected(event.getPageState())) { .isSelected(event.getPageState())) {
article.getDescription().addValue(KernelConfig.getConfig() final String selectedLanguage = (String) state
.getDefaultLocale(), (String) data.get(LEAD)); .getValue(selectedLanguageParam);
final Locale selectedLocale;
if (selectedLanguage == null) {
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
} else {
selectedLocale = new Locale(selectedLanguage);
}
article
.getDescription()
.addValue(selectedLocale, (String) data.get(LEAD));
final ContentItemRepository itemRepo = CdiUtil final ContentItemRepository itemRepo = CdiUtil
.createCdiUtil() .createCdiUtil()
.findBean(ContentItemRepository.class); .findBean(ContentItemRepository.class);
itemRepo.save(article); itemRepo.save(article);
} }
if (propertyStep != null) { if (propertiesStep != null) {
propertyStep.maybeForwardToNextStep(event.getPageState()); propertiesStep.maybeForwardToNextStep(event.getPageState());
} }
} }

View File

@ -85,7 +85,9 @@ public class EventPropertiesStep extends SimpleEditStep {
setDefaultEditKey(EDIT_SHEET_NAME); setDefaultEditKey(EDIT_SHEET_NAME);
BasicPageForm editSheet; BasicPageForm editSheet;
editSheet = new EventPropertyForm(itemSelectionModel, this); editSheet = new EventPropertyForm(itemSelectionModel,
this,
selectedLanguageParam);
add(EDIT_SHEET_NAME, add(EDIT_SHEET_NAME,
new GlobalizedMessage("cms.ui.edit", CmsConstants.CMS_BUNDLE), new GlobalizedMessage("cms.ui.edit", CmsConstants.CMS_BUNDLE),
new WorkflowLockedComponentAccess(editSheet, itemSelectionModel), new WorkflowLockedComponentAccess(editSheet, itemSelectionModel),

View File

@ -20,6 +20,7 @@ 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.PageState;
import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
@ -53,6 +54,8 @@ import org.librecms.contenttypes.EventConfig;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Objects;
/** /**
* Form to edit the basic properties of an {@link Event} object. * Form to edit the basic properties of an {@link Event} object.
@ -108,6 +111,8 @@ public class EventPropertyForm
*/ */
public static final String COST = "cost"; public static final String COST = "cost";
private final StringParameter selectedLanguageParam;
/* DateWidgets have to be accessible later on */ /* DateWidgets have to be accessible later on */
private com.arsdigita.bebop.form.Date startDateField; private com.arsdigita.bebop.form.Date startDateField;
private com.arsdigita.bebop.form.Date endDateField; private com.arsdigita.bebop.form.Date endDateField;
@ -116,28 +121,37 @@ public class EventPropertyForm
* Creates a new form to edit the Event object specified by the item * Creates a new form to edit the Event object specified by the item
* selection model passed in. * selection model passed in.
* *
* @param itemSelectionModel The ItemSelectionModel to use to obtain the * @param itemSelectionModel The ItemSelectionModel to use to obtain the
* Event to work on * Event to work on
* @param selectedLanguageParam
* *
*/ */
public EventPropertyForm(final ItemSelectionModel itemSelectionModel) { public EventPropertyForm(final ItemSelectionModel itemSelectionModel,
this(itemSelectionModel, null); final StringParameter selectedLanguageParam) {
this(itemSelectionModel, null, selectedLanguageParam);
} }
/** /**
* Creates a new form to edit the Event object specified by the item * Creates a new form to edit the Event object specified by the item
* selection model passed in. * selection model passed in.
* *
* @param itemSelectionModel The ItemSelectionModel to use to obtain the * @param itemSelectionModel The ItemSelectionModel to use to obtain the
* Event to work on * Event to work on
* @param eventPropertiesStep The EventPropertiesStep which controls this * @param eventPropertiesStep The EventPropertiesStep which controls this
* form. * form.
* @param selectedLanguageParam
* *
*/ */
public EventPropertyForm(final ItemSelectionModel itemSelectionModel, public EventPropertyForm(final ItemSelectionModel itemSelectionModel,
final EventPropertiesStep eventPropertiesStep) { final EventPropertiesStep eventPropertiesStep,
super(ID, itemSelectionModel); final StringParameter selectedLanguageParam) {
super(ID, itemSelectionModel, selectedLanguageParam);
Objects.requireNonNull(selectedLanguageParam);
this.eventPropertiesStep = eventPropertiesStep; this.eventPropertiesStep = eventPropertiesStep;
this.selectedLanguageParam = selectedLanguageParam;
addSubmissionListener(this); addSubmissionListener(this);
} }
@ -388,6 +402,7 @@ public class EventPropertyForm
public void init(final FormSectionEvent event) { public void init(final FormSectionEvent event) {
// Do some initialization hook stuff // Do some initialization hook stuff
final FormData data = event.getFormData(); final FormData data = event.getFormData();
final PageState state = event.getPageState();
final Event item = (Event) super.initBasicWidgets(event); final Event item = (Event) super.initBasicWidgets(event);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
@ -416,26 +431,39 @@ public class EventPropertyForm
} }
endDateField.addYear(endDate); endDateField.addYear(endDate);
data.put(LEAD, item.getDescription()); final String selectedLanguage = (String) state
.getValue(selectedLanguageParam);
final Locale selectedLocale;
if (selectedLanguage == null) {
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
} else {
selectedLocale = new Locale(selectedLanguage);
}
data.put(LEAD, item.getDescription().getValue(selectedLocale));
data.put(START_DATE, startDate); data.put(START_DATE, startDate);
data.put(START_TIME, startDate.getTime()); data.put(START_TIME, startDate.getTime());
data.put(END_DATE, endDate); data.put(END_DATE, endDate);
data.put(END_TIME, endDate.getTime()); data.put(END_TIME, endDate.getTime());
if (!eventConfig.isHideDateDescription()) { if (!eventConfig.isHideDateDescription()) {
data.put(EVENT_DATE, item.getEventDate()); data.put(EVENT_DATE,
item.getEventDate().getValue(selectedLocale));
} }
data.put(LOCATION, item.getLocation()); data.put(LOCATION, item.getLocation());
if (!eventConfig.isHideMainContributor()) { if (!eventConfig.isHideMainContributor()) {
data.put(MAIN_CONTRIBUTOR, item.getMainContributor()); data.put(MAIN_CONTRIBUTOR,
item.getMainContributor().getValue(selectedLocale));
} }
if (!eventConfig.isHideEventType()) { if (!eventConfig.isHideEventType()) {
data.put(EVENT_TYPE, item.getEventType()); data.put(EVENT_TYPE,
item.getEventType().getValue(selectedLocale));
} }
if (!eventConfig.isHideLinkToMap()) { if (!eventConfig.isHideLinkToMap()) {
data.put(MAP_LINK, item.getMapLink()); data.put(MAP_LINK, item.getMapLink());
} }
if (!eventConfig.isHideCost()) { if (!eventConfig.isHideCost()) {
data.put(COST, item.getCost()); data.put(COST,
item.getCost().getValue(selectedLocale));
} }
} }

View File

@ -36,6 +36,7 @@ import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.Objects;
/** /**
* Authoring step to edit the simple attributes of the GenericArticle content * Authoring step to edit the simple attributes of the GenericArticle content
@ -52,7 +53,7 @@ public class GenericArticlePropertiesStep extends SimpleEditStep {
private DomainObjectPropertySheet domainObjectPropertySheet; private DomainObjectPropertySheet domainObjectPropertySheet;
private StringParameter selectedLanguageParam; private final StringParameter selectedLanguageParam;
public GenericArticlePropertiesStep( public GenericArticlePropertiesStep(
final ItemSelectionModel itemModel, final ItemSelectionModel itemModel,
@ -60,17 +61,24 @@ public class GenericArticlePropertiesStep extends SimpleEditStep {
final StringParameter selectedLanguageParam) { final StringParameter selectedLanguageParam) {
super(itemModel, parent, selectedLanguageParam); super(itemModel, parent, selectedLanguageParam);
Objects.requireNonNull(selectedLanguageParam);
this.selectedLanguageParam = selectedLanguageParam; this.selectedLanguageParam = selectedLanguageParam;
setDefaultEditKey(EDIT_SHEET_NAME); setDefaultEditKey(EDIT_SHEET_NAME);
createEditSheet(itemModel); createEditSheet(itemModel, selectedLanguageParam);
setDisplayComponent(itemModel); setDisplayComponent(itemModel);
} }
protected void createEditSheet(final ItemSelectionModel itemModel) { protected void createEditSheet(final ItemSelectionModel itemModel,
BasicPageForm editSheet; final StringParameter selectedLanguageParam) {
editSheet = new GenericArticlePropertyForm(itemModel, this);
final BasicPageForm editSheet = new GenericArticlePropertyForm(
itemModel,
this,
selectedLanguageParam);
add(EDIT_SHEET_NAME, add(EDIT_SHEET_NAME,
new GlobalizedMessage("cms.ui.edit", CmsConstants.CMS_BUNDLE), new GlobalizedMessage("cms.ui.edit", CmsConstants.CMS_BUNDLE),
new WorkflowLockedComponentAccess(editSheet, itemModel), new WorkflowLockedComponentAccess(editSheet, itemModel),

View File

@ -24,6 +24,7 @@ import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import org.librecms.contenttypes.Article; import org.librecms.contenttypes.Article;
@ -33,7 +34,6 @@ import com.arsdigita.cms.ui.authoring.BasicPageForm;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.contentsection.ContentItemRepository; import org.librecms.contentsection.ContentItemRepository;
/** /**
* Form to edit the basic properties of an article. This form can be extended to * Form to edit the basic properties of an article. This form can be extended to
* create forms for Article subclasses. * create forms for Article subclasses.
@ -49,9 +49,13 @@ public class GenericArticlePropertyForm extends BasicPageForm
* *
* @param itemModel The ItemSelectionModel to use to obtain the Article to * @param itemModel The ItemSelectionModel to use to obtain the Article to
* work on * work on
* @param selectedLanguageParam
*/ */
public GenericArticlePropertyForm(final ItemSelectionModel itemModel) { public GenericArticlePropertyForm(
this(itemModel, null); final ItemSelectionModel itemModel,
final StringParameter selectedLanguageParam) {
this(itemModel, null, selectedLanguageParam);
} }
/** /**
@ -62,10 +66,14 @@ public class GenericArticlePropertyForm extends BasicPageForm
* GenericArticle to work on * GenericArticle to work on
* @param step The GenericArticlePropertiesStep which controls this * @param step The GenericArticlePropertiesStep which controls this
* form. * form.
* @param selectedLanguageParam
*/ */
public GenericArticlePropertyForm(final ItemSelectionModel itemModel, public GenericArticlePropertyForm(
final GenericArticlePropertiesStep step) { final ItemSelectionModel itemModel,
super(ID, itemModel); final GenericArticlePropertiesStep step,
final StringParameter selectedLanguageParam) {
super(ID, itemModel, selectedLanguageParam);
propertiesStep = step; propertiesStep = step;
addSubmissionListener(this); addSubmissionListener(this);
} }

View File

@ -46,6 +46,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
/** /**
@ -69,11 +70,13 @@ public class NewsPropertiesStep extends SimpleEditStep {
final StringParameter selectedLanguageParam) { final StringParameter selectedLanguageParam) {
super(itemModel, parent, selectedLanguageParam); super(itemModel, parent, selectedLanguageParam);
Objects.requireNonNull(selectedLanguageParam);
setDefaultEditKey(EDIT_SHEET_NAME); setDefaultEditKey(EDIT_SHEET_NAME);
BasicPageForm editSheet; BasicPageForm editSheet;
editSheet = new NewsPropertyForm(itemModel, this); editSheet = new NewsPropertyForm(itemModel, this, selectedLanguageParam);
add(EDIT_SHEET_NAME, add(EDIT_SHEET_NAME,
new GlobalizedMessage("cms.ui.edit", CmsConstants.CMS_BUNDLE), new GlobalizedMessage("cms.ui.edit", CmsConstants.CMS_BUNDLE),
new WorkflowLockedComponentAccess(editSheet, itemModel), new WorkflowLockedComponentAccess(editSheet, itemModel),
@ -89,6 +92,7 @@ public class NewsPropertiesStep extends SimpleEditStep {
* specified by the ItemSelectionModel passed in. * specified by the ItemSelectionModel passed in.
* *
* @param itemModel The ItemSelectionModel to use * @param itemModel The ItemSelectionModel to use
* @param selectedLanguageParam
* *
* @pre itemModel != null * @pre itemModel != null
* @return A component to display the state of the basic properties of the * @return A component to display the state of the basic properties of the

View File

@ -19,6 +19,7 @@
package com.arsdigita.cms.contenttypes.ui; package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
@ -44,6 +45,8 @@ import org.librecms.contenttypes.NewsConfig;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Objects;
/** /**
* Form to edit the basic properties of a {@link News} item. These are name, * Form to edit the basic properties of a {@link News} item. These are name,
@ -71,32 +74,44 @@ public class NewsPropertyForm extends BasicPageForm
*/ */
public static final String ID = "news_item_edit"; public static final String ID = "news_item_edit";
private final StringParameter selectedLanguageParam;
private com.arsdigita.bebop.form.Date releaseDateSelector; private com.arsdigita.bebop.form.Date releaseDateSelector;
/** /**
* Creates a new form to edit the NewsItem object specified by the item * Creates a new form to edit the NewsItem object specified by the item
* selection model passed in. * selection model passed in.
* *
* @param itemSelectionModel The ItemSelectionModel to use to obtain the * @param itemSelectionModel The ItemSelectionModel to use to obtain the
* NewsItem to work on * NewsItem to work on
* @param selectedLanguageParam
*/ */
public NewsPropertyForm(final ItemSelectionModel itemSelectionModel) { public NewsPropertyForm(final ItemSelectionModel itemSelectionModel,
this(itemSelectionModel, null); final StringParameter selectedLanguageParam) {
this(itemSelectionModel, null, selectedLanguageParam);
} }
/** /**
* Creates a new form to edit the NewsItem object specified by the item * Creates a new form to edit the NewsItem object specified by the item
* selection model passed in. * selection model passed in.
* *
* @param itemSelectionModel The ItemSelectionModel to use to obtain the * @param itemSelectionModel The ItemSelectionModel to use to obtain the
* NewsItem to work on * NewsItem to work on
* @param propertiesStep The NewsPropertiesStep which controls this * @param propertiesStep The NewsPropertiesStep which controls this
form. * form.
* @param selectedLanguageParam
*/ */
public NewsPropertyForm(final ItemSelectionModel itemSelectionModel, public NewsPropertyForm(final ItemSelectionModel itemSelectionModel,
final NewsPropertiesStep propertiesStep) { final NewsPropertiesStep propertiesStep,
super(ID, itemSelectionModel); final StringParameter selectedLanguageParam) {
super(ID, itemSelectionModel, selectedLanguageParam);
Objects.requireNonNull(selectedLanguageParam);
this.propertiesStep = propertiesStep; this.propertiesStep = propertiesStep;
this.selectedLanguageParam = selectedLanguageParam;
addSubmissionListener(this); addSubmissionListener(this);
} }
@ -148,18 +163,30 @@ public class NewsPropertyForm extends BasicPageForm
@Override @Override
public void init(final FormSectionEvent event) { public void init(final FormSectionEvent event) {
final FormData data = event.getFormData(); final FormData data = event.getFormData();
final PageState state = event.getPageState();
final News item = (News) super.initBasicWidgets(event); final News item = (News) super.initBasicWidgets(event);
// set a default item date, if none set // set a default item date, if none set
java.util.Date releaseDate = item.getReleaseDate(); final java.util.Date releaseDate;
if (releaseDate == null) { if (item.getReleaseDate() == null) {
// new Date is initialised to current time // new Date is initialised to current time
releaseDate = new java.util.Date(); releaseDate = new java.util.Date();
} else {
releaseDate = item.getReleaseDate();
}
final String selectedLanguage = (String) state
.getValue(selectedLanguageParam);
final Locale selectedLocale;
if (selectedLanguage == null) {
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
} else {
selectedLocale = new Locale(selectedLanguage);
} }
releaseDateSelector.addYear(releaseDate); releaseDateSelector.addYear(releaseDate);
data.put(NEWS_DATE, releaseDate); data.put(NEWS_DATE, releaseDate);
data.put(LEAD, item.getDescription()); data.put(LEAD, item.getDescription().getValue(selectedLocale));
} }
/** /**
@ -185,7 +212,8 @@ public class NewsPropertyForm extends BasicPageForm
@Override @Override
public void process(final FormSectionEvent event) { public void process(final FormSectionEvent event) {
FormData data = event.getFormData(); final FormData data = event.getFormData();
final PageState state = event.getPageState();
final News item = (News) super.processBasicWidgets(event); final News item = (News) super.processBasicWidgets(event);
@ -195,10 +223,21 @@ public class NewsPropertyForm extends BasicPageForm
.getSaveButton() .getSaveButton()
.isSelected(event.getPageState())) { .isSelected(event.getPageState())) {
final String selectedLanguage = (String) state
.getValue(selectedLanguageParam);
final Locale selectedLocale;
if (selectedLanguage == null) {
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
} else {
selectedLocale = new Locale(selectedLanguage);
}
item.setReleaseDate((java.util.Date) data.get(NEWS_DATE)); item.setReleaseDate((java.util.Date) data.get(NEWS_DATE));
item.getDescription().addValue( item
KernelConfig.getConfig().getDefaultLocale(), .getDescription()
(String) data.get(LEAD)); .addValue(
selectedLocale,
(String) data.get(LEAD));
final ContentItemRepository itemRepo = CdiUtil final ContentItemRepository itemRepo = CdiUtil
.createCdiUtil() .createCdiUtil()

View File

@ -430,6 +430,8 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
page.setVisibleDefault(child, false); page.setVisibleDefault(child, false);
} }
page.addGlobalStateParam(selectedLanguageParam);
page.addActionListener(new ActionListener() { page.addActionListener(new ActionListener() {
@Override @Override
@ -601,11 +603,11 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
* @return The instance of the component. * @return The instance of the component.
*/ */
protected Component instantiateStep(final String className) { protected Component instantiateStep(final String className) {
LOGGER.debug("Instantiating kit wizard \"{}\" with arguments {}...", LOGGER.debug("Instantiating kit wizard \"{}\" with arguments {}...",
className, className,
arguments); arguments);
Object[] vals;
try { try {
// Get the creation component // Get the creation component
final Class createClass = Class.forName(className); final Class createClass = Class.forName(className);
@ -620,8 +622,11 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
| InvocationTargetException | InvocationTargetException
| NoSuchMethodException | NoSuchMethodException
| SecurityException ex) { | SecurityException ex) {
LOGGER.error("Failed to instantiate authoring kit component \"{}\"...",
className);
LOGGER.error("Exception is: ", ex);
throw new UncheckedWrapperException(String.format( throw new UncheckedWrapperException(String.format(
"Failed to instantiate authoring kit component \"{}\".", "Failed to instantiate authoring kit component \"%s\".",
className), className),
ex); ex);
} }

View File

@ -33,6 +33,7 @@ import com.arsdigita.bebop.event.FormValidationListener;
import com.arsdigita.bebop.form.Hidden; import com.arsdigita.bebop.form.Hidden;
import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.parameters.TrimmedStringParameter; import com.arsdigita.bebop.parameters.TrimmedStringParameter;
import com.arsdigita.bebop.parameters.URLTokenValidationListener; import com.arsdigita.bebop.parameters.URLTokenValidationListener;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
@ -41,12 +42,13 @@ import com.arsdigita.web.Web;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryRepository;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemRepository; import org.librecms.contentsection.ContentItemRepository;
import java.util.Objects;
/** /**
* A form for editing subclasses of ContentItem. This is just a convenience * A form for editing subclasses of ContentItem. This is just a convenience
* class. * class.
@ -59,33 +61,50 @@ public abstract class BasicItemForm extends FormSection
FormProcessListener, FormProcessListener,
FormValidationListener { FormValidationListener {
private final ItemSelectionModel m_itemModel;
private SaveCancelSection m_saveCancelSection;
private final FormSection m_widgetSection;
public static final String CONTENT_ITEM_ID = "ContentItemId"; public static final String CONTENT_ITEM_ID = "ContentItemId";
public static final String NAME = "ContentItemName"; public static final String NAME = "ContentItemName";
public static final String TITLE = "ContentPageTitle"; public static final String TITLE = "ContentPageTitle";
public static final String LANGUAGE = "ContentItemLanguage"; public static final String LANGUAGE = "ContentItemLanguage";
private final ItemSelectionModel itemSelectionModel;
private final StringParameter selectedLanguageParam;
private SaveCancelSection saveCancelSection;
private final FormSection widgetSection;
/**
* Currently, to insert JavaScript code the Label Widget is "abused".
*/
private final Label script = new Label(String
.format("<script language=\"javascript\" "
+ "src=\"%s/javascript/manipulate-input.js\"></script>",
Web.getWebappContextPath()),
false);
/** /**
* Construct a new BasicItemForm with 2 ColumnPanels and add basic content. * Construct a new BasicItemForm with 2 ColumnPanels and add basic content.
* The left Panel is used for Labels, the right Panel for values. * The left Panel is used for Labels, the right Panel for values.
* *
* @param formName the name of this form * @param formName the name of this form
* @param itemModel The {@link ItemSelectionModel} which will be responsible * @param itemSelectionModel The {@link ItemSelectionModel} which will be
* for loading the current item * responsible for loading the current item
* @param selectedLanguageParam
*/ */
public BasicItemForm(String formName, ItemSelectionModel itemModel) { public BasicItemForm(final String formName,
final ItemSelectionModel itemSelectionModel,
final StringParameter selectedLanguageParam) {
super(new ColumnPanel(2)); super(new ColumnPanel(2));
m_widgetSection = new FormSection(new ColumnPanel(2, true)); Objects.requireNonNull(selectedLanguageParam);
widgetSection = new FormSection(new ColumnPanel(2, true));
super.add(m_widgetSection, ColumnPanel.INSERT); super.add(widgetSection, ColumnPanel.INSERT);
m_itemModel = itemModel; this.itemSelectionModel = itemSelectionModel;
this.selectedLanguageParam = selectedLanguageParam;
/* Prepare Panel design */ /* Prepare Panel design */
ColumnPanel panel = (ColumnPanel) getPanel(); final ColumnPanel panel = (ColumnPanel) getPanel();
panel.setBorder(false); panel.setBorder(false);
panel.setPadColor("#FFFFFF"); panel.setPadColor("#FFFFFF");
panel.setColumnWidth(1, "20%"); panel.setColumnWidth(1, "20%");
@ -95,8 +114,8 @@ public abstract class BasicItemForm extends FormSection
/* Add basic contents */ /* Add basic contents */
addWidgets(); addWidgets();
m_saveCancelSection = new SaveCancelSection(); saveCancelSection = new SaveCancelSection();
super.add(m_saveCancelSection, super.add(saveCancelSection,
ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT); ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
addInitListener(this); addInitListener(this);
@ -108,40 +127,38 @@ public abstract class BasicItemForm extends FormSection
* Construct a new BasicItemForm with a specified number of ColumnPanels and * Construct a new BasicItemForm with a specified number of ColumnPanels and
* without any content. * without any content.
* *
* @param formName the name of this form * @param formName the name of this form
* @param columnPanel the columnpanel of the form * @param columnPanel the column panel of the form
* @param itemModel The {@link ItemSelectionModel} which will be * @param itemSelectionModel The {@link ItemSelectionModel} which will be
* responsible for loading the current item * responsible for loading the current item
* @param selectedLanguageParam
*/ */
public BasicItemForm(String formName, public BasicItemForm(final String formName,
ColumnPanel columnPanel, final ColumnPanel columnPanel,
ItemSelectionModel itemModel) { final ItemSelectionModel itemSelectionModel,
final StringParameter selectedLanguageParam) {
super(columnPanel); super(columnPanel);
m_widgetSection = new FormSection(new ColumnPanel(columnPanel. Objects.requireNonNull(selectedLanguageParam);
widgetSection = new FormSection(new ColumnPanel(columnPanel.
getNumCols(), getNumCols(),
true)); true));
super.add(m_widgetSection, ColumnPanel.INSERT); super.add(widgetSection, ColumnPanel.INSERT);
m_itemModel = itemModel; this.itemSelectionModel = itemSelectionModel;
this.selectedLanguageParam = selectedLanguageParam;
} }
/** /**
* instanciate and add the save/cancel section for this form * create and add the save/cancel section for this form
*/ */
public void addSaveCancelSection() { public void addSaveCancelSection() {
m_saveCancelSection = new SaveCancelSection(); saveCancelSection = new SaveCancelSection();
super.add(m_saveCancelSection, super.add(saveCancelSection,
ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT); ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
} }
/**
* Currently, to insert javascript code the Label Widget is "abused".
*/
private final Label m_script = new Label(String.format(
"<script language=\"javascript\" src=\"%s/javascript/manipulate-input.js\"></script>",
Web.getWebappContextPath()),
false);
/** /**
* Add basic widgets to the form. * Add basic widgets to the form.
* *
@ -208,69 +225,70 @@ public abstract class BasicItemForm extends FormSection
} }
@Override @Override
public void generateXML(PageState ps, Element parent) { public void generateXML(final PageState state,
m_script.generateXML(ps, parent); final Element parent) {
super.generateXML(ps, parent); script.generateXML(state, parent);
super.generateXML(state, parent);
} }
/** /**
* @return the item selection model used in this form * @return the item selection model used in this form
*/ */
public ItemSelectionModel getItemSelectionModel() { public ItemSelectionModel getItemSelectionModel() {
return m_itemModel; return itemSelectionModel;
} }
/** /**
* @return the save/cancel section for this form * @return the save/cancel section for this form
*/ */
public SaveCancelSection getSaveCancelSection() { public SaveCancelSection getSaveCancelSection() {
return m_saveCancelSection; return saveCancelSection;
} }
/** /**
* Perform form initialisation. Children should override this this method to * Perform form initialisation. Children should override this this method to
* pre-fill the widgets with data, instantiate the content item, etc. * pre-fill the widgets with data, instantiate the content item, etc.
* *
* @param e * @param event
* *
* @throws FormProcessException * @throws FormProcessException
*/ */
@Override @Override
public abstract void init(FormSectionEvent e) throws FormProcessException; public abstract void init(final FormSectionEvent event) throws FormProcessException;
/** /**
* Process the form. Children have to override this method to save the * Process the form. Children have to override this method to save the
* user's changes to the database. * user's changes to the database.
* *
* @param e * @param event
* *
* @throws FormProcessException * @throws FormProcessException
*/ */
@Override @Override
public abstract void process(FormSectionEvent e) throws FormProcessException; public abstract void process(final FormSectionEvent event) throws FormProcessException;
/** /**
* Validate the form. Children have to override this method to provide * Validate the form. Children have to override this method to provide
* context form validation, specifically name (url) uniqueness in a folder! * context form validation, specifically name (url) uniqueness in a folder!
* *
* @param e * @param event
* *
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
*/ */
@Override @Override
public void validate(FormSectionEvent e) throws FormProcessException { public void validate(final FormSectionEvent event) throws FormProcessException {
// do nothing // do nothing
} }
/** /**
* Adds a component to this container. * Adds a component to this container.
* *
* @param pc the component to add to this BasicPageForm * @param component the component to add to this BasicPageForm
* *
*/ */
@Override @Override
public void add(Component pc) { public void add(final Component component) {
m_widgetSection.add(pc); widgetSection.add(component);
} }
/** /**
@ -278,21 +296,22 @@ public abstract class BasicItemForm extends FormSection
* Layout constraints are defined in each layout container as static ints. * Layout constraints are defined in each layout container as static ints.
* Use a bitwise OR to specify multiple constraints. * Use a bitwise OR to specify multiple constraints.
* *
* @param pc the component to add to this container * @param component the component to add to this container
* @param constraints layout constraints (a bitwise OR of static ints in the * @param constraints layout constraints (a bitwise OR of static ints in the
* particular layout) * particular layout)
*/ */
@Override @Override
public void add(Component pc, int constraints) { public void add(final Component component,
m_widgetSection.add(pc, constraints); final int constraints) {
widgetSection.add(component, constraints);
} }
/** /**
* This method can be overridden to change the label of the title field. To * This method can be overridden to change the label of the title field. To
* change to label of the title field can be useful for some content types. * change to label of the title field can be useful for some content types.
* For example, for an organization the label "Title" for the field may be * For example, for an organisation the label "Title" for the field may be
* confusing for the normal user. For such a content type, the label would * confusing for the normal user. For such a content type, the label would
* be changed to something like "Name of the organization". * be changed to something like "Name of the organisation".
* *
* @return (Content for the) Label for the title field as string * @return (Content for the) Label for the title field as string
*/ */

View File

@ -30,6 +30,7 @@ import com.arsdigita.bebop.event.ParameterListener;
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 org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
@ -42,6 +43,7 @@ import com.arsdigita.util.Assert;
import org.arsdigita.cms.CMSConfig; import org.arsdigita.cms.CMSConfig;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.workflow.WorkflowTemplate; import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItemInitializer; import org.librecms.contentsection.ContentItemInitializer;
@ -50,6 +52,7 @@ import org.librecms.contentsection.ContentType;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
/** /**
@ -73,32 +76,41 @@ public abstract class BasicPageForm extends BasicItemForm {
private static final String LAUNCH_DATE = "launch_date"; private static final String LAUNCH_DATE = "launch_date";
private final StringParameter selectedLanguageParam;
/** /**
* Construct a new BasicPageForm * Construct a new BasicPageForm
* *
* @param formName the name of this form * @param formName the name of this form
* @param itemModel The {@link ItemSelectionModel} which will be responsible * @param itemModel The {@link ItemSelectionModel} which will be
* for loading the current item * responsible for loading the current item
* @param selectedLanguageParam
*/ */
public BasicPageForm(final String formName, public BasicPageForm(final String formName,
final ItemSelectionModel itemModel) { final ItemSelectionModel itemModel,
final StringParameter selectedLanguageParam) {
super(formName, itemModel); super(formName, itemModel, selectedLanguageParam);
Objects.requireNonNull(selectedLanguageParam);
this.selectedLanguageParam = selectedLanguageParam;
} }
/** /**
* Construct a new BasicPageForm with nothing on it * Construct a new BasicPageForm with nothing on it
* *
* @param formName the name of this form * @param formName the name of this form
* @param columnPanel the column panel of the form * @param columnPanel the column panel of the form
* @param itemModel The {@link ItemSelectionModel} which will be * @param itemModel The {@link ItemSelectionModel} which will be
* responsible for loading the current item * responsible for loading the current item
* @param selectedLanguageParam
*/ */
public BasicPageForm(final String formName, public BasicPageForm(final String formName,
final ColumnPanel columnPanel, final ColumnPanel columnPanel,
final ItemSelectionModel itemModel) { final ItemSelectionModel itemModel,
final StringParameter selectedLanguageParam) {
super(formName, columnPanel, itemModel); super(formName, columnPanel, itemModel, selectedLanguageParam);
this.selectedLanguageParam = selectedLanguageParam;
} }
/** /**
@ -151,11 +163,20 @@ public abstract class BasicPageForm extends BasicItemForm {
final ContentItem item = getItemSelectionModel() final ContentItem item = getItemSelectionModel()
.getSelectedObject(state); .getSelectedObject(state);
final String selectedLanguage = (String) state
.getValue(selectedLanguageParam);
final Locale selectedLocale;
if (selectedLanguage == null) {
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
} else {
selectedLocale = new Locale(selectedLanguage);
}
if (item != null) { if (item != null) {
// Preset fields // Preset fields
data.put(CONTENT_ITEM_ID, Long.toString(item.getObjectId())); data.put(CONTENT_ITEM_ID, Long.toString(item.getObjectId()));
data.put(NAME, item.getName()); data.put(NAME, item.getName().getValue(selectedLocale));
data.put(TITLE, item.getTitle()); data.put(TITLE, item.getTitle().getValue(selectedLocale));
final CMSConfig cmsConfig = CMSConfig.getConfig(); final CMSConfig cmsConfig = CMSConfig.getConfig();
if (!cmsConfig.isHideLaunchDate()) { if (!cmsConfig.isHideLaunchDate()) {
data.put(LAUNCH_DATE, item.getLaunchDate()); data.put(LAUNCH_DATE, item.getLaunchDate());
@ -219,10 +240,17 @@ public abstract class BasicPageForm extends BasicItemForm {
if (item != null) { if (item != null) {
// Update attributes // Update attributes
final KernelConfig kernelConfig = KernelConfig.getConfig(); final String selectedLanguage = (String) state
final Locale defaultLocale = kernelConfig.getDefaultLocale(); .getValue(selectedLanguageParam);
item.getName().addValue(defaultLocale, (String) data.get(NAME)); final Locale selectedLocale;
item.getTitle().addValue(defaultLocale, (String) data.get(TITLE)); if (selectedLanguage == null) {
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
} else {
selectedLocale = new Locale(selectedLanguage);
}
item.getName().addValue(selectedLocale, (String) data.get(NAME));
item.getTitle().addValue(selectedLocale, (String) data.get(TITLE));
if (!CMSConfig.getConfig().isHideLaunchDate()) { if (!CMSConfig.getConfig().isHideLaunchDate()) {
item.setLaunchDate((Date) data.get(LAUNCH_DATE)); item.setLaunchDate((Date) data.get(LAUNCH_DATE));
} }
@ -238,6 +266,7 @@ public abstract class BasicPageForm extends BasicItemForm {
* Creation components may call this method in the process listener of their * Creation components may call this method in the process listener of their
* form. See {@link PageCreate} for an example. * form. See {@link PageCreate} for an example.
* *
* @param <T>
* @param state * @param state
* @param name * @param name
* @param section * @param section
@ -331,8 +360,9 @@ public abstract class BasicPageForm extends BasicItemForm {
// folder, // folder,
// clazz, // clazz,
// initializer); // initializer);
item = controller.createContentItem(name, section, folder, clazz, item = controller
initializer); .createContentItem(name, section, folder, clazz,
initializer);
} else { } else {
// item = itemManager.createContentItem(name, // item = itemManager.createContentItem(name,
// section, // section,
@ -341,11 +371,11 @@ public abstract class BasicPageForm extends BasicItemForm {
// clazz, // clazz,
// initializer); // initializer);
item = controller.createContentItem(name, item = controller.createContentItem(name,
section, section,
folder, folder,
workflowTemplate, workflowTemplate,
clazz, clazz,
initializer); initializer);
} }
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
throw new FormProcessException( throw new FormProcessException(

View File

@ -27,6 +27,7 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.PrintEvent; import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener; import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.parameters.StringParameter;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentType; import org.librecms.contentsection.ContentType;
@ -78,18 +79,20 @@ public class PageCreateForm
/** /**
* Construct a new PageCreationForm * Construct a new PageCreationForm
* *
* @param itemModel The {@link ItemSelectionModel} which will be * @param itemModel The {@link ItemSelectionModel} which will be
* responsible for loading the current item * responsible for loading the current item
* @param creationSelector The {@link CreationSelector} parent. This class * @param creationSelector The {@link CreationSelector} parent. This
* should call either the {@link * class should call either the {@link
* CreationSelector#redirectBack(PageState)} or {@link * CreationSelector#redirectBack(PageState)} or {@link
* CreationSelector#editItem(PageState, ContentItem)} methods on the parent * CreationSelector#editItem(PageState, ContentItem)} methods on the parent
* eventually * eventually
* @param selectedLanguageParam
*/ */
public PageCreateForm(final ItemSelectionModel itemModel, public PageCreateForm(final ItemSelectionModel itemModel,
final CreationSelector creationSelector) { final CreationSelector creationSelector,
final StringParameter selectedLanguageParam) {
super("PageCreate", itemModel); super("PageCreate", itemModel, selectedLanguageParam);
this.creationSelector = creationSelector; this.creationSelector = creationSelector;

View File

@ -50,6 +50,7 @@ import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
/** /**
@ -136,6 +137,9 @@ public class SimpleEditStep extends SecurityPropertyEditor
final String parameterSuffix) { final String parameterSuffix) {
super(); super();
Objects.requireNonNull(selectedLanguageParam);
this.authoringKitWizard = authoringKitWizard; this.authoringKitWizard = authoringKitWizard;
this.itemSelectionModel = itemSelectionModel; this.itemSelectionModel = itemSelectionModel;

View File

@ -23,6 +23,7 @@ import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.form.Date; import com.arsdigita.bebop.form.Date;
import com.arsdigita.bebop.parameters.NotEmptyValidationListener; import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.CreationSelector; import com.arsdigita.cms.ui.authoring.CreationSelector;
import com.arsdigita.cms.ui.authoring.PageCreateForm; import com.arsdigita.cms.ui.authoring.PageCreateForm;
@ -43,8 +44,10 @@ public class EventCreateForm extends PageCreateForm {
private Date startDate; private Date startDate;
public EventCreateForm(final ItemSelectionModel itemSelectionModel, public EventCreateForm(final ItemSelectionModel itemSelectionModel,
final CreationSelector creationSelector) { final CreationSelector creationSelector,
super(itemSelectionModel, creationSelector); final StringParameter selectedLanguageParam) {
super(itemSelectionModel, creationSelector, selectedLanguageParam);
} }
@Override @Override

View File

@ -21,10 +21,9 @@ package com.arsdigita.cms.ui.contenttypes;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
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.FormSubmissionListener;
import com.arsdigita.bebop.form.Date; import com.arsdigita.bebop.form.Date;
import com.arsdigita.bebop.parameters.NotEmptyValidationListener; import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.CreationSelector; import com.arsdigita.cms.ui.authoring.CreationSelector;
import com.arsdigita.cms.ui.authoring.PageCreateForm; import com.arsdigita.cms.ui.authoring.PageCreateForm;
@ -45,9 +44,10 @@ public class NewsCreateForm extends PageCreateForm {
private Date newsDate; private Date newsDate;
public NewsCreateForm(final ItemSelectionModel itemSelectionModel, public NewsCreateForm(final ItemSelectionModel itemSelectionModel,
final CreationSelector creationSelector) { final CreationSelector creationSelector,
final StringParameter selectedLanguageParam) {
super(itemSelectionModel, creationSelector); super(itemSelectionModel, creationSelector, selectedLanguageParam);
} }
@Override @Override