001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://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: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://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     * @see org.opencms.workplace.list.CmsListColumnDefinition#htmlCell(org.opencms.workplace.list.CmsListItem, boolean)
052     */
053    @Override
054    public String htmlCell(CmsListItem item, boolean isPrintable) {
055
056        if (isPrintable) {
057            return super.htmlCell(item, isPrintable);
058        }
059        CmsResourceUtil resUtil = ((A_CmsListExplorerDialog)getWp()).getResourceUtil(item);
060        StringBuffer html = new StringBuffer(128);
061        html.append("<table cellpadding='0' cellspacing='0' border='0'><tr><td class='");
062        html.append(resUtil.getStyleClassName());
063        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(resUtil.getTimeWindowLayoutStyle())) {
064            html.append(" ' style='");
065            html.append(resUtil.getTimeWindowLayoutStyle());
066            html.append("'");
067        }
068        html.append("'>");
069        html.append(super.htmlCell(item, isPrintable));
070        html.append("</td></tr></table>");
071        return html.toString();
072    }
073
074    /**
075     * Generates the needed style sheet definitions.<p>
076     *
077     * @return html code
078     */
079    public static String getExplorerStyleDef() {
080
081        StringBuffer result = new StringBuffer(256);
082        result.append("<style type='text/css'>\n");
083        result.append(".fc, .fc .link a { color: #b40000; }\n");
084        result.append(".fn, .fn .link a { color: #0000aa; }\n");
085        result.append(".fd, .fd .link a { color: #000000; text-decoration: line-through; }\n");
086        result.append(".fp, .fp .link a { color: #888888; }\n");
087        result.append(".nf, .nf .link a { color:#000000; }\n");
088        result.append("</style>");
089        return result.toString();
090    }
091}