KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > list > CmsListPrintDialog


1 /*
2  * File : $Source$
3  * Date : $Date$
4  * Version: $Revision$
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.list;
33
34 import org.opencms.i18n.CmsMessages;
35 import org.opencms.jsp.CmsJspActionElement;
36 import org.opencms.workplace.CmsDialog;
37 import org.opencms.workplace.tools.A_CmsHtmlIconButton;
38 import org.opencms.workplace.tools.CmsHtmlIconButtonStyleEnum;
39 import org.opencms.workplace.tools.CmsToolMacroResolver;
40
41 import javax.servlet.http.HttpServletRequest JavaDoc;
42 import javax.servlet.http.HttpServletResponse JavaDoc;
43 import javax.servlet.jsp.PageContext JavaDoc;
44
45 /**
46  * Displays a print preview of a given list.<p>
47  *
48  * @author Michael Moossen
49  *
50  * @version $Revision$
51  *
52  * @since 6.0.0
53  */

54 public class CmsListPrintDialog extends CmsDialog {
55
56     /** List class parameter name constant. */
57     public static final String JavaDoc PARAM_LISTCLASS = "listclass";
58
59     /** The list to print. */
60     private final CmsHtmlList m_list;
61
62     /** List class paramater value. */
63     private String JavaDoc m_paramListclass;
64
65     /**
66      * Public constructor.<p>
67      *
68      * @param jsp an initialized JSP action element
69      *
70      * @throws ClassNotFoundException if the list dialog class is not found
71      */

72     public CmsListPrintDialog(CmsJspActionElement jsp)
73     throws ClassNotFoundException JavaDoc {
74
75         super(jsp);
76         setParamStyle(STYLE_NEW);
77         m_list = A_CmsListDialog.getListObject(Class.forName(getParamListclass()), getSettings());
78     }
79
80     /**
81      * Public constructor with JSP variables.<p>
82      *
83      * @param context the JSP page context
84      * @param req the JSP request
85      * @param res the JSP response
86      *
87      * @throws ClassNotFoundException if the list dialog class is not found
88      */

89     public CmsListPrintDialog(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res)
90     throws ClassNotFoundException JavaDoc {
91
92         this(new CmsJspActionElement(context, req, res));
93     }
94
95     /**
96      * @see org.opencms.workplace.tools.CmsToolDialog#dialogTitle()
97      */

98     public String JavaDoc dialogTitle() {
99
100         // build title
101
StringBuffer JavaDoc html = new StringBuffer JavaDoc(512);
102         CmsMessages message = Messages.get().getBundle(getLocale());
103         html.append("<div class='screenTitle'>\n");
104         html.append("\t<table width='100%' cellspacing='0'>\n");
105         html.append("\t\t<tr>\n");
106         html.append("\t\t\t<td>\n");
107         html.append(m_list.getName().key(getLocale()));
108         html.append("\n\t\t\t</td>");
109         html.append("\t\t\t<td class='uplevel'>\n\t\t\t\t");
110         html.append(A_CmsHtmlIconButton.defaultButtonHtml(
111             getJsp(),
112             CmsHtmlIconButtonStyleEnum.SMALL_ICON_TEXT,
113             "id-print",
114             message.key(Messages.GUI_ACTION_PRINT_NAME_0),
115             message.key(Messages.GUI_ACTION_PRINT_HELP_0),
116             true,
117             "list/print.png",
118             null,
119             "print();"));
120         html.append("\n\t\t\t</td>\n");
121         html.append("\t\t</tr>\n");
122         html.append("\t</table>\n");
123         html.append("</div>\n");
124
125         return CmsToolMacroResolver.resolveMacros(html.toString(), this);
126     }
127
128     /**
129      * Generates the printable output for the given list.<p>
130      *
131      * @return html code
132      */

133     public String JavaDoc generateHtml() {
134
135         StringBuffer JavaDoc result = new StringBuffer JavaDoc(2048);
136         result.append(htmlStart(null));
137         result.append(bodyStart("dialog", null));
138         result.append(dialogStart());
139         result.append(dialogContentStart(getParamTitle()));
140         result.append(m_list.printableHtml(this));
141         result.append(dialogContentEnd());
142         result.append(dialogEnd());
143         result.append(bodyEnd());
144         result.append(htmlEnd());
145         return result.toString();
146     }
147
148     /**
149      * Returns the value for the List class parameter.<p>
150      *
151      * @return the value for the List class parameter
152      */

153     public String JavaDoc getParamListclass() {
154
155         return m_paramListclass;
156     }
157
158     /**
159      * Sets the value for the List class parameter.<p>
160      *
161      * @param listclass the value for the List class parameter to set
162      */

163     public void setParamListclass(String JavaDoc listclass) {
164
165         m_paramListclass = listclass;
166     }
167 }
Popular Tags