001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: https://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: https://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.workplace.list;
029
030import org.opencms.i18n.CmsMessageContainer;
031
032/**
033 * For adding detail information to the list items add an instance
034 * of this class to the list metadata and fill the data like an
035 * additional column.<p>
036 *
037 * For detail contents you may use HTML code.<p>
038 *
039 * @since 6.0.0
040 */
041public class CmsListItemDetails extends CmsListColumnDefinition {
042
043    /** Id of the first column to include. */
044    private String m_atColumn;
045
046    /** Action for hidding the details. */
047    private I_CmsListAction m_hideAction;
048
049    /** Action for showing the details. */
050    private I_CmsListAction m_showAction;
051
052    /**
053     * Default constructor.<p>
054     *
055     * @param id the unique id
056     */
057    public CmsListItemDetails(String id) {
058
059        super(id);
060        // set default actions
061        setAlign(CmsListColumnAlignEnum.ALIGN_LEFT);
062        m_hideAction = new CmsListIndependentAction(id);
063        m_hideAction.setIconPath(A_CmsListDialog.ICON_DETAILS_HIDE);
064        m_showAction = new CmsListIndependentAction(id);
065        m_showAction.setIconPath(A_CmsListDialog.ICON_DETAILS_SHOW);
066    }
067
068    /**
069     * Returns the current active action.<p>
070     *
071     * @return the current active action
072     */
073    public I_CmsListAction getAction() {
074
075        return isVisible() ? m_hideAction : m_showAction;
076    }
077
078    /**
079     * Returns the id of the first column to include.<p>
080     *
081     * @return the id of the first column to include
082     */
083    public String getAtColumn() {
084
085        return m_atColumn;
086    }
087
088    /**
089     * Sets the id of the first column to include.<p>
090     *
091     * @param atColumn the id of the first column to set
092     */
093    public void setAtColumn(String atColumn) {
094
095        m_atColumn = atColumn;
096    }
097
098    /**
099     * Sets the hide details Action.<p>
100     *
101     * @param hideAction the hide details Action to set
102     */
103    public void setHideAction(I_CmsListAction hideAction) {
104
105        m_hideAction = hideAction;
106    }
107
108    /**
109     * Sets the help text of the hide action.<p>
110     *
111     * @param hideActionHelp the help text of the hide action
112     */
113    public void setHideActionHelpText(CmsMessageContainer hideActionHelp) {
114
115        m_hideAction.setHelpText(hideActionHelp);
116    }
117
118    /**
119     * Sets the name of the hide action.<p>
120     *
121     * @param hideActionName the name of the hide action
122     */
123    public void setHideActionName(CmsMessageContainer hideActionName) {
124
125        m_hideAction.setName(hideActionName);
126    }
127
128    /**
129     * Sets the id of the list.<p>
130     *
131     * @param listId the id of the list
132     */
133    @Override
134    public void setListId(String listId) {
135
136        m_hideAction.setListId(listId);
137        m_showAction.setListId(listId);
138    }
139
140    /**
141     * Sets the show details Action.<p>
142     *
143     * @param showAction the showdetails Action to set
144     */
145    public void setShowAction(I_CmsListAction showAction) {
146
147        m_showAction = showAction;
148    }
149
150    /**
151     * Sets the help text of the show action.<p>
152     *
153     * @param showActionHelp the help text of the show action
154     */
155    public void setShowActionHelpText(CmsMessageContainer showActionHelp) {
156
157        m_showAction.setHelpText(showActionHelp);
158    }
159
160    /**
161     * Sets the name of the show action.<p>
162     *
163     * @param showActionName the name of the show action
164     */
165    public void setShowActionName(CmsMessageContainer showActionName) {
166
167        m_showAction.setName(showActionName);
168    }
169
170    /**
171     * @see org.opencms.workplace.list.CmsListColumnDefinition#setWp(org.opencms.workplace.list.A_CmsListDialog)
172     */
173    @Override
174    public void setWp(A_CmsListDialog wp) {
175
176        super.setWp(wp);
177        m_hideAction.setWp(wp);
178        m_showAction.setWp(wp);
179    }
180}