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