From 15ff6e8f86d2dddc5c12c5438d4d4e7f44aab86c Mon Sep 17 00:00:00 2001 From: jensp Date: Wed, 6 Sep 2017 08:41:30 +0000 Subject: [PATCH] CCM NG/ccm-cms: Some bugfixes git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4985 8810af33-2d31-482b-a856-94f89814c4df --- .../cms/ui/authoring/WizardSelector.java | 1 + .../assets/relatedinfo/AttachmentsTable.java | 5 ++++ .../RelatedInfoAttachAssetForm.java | 23 +++++++++++++--- .../relatedinfo/RelatedInfoListForm.java | 3 ++- .../relatedinfo/RelatedInfoListTable.java | 4 +++ .../RelatedInfoListTableModel.java | 13 +++++---- .../assets/relatedinfo/RelatedInfoStep.java | 27 +++++++++++++------ .../RelatedInfoStepController.java | 16 +++++------ .../org/librecms/CmsResources.properties | 19 +++++++++++++ .../org/librecms/CmsResources_de.properties | 19 +++++++++++++ .../org/librecms/CmsResources_fr.properties | 19 +++++++++++++ .../main/java/com/arsdigita/xml/Document.java | 2 +- 12 files changed, 125 insertions(+), 26 deletions(-) diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/WizardSelector.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/WizardSelector.java index e476cf09a..b5d990d37 100755 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/WizardSelector.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/WizardSelector.java @@ -149,6 +149,7 @@ public class WizardSelector extends AuthoringKitSelector /** * Reset the state of the current wizard */ + @Override public void reset(final PageState state) { final Resettable resettable = (Resettable) getCurrentWizard(state); if (resettable != null) { diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/AttachmentsTable.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/AttachmentsTable.java index 6aff69773..9807d15c7 100644 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/AttachmentsTable.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/AttachmentsTable.java @@ -31,6 +31,7 @@ import com.arsdigita.bebop.table.TableCellRenderer; import com.arsdigita.bebop.table.TableColumn; import com.arsdigita.bebop.table.TableColumnModel; import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.GlobalNavigation; import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel; import com.arsdigita.cms.ui.authoring.assets.AttachmentSelectionModel; import com.arsdigita.globalization.GlobalizedMessage; @@ -108,6 +109,10 @@ class AttachmentsTable extends Table { .getColumn(COL_REMOVE) .setCellRenderer(new ControlLinkCellRenderer()); + setEmptyView(new Label(new GlobalizedMessage( + "cms.ui.authoring.assets.related_info_step.attachment.none", + CmsConstants.CMS_BUNDLE))); + super .addTableActionListener(new TableActionListener() { diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoAttachAssetForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoAttachAssetForm.java index 16cbd1b54..f14b8e7b6 100644 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoAttachAssetForm.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoAttachAssetForm.java @@ -20,6 +20,7 @@ package com.arsdigita.cms.ui.authoring.assets.relatedinfo; import com.arsdigita.bebop.Form; import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SaveCancelSection; import com.arsdigita.bebop.event.FormInitListener; @@ -79,9 +80,20 @@ class RelatedInfoAttachAssetForm super.addSubmissionListener(this); } + @Override + public void register(final Page page) { + super.register(page); + + page.addComponentStateParam(this, itemSelectionModel.getStateParameter()); + page.addComponentStateParam(this, listSelectionModel.getStateParameter()); + } + @Override public void init(final FormSectionEvent event) throws FormProcessException { - // Nothing yet + if (listSelectionModel.getSelectedKey(event.getPageState()) == null) { + throw new UnexpectedErrorException("The selected list null. " + + "This should not happen."); + } } @Override @@ -90,6 +102,11 @@ class RelatedInfoAttachAssetForm final PageState state = event.getPageState(); + if (listSelectionModel.getSelectedKey(state) == null) { + throw new UnexpectedErrorException("The selected list null. " + + "This should not happen."); + } + final Object value = searchWidget.getValue(state); if (value != null) { final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); @@ -101,10 +118,10 @@ class RelatedInfoAttachAssetForm .findById((long) value) .orElseThrow(() -> new UnexpectedErrorException(String .format("No Asset with ID %d in the database.", value))); - + final AttachmentList list = listSelectionModel .getSelectedAttachmentList(state); - + attachmentManager.attachAsset(asset, list); } diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListForm.java index a6e6fe798..b27d9389a 100644 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListForm.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListForm.java @@ -37,7 +37,6 @@ import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.parameters.GlobalizedParameterListener; import com.arsdigita.bebop.parameters.ParameterData; -import com.arsdigita.bebop.parameters.StringIsLettersOrDigitsValidationListener; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel; @@ -365,6 +364,8 @@ class RelatedInfoListForm controller.saveAttachmentList(attachmentList); } + + relatedInfoStep.showAttachmentListTable(state); } @Override diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListTable.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListTable.java index 0709a41de..b9837dd7a 100644 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListTable.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListTable.java @@ -122,6 +122,10 @@ class RelatedInfoListTable extends Table { .getColumn(COL_DELETE) .setCellRenderer(new ControlLinkCellRenderer()); + super.setEmptyView(new Label(new GlobalizedMessage( + "cms.ui.authoring.assets.related_info_step.list.none", + CmsConstants.CMS_BUNDLE))); + super .addTableActionListener(new TableActionListener() { diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListTableModel.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListTableModel.java index 003c90dd2..3651c9082 100644 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListTableModel.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoListTableModel.java @@ -20,6 +20,7 @@ package com.arsdigita.cms.ui.authoring.assets.relatedinfo; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.Text; import com.arsdigita.bebop.table.TableModel; import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel; import com.arsdigita.globalization.GlobalizedMessage; @@ -71,14 +72,15 @@ class RelatedInfoListTableModel implements TableModel { switch (columnIndex) { case RelatedInfoListTable.COL_NAME: - return currentRow.getName(); + return new Text(currentRow.getName()); case RelatedInfoListTable.COL_TITLE: - return currentRow.getTitle(); + return new Text(currentRow.getTitle()); case RelatedInfoListTable.COL_DESC: - return currentRow.getDescription(); + return new Text(currentRow.getDescription()); case RelatedInfoListTable.COL_EDIT: return new Label(new GlobalizedMessage( - "cms.ui.authoring.assets.related_info_step.list.edit")); + "cms.ui.authoring.assets.related_info_step.list.edit", + CmsConstants.CMS_BUNDLE)); case RelatedInfoListTable.COL_MOVE: if (moveListModel.getSelectedAttachmentList(state) == null) { return new Label(new GlobalizedMessage( @@ -91,7 +93,8 @@ class RelatedInfoListTableModel implements TableModel { } case RelatedInfoListTable.COL_DELETE: return new Label(new GlobalizedMessage( - "cms.ui.authoring.assets.related_info_step.list.delete")); + "cms.ui.authoring.assets.related_info_step.list.delete", + CmsConstants.CMS_BUNDLE)); default: throw new IllegalArgumentException(String.format( "Illegal column index %d.", columnIndex)); diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStep.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStep.java index 2037d7619..498640fcd 100644 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStep.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStep.java @@ -19,6 +19,7 @@ package com.arsdigita.cms.ui.authoring.assets.relatedinfo; import com.arsdigita.bebop.ActionLink; +import com.arsdigita.bebop.BoxPanel; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; @@ -91,9 +92,6 @@ public class RelatedInfoStep extends ResettableContainer { selectedListModel, selectedLanguageParam); - super.add(listTable); - super.add(listForm); - addListLink = new ActionLink(new Label(new GlobalizedMessage( "cms.ui.authoring.assets.related_info_step.add_list", CmsConstants.CMS_BUNDLE))); @@ -160,8 +158,7 @@ public class RelatedInfoStep extends ResettableContainer { CmsConstants.CMS_BUNDLE)); attachmentToFirstLink.addActionListener(event -> { final PageState state = event.getPageState(); - final ItemAttachment - toMove = moveAttachmentModel + final ItemAttachment toMove = moveAttachmentModel .getSelectedAttachment(state); final RelatedInfoStepController controller = CdiUtil @@ -186,6 +183,20 @@ public class RelatedInfoStep extends ResettableContainer { attachmentToFirstLink.setVisible(state, true); } }); + + final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL); + + panel.add(addListLink); + panel.add(listToFirstLink); + panel.add(listTable); + panel.add(listForm); + + panel.add(attachAssetLink); + panel.add(attachmentToFirstLink); + panel.add(attachmentsTable); + panel.add(attachAssetForm); + + super.add(panel); } @Override @@ -195,9 +206,9 @@ public class RelatedInfoStep extends ResettableContainer { page.addComponentStateParam(this, selectedListModel.getStateParameter()); page.addComponentStateParam(this, moveListModel.getStateParameter()); - page.addComponentStateParam(this, + page.addComponentStateParam(this, selectedAttachmentModel.getStateParameter()); - page.addComponentStateParam(this, + page.addComponentStateParam(this, moveAttachmentModel.getStateParameter()); page.setVisibleDefault(listTable, true); @@ -245,7 +256,7 @@ public class RelatedInfoStep extends ResettableContainer { attachAssetLink.setVisible(state, true); attachmentToFirstLink.setVisible(state, false); } - + void showAttachAssetForm(final PageState state) { listTable.setVisible(state, false); listForm.setVisible(state, false); diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStepController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStepController.java index 4a4215c9f..44501d95d 100644 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStepController.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/assets/relatedinfo/RelatedInfoStepController.java @@ -20,7 +20,6 @@ package com.arsdigita.cms.ui.authoring.assets.relatedinfo; import com.arsdigita.kernel.KernelConfig; -import org.apache.commons.fileupload.MultipartStream; import org.libreccm.configuration.ConfigurationManager; import org.librecms.assets.RelatedLink; import org.librecms.contentsection.AttachmentList; @@ -284,19 +283,18 @@ class RelatedInfoStepController { protected void createInternalLink(final AttachmentList attachmentList, final long targetItemId, final String title, -// final String description, + // final String description, final String selectedLanguage) { final ContentItem targetItem = itemRepo .findById(targetItemId) .orElseThrow(() -> new IllegalArgumentException(String .format("No ContentItem with ID %d in the database.", targetItemId))); - + final RelatedLink link = new RelatedLink(); link.setTargetItem(targetItem); final Locale selectedLocale = new Locale(selectedLanguage); link.getTitle().addValue(selectedLocale, title); - itemAttachmentManager.attachAsset(link, attachmentList); } @@ -319,15 +317,15 @@ class RelatedInfoStepController { } if (attachmentList.getDescription().hasValue(selectedLocale)) { - row.setTitle(shortenDescription(attachmentList + row.setDescription(shortenDescription(attachmentList .getDescription() .getValue(selectedLocale))); } else if (attachmentList.getDescription().hasValue(defaultLocale)) { - row.setTitle(shortenDescription(attachmentList + row.setDescription(shortenDescription(attachmentList .getDescription() .getValue(defaultLocale))); } else { - row.setTitle(shortenDescription(attachmentList + row.setDescription(shortenDescription(attachmentList .getDescription() .getValue())); } @@ -366,7 +364,9 @@ class RelatedInfoStepController { private String shortenDescription(final String description) { - if (description.trim().length() < 140) { + if (description == null) { + return ""; + } else if (description.trim().length() < 140) { return description.trim(); } else { final String tmp = description.trim().substring(0, 140); diff --git a/ccm-cms/src/main/resources/org/librecms/CmsResources.properties b/ccm-cms/src/main/resources/org/librecms/CmsResources.properties index 2e846a740..bafe3d755 100644 --- a/ccm-cms/src/main/resources/org/librecms/CmsResources.properties +++ b/ccm-cms/src/main/resources/org/librecms/CmsResources.properties @@ -420,3 +420,22 @@ cms.ui.assetlist.add_locale=Add data for language cms.ui.assetlist.name=Name cms.ui.assetlist.title=Title cms.ui.assetlist.description=Description +cms.ui.authoring.assets.related_info_step.add_list=Add list +cms.ui.authoring.assets.related_info_step.attachment_list.move_to_beginning=Move to first position +cms.ui.authoring.assets.related_info_step.attach_asset=Add related information +cms.ui.authoring.assets.related_info_step.attachment.move_to_first=Move to first position +cms.ui.authoring.assets.related_info_step.list.name=Name of list +cms.ui.authoring.assets.related_info_step.list.title=Title of list +cms.ui.authoring.assets.related_info_step.list.description=Description +cms.ui.authoring.assets.related_info_step.list.edit=Edit +cms.ui.authoring.assets.related_info_step.list.move=Move +cms.ui.authoring.assets.related_info_step.list.delete=Delete +cms.ui.authoring.assets.related_info_step.attachment.title=Attachment title +cms.ui.authoring.assets.related_info_step.attachment.type=Type +cms.ui.authoring.assets.related_info_step.attachment.move=Move +cms.ui.authoring.assets.related_info_step.attachment.remove=Remove +cms.ui.authoring.assets.related_info_step.attachment.none=No related information in this list yet +cms.ui.authoring.assets.related_info_step.attachment.move_here=Move here +cms.ui.authoring.assets.related_info_step.list.move_here=Move here +cms.ui.authoring.assets.related_info_step.list.none=No related informations yet +cms.ui.authoring.assets.related_info_step.list.edit\ \t=Edit diff --git a/ccm-cms/src/main/resources/org/librecms/CmsResources_de.properties b/ccm-cms/src/main/resources/org/librecms/CmsResources_de.properties index 1ef8fdb99..9ea363267 100644 --- a/ccm-cms/src/main/resources/org/librecms/CmsResources_de.properties +++ b/ccm-cms/src/main/resources/org/librecms/CmsResources_de.properties @@ -417,3 +417,22 @@ cms.ui.assetlist.add_locale=Daten f\u00fcr folgende Sprache hinzuf\u00fcgen cms.ui.assetlist.name=Name cms.ui.assetlist.title=Titel cms.ui.assetlist.description=Beschreibung +cms.ui.authoring.assets.related_info_step.add_list=Liste hinzuf\u00fcgen +cms.ui.authoring.assets.related_info_step.attachment_list.move_to_beginning=An die erste Position verschieben +cms.ui.authoring.assets.related_info_step.attach_asset=Weiterf\u00fchrende Informationen hinzuf\u00fcgen +cms.ui.authoring.assets.related_info_step.attachment.move_to_first=An die erste Position verschieben +cms.ui.authoring.assets.related_info_step.list.name=Name der Liste +cms.ui.authoring.assets.related_info_step.list.title=Titel der Liste +cms.ui.authoring.assets.related_info_step.list.description=Beschreibung +cms.ui.authoring.assets.related_info_step.list.edit=Bearbeiten +cms.ui.authoring.assets.related_info_step.list.move=Verschieben +cms.ui.authoring.assets.related_info_step.list.delete=L\u00f6schen +cms.ui.authoring.assets.related_info_step.attachment.title=Titel +cms.ui.authoring.assets.related_info_step.attachment.type=Typ +cms.ui.authoring.assets.related_info_step.attachment.move=Verschieben +cms.ui.authoring.assets.related_info_step.attachment.remove=Entfernen +cms.ui.authoring.assets.related_info_step.attachment.none=Diese Liste enth\u00e4lt noch keine weiterf\u00fchrenden Informationen +cms.ui.authoring.assets.related_info_step.attachment.move_here=Hierher verschieben +cms.ui.authoring.assets.related_info_step.list.move_here=Hierher verschieben +cms.ui.authoring.assets.related_info_step.list.none=Es wurden noch keine weiterf\u00fchrenden Informationen hinzugef\u00fcgt +cms.ui.authoring.assets.related_info_step.list.edit\ \t=Bearbeiten diff --git a/ccm-cms/src/main/resources/org/librecms/CmsResources_fr.properties b/ccm-cms/src/main/resources/org/librecms/CmsResources_fr.properties index 8f57e02a7..3a25b3fb1 100644 --- a/ccm-cms/src/main/resources/org/librecms/CmsResources_fr.properties +++ b/ccm-cms/src/main/resources/org/librecms/CmsResources_fr.properties @@ -376,3 +376,22 @@ cms.ui.assetlist.add_locale=Add data for language cms.ui.assetlist.name=Name cms.ui.assetlist.title=Title cms.ui.assetlist.description=Description +cms.ui.authoring.assets.related_info_step.add_list=Add list +cms.ui.authoring.assets.related_info_step.attachment_list.move_to_beginning=Move to first position +cms.ui.authoring.assets.related_info_step.attach_asset=Add related information +cms.ui.authoring.assets.related_info_step.attachment.move_to_first=Move to first position +cms.ui.authoring.assets.related_info_step.list.name=Name of list +cms.ui.authoring.assets.related_info_step.list.title=Title of list +cms.ui.authoring.assets.related_info_step.list.description=Description +cms.ui.authoring.assets.related_info_step.list.edit=Edit +cms.ui.authoring.assets.related_info_step.list.move=Move +cms.ui.authoring.assets.related_info_step.list.delete=Delete +cms.ui.authoring.assets.related_info_step.attachment.title=Attachment title +cms.ui.authoring.assets.related_info_step.attachment.type=Type +cms.ui.authoring.assets.related_info_step.attachment.move=Move +cms.ui.authoring.assets.related_info_step.attachment.remove=Remove +cms.ui.authoring.assets.related_info_step.attachment.none=No related information in this list yet +cms.ui.authoring.assets.related_info_step.attachment.move_here=Move here +cms.ui.authoring.assets.related_info_step.list.move_here=Move here +cms.ui.authoring.assets.related_info_step.list.none=No related informations yet +cms.ui.authoring.assets.related_info_step.list.edit\ \t=Edit diff --git a/ccm-core/src/main/java/com/arsdigita/xml/Document.java b/ccm-core/src/main/java/com/arsdigita/xml/Document.java index 72f89a8f5..f4198cb02 100644 --- a/ccm-core/src/main/java/com/arsdigita/xml/Document.java +++ b/ccm-core/src/main/java/com/arsdigita/xml/Document.java @@ -84,7 +84,7 @@ public class Document { // Explicitly create elements & attributes to avoid namespace // problems private final static String identityXSL = - "\n" + "\n" + "\n"