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.i18n.CmsMessages; 031import org.opencms.jsp.CmsJspActionElement; 032import org.opencms.workplace.CmsDialog; 033import org.opencms.workplace.tools.A_CmsHtmlIconButton; 034import org.opencms.workplace.tools.CmsHtmlIconButtonStyleEnum; 035import org.opencms.workplace.tools.CmsToolMacroResolver; 036 037import javax.servlet.http.HttpServletRequest; 038import javax.servlet.http.HttpServletResponse; 039import javax.servlet.jsp.PageContext; 040 041/** 042 * Displays a print preview of a given list.<p> 043 * 044 * @since 6.0.0 045 */ 046public class CmsListPrintDialog extends CmsDialog { 047 048 /** List class parameter name constant. */ 049 public static final String PARAM_LISTCLASS = "listclass"; 050 051 /** The list to print. */ 052 private final CmsHtmlList m_list; 053 054 /** List class paramater value. */ 055 private String m_paramListclass; 056 057 /** 058 * Public constructor.<p> 059 * 060 * @param jsp an initialized JSP action element 061 * 062 * @throws ClassNotFoundException if the list dialog class is not found 063 */ 064 public CmsListPrintDialog(CmsJspActionElement jsp) 065 throws ClassNotFoundException { 066 067 super(jsp); 068 setParamStyle(STYLE_NEW); 069 m_list = A_CmsListDialog.getListObject(Class.forName(getParamListclass()), getSettings()); 070 } 071 072 /** 073 * Public constructor with JSP variables.<p> 074 * 075 * @param context the JSP page context 076 * @param req the JSP request 077 * @param res the JSP response 078 * 079 * @throws ClassNotFoundException if the list dialog class is not found 080 */ 081 public CmsListPrintDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) 082 throws ClassNotFoundException { 083 084 this(new CmsJspActionElement(context, req, res)); 085 } 086 087 /** 088 * @see org.opencms.workplace.tools.CmsToolDialog#dialogTitle() 089 */ 090 @Override 091 public String dialogTitle() { 092 093 // build title 094 StringBuffer html = new StringBuffer(512); 095 CmsMessages message = Messages.get().getBundle(getLocale()); 096 html.append("<div class='screenTitle'>\n"); 097 html.append("\t<table width='100%' cellspacing='0'>\n"); 098 html.append("\t\t<tr>\n"); 099 html.append("\t\t\t<td>\n"); 100 html.append(m_list.getName().key(getLocale())); 101 html.append("\n\t\t\t</td>"); 102 html.append("\t\t\t<td class='uplevel'>\n\t\t\t\t"); 103 html.append( 104 A_CmsHtmlIconButton.defaultButtonHtml( 105 CmsHtmlIconButtonStyleEnum.SMALL_ICON_TEXT, 106 "id-print", 107 message.key(Messages.GUI_ACTION_PRINT_NAME_0), 108 message.key(Messages.GUI_ACTION_PRINT_HELP_0), 109 true, 110 "list/print.png", 111 null, 112 "print();")); 113 html.append("\n\t\t\t</td>\n"); 114 html.append("\t\t</tr>\n"); 115 html.append("\t</table>\n"); 116 html.append("</div>\n"); 117 118 return CmsToolMacroResolver.resolveMacros(html.toString(), this); 119 } 120 121 /** 122 * Generates the printable output for the given list.<p> 123 * 124 * @return html code 125 */ 126 public String generateHtml() { 127 128 StringBuffer result = new StringBuffer(2048); 129 result.append(htmlStart(null)); 130 result.append(CmsListExplorerColumn.getExplorerStyleDef()); 131 result.append(bodyStart("dialog", null)); 132 result.append(dialogStart()); 133 result.append(dialogContentStart(getParamTitle())); 134 result.append(m_list.printableHtml()); 135 result.append(dialogContentEnd()); 136 result.append(dialogEnd()); 137 result.append(bodyEnd()); 138 result.append(htmlEnd()); 139 return result.toString(); 140 } 141 142 /** 143 * Returns the value for the List class parameter.<p> 144 * 145 * @return the value for the List class parameter 146 */ 147 public String getParamListclass() { 148 149 return m_paramListclass; 150 } 151 152 /** 153 * Sets the value for the List class parameter.<p> 154 * 155 * @param listclass the value for the List class parameter to set 156 */ 157 public void setParamListclass(String listclass) { 158 159 m_paramListclass = listclass; 160 } 161}