KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > widgets > A_CmsGalleryWidget


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/widgets/A_CmsGalleryWidget.java,v $
3  * Date : $Date: 2006/10/18 09:17:07 $
4  * Version: $Revision: 1.10 $
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.widgets;
33
34 import org.opencms.file.CmsObject;
35 import org.opencms.workplace.CmsWorkplace;
36 import org.opencms.workplace.galleries.A_CmsGallery;
37
38 /**
39  * Base class for all gallery widget implementations.<p>
40  *
41  * @author Alexander Kandzior
42  * @author Andreas Zahner
43  *
44  * @version $Revision: 1.10 $
45  *
46  * @since 6.0.0
47  */

48 public abstract class A_CmsGalleryWidget extends A_CmsWidget {
49
50     /**
51      * Creates a new gallery widget.<p>
52      */

53     protected A_CmsGalleryWidget() {
54
55         // empty constructor is required for class registration
56
this("");
57     }
58
59     /**
60      * Creates a new gallery widget with the given configuration.<p>
61      *
62      * @param configuration the configuration to use
63      */

64     protected A_CmsGalleryWidget(String JavaDoc configuration) {
65
66         super(configuration);
67     }
68
69     /**
70      * @see org.opencms.widgets.I_CmsWidget#getDialogIncludes(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog)
71      */

72     public String JavaDoc getDialogIncludes(CmsObject cms, I_CmsWidgetDialog widgetDialog) {
73
74         return getJSIncludeFile(CmsWorkplace.getSkinUri() + "components/widgets/" + getNameLower() + "gallery.js");
75     }
76
77     /**
78      * @see org.opencms.widgets.I_CmsWidget#getDialogInitCall(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog)
79      */

80     public String JavaDoc getDialogInitCall(CmsObject cms, I_CmsWidgetDialog widgetDialog) {
81
82         return "\tinit" + getNameUpper() + "Gallery();\n";
83     }
84
85     /**
86      * @see org.opencms.widgets.I_CmsWidget#getDialogInitMethod(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog)
87      */

88     public String JavaDoc getDialogInitMethod(CmsObject cms, I_CmsWidgetDialog widgetDialog) {
89
90         StringBuffer JavaDoc result = new StringBuffer JavaDoc(16);
91         result.append("function init");
92         result.append(getNameUpper());
93         result.append("Gallery() {\n");
94         result.append("\t");
95         result.append(getNameLower());
96         result.append("GalleryPath = \"");
97         result.append(A_CmsGallery.PATH_GALLERIES);
98         result.append(A_CmsGallery.OPEN_URI_SUFFIX);
99         result.append("?");
100         result.append(A_CmsGallery.PARAM_GALLERY_TYPENAME);
101         result.append("=");
102         result.append(getNameLower());
103         result.append("gallery");
104         result.append("\";\n");
105         result.append("}\n");
106         return result.toString();
107     }
108
109     /**
110      * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter)
111      */

112     public String JavaDoc getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) {
113
114         String JavaDoc id = param.getId();
115         StringBuffer JavaDoc result = new StringBuffer JavaDoc(128);
116         result.append("<td class=\"xmlTd\">");
117         result.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td>");
118         result.append("<input class=\"xmlInputMedium");
119         if (param.hasError()) {
120             result.append(" xmlInputError");
121         }
122         result.append("\" value=\"");
123         String JavaDoc value = param.getStringValue(cms);
124         result.append(value);
125         result.append("\" name=\"");
126         result.append(id);
127         result.append("\" id=\"");
128         result.append(id);
129         result.append("\" onkeyup=\"checkPreview('");
130         result.append(id);
131         result.append("');\"></td>");
132         result.append(widgetDialog.dialogHorizontalSpacer(10));
133         result.append("<td><table class=\"editorbuttonbackground\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
134
135         result.append(widgetDialog.button(
136             "javascript:open" + getNameUpper() + "Gallery('" + A_CmsGallery.MODE_WIDGET + "', '" + id + "');",
137             null,
138             getNameLower() + "gallery",
139             Messages.getButtonName(getNameLower()),
140             widgetDialog.getButtonStyle()));
141         // create preview button
142
String JavaDoc previewClass = "hide";
143         if (showPreview(value)) {
144             // show button if preview is enabled
145
previewClass = "show";
146         }
147         result.append("<td class=\"");
148         result.append(previewClass);
149         result.append("\" id=\"preview");
150         result.append(id);
151         result.append("\">");
152         result.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
153         result.append(widgetDialog.button(
154             "javascript:preview" + getNameUpper() + "('" + id + "');",
155             null,
156             "preview.png",
157             Messages.GUI_BUTTON_PREVIEW_0,
158             widgetDialog.getButtonStyle()));
159         result.append("</tr></table>");
160
161         result.append("</td></tr></table>");
162
163         result.append("</td>");
164         result.append("</tr></table>");
165
166         result.append("</td>");
167
168         return result.toString();
169     }
170
171     /**
172      * Returns the lower case name of the gallery, for example <code>"html"</code>.<p>
173      *
174      * @return the lower case name of the gallery
175      */

176     public abstract String JavaDoc getNameLower();
177
178     /**
179      * Returns the upper case name of the gallery, for example <code>"Html"</code>.<p>
180      *
181      * @return the upper case name of the gallery
182      */

183     public abstract String JavaDoc getNameUpper();
184
185     /**
186      * Returns <code>true</code> if the preview button should be shown.<p>
187      *
188      * @param value the current widget value
189      * @return <code>true</code> if the preview button should be shown
190      */

191     public abstract boolean showPreview(String JavaDoc value);
192 }
Popular Tags