/* * This library is part of OpenCms - * the Open Source Content Management System * * Copyright (c) Alkacon Software GmbH (http://www.alkacon.com) * * 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. * * For further information about Alkacon Software GmbH, please see the * company website: http://www.alkacon.com * * For further information about OpenCms, please see the * project website: http://www.opencms.org * * 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 org.opencms.workplace.commons; import org.opencms.db.CmsUserSettings; import org.opencms.file.CmsObject; import org.opencms.file.CmsResourceFilter; import org.opencms.jsp.CmsJspActionElement; import org.opencms.main.CmsException; import org.opencms.main.CmsRuntimeException; import org.opencms.main.OpenCms; import org.opencms.util.CmsStringUtil; import org.opencms.workplace.explorer.CmsResourceUtil; import org.opencms.workplace.list.A_CmsListExplorerDialog; import org.opencms.workplace.list.A_CmsListResourceCollector; import org.opencms.workplace.list.CmsListExplorerColumn; import org.opencms.workplace.list.CmsListItem; import org.opencms.workplace.list.CmsListMetadata; import org.opencms.workplace.list.I_CmsListResourceCollector; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * List to show siblings of a given resource.<p> * * @since 6.9.2 */ public class CmsShowSiblingsList extends A_CmsListExplorerDialog { /** The list id for this class. */ private static final String LIST_ID = "lshsib"; /** The resource collector for this class. */ private I_CmsListResourceCollector m_collector; /** * Default constructor.<p> * * @param jsp an initialized JSP action element */ public CmsShowSiblingsList(CmsJspActionElement jsp) { super(jsp, LIST_ID, Messages.get().container(Messages.GUI_SHOW_SIBLINGS_LIST_NAME_0)); // set the right resource util parameters CmsResourceUtil resUtil = getResourceUtil(); resUtil.setAbbrevLength(50); resUtil.setRelativeTo(getCms().getRequestContext().addSiteRoot(jsp.getRequestContext().getFolderUri())); resUtil.setSiteMode(CmsResourceUtil.SITE_MODE_MATCHING); } /** * @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions() */ public void executeListMultiActions() throws CmsRuntimeException { throwListUnsupportedActionException(); } /** * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions() */ public void executeListSingleActions() throws CmsRuntimeException { throwListUnsupportedActionException(); } /** * @see org.opencms.workplace.list.A_CmsListExplorerDialog#getCollector() */ public I_CmsListResourceCollector getCollector() { if (m_collector == null) { m_collector = new A_CmsListResourceCollector(this) { /** Parameter of the default collector name. */ private static final String COLLECTOR_NAME = "showSiblings"; /** * @see org.opencms.file.collectors.I_CmsResourceCollector#getCollectorNames() */ public List getCollectorNames() { List names = new ArrayList(); names.add(COLLECTOR_NAME); return names; } /** * @see org.opencms.workplace.list.A_CmsListResourceCollector#getResources(org.opencms.file.CmsObject, java.util.Map) */ public List getResources(CmsObject cms, Map params) throws CmsException { return getCms().readSiblings( ((CmsShowSiblingsList)getWp()).getParamResource(), CmsResourceFilter.ALL); } /** * @see org.opencms.workplace.list.A_CmsListResourceCollector#setAdditionalColumns(org.opencms.workplace.list.CmsListItem, org.opencms.workplace.explorer.CmsResourceUtil) */ protected void setAdditionalColumns(CmsListItem item, CmsResourceUtil resUtil) { // empty } }; } return m_collector; } /** * @see org.opencms.workplace.list.A_CmsListDialog#defaultActionHtmlStart() */ protected String defaultActionHtmlStart() { return getList().listJs() + CmsListExplorerColumn.getExplorerStyleDef() + dialogContentStart(getParamTitle()); } /** * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String) */ protected void fillDetails(String detailId) { // empty } /** * @see org.opencms.workplace.list.A_CmsListExplorerDialog#setColumns(org.opencms.workplace.list.CmsListMetadata) */ protected void setColumns(CmsListMetadata metadata) { super.setColumns(metadata); metadata.getColumnDefinition(A_CmsListExplorerDialog.LIST_COLUMN_NAME).setName( org.opencms.workplace.explorer.Messages.get().container( org.opencms.workplace.explorer.Messages.GUI_INPUT_PATH_0)); } /** * @see org.opencms.workplace.list.A_CmsListExplorerDialog#isColumnVisible(int) */ protected boolean isColumnVisible(int colFlag) { boolean isVisible = (colFlag == CmsUserSettings.FILELIST_TITLE); isVisible = isVisible || (colFlag == LIST_COLUMN_TYPEICON.hashCode()); isVisible = isVisible || (colFlag == LIST_COLUMN_LOCKICON.hashCode()); isVisible = isVisible || (colFlag == LIST_COLUMN_PROJSTATEICON.hashCode()); isVisible = isVisible || (colFlag == LIST_COLUMN_NAME.hashCode()); isVisible = isVisible || (colFlag == CmsUserSettings.FILELIST_TYPE); isVisible = isVisible || (colFlag == CmsUserSettings.FILELIST_SIZE); isVisible = isVisible || ((colFlag == LIST_COLUMN_SITE.hashCode()) && (OpenCms.getSiteManager().getSites().size() > 1)); return isVisible; } /** * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata) */ protected void setMultiActions(CmsListMetadata metadata) { // empty } /** * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters() */ protected void validateParamaters() throws Exception { if (CmsStringUtil.isEmptyOrWhitespaceOnly(getParamResource())) { throw new Exception(); } } }