diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleCreateForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleCreateForm.java new file mode 100644 index 000000000..ee8c9d343 --- /dev/null +++ b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleCreateForm.java @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2017 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.arsdigita.cms.contenttypes.ui.mparticle; + +import com.arsdigita.bebop.ColumnPanel; +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.FormSection; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.FormSubmissionListener; +import com.arsdigita.bebop.event.FormValidationListener; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection; +import com.arsdigita.cms.ui.authoring.CreationComponent; +import com.arsdigita.cms.ui.authoring.CreationSelector; +import com.arsdigita.cms.ui.authoring.LanguageWidget; +import com.arsdigita.globalization.GlobalizedMessage; +import com.arsdigita.kernel.KernelConfig; +import java.util.Date; +import org.arsdigita.cms.CMSConfig; +import org.librecms.CmsConstants; +import org.librecms.contentsection.ContentSection; +import org.librecms.contentsection.Folder; +import org.librecms.contenttypes.MultiPartArticle; + +/** + * A form which will create a MultiPartArticle or one of its subclasses. + * + * @author Dave Turner + * @author Jens Pelzetter + */ +public class MultiPartArticleCreateForm + extends MultiPartArticleForm + implements FormInitListener, + FormProcessListener, + FormSubmissionListener, + FormValidationListener, + CreationComponent { + + private final CreationSelector creationSelector; + private ApplyWorkflowFormSection workflowSection; + + public MultiPartArticleCreateForm(final ItemSelectionModel itemSelectionModel, + final CreationSelector creationSelector) { + super("MultiPartArticleCreate", itemSelectionModel); + this.creationSelector = creationSelector; + workflowSection.setCreationSelector(creationSelector); + workflowSection.setContentType(itemSelectionModel.getContentType()); + addSubmissionListener(this); + getSaveCancelSection() + .getSaveButton() + .setButtonLabel(new GlobalizedMessage("cms.ui.create", + CmsConstants.CMS_BUNDLE)); + } + + @Override + protected void addWidgets() { + workflowSection = new ApplyWorkflowFormSection(); + add(workflowSection, ColumnPanel.INSERT); + add(new Label(new GlobalizedMessage("cms.ui.language.field", + CmsConstants.CMS_BUNDLE))); + add(new LanguageWidget(LANGUAGE)); + super.addWidgets(); + } + + /** + * Return the ApplyWorkflowFormSection associated with this + * CreationComponent. + * + * @return the ApplyWorkflowFormSection associated with this + * CreationComponent. + */ + @Override + public ApplyWorkflowFormSection getWorkflowSection() { + return workflowSection; + } + + @Override + public void init(final FormSectionEvent event) throws FormProcessException { + // this is currently a no-op + } + + @Override + public void submitted(final FormSectionEvent event) + throws FormProcessException { + + final PageState state = event.getPageState(); + + if (getSaveCancelSection().getCancelButton().isSelected(state)) { + creationSelector.redirectBack(state); + throw new FormProcessException( + "Submission cancelled", + new GlobalizedMessage( + "cms.contenttypes.ui.mparticle.submission_cancelled", + CmsConstants.CMS_BUNDLE) + ); + } + } + + @Override + public void validate(final FormSectionEvent event) + throws FormProcessException { + + final Folder folder = creationSelector.getFolder(event.getPageState()); + if (!validateNameUniqueness(folder, event)) { + throw new FormProcessException( + "An item with this name already exists", + new GlobalizedMessage( + "cms.contenttypes.ui.mparticle." + + "an_item_with_this_name_already_exists", + CmsConstants.CMS_BUNDLE) + ); + } + } + + @Override + public void process(final FormSectionEvent e) throws FormProcessException { + final FormData data = e.getFormData(); + final PageState state = e.getPageState(); + final ContentSection section = creationSelector.getContentSection(state); + final Folder folder = creationSelector.getFolder(state); + + final MultiPartArticle article = createArticle(state, + (String) data.get(NAME), + section, + folder); + article.getTitle().addValue(KernelConfig.getConfig().getDefaultLocale(), + (String) data.get(TITLE)); + if (!CMSConfig.getConfig().isHideLaunchDate()) { + article.setLaunchDate((Date) data.get(LAUNCH_DATE)); + } + article + .getSummary() + .addValue(KernelConfig.getConfig().getDefaultLocale(), + (String) data.get(SUMMARY)); + + workflowSection.applyWorkflow(state, article); + + creationSelector.editItem(state, article); + } +} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleForm.java new file mode 100644 index 000000000..8622e43e7 --- /dev/null +++ b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleForm.java @@ -0,0 +1,338 @@ +/* + * Copyright (C) 2017 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.arsdigita.cms.contenttypes.ui.mparticle; + +import com.arsdigita.bebop.ColumnPanel; +import com.arsdigita.bebop.Embedded; +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.FormSection; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.SaveCancelSection; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.FormValidationListener; +import com.arsdigita.bebop.form.TextArea; +import com.arsdigita.bebop.form.TextField; +import com.arsdigita.bebop.parameters.DateParameter; +import com.arsdigita.bebop.parameters.NotEmptyValidationListener; +import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.bebop.parameters.ParameterModel; +import com.arsdigita.bebop.parameters.TrimmedStringParameter; +import com.arsdigita.bebop.parameters.URLTokenValidationListener; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.globalization.GlobalizedMessage; +import com.arsdigita.kernel.KernelConfig; +import com.arsdigita.web.Web; +import com.arsdigita.xml.Element; +import java.util.Date; +import java.util.Locale; +import javax.servlet.ServletException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.arsdigita.cms.CMSConfig; +import org.libreccm.cdi.utils.CdiUtil; +import org.librecms.CmsConstants; +import org.librecms.contentsection.ContentItemManager; +import org.librecms.contentsection.ContentItemRepository; +import org.librecms.contentsection.ContentSection; +import org.librecms.contentsection.Folder; +import org.librecms.contenttypes.MultiPartArticle; + +/** + * A form for editing MultiPartArticle and subclasses. + * + * @author Dave Turner + * @author Jens Pelzetter + */ +public abstract class MultiPartArticleForm + extends FormSection + implements FormInitListener, + FormProcessListener, + FormValidationListener { + + private ItemSelectionModel itemSelectionModel; + private SaveCancelSection saveCancelSection; + /** + * Constant property, placeholder for a JavaScript element. + */ + private final Embedded m_script = new Embedded( + String.format("" + + "", + Web.getWebappContextPath()), + false); + + public static final String NAME = "name"; + public static final String TITLE = "title"; + public static final String SUMMARY = "summary"; + public static final String LAUNCH_DATE = "launch_date"; + public static final String LANGUAGE = "language"; + + private static final Logger LOGGER = LogManager.getLogger( + MultiPartArticleForm.class); + + public MultiPartArticleForm(final String formName, + final ItemSelectionModel itemSelectionModel) { + + super(new ColumnPanel(2)); + + this.itemSelectionModel = itemSelectionModel; + + ColumnPanel panel = (ColumnPanel) getPanel(); + panel.setBorder(false); + panel.setPadColor("#FFFFFF"); + panel.setColumnWidth(1, "20%"); + panel.setColumnWidth(2, "80%"); + panel.setWidth("100%"); + + addWidgets(); + + addSaveCancelSection(); + + addInitListener(this); + addProcessListener(this); + addValidationListener(this); + } + + public void addSaveCancelSection() { + saveCancelSection = new SaveCancelSection(); + add(saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT); + } + + public SaveCancelSection getSaveCancelSection() { + return saveCancelSection; + } + + protected void addWidgets() { + + // add(new Label(GlobalizationUtil + // .globalize("cms.contenttypes.ui.title"))); + TextField titleWidget = new TextField(new TrimmedStringParameter(TITLE)); + titleWidget.setLabel(new GlobalizedMessage("cms.contenttypes.ui.title", + CmsConstants.CMS_BUNDLE)); + titleWidget.addValidationListener(new NotNullValidationListener()); + titleWidget.setOnFocus("if (this.form." + NAME + ".value == '') { " + + " defaulting = true; this.form." + NAME + + ".value = urlize(this.value); }"); + titleWidget.setOnKeyUp( + "if (defaulting) { this.form." + NAME + + ".value = urlize(this.value) }" + ); + add(titleWidget); + + //add(new Label(GlobalizationUtil + // .globalize("cms.contenttypes.ui.name"))); + TextField nameWidget = new TextField(new TrimmedStringParameter(NAME)); + nameWidget.setLabel(new GlobalizedMessage("cms.contenttypes.ui.name", + CmsConstants.CMS_BUNDLE)); + nameWidget.addValidationListener(new NotNullValidationListener()); + nameWidget.addValidationListener(new URLTokenValidationListener()); + nameWidget.setOnFocus("defaulting = false"); + nameWidget.setOnBlur( + "if (this.value == '') " + + "{ defaulting = true; this.value = urlize(this.form." + TITLE + + ".value) }" + ); + add(nameWidget); + + if (!CMSConfig.getConfig().isHideLaunchDate()) { + //add(new Label(GlobalizationUtil + // .globalize("cms.ui.authoring.page_launch_date"))); + final ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE); + com.arsdigita.bebop.form.Date launchDate + = new com.arsdigita.bebop.form.Date( + launchDateParam); + if (CMSConfig.getConfig().isRequireLaunchDate()) { + launchDate.addValidationListener(new NotNullValidationListener( + new GlobalizedMessage( + "cms.contenttypes.ui.mparticle.no_launch_date", + CmsConstants.CMS_BUNDLE))); + // if launch date is required, help user by suggesting today's date + launchDateParam.setDefaultValue(new Date()); + } + launchDate.setLabel(new GlobalizedMessage( + "cms.ui.authoring.page_launch_date", + CmsConstants.CMS_BUNDLE)); + add(launchDate); + } + + //add(new Label(GlobalizationUtil + // .globalize("cms.contenttypes.ui.summary"))); + final TextArea summaryWidget = new TextArea( + new TrimmedStringParameter(SUMMARY)); + if (CMSConfig.getConfig().isMandatoryDescriptions()) { + summaryWidget + .addValidationListener(new NotEmptyValidationListener( + new GlobalizedMessage( + "cms.contenttypes.ui.description_missing", + CmsConstants.CMS_BUNDLE))); + } + summaryWidget.setLabel(new GlobalizedMessage( + "cms.contenttypes.ui.summary", + CmsConstants.CMS_BUNDLE)); + summaryWidget.setRows(5); + summaryWidget.setCols(30); + summaryWidget.setHint(new GlobalizedMessage( + "cms.contenttypes.ui.summary_hint", + CmsConstants.CMS_BUNDLE)); + add(summaryWidget); + } + + @Override + public abstract void init(final FormSectionEvent event) + throws FormProcessException; + + @Override + public abstract void process(final FormSectionEvent event) + throws FormProcessException; + + @Override + public abstract void validate(final FormSectionEvent event) + throws FormProcessException; + + /** + * Utility method to initialise the name/title/summary widgets. + * + * @param event + * @return + */ + public MultiPartArticle initBasicWidgets(final FormSectionEvent event) { + + final FormData data = event.getFormData(); + final PageState state = event.getPageState(); + final MultiPartArticle article = (MultiPartArticle) itemSelectionModel + .getSelectedObject(state); + + if (article != null) { + data.put(NAME, article.getName()); + data.put(TITLE, article.getTitle()); + if (!CMSConfig.getConfig().isHideLaunchDate()) { + data.put(LAUNCH_DATE, article.getLaunchDate()); + } + data.put(SUMMARY, article.getSummary()); + } + + return article; + } + + /** + * Utility method to process the name/title/summary widgets. + * + * @param event + * @return + */ + public MultiPartArticle processBasicWidgets(final FormSectionEvent event) { + + final FormData data = event.getFormData(); + final PageState state = event.getPageState(); + final MultiPartArticle article = (MultiPartArticle) itemSelectionModel + .getSelectedObject(state); + + if (article != null) { + final Locale defaultLocale = KernelConfig.getConfig(). + getDefaultLocale(); + article.getName().addValue(defaultLocale, + (String) data.get(NAME)); + article.getTitle().addValue(defaultLocale, + (String) data.get(TITLE)); + if (!CMSConfig.getConfig().isHideLaunchDate()) { + article.setLaunchDate((Date) data.get(LAUNCH_DATE)); + } + article.getSummary().addValue(defaultLocale, + (String) data.get(SUMMARY)); + } + + return article; + } + + /** + * Ensure that the name of an item is unique within a folder. + * + * @param folder the folder in which to check + * @param event the FormSectionEvent which was passed to the validation + * listener + * + * @return true if the name is not null and unique, false otherwise + */ + public boolean validateNameUniqueness(final Folder folder, + final FormSectionEvent event) { + + final FormData data = event.getFormData(); + final String name = (String) data.get(NAME); + + if (name != null) { + final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); + final ContentItemRepository itemRepo = cdiUtil + .findBean(ContentItemRepository.class); + + final long result = itemRepo.countByNameInFolder(folder, name); + + return result == 0; + } + + // false if name == null + return false; + } + + /** + * Utility method to create a new MultiPartArticle and update the selected + * model. This can be called in the process method of a ProcessListener. + * + * @param state the current page state + * @param name + * @param section + * @param folder + * + * @return the new content item (or a proper subclass) + * @throws com.arsdigita.bebop.FormProcessException + */ + public MultiPartArticle createArticle(final PageState state, + final String name, + final ContentSection section, + final Folder folder) + throws FormProcessException { + + final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); + final ContentItemManager itemManager = cdiUtil + .findBean(ContentItemManager.class); + + final MultiPartArticle article = itemManager + .createContentItem(name, + section, + folder, + MultiPartArticle.class); + + if (itemSelectionModel.getSelectedKey(state) == null) { + itemSelectionModel.setSelectedKey(state, article.getObjectId()); + } + + return article; + } + + @Override + public void generateXML(final PageState state, final Element parent) { + + m_script.generateXML(state, parent); + super.generateXML(state, parent); + } + +} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicItemForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicItemForm.java index 93eec9f44..55332a442 100755 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicItemForm.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicItemForm.java @@ -372,8 +372,6 @@ public abstract class BasicItemForm extends FormSection if (newName != null) { final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final CategoryRepository categoryRepo = cdiUtil - .findBean(CategoryRepository.class); final ContentItemRepository itemRepo = cdiUtil .findBean(ContentItemRepository.class); diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicPageForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicPageForm.java index 83397384e..c63aeb99b 100755 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicPageForm.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicPageForm.java @@ -45,9 +45,6 @@ import org.libreccm.cdi.utils.CdiUtil; import org.librecms.CmsConstants; import org.librecms.contentsection.ContentItemManager; import org.librecms.contentsection.ContentType; -import org.librecms.contentsection.FolderManager; - -import javax.servlet.ServletException; import java.util.Date; import java.util.Locale; @@ -74,8 +71,6 @@ public abstract class BasicPageForm extends BasicItemForm { private static final String LAUNCH_DATE = "launch_date"; - private FormSection widgetSection; - /** * Construct a new BasicPageForm * @@ -194,7 +189,6 @@ public abstract class BasicPageForm extends BasicItemForm { final Optional folder = itemManager.getItemFolder(item); if (folder.isPresent()) { - final FormData data = fse.getFormData(); final String name = fse.getFormData().getString(NAME); if (!item.getName() .getValue(KernelConfig.getConfig().getDefaultLocale()) diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/CreationSelector.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/CreationSelector.java index 8d6266389..485b13dca 100755 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/CreationSelector.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/CreationSelector.java @@ -21,6 +21,7 @@ package com.arsdigita.cms.ui.authoring; import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Form; +import com.arsdigita.bebop.FormSection; import com.arsdigita.bebop.MetaForm; import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; @@ -107,13 +108,11 @@ public class CreationSelector extends MetaForm { * Constructs a new CreationSelector. Load all the possible * creation components from the database and stick them in the Map. * - * @param typeSelectionModel the {@link SingleSelectionModel} which will - * supply a BigDecimal ID of the content type to - * instantiate + * @param typeSelectionModel the {@link SingleSelectionModel} which will + * supply a BigDecimal ID of the content type to instantiate * * @param folderSelectionModel the {@link FolderSelectionModel} containing - * the folder in which new items are to be - * created + * the folder in which new items are to be created */ public CreationSelector(final SingleSelectionModel typeSelectionModel, final FolderSelectionModel folderSelectionModel) { @@ -191,7 +190,7 @@ public class CreationSelector extends MetaForm { */ protected Component instantiateKitComponent(final AuthoringKitInfo kit, final ContentType type) { - final Class createClass = kit + final Class createClass = kit .getCreateComponent(); final Object[] vals; @@ -200,18 +199,17 @@ public class CreationSelector extends MetaForm { itemIdParameter); vals = new Object[]{itemModel, this}; - final Constructor constructor - = createClass - .getConstructor(arguments); + final Constructor constructor = createClass + .getConstructor(arguments); final Component component = (Component) constructor .newInstance(vals); return component; } catch (IllegalAccessException - | IllegalArgumentException - | InstantiationException - | NoSuchMethodException - | SecurityException - | InvocationTargetException ex) { + | IllegalArgumentException + | InstantiationException + | NoSuchMethodException + | SecurityException + | InvocationTargetException ex) { LOGGER.error("\"Failed to instantiate creation component \"{}\".", kit.getCreateComponent().getName()); LOGGER.error(ex); @@ -229,7 +227,7 @@ public class CreationSelector extends MetaForm { * @param state represents the current request * * @return the currently selected folder, in which new items should be - * placed. + * placed. */ public final Folder getFolder(final PageState state) { return (Folder) folderSelectionModel.getSelectedObject(state); @@ -257,7 +255,7 @@ public class CreationSelector extends MetaForm { * complete. * * @param state the page state - * @param item the newly created item + * @param item the newly created item */ public void editItem(final PageState state, final ContentItem item) { final ContentSection section = getContentSection(state); diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/PageCreate.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/PageCreateForm.java similarity index 97% rename from ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/PageCreate.java rename to ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/PageCreateForm.java index a5a6247dc..13d09dd0d 100755 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/PageCreate.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/PageCreateForm.java @@ -35,13 +35,9 @@ import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.kernel.KernelConfig; import com.arsdigita.util.Assert; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.arsdigita.cms.CMSConfig; import org.librecms.CmsConstants; import org.librecms.contentsection.ContentItem; -import java.util.Date; import java.util.Locale; /** @@ -58,7 +54,7 @@ import java.util.Locale; * @author Stanislav Freidin (stas@arsdigita.com) * @author Jens Pelzetter */ -public class PageCreate +public class PageCreateForm extends BasicPageForm implements FormSubmissionListener, CreationComponent { @@ -81,7 +77,7 @@ public class PageCreate * CreationSelector#editItem(PageState, ContentItem)} methods on the parent * eventually */ - public PageCreate(final ItemSelectionModel itemModel, + public PageCreateForm(final ItemSelectionModel itemModel, final CreationSelector creationSelector) { super("PageCreate", itemModel); @@ -141,6 +137,7 @@ public class PageCreate /** * Create a new item id. * + * @param event * @throws com.arsdigita.bebop.FormProcessException */ @Override @@ -152,6 +149,7 @@ public class PageCreate * If the Cancel button was pressed, hide self and show the display * component. * + * @param event * @throws com.arsdigita.bebop.FormProcessException */ @Override diff --git a/ccm-cms/src/main/java/org/librecms/contenttypes/Article.java b/ccm-cms/src/main/java/org/librecms/contenttypes/Article.java index 13d805269..c8e2fb4ba 100644 --- a/ccm-cms/src/main/java/org/librecms/contenttypes/Article.java +++ b/ccm-cms/src/main/java/org/librecms/contenttypes/Article.java @@ -18,6 +18,7 @@ */ package org.librecms.contenttypes; +import com.arsdigita.cms.ui.authoring.PageCreateForm; import java.io.Serializable; import java.util.Objects; @@ -44,6 +45,8 @@ import org.librecms.contentsection.ContentItem; @Table(name = "ARTICLES", schema = DB_SCHEMA) @ContentTypeDescription(labelBundle = "org.librecms.contenttypes.Article", descriptionBundle = "org.librecms.contenttypes.Article") +@AuthoringKit(createComponent = PageCreateForm.class, + steps = {}) public class Article extends ContentItem implements Serializable { private static final long serialVersionUID = 3832010184748095822L; diff --git a/ccm-cms/src/main/java/org/librecms/contenttypes/AuthoringKit.java b/ccm-cms/src/main/java/org/librecms/contenttypes/AuthoringKit.java index e1be1afbf..a9a7da70a 100644 --- a/ccm-cms/src/main/java/org/librecms/contenttypes/AuthoringKit.java +++ b/ccm-cms/src/main/java/org/librecms/contenttypes/AuthoringKit.java @@ -18,7 +18,8 @@ */ package org.librecms.contenttypes; -import com.arsdigita.cms.ui.item.ItemCreateForm; +import com.arsdigita.bebop.FormSection; +import com.arsdigita.cms.ui.authoring.PageCreateForm; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -33,7 +34,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) public @interface AuthoringKit { - Class createComponent(); + Class createComponent(); AuthoringStep[] steps(); diff --git a/ccm-cms/src/main/java/org/librecms/contenttypes/AuthoringKitInfo.java b/ccm-cms/src/main/java/org/librecms/contenttypes/AuthoringKitInfo.java index e6a9e0596..352bb6729 100644 --- a/ccm-cms/src/main/java/org/librecms/contenttypes/AuthoringKitInfo.java +++ b/ccm-cms/src/main/java/org/librecms/contenttypes/AuthoringKitInfo.java @@ -18,6 +18,8 @@ */ package org.librecms.contenttypes; +import com.arsdigita.bebop.FormSection; +import com.arsdigita.cms.ui.authoring.PageCreateForm; import com.arsdigita.cms.ui.item.ItemCreateForm; import java.util.ArrayList; @@ -36,7 +38,7 @@ public class AuthoringKitInfo { * The create component (the form used to collect the mandatory data for the * content type). */ - private Class createComponent; + private Class createComponent; /** * The authoring steps of the authoring kit. @@ -47,12 +49,12 @@ public class AuthoringKitInfo { authoringSteps = new ArrayList<>(); } - public Class getCreateComponent() { + public Class getCreateComponent() { return createComponent; } public void setCreateComponent( - final Class createComponent) { + final Class createComponent) { this.createComponent = createComponent; } @@ -66,7 +68,7 @@ public class AuthoringKitInfo { } protected void setAuthoringSteps( - final List authoringSteps) { + final List authoringSteps) { this.authoringSteps = authoringSteps; } @@ -118,9 +120,9 @@ public class AuthoringKitInfo { public String toString(final String data) { return String.format("%s{ " - + "createComponent = \"%s\", " - + "authoringSteps = { %s }%s" - + " }", + + "createComponent = \"%s\", " + + "authoringSteps = { %s }%s" + + " }", super.toString(), Objects.toString(createComponent), Objects.toString(authoringSteps), diff --git a/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java b/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java index d5b6e7db1..9f4cebea9 100644 --- a/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java +++ b/ccm-cms/src/main/java/org/librecms/contenttypes/Event.java @@ -18,6 +18,7 @@ */ package org.librecms.contenttypes; +import com.arsdigita.cms.ui.authoring.PageCreateForm; import java.io.Serializable; import java.util.Date; import java.util.Objects; @@ -50,6 +51,8 @@ import static org.librecms.CmsConstants.*; @Table(name = "EVENTS", schema = DB_SCHEMA) @ContentTypeDescription(labelBundle = "org.librecms.contenttypes.Event", descriptionBundle = "org.librecms.contenttypes.Event") +@AuthoringKit(createComponent = PageCreateForm.class, + steps = {}) public class Event extends ContentItem implements Serializable { private static final long serialVersionUID = -9104886733503414635L; diff --git a/ccm-cms/src/main/java/org/librecms/contenttypes/MultiPartArticle.java b/ccm-cms/src/main/java/org/librecms/contenttypes/MultiPartArticle.java index 5b1b5caf9..6b6b2e356 100644 --- a/ccm-cms/src/main/java/org/librecms/contenttypes/MultiPartArticle.java +++ b/ccm-cms/src/main/java/org/librecms/contenttypes/MultiPartArticle.java @@ -18,6 +18,7 @@ */ package org.librecms.contenttypes; +import com.arsdigita.cms.contenttypes.ui.mparticle.MultiPartArticleCreateForm; import org.hibernate.envers.Audited; import org.libreccm.l10n.LocalizedString; import org.librecms.contentsection.ContentItem; @@ -47,6 +48,8 @@ import static org.librecms.CmsConstants.*; @Table(name = "MULTIPART_ARTICLES", schema = DB_SCHEMA) @ContentTypeDescription(labelBundle = "org.librecms.contenttypes.MultiPartArticle", descriptionBundle = "org.librecms.contenttypes.MultiPartArticle") +@AuthoringKit(createComponent = MultiPartArticleCreateForm.class, + steps = {}) public class MultiPartArticle extends ContentItem implements Serializable { private static final long serialVersionUID = -587374085831420868L; diff --git a/ccm-cms/src/main/java/org/librecms/contenttypes/News.java b/ccm-cms/src/main/java/org/librecms/contenttypes/News.java index 4438dcfd0..8dddfd3f4 100644 --- a/ccm-cms/src/main/java/org/librecms/contenttypes/News.java +++ b/ccm-cms/src/main/java/org/librecms/contenttypes/News.java @@ -18,6 +18,7 @@ */ package org.librecms.contenttypes; +import com.arsdigita.cms.ui.authoring.PageCreateForm; import org.hibernate.envers.Audited; import org.hibernate.validator.constraints.NotEmpty; import org.libreccm.l10n.LocalizedString; @@ -48,6 +49,8 @@ import static org.librecms.CmsConstants.*; @Table(name = "NEWS", schema = DB_SCHEMA) @ContentTypeDescription(labelBundle = "org.librecms.contenttypes.News", descriptionBundle = "org.librecms.contenttypes.News") +@AuthoringKit(createComponent = PageCreateForm.class, + steps = {}) public class News extends ContentItem implements Serializable { private static final long serialVersionUID = -4939565845920227974L;