From ccbf683c66ae1c1937d53b06b521df0815a16aa3 Mon Sep 17 00:00:00 2001 From: baka Date: Mon, 31 Oct 2016 16:09:24 +0000 Subject: [PATCH] Adds CategoryLinks. Needs confirmation because makes heavy use of multiple parents which are not a thing anymore. git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4422 8810af33-2d31-482b-a856-94f89814c4df --- .../cms/ui/category/CategoryLinks.java | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLinks.java diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLinks.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLinks.java new file mode 100755 index 000000000..58a52c75b --- /dev/null +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/category/CategoryLinks.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.ui.category; + +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.List; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.ParameterSingleSelectionModel; +import com.arsdigita.bebop.SingleSelectionModel; +import com.arsdigita.bebop.event.ActionEvent; +import com.arsdigita.bebop.event.ActionListener; +import com.arsdigita.bebop.list.ListModel; +import com.arsdigita.bebop.list.ListModelBuilder; +import com.arsdigita.bebop.parameters.BigDecimalParameter; +import com.arsdigita.bebop.util.GlobalizationUtil; +import com.arsdigita.util.LockableImpl; +import org.libreccm.categorization.Category; + +/** + * A List of all secondary parents of the current category. + * + * @author Stanislav Freidin (stas@arsdigita.com) + * @author Michael Pih (pihman@arsdigita.com) + * @version $Id: CategoryLinks.java 2140 2011-01-16 12:04:20Z pboy $ + */ +public class CategoryLinks extends List { + public final static String SUB_CATEGORY = "sc"; + + private final CategoryRequestLocal m_parent; + private final SingleSelectionModel m_model; + + public CategoryLinks(final CategoryRequestLocal parent, + final SingleSelectionModel model) { + super(new ParameterSingleSelectionModel + (new BigDecimalParameter(SUB_CATEGORY))); + setIdAttr("category_links_list"); + + m_parent = parent; + m_model = model; + + //setModelBuilder(new LinkedCategoryModelBuilder()); + + // Select the category in the main tree when the + // user selects it here + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + final PageState state = e.getPageState(); + final String id = (String) getSelectedKey(state); + + if (id != null) { + m_model.setSelectedKey(state, id); + } + } + }); + + final Label label = new Label + (GlobalizationUtil.globalize("cms.ui.category.linked_none")); + label.setFontWeight(Label.ITALIC); + setEmptyView(label); + } + + /* TODO There is only one parent + private class LinkedCategoryModelBuilder extends LockableImpl + implements ListModelBuilder { + public ListModel makeModel(List list, PageState state) { + final Category category = m_parent.getCategory(state); + + if (category != null && category.getParent().isPresent()) { + + return new CategoryCollectionListModel + (category.getParents(), + parent == null ? null : parent.getID()); + } else { + return List.EMPTY_MODEL; + } + } + }*/ + +}