From f6d8bb92cff19a86edc80e13495e95bcd7454165 Mon Sep 17 00:00:00 2001 From: jensp Date: Wed, 22 Jan 2014 13:46:56 +0000 Subject: [PATCH] Categories can now be moved using the category ui in the content center git-svn-id: https://svn.libreccm.org/ccm/trunk@2493 8810af33-2d31-482b-a856-94f89814c4df --- .../com/arsdigita/cms/CMSResources.properties | 3 + .../arsdigita/cms/CMSResources_de.properties | 3 + .../cms/CMSResources_en_GB.properties | 3 + .../arsdigita/cms/CMSResources_fr.properties | 3 + .../cms/ui/category/CategoryAdminPane.java | 27 ++-- .../cms/ui/category/CategoryItemPane.java | 55 ++++++- .../ui/category/IndexItemSelectionForm.java | 146 ++++++++---------- 7 files changed, 141 insertions(+), 99 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties index d25737dd4..9d265f25b 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties @@ -1064,3 +1064,6 @@ cms.ui.section.new_section_root_category=Root category of the new Content Sectio cms.ui.admin_center=Admin Center cms.contentasset.image.ui.display.dimensions=Dimensions (width x height): cms.ui.remove_home_folder=Remove home folder +cms.ui.move.category=Move category "{0}" to +cms.ui.category.move=Move category +cms.ui.category.cantmoved=This category can't be moved diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties index 5b4c494cf..3d708a566 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties @@ -1058,3 +1058,6 @@ cms.ui.section.new_section_root_category=Kategoriensystem der neuen Content Sect cms.ui.admin_center=Admin Center cms.contentasset.image.ui.display.dimensions=Ma\u00dfe (Breite x H\u00f6he): cms.ui.remove_home_folder=Start-Ordner zur\u00fccksetzen +cms.ui.move.category=Verschiebe Kategorie "{0}" nach +cms.ui.category.move=Kategorie verschieben +cms.ui.category.cantmoved=Diese Kategorie kann nicht verschoben werden diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties index 83c024fcb..2beaa60a8 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties @@ -112,3 +112,6 @@ cms.ui.section.new_section_root_category= cms.ui.admin_center=Admin Center cms.contentasset.image.ui.display.dimensions=Dimensions (width x height): cms.ui.remove_home_folder=Remove home folder +cms.ui.move.category= +cms.ui.category.move= +cms.ui.category.cantmoved= diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties index 235ef7280..9527f0c54 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties @@ -586,3 +586,6 @@ cms.ui.section.new_section_root_category= cms.ui.admin_center=Admin Center cms.contentasset.image.ui.display.dimensions=Dimensions (width x height): cms.ui.remove_home_folder= +cms.ui.move.category= +cms.ui.category.move= +cms.ui.category.cantmoved= diff --git a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryAdminPane.java b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryAdminPane.java index c7187af24..eb70cab03 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryAdminPane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryAdminPane.java @@ -35,15 +35,10 @@ import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.permissions.PermissionDescriptor; import com.arsdigita.kernel.permissions.PermissionService; import com.arsdigita.kernel.permissions.PrivilegeDescriptor; -import com.arsdigita.persistence.DataCollection; -import com.arsdigita.persistence.Session; -import com.arsdigita.persistence.SessionManager; import com.arsdigita.toolbox.ui.ActionGroup; -import com.arsdigita.toolbox.ui.DataQueryBuilder; import com.arsdigita.toolbox.ui.Section; import com.arsdigita.xml.Element; import java.math.BigDecimal; -import java.util.TooManyListenersException; import org.apache.log4j.Logger; /** @@ -69,8 +64,6 @@ public final class CategoryAdminPane extends BaseAdminPane { m_contextModel = new UseContextSelectionModel(new StringParameter(CONTEXT_SELECTED)); - - /* Left column */ /* Use context section */ List list = new List(new CategoryUseContextModelBuilder()); @@ -82,7 +75,6 @@ public final class CategoryAdminPane extends BaseAdminPane { m_categoryTree.addChangeListener(new SelectionListener()); m_model = m_categoryTree.getSelectionModel(); - setSelectionModel(m_model); setSelector(m_categoryTree); @@ -94,7 +86,8 @@ public final class CategoryAdminPane extends BaseAdminPane { contextGroup.setSubject(list); if (CMS.getConfig().getAllowCategoryCreateUseContext()) { - ActionLink addContextAction = new ActionLink(new Label(gz("cms.ui.category.add_use_context"))); + ActionLink addContextAction = new ActionLink(new Label(gz( + "cms.ui.category.add_use_context"))); Form addContextForm = new AddUseContextForm(m_contextModel); getBody().add(addContextForm); getBody().connect(addContextAction, addContextForm); @@ -113,7 +106,6 @@ public final class CategoryAdminPane extends BaseAdminPane { leftContainer.add(categorySection); setLeft(leftContainer); - m_parent = new ParentRequestLocal(); m_category = new SelectionRequestLocal(); @@ -122,12 +114,15 @@ public final class CategoryAdminPane extends BaseAdminPane { setEdit(gz("cms.ui.category.edit"), new CategoryEditForm(m_parent, m_category)); - - setDelete(new DeleteLink(new Label(gz("cms.ui.category.delete"))), new DeleteForm(new SimpleContainer())); + + setDelete(new DeleteLink(new Label(gz("cms.ui.category.delete"))), new DeleteForm( + new SimpleContainer())); setIntroPane(new Label(gz("cms.ui.category.intro"))); - setItemPane(new CategoryItemPane(m_model, m_category, - getAddLink(), getEditLink(), + setItemPane(new CategoryItemPane(m_model, + m_category, + getAddLink(), + getEditLink(), getDeleteLink())); //m_contextList = new List(new ContextListModelBuilder()); @@ -179,7 +174,6 @@ public final class CategoryAdminPane extends BaseAdminPane { prompt.add(new Label(gz("cms.ui.category.delete_prompt"))); Label catLabel = new Label(); catLabel.addPrintListener(new PrintListener() { - public void prepare(PrintEvent pe) { Label label = (Label) pe.getTarget(); Category cat = @@ -221,7 +215,8 @@ public final class CategoryAdminPane extends BaseAdminPane { PermissionService.assertPermission(new PermissionDescriptor(PrivilegeDescriptor.DELETE, category, - Kernel.getContext().getParty())); + Kernel.getContext(). + getParty())); if (category.isRoot()) { Category root = diff --git a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java index 90fb290e4..43485ea3f 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java @@ -22,7 +22,6 @@ import com.arsdigita.bebop.ActionLink; import com.arsdigita.bebop.BaseLink; import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Form; -import com.arsdigita.bebop.FormModel; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Link; import com.arsdigita.bebop.Page; @@ -48,6 +47,7 @@ import com.arsdigita.cms.ui.ContentItemPage; import com.arsdigita.cms.ui.VisibilityComponent; import com.arsdigita.cms.ui.permissions.CMSPermissionsPane; import com.arsdigita.cms.ui.templates.CategoryTemplates; +import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.kernel.ACSObject; import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.User; @@ -63,6 +63,7 @@ import com.arsdigita.toolbox.ui.PropertyList; import com.arsdigita.toolbox.ui.Section; import com.arsdigita.util.Assert; import com.arsdigita.web.Web; +import com.arsdigita.xml.Element; import java.math.BigDecimal; import java.net.URLEncoder; @@ -126,6 +127,11 @@ class CategoryItemPane extends BaseItemPane { "cms.ui.category.change_index_item"))); final Form indexForm = new IndexItemSelectionForm(m_category); add(indexForm); + + //Move link + final ActionLink moveLink = new MoveLink(new Label(gz("cms.ui.category.move"))); + final Form moveForm = new CategoryMoveForm(m_category); + add(moveForm); ViewItemLink viewIndexLink = new ViewItemLink(new Label(gz( "cms.ui.category.view_index_item")), ""); @@ -133,8 +139,13 @@ class CategoryItemPane extends BaseItemPane { "cms.ui.category.edit_index_item")), ""); // Summary - m_detailPane.add(new SummarySection(editLink, deleteLink, indexLink, - viewIndexLink, editIndexLink, orderItemsLink)); + m_detailPane.add(new SummarySection(editLink, + deleteLink, + indexLink, + moveLink, + viewIndexLink, + editIndexLink, + orderItemsLink)); // Quasimodo: BEGIN // Localizations @@ -189,6 +200,9 @@ class CategoryItemPane extends BaseItemPane { connect(indexLink, indexForm); connect(indexForm); + + connect(moveLink, moveForm); + connect(moveForm); connect(orderItemsLink, orderItemsForm); connect(orderItemsForm); @@ -226,6 +240,7 @@ class CategoryItemPane extends BaseItemPane { SummarySection(final ActionLink editLink, final ActionLink deleteLink, final ActionLink indexLink, + final ActionLink moveLink, final ActionLink orderItemsLink) { setHeading(new Label(gz("cms.ui.category.details"))); @@ -236,6 +251,7 @@ class CategoryItemPane extends BaseItemPane { group.addAction(new EditVisible(editLink), ActionGroup.EDIT); group.addAction(new EditVisible(orderItemsLink)); + group.addAction(new EditVisible(moveLink)); group.addAction(new EditVisible(indexLink)); group.addAction(new AdminVisible(deleteLink), ActionGroup.DELETE); } @@ -247,6 +263,7 @@ class CategoryItemPane extends BaseItemPane { SummarySection(final ActionLink editLink, final ActionLink deleteLink, final ActionLink indexLink, + final ActionLink moveLink, final BaseLink viewIndexItem, final BaseLink editIndexItem, final ActionLink orderItemsLink) { @@ -260,6 +277,7 @@ class CategoryItemPane extends BaseItemPane { group.addAction(new EditVisible(editLink), ActionGroup.EDIT); group.addAction(new EditVisible(orderItemsLink)); group.addAction(new EditVisible(indexLink)); + group.addAction(new EditVisible(moveLink)); group.addAction(new EditVisible(viewIndexItem)); group.addAction(new EditVisible(editIndexItem)); group.addAction(new AdminVisible(deleteLink), ActionGroup.DELETE); @@ -360,7 +378,8 @@ class CategoryItemPane extends BaseItemPane { group.setSubject(m_catLocalizationTable); group.addAction(new AdminVisible(addLink), ActionGroup.ADD); - m_editCategoryLocalizationForm = new CategoryLocalizationEditForm(m_category, m_catLocale); + m_editCategoryLocalizationForm = new CategoryLocalizationEditForm(m_category, + m_catLocale); add(m_editCategoryLocalizationForm); connect(m_editCategoryLocalizationForm); connect(m_catLocalizationTable, 0, m_editCategoryLocalizationForm); @@ -449,7 +468,8 @@ class CategoryItemPane extends BaseItemPane { privMap.put(Category.MAP_DESCRIPTOR.getName(), "Categorize Items"); privMap.put("admin", "Admin"); - final CMSPermissionsPane permPane = new CMSPermissionsPane(privs, privMap, new ACSObjectSelectionModel( + final CMSPermissionsPane permPane = new CMSPermissionsPane(privs, privMap, + new ACSObjectSelectionModel( m_model)) { @Override public void showAdmin(PageState ps) { @@ -672,4 +692,29 @@ class CategoryItemPane extends BaseItemPane { } }; + + private class MoveLink extends ActionLink { + + private final Label alternativeLabel; + + public MoveLink(final Label label) { + super(label); + alternativeLabel = new Label(GlobalizationUtil.globalize("cms.ui.category.cantmoved")); + } + + @Override + public void generateXML(final PageState state, final Element parent) { + if (!isVisible(state)) { + return; + } + + final Category category = m_category.getCategory(state); + if (category.isRoot()) { + alternativeLabel.generateXML(state, parent); + } else { + super.generateXML(state, parent); + } + } + + } } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/category/IndexItemSelectionForm.java b/ccm-cms/src/com/arsdigita/cms/ui/category/IndexItemSelectionForm.java index c25e46beb..777f02c30 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/category/IndexItemSelectionForm.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/category/IndexItemSelectionForm.java @@ -56,15 +56,14 @@ import java.math.BigDecimal; * @version $Revision: #18 $ $DateTime: 2004/08/17 23:15:09 $ */ public class IndexItemSelectionForm extends CMSForm { - private static org.apache.log4j.Logger s_log = - org.apache.log4j.Logger.getLogger(IndexItemSelectionForm.class); + private static org.apache.log4j.Logger s_log = + org.apache.log4j.Logger.getLogger( + IndexItemSelectionForm.class); private final CategoryRequestLocal m_category; private RadioGroup m_options; - private static final String NULL_OPTION_VALUE = ""; private static final String NONE_OPTION_VALUE = "None"; - private FormErrorDisplay m_errors; private SaveCancelSection m_saveCancelSection; @@ -75,8 +74,7 @@ public class IndexItemSelectionForm extends CMSForm { m_category = m; // Form header - Label header = new Label(GlobalizationUtil.globalize - ("cms.ui.category.select_index_item")); + Label header = new Label(GlobalizationUtil.globalize("cms.ui.category.select_index_item")); header.setFontWeight(Label.BOLD); add(header, ColumnPanel.FULL_WIDTH); @@ -89,52 +87,49 @@ public class IndexItemSelectionForm extends CMSForm { try { m_options.addPrintListener(new PrintListener() { public void prepare(PrintEvent event) { - RadioGroup group = (RadioGroup)event.getTarget(); + RadioGroup group = (RadioGroup) event.getTarget(); PageState state = event.getPageState(); Category category = getCategory(event.getPageState()); - CategorizedCollection children = category.getObjects - (ContentItem.BASE_DATA_OBJECT_TYPE); + CategorizedCollection children = category.getObjects( + ContentItem.BASE_DATA_OBJECT_TYPE); - // option for NO index Object - group.addOption(new Option(NONE_OPTION_VALUE, - new Label(NONE_OPTION_VALUE))); + // option for NO index Object + group.addOption(new Option(NONE_OPTION_VALUE, + new Label(NONE_OPTION_VALUE))); - // option for inheriting from the parent category - if (category.getParentCategoryCount() > 0) { - group.addOption - (new Option(NULL_OPTION_VALUE, - new Label("Inherit Index from Parent Category"))); - } - - while (children.next()) { - ACSObject item = - (ACSObject) children.getDomainObject(); - - if ((item instanceof ContentItem) && - ((ContentItem) item).getVersion().equals(ContentItem.DRAFT)) - { - group.addOption - (new Option(item.getID().toString(), - ((ContentItem)item).getName())); - } - } - // get currently selected item - ACSObject indexItem = category.getDirectIndexObject(); - if (indexItem != null && indexItem instanceof ContentItem) { - group.setValue(state, ((ContentItem) indexItem) - .getWorkingVersion() - .getID().toString()); - } else { - String value = NONE_OPTION_VALUE; - if (!category.ignoreParentIndexItem() - && category.getParentCategoryCount() > 0) - { - value = NULL_OPTION_VALUE; - } - group.setValue(state, value); - } - } - }); + // option for inheriting from the parent category + if (category.getParentCategoryCount() > 0) { + group.addOption(new Option(NULL_OPTION_VALUE, + new Label("Inherit Index from Parent Category"))); + } + + while (children.next()) { + ACSObject item = + (ACSObject) children.getDomainObject(); + + if ((item instanceof ContentItem) && ((ContentItem) item).getVersion(). + equals(ContentItem.DRAFT)) { + group.addOption(new Option(item.getID().toString(), + ((ContentItem) item).getName())); + } + } + // get currently selected item + ACSObject indexItem = category.getDirectIndexObject(); + if (indexItem != null && indexItem instanceof ContentItem) { + group.setValue(state, ((ContentItem) indexItem) + .getWorkingVersion() + .getID().toString()); + } else { + String value = NONE_OPTION_VALUE; + if (!category.ignoreParentIndexItem() + && category.getParentCategoryCount() > 0) { + value = NULL_OPTION_VALUE; + } + group.setValue(state, value); + } + } + + }); } catch (java.util.TooManyListenersException e) { s_log.error("Error adding init listener to Radio Group", e); throw new UncheckedWrapperException(e); @@ -146,44 +141,40 @@ public class IndexItemSelectionForm extends CMSForm { m_saveCancelSection = new SaveCancelSection(); add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT); - addSubmissionListener - (new FormSecurityListener(SecurityManager.CATEGORY_ADMIN)); + addSubmissionListener(new FormSecurityListener(SecurityManager.CATEGORY_ADMIN)); // Process listener addProcessListener(new FormProcessListener() { - public void process(FormSectionEvent event) - throws FormProcessException { - PageState state = event.getPageState(); - FormData data = event.getFormData(); - ParameterData param = data.getParameter - (m_options.getParameterModel().getName()); - String selectedValue = (String)param.getValue(); + public void process(FormSectionEvent event) + throws FormProcessException { + PageState state = event.getPageState(); + FormData data = event.getFormData(); + ParameterData param = data.getParameter(m_options.getParameterModel().getName()); + String selectedValue = (String) param.getValue(); - Category category = - getCategory(event.getPageState()); + Category category = + getCategory(event.getPageState()); - ContentItem item = null; - if (selectedValue != null) { - if (NULL_OPTION_VALUE.equals(selectedValue)) { - category.setIgnoreParentIndexItem(false); - selectedValue = null; - } - else if(NONE_OPTION_VALUE.equals(selectedValue)) { - category.setIgnoreParentIndexItem(true); - selectedValue = null; + ContentItem item = null; + if (selectedValue != null) { + if (NULL_OPTION_VALUE.equals(selectedValue)) { + category.setIgnoreParentIndexItem(false); + selectedValue = null; + } else if (NONE_OPTION_VALUE.equals(selectedValue)) { + category.setIgnoreParentIndexItem(true); + selectedValue = null; - } else { - item = new ContentItem - (new BigDecimal(selectedValue)); - item = item.getWorkingVersion (); - } + } else { + item = new ContentItem(new BigDecimal(selectedValue)); + item = item.getWorkingVersion(); } - category.setIndexObject(item); - category.save(); } - }); - } + category.setIndexObject(item); + category.save(); + } + }); + } /** * Get the cancel button. @@ -194,7 +185,6 @@ public class IndexItemSelectionForm extends CMSForm { return m_saveCancelSection.getCancelButton(); } - /** * Fetch the selected category. *