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.util.CmsStringUtil;
031import org.opencms.workplace.explorer.CmsResourceUtil;
032
033/**
034 * For adding text style to the columns in the explorer list.<p>
035 *
036 * @since 6.0.0
037 */
038public class CmsListExplorerColumn extends CmsListColumnDefinition {
039
040    /**
041     * Default constructor.<p>
042     *
043     * @param id the unique id
044     */
045    public CmsListExplorerColumn(String id) {
046
047        super(id);
048    }
049
050    /**
051     * Generates the needed style sheet definitions.<p>
052     *
053     * @return html code
054     */
055    public static String getExplorerStyleDef() {
056
057        StringBuffer result = new StringBuffer(256);
058        result.append("<style type='text/css'>\n");
059        result.append(".fc, .fc .link a { color: #b40000; }\n");
060        result.append(".fn, .fn .link a { color: #0000aa; }\n");
061        result.append(".fd, .fd .link a { color: #000000; text-decoration: line-through; }\n");
062        result.append(".fp, .fp .link a { color: #888888; }\n");
063        result.append(".nf, .nf .link a { color:#000000; }\n");
064        result.append("</style>");
065        return result.toString();
066    }
067
068    /**
069     * @see org.opencms.workplace.list.CmsListColumnDefinition#htmlCell(org.opencms.workplace.list.CmsListItem, boolean)
070     */
071    @Override
072    public String htmlCell(CmsListItem item, boolean isPrintable) {
073
074        if (isPrintable) {
075            return super.htmlCell(item, isPrintable);
076        }
077        CmsResourceUtil resUtil = ((A_CmsListExplorerDialog)getWp()).getResourceUtil(item);
078        StringBuffer html = new StringBuffer(128);
079        html.append("<table cellpadding='0' cellspacing='0' border='0'><tr><td class='");
080        html.append(resUtil.getStyleClassName());
081        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(resUtil.getTimeWindowLayoutStyle())) {
082            html.append(" ' style='");
083            html.append(resUtil.getTimeWindowLayoutStyle());
084            html.append("'");
085        }
086        html.append("'>");
087        html.append(super.htmlCell(item, isPrintable));
088        html.append("</td></tr></table>");
089        return html.toString();
090    }
091}