Source Code Cross Referenced for CmsComboWidget.java in  » Content-Management-System » opencms » org » opencms » widgets » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » opencms » org.opencms.widgets 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/widgets/CmsComboWidget.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:44 $
004:         * Version: $Revision: 1.14 $
005:         *
006:         * This library is part of OpenCms -
007:         * the Open Source Content Management System
008:         *
009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010:         *
011:         * This library is free software; you can redistribute it and/or
012:         * modify it under the terms of the GNU Lesser General Public
013:         * License as published by the Free Software Foundation; either
014:         * version 2.1 of the License, or (at your option) any later version.
015:         *
016:         * This library is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019:         * Lesser General Public License for more details.
020:         *
021:         * For further information about Alkacon Software GmbH, please see the
022:         * company website: http://www.alkacon.com
023:         *
024:         * For further information about OpenCms, please see the
025:         * project website: http://www.opencms.org
026:         * 
027:         * You should have received a copy of the GNU Lesser General Public
028:         * License along with this library; if not, write to the Free Software
029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030:         */
031:
032:        package org.opencms.widgets;
033:
034:        import org.opencms.file.CmsObject;
035:        import org.opencms.i18n.CmsEncoder;
036:        import org.opencms.util.CmsStringUtil;
037:        import org.opencms.workplace.CmsWorkplace;
038:
039:        import java.util.Iterator;
040:        import java.util.List;
041:
042:        /**
043:         * Provides a HTML text input field with optional values to select in a combo box, for use on a widget dialog.<p>
044:         * 
045:         * Please see the documentation of <code>{@link org.opencms.widgets.CmsSelectWidgetOption}</code> for a description 
046:         * about the configuration String syntax for the select options.<p>
047:         * 
048:         * The combo widget does use the following select options:<ul>
049:         * <li><code>{@link org.opencms.widgets.CmsSelectWidgetOption#getValue()}</code> for the texts to be displayed in the combo selector
050:         * <li><code>{@link org.opencms.widgets.CmsSelectWidgetOption#isDefault()}</code> to fill the input with a preselected text
051:         * <li><code>{@link org.opencms.widgets.CmsSelectWidgetOption#getHelp()}</code> to display an (optional) help text for the combo option
052:         * </ul>
053:         * 
054:         * @author Andreas Zahner 
055:         * @author Alexander Kandzior 
056:         * 
057:         * @version $Revision: 1.14 $ 
058:         * 
059:         * @since 6.0.0 
060:         */
061:        public class CmsComboWidget extends A_CmsSelectWidget {
062:
063:            /**
064:             * Creates a new combo widget.<p>
065:             */
066:            public CmsComboWidget() {
067:
068:                // empty constructor is required for class registration
069:                super ();
070:            }
071:
072:            /**
073:             * Creates a combo widget with the select options specified in the given configuration List.<p>
074:             * 
075:             * The list elements must be of type <code>{@link CmsSelectWidgetOption}</code>.<p>
076:             * 
077:             * @param configuration the configuration (possible options) for the select widget
078:             * 
079:             * @see CmsSelectWidgetOption
080:             */
081:            public CmsComboWidget(List configuration) {
082:
083:                super (configuration);
084:            }
085:
086:            /**
087:             * Creates a combo widget with the specified combo options.<p>
088:             * 
089:             * @param configuration the configuration (possible options) for the combo box
090:             */
091:            public CmsComboWidget(String configuration) {
092:
093:                super (configuration);
094:            }
095:
096:            /**
097:             * @see org.opencms.widgets.A_CmsWidget#getDialogHtmlEnd(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter)
098:             */
099:            public String getDialogHtmlEnd(CmsObject cms,
100:                    I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) {
101:
102:                String id = param.getId();
103:                StringBuffer result = new StringBuffer(256);
104:
105:                // get the select box options
106:                List options = parseSelectOptions(cms, widgetDialog, param);
107:
108:                if (options.size() > 0) {
109:                    // create combo div
110:                    result.append("<div class=\"widgetcombo\" id=\"combo");
111:                    result.append(id);
112:                    result.append("\">\n");
113:
114:                    int count = 0;
115:                    Iterator i = options.iterator();
116:                    while (i.hasNext()) {
117:                        CmsSelectWidgetOption option = (CmsSelectWidgetOption) i
118:                                .next();
119:                        String itemId = new StringBuffer(64).append("ci")
120:                                .append(id).append('.').append(count)
121:                                .toString();
122:                        // create the link around value
123:                        result
124:                                .append("\t<a href=\"javascript:setComboValue(\'");
125:                        result.append(id);
126:                        result.append("\', \'");
127:                        result.append(itemId);
128:                        result.append("\')\" name=\"");
129:                        result.append(itemId);
130:                        result.append("\" id=\"");
131:                        result.append(itemId);
132:                        result.append("\"");
133:                        if (option.getHelp() != null) {
134:                            // create help text mousevent attributes
135:                            // can't use method in CmsEncoder because we need to keep < > for HTML in help text
136:                            String locValue = CmsStringUtil.substitute(option
137:                                    .getHelp(), "\"", "&quot;");
138:                            result.append(getJsHelpMouseHandler(widgetDialog,
139:                                    itemId, CmsStringUtil
140:                                            .escapeJavaScript(locValue)));
141:                        }
142:                        result.append(">");
143:                        result.append(option.getValue());
144:                        result.append("</a>\n");
145:                        count++;
146:                    }
147:
148:                    // close combo div
149:                    result.append("</div>\n");
150:
151:                    if (widgetDialog.useNewStyle()) {
152:                        // create help texts for the values in admin view
153:                        count = 0;
154:                        i = options.iterator();
155:                        while (i.hasNext()) {
156:                            CmsSelectWidgetOption option = (CmsSelectWidgetOption) i
157:                                    .next();
158:                            if (option.getHelp() != null) {
159:                                // help text is optional
160:                                String itemId = new StringBuffer(64).append(
161:                                        "ci").append(id).append('.').append(
162:                                        count).toString();
163:                                result.append("<div class=\"help\" id=\"help");
164:                                result.append(itemId);
165:                                result.append("\"");
166:                                result.append(getJsHelpMouseHandler(
167:                                        widgetDialog, itemId, itemId));
168:                                result.append(">");
169:                                result.append(option.getHelp());
170:                                result.append("</div>\n");
171:                                count++;
172:                            }
173:                        }
174:                    }
175:                }
176:
177:                // return the icon help text from super class
178:                result.append(super .getDialogHtmlEnd(cms, widgetDialog, param));
179:                return result.toString();
180:            }
181:
182:            /**
183:             * @see org.opencms.widgets.I_CmsWidget#getDialogIncludes(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog)
184:             */
185:            public String getDialogIncludes(CmsObject cms,
186:                    I_CmsWidgetDialog widgetDialog) {
187:
188:                StringBuffer result = new StringBuffer(16);
189:                result.append(getJSIncludeFile(CmsWorkplace.getSkinUri()
190:                        + "components/widgets/combobox.js"));
191:                return result.toString();
192:            }
193:
194:            /**
195:             * @see org.opencms.widgets.I_CmsWidget#getDialogInitCall(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog)
196:             */
197:            public String getDialogInitCall(CmsObject cms,
198:                    I_CmsWidgetDialog widgetDialog) {
199:
200:                return "\tinitComboBox();\n";
201:            }
202:
203:            /**
204:             * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter)
205:             */
206:            public String getDialogWidget(CmsObject cms,
207:                    I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) {
208:
209:                String id = param.getId();
210:                StringBuffer result = new StringBuffer(16);
211:                result.append("<td class=\"xmlTd\">");
212:
213:                result
214:                        .append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td>");
215:                // medium text input field
216:                result.append("<input type=\"text\" class=\"xmlInputMedium");
217:                if (param.hasError()) {
218:                    result.append(" xmlInputError");
219:                }
220:                result.append("\" name=\"");
221:                result.append(id);
222:                result.append("\" id=\"");
223:                result.append(id);
224:                result.append("\"");
225:                String selected = getSelectedValue(cms, param);
226:                if (selected != null) {
227:                    // append the selection 
228:                    result.append(" value=\"");
229:                    result.append(CmsEncoder.escapeXml(selected));
230:                    result.append("\"");
231:                }
232:                result.append(">");
233:                result.append("</td><td>");
234:                // button to open combo box
235:                result.append("<button name=\"test\" onclick=\"showCombo(\'")
236:                        .append(id).append("\', \'combo").append(id);
237:                result
238:                        .append("\');return false;\" class=\"widgetcombobutton\">");
239:                result.append("<img src=\"");
240:                result.append(CmsWorkplace.getSkinUri()).append(
241:                        "components/widgets/combo.png");
242:                result
243:                        .append("\" width=\"7\" height=\"12\" alt=\"\" border=\"0\">");
244:                result.append("</button></td></tr></table>");
245:
246:                result.append("</td>");
247:                return result.toString();
248:            }
249:
250:            /**
251:             * @see org.opencms.widgets.I_CmsWidget#newInstance()
252:             */
253:            public I_CmsWidget newInstance() {
254:
255:                return new CmsComboWidget(getConfiguration());
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.