KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/galleries/CmsTableGallery.java,v $
3  * Date : $Date: 2006/03/27 14:52:54 $
4  * Version: $Revision: 1.14 $
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.jsp.CmsJspActionElement;
36 import org.opencms.main.CmsException;
37 import org.opencms.main.CmsLog;
38 import org.opencms.main.OpenCms;
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 import org.apache.commons.logging.Log;
46
47 /**
48  * Generates the html gallery popup window which can be used in editors or as a dialog widget.<p>
49  *
50  * @author Jan Baudisch
51  *
52  * @version $Revision: 1.14 $
53  *
54  * @since 6.0.0
55  */

56 public class CmsTableGallery extends CmsHtmlGallery {
57     
58     /** The log object for this class. */
59     private static final Log LOG = CmsLog.getLog(CmsTableGallery.class);
60
61     /** The order value of the gallery for sorting the galleries. */
62     private static final Integer JavaDoc ORDER_GALLERY = new Integer JavaDoc(50);
63
64     /**
65      * Public empty constructor, required for {@link A_CmsGallery#createInstance(String, CmsJspActionElement)}.<p>
66      */

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

77     public CmsTableGallery(CmsJspActionElement jsp) {
78
79         super(jsp);
80     }
81
82     /**
83      * Public constructor with JSP variables.<p>
84      *
85      * @param context the JSP page context
86      * @param req the JSP request
87      * @param res the JSP response
88      */

89     public CmsTableGallery(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
90
91         this(new CmsJspActionElement(context, req, res));
92     }
93
94     /**
95      * Builds the html String for the preview frame.<p>
96      *
97      * @return the html String for the preview frame
98      */

99     public String JavaDoc buildGalleryItemPreview() {
100
101         String JavaDoc cssFile = "";
102         if (CmsStringUtil.isNotEmpty(getParamResourcePath())) {
103             try {
104                 cssFile = getJsp().link(
105                     getCms().readPropertyObject(getParamResourcePath(), CmsPropertyDefinition.PROPERTY_STYLESHEET, true).getValue(
106                         ""));
107             } catch (CmsException e) {
108                 if (LOG.isErrorEnabled()) {
109                     LOG.error(e);
110                 }
111             }
112             StringBuffer JavaDoc result = new StringBuffer JavaDoc();
113             if (CmsStringUtil.isNotEmpty(cssFile)) {
114                 result.append("<link rel=\"stylesheet\" type=\"text/css\" HREF=\"").append(cssFile).append("\">");
115             }
116             result.append(super.buildGalleryItemPreview());
117             return result.toString();
118         }
119         return "";
120     }
121
122     /**
123      * Returns the height of the head frameset.<p>
124      *
125      * @return the height of the head frameset
126      */

127     public String JavaDoc getHeadFrameSetHeight() {
128
129         return "440";
130     }
131     
132     /**
133      * Returns the order of the implemented gallery, used to sort the gallery buttons in the editors.<p>
134      *
135      * @return the order of the implemented gallery
136      */

137     public Integer JavaDoc getOrder() {
138         
139         return ORDER_GALLERY;
140     }
141
142     /**
143      * Builds the HTML for the wizard button.<p>
144      *
145      * @return the HTML for the wizard button
146      */

147     public String JavaDoc wizardButton() {
148
149         StringBuffer JavaDoc uploadUrl = new StringBuffer JavaDoc(512);
150         uploadUrl.append(getJsp().link(
151             PATH_DIALOGS + OpenCms.getWorkplaceManager().getExplorerTypeSetting("upload").getNewResourceUri()).replaceFirst(
152             "newresource",
153             "newcsvfile"));
154         uploadUrl.append("?redirecturl=/system/workplace/galleries/gallery_list.jsp&targetframe=gallery_list&currentfolder=");
155         uploadUrl.append(getParamGalleryPath());
156         return button(
157             uploadUrl.toString(),
158             "gallery_fs",
159             "upload.png",
160             OpenCms.getWorkplaceManager().getExplorerTypeSetting("upload").getKey(),
161             0);
162     }
163
164 }
Popular Tags