KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > galleries > CmsDownloadGallery


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/galleries/CmsDownloadGallery.java,v $
3  * Date : $Date: 2006/03/27 14:52:54 $
4  * Version: $Revision: 1.15 $
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.galleries;
33
34 import org.opencms.file.CmsPropertyDefinition;
35 import org.opencms.file.CmsResource;
36 import org.opencms.jsp.CmsJspActionElement;
37 import org.opencms.main.CmsException;
38 import org.opencms.main.CmsLog;
39 import org.opencms.util.CmsStringUtil;
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  * Generates the download gallery popup window which can be used in editors or as a dialog widget.<p>
47  *
48  * @author Armen Markarian
49  *
50  * @version $Revision: 1.15 $
51  *
52  * @since 6.0.0
53  */

54 public class CmsDownloadGallery extends A_CmsGallery {
55
56     /** URI of the download gallery popup dialog. */
57     public static final String JavaDoc URI_GALLERY = PATH_GALLERIES + "download_fs.jsp";
58
59     /** The order value of the gallery for sorting the galleries. */
60     private static final Integer JavaDoc ORDER_GALLERY = new Integer JavaDoc(20);
61
62     /**
63      * Public empty constructor, required for {@link A_CmsGallery#createInstance(String, CmsJspActionElement)}.<p>
64      */

65     public CmsDownloadGallery() {
66
67         // noop
68
}
69
70     /**
71      * Public constructor with JSP action element.<p>
72      *
73      * @param jsp an initialized JSP action element
74      */

75     public CmsDownloadGallery(CmsJspActionElement jsp) {
76
77         super(jsp);
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     public CmsDownloadGallery(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
88
89         this(new CmsJspActionElement(context, req, res));
90     }
91
92     /**
93      * Builds the html String for the preview frame.<p>
94      *
95      * @return the html String for the preview frame
96      */

97     public String JavaDoc buildGalleryItemPreview() {
98
99         StringBuffer JavaDoc html = new StringBuffer JavaDoc(64);
100         try {
101             if (CmsStringUtil.isNotEmpty(getParamResourcePath())) {
102                 CmsResource res = getCms().readResource(getParamResourcePath());
103                 if (res != null) {
104                     String JavaDoc title = getJsp().property(
105                         CmsPropertyDefinition.PROPERTY_TITLE,
106                         getParamResourcePath(),
107                         res.getName());
108                     String JavaDoc description = getJsp().property(
109                         CmsPropertyDefinition.PROPERTY_DESCRIPTION,
110                         getParamResourcePath());
111                     String JavaDoc keywords = getJsp().property(CmsPropertyDefinition.PROPERTY_KEYWORDS, getParamResourcePath());
112                     String JavaDoc lastmodified = getMessages().getDateTime(res.getDateLastModified());
113                     html.append("<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" style=\"align: left; width:100%; background-color: ThreeDFace; margin: 0;\">");
114                     // file name
115
html.append("<tr align=\"left\">");
116                     html.append("<td width=\"35%\"><b>");
117                     html.append(key("label.name"));
118                     html.append("</b></td>");
119                     html.append("<td width=\"65%\"><a HREF=\"#\" onclick=\"");
120                     html.append("javascript:window.open('");
121                     html.append(getJsp().link(getCms().getSitePath(res)));
122                     html.append("','_preview','')");
123                     html.append("\">");
124                     html.append(res.getName());
125                     html.append("</a></td>");
126                     html.append("</tr>");
127                     // file title
128
html.append(previewRow(key(Messages.GUI_INPUT_TITLE_0), title));
129
130                     // file last modified date
131
html.append(previewRow(key(Messages.GUI_INPUT_DATELASTMODIFIED_0), lastmodified));
132                     // file description if existing
133
if (CmsStringUtil.isNotEmpty(description)) {
134                         html.append(previewRow(key(Messages.GUI_INPUT_DESCRIPTION_0), description));
135                     }
136                     // file keywords if existing
137
if (CmsStringUtil.isNotEmpty(keywords)) {
138                         html.append(previewRow(key(Messages.GUI_INPUT_KEYWORDS_0), keywords));
139                     }
140                     html.append("</table>");
141                 }
142             }
143         } catch (CmsException e) {
144             // reading the resource or property value failed
145
CmsLog.getLog(CmsDownloadGallery.class).error(e);
146         }
147         return html.toString();
148     }
149
150     /**
151      * @see org.opencms.workplace.galleries.A_CmsGallery#getGalleryItemsTypeId()
152      */

153     public int getGalleryItemsTypeId() {
154
155         return -1;
156     }
157
158     /**
159      * @see org.opencms.workplace.galleries.A_CmsGallery#getHeadFrameSetHeight()
160      */

161     public String JavaDoc getHeadFrameSetHeight() {
162
163         return "450";
164     }
165
166     /**
167      * Returns the order of the implemented gallery, used to sort the gallery buttons in the editors.<p>
168      *
169      * @return the order of the implemented gallery
170      */

171     public Integer JavaDoc getOrder() {
172
173         return ORDER_GALLERY;
174     }
175 }
Popular Tags