Source Code Cross Referenced for A_CmsHtmlIconButton.java in  » Content-Management-System » opencms » org » opencms » workplace » tools » 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.workplace.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/tools/A_CmsHtmlIconButton.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:31 $
004:         * Version: $Revision: 1.24 $
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.workplace.tools;
033:
034:        import org.opencms.i18n.CmsMessageContainer;
035:        import org.opencms.main.OpenCms;
036:        import org.opencms.util.CmsStringUtil;
037:        import org.opencms.workplace.CmsWorkplace;
038:
039:        import java.io.File;
040:
041:        /**
042:         * Default skeleton for an html icon button.<p>
043:         * 
044:         * @author Michael Moossen  
045:         * 
046:         * @version $Revision: 1.24 $ 
047:         * 
048:         * @since 6.0.0 
049:         */
050:        public abstract class A_CmsHtmlIconButton implements 
051:                I_CmsHtmlIconButton {
052:
053:            /** Constant for an empty message. */
054:            public static final CmsMessageContainer EMPTY_MESSAGE = Messages
055:                    .get().container(Messages.GUI_EMPTY_MESSAGE_0);
056:
057:            /** unique id. */
058:            protected String m_id;
059:
060:            /** Enabled flag. */
061:            private boolean m_enabled = true;
062:
063:            /** Help text or description. */
064:            private CmsMessageContainer m_helpText;
065:
066:            /** Path to the icon. */
067:            private String m_iconPath;
068:
069:            /** Display name. */
070:            private CmsMessageContainer m_name;
071:
072:            /** Visibility flag. */
073:            private boolean m_visible = true;
074:
075:            /**
076:             * Default Constructor.<p>
077:             * 
078:             * @param id the id
079:             */
080:            public A_CmsHtmlIconButton(String id) {
081:
082:                m_id = id;
083:            }
084:
085:            /**
086:             * Full Constructor.<p>
087:             * 
088:             * @param id the id
089:             * @param name the name
090:             * @param helpText the help text
091:             * @param iconPath the path to the icon
092:             * @param enabled if enabled or not
093:             */
094:            public A_CmsHtmlIconButton(String id, CmsMessageContainer name,
095:                    CmsMessageContainer helpText, String iconPath,
096:                    boolean enabled) {
097:
098:                this (id);
099:                setName(name);
100:                setHelpText(helpText);
101:                setIconPath(iconPath);
102:                setEnabled(enabled);
103:            }
104:
105:            /**
106:             * Generates a default html code for icon buttons.<p>
107:             * 
108:             * @param style the style of the button
109:             * @param id the id
110:             * @param name the name
111:             * @param helpText the help text
112:             * @param enabled if enabled or not
113:             * @param iconPath the path to the icon
114:             * @param confirmationMessage the optional confirmation message
115:             * @param onClick the js code to execute
116:             * 
117:             * @return html code
118:             */
119:            public static String defaultButtonHtml(
120:                    CmsHtmlIconButtonStyleEnum style, String id, String name,
121:                    String helpText, boolean enabled, String iconPath,
122:                    String confirmationMessage, String onClick) {
123:
124:                return defaultButtonHtml(style, id, id, name, helpText,
125:                        enabled, iconPath, confirmationMessage, onClick, false,
126:                        null);
127:            }
128:
129:            /**
130:             * Generates a default html code where several buttons can have the same help text.<p>
131:             * 
132:             * @param style the style of the button
133:             * @param id the id
134:             * @param helpId the id of the helptext div tag
135:             * @param name the name, if empty only the icon is displayed
136:             * @param helpText the help text, if empty no mouse events are generated
137:             * @param enabled if enabled or not, if not set be sure to take an according helptext
138:             * @param iconPath the path to the icon, if empty only the name is displayed
139:             * @param confirmationMessage the confirmation message
140:             * @param onClick the js code to execute, if empty no link is generated
141:             * @param singleHelp if set, no helptext is written, you have to use the defaultHelpHtml() method later
142:             * @param rightHtml optional html code that should come direct after the button
143:             * 
144:             * @return html code
145:             */
146:            public static String defaultButtonHtml(
147:                    CmsHtmlIconButtonStyleEnum style, String id, String helpId,
148:                    String name, String helpText, boolean enabled,
149:                    String iconPath, String confirmationMessage,
150:                    String onClick, boolean singleHelp, String rightHtml) {
151:
152:                StringBuffer html = new StringBuffer(1024);
153:                if (style == CmsHtmlIconButtonStyleEnum.BIG_ICON_TEXT) {
154:                    html.append("<div class='bigLink' id='img");
155:                    html.append(id);
156:                    html.append("'>\n");
157:                }
158:                html.append("\t<span class=\"link");
159:                if (enabled) {
160:                    html.append("\"");
161:                } else {
162:                    html.append(" linkdisabled\"");
163:                }
164:                if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(helpText)) {
165:                    if (!singleHelp) {
166:                        html.append(" onMouseOver=\"sMH('");
167:                        html.append(id);
168:                        html.append("');\" onMouseOut=\"hMH('");
169:                        html.append(id);
170:                        html.append("');\"");
171:                    } else {
172:                        html.append(" onMouseOver=\"sMHS('");
173:                        html.append(id);
174:                        html.append("', '");
175:                        html.append(helpId);
176:                        html.append("');\" onMouseOut=\"hMH('");
177:                        html.append(id);
178:                        html.append("', '");
179:                        html.append(helpId);
180:                        html.append("');\"");
181:                    }
182:                }
183:                if (enabled
184:                        && CmsStringUtil.isNotEmptyOrWhitespaceOnly(onClick)) {
185:                    html.append(" onClick=\"");
186:                    if (CmsStringUtil
187:                            .isNotEmptyOrWhitespaceOnly(confirmationMessage)) {
188:                        html.append("if (confirm('"
189:                                + CmsStringUtil
190:                                        .escapeJavaScript(confirmationMessage)
191:                                + "')) {");
192:                    }
193:                    html.append(onClick);
194:                    if (CmsStringUtil
195:                            .isNotEmptyOrWhitespaceOnly(confirmationMessage)) {
196:                        html.append(" }");
197:                    }
198:                    html.append("\"");
199:                }
200:                if (style == CmsHtmlIconButtonStyleEnum.SMALL_ICON_ONLY) {
201:                    html.append(" title='");
202:                    html.append(name);
203:                    html.append("'");
204:                }
205:                html.append(">");
206:                if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(iconPath)) {
207:                    html.append("<img src='");
208:                    html.append(CmsWorkplace.getSkinUri());
209:                    if (!enabled) {
210:                        StringBuffer icon = new StringBuffer(128);
211:                        icon.append(iconPath.substring(0, iconPath
212:                                .lastIndexOf('.')));
213:                        icon.append("_disabled");
214:                        icon.append(iconPath.substring(iconPath
215:                                .lastIndexOf('.')));
216:                        String resourcesRoot = OpenCms.getSystemInfo()
217:                                .getWebApplicationRfsPath()
218:                                + "resources/";
219:                        File test = new File(resourcesRoot + icon.toString());
220:                        if (test.exists()) {
221:                            html.append(icon);
222:                        } else {
223:                            html.append(iconPath);
224:                        }
225:                    } else {
226:                        html.append(iconPath);
227:                    }
228:                    html.append("'");
229:                    if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(name)) {
230:                        html.append(" alt='");
231:                        html.append(name);
232:                        html.append("'");
233:                        html.append(" title='");
234:                        html.append(name);
235:                        html.append("'");
236:                    }
237:                    html.append(">");
238:                    if (style == CmsHtmlIconButtonStyleEnum.BIG_ICON_TEXT) {
239:                        html.append("<br>");
240:                    }
241:                }
242:                if ((style != CmsHtmlIconButtonStyleEnum.SMALL_ICON_ONLY)
243:                        && CmsStringUtil.isNotEmptyOrWhitespaceOnly(name)) {
244:                    if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(iconPath)
245:                            && (style != CmsHtmlIconButtonStyleEnum.BIG_ICON_TEXT)) {
246:                        html.append("&nbsp;");
247:                    }
248:                    if (enabled) {
249:                        if (style != CmsHtmlIconButtonStyleEnum.SMALL_ICON_TEXT) {
250:                            html.append("<a href='#'>");
251:                        } else {
252:                            html
253:                                    .append("<a href='#' style='white-space: nowrap;'>");
254:                        }
255:                    }
256:                    html.append(name);
257:                    if (enabled) {
258:                        html.append("</a>");
259:                    }
260:
261:                    // doesn't work in new dialog for the radio button cols
262:                    // couldn't find a place where this is needed
263:                    // if (style != CmsHtmlIconButtonStyleEnum.BIG_ICON_TEXT && name.length() > 1) {
264:                    //  html.append("&nbsp;");
265:                    // }
266:                }
267:                html.append("</span>");
268:                if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(rightHtml)) {
269:                    html.append(rightHtml);
270:                }
271:                if (style == CmsHtmlIconButtonStyleEnum.BIG_ICON_TEXT) {
272:                    html.append("</div>\n");
273:                }
274:                if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(helpText)
275:                        && !singleHelp) {
276:                    html.append("<div class='help' id='help");
277:                    html.append(helpId);
278:                    html.append("' onMouseOver=\"sMH('");
279:                    html.append(id);
280:                    html.append("');\" onMouseOut=\"hMH('");
281:                    html.append(id);
282:                    html.append("');\">");
283:                    html.append(helpText);
284:                    html.append("</div>\n");
285:                }
286:                return html.toString();
287:            }
288:
289:            /**
290:             * Generates html for the helptext when having one helptext for several buttons.<p>
291:             * 
292:             * @param helpId the id of the help text
293:             * @param helpText the help text
294:             * 
295:             * @return html code
296:             */
297:            public static String defaultHelpHtml(String helpId, String helpText) {
298:
299:                StringBuffer html = new StringBuffer(1024);
300:                if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(helpText)) {
301:                    html.append("<div class='help' id='help");
302:                    html.append(helpId);
303:                    html.append("' onMouseOut=\"hMH('");
304:                    html.append(helpId);
305:                    html.append("');\">");
306:                    html.append(helpText);
307:                    html.append("</div>\n");
308:                }
309:                return html.toString();
310:            }
311:
312:            /**
313:             * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#getHelpText()
314:             */
315:            public CmsMessageContainer getHelpText() {
316:
317:                if (m_helpText == null) {
318:                    m_helpText = EMPTY_MESSAGE;
319:                }
320:                return m_helpText;
321:            }
322:
323:            /**
324:             * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#getIconPath()
325:             */
326:            public String getIconPath() {
327:
328:                return m_iconPath;
329:            }
330:
331:            /**
332:             * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#getId()
333:             */
334:            public String getId() {
335:
336:                return m_id;
337:            }
338:
339:            /**
340:             * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#getName()
341:             */
342:            public CmsMessageContainer getName() {
343:
344:                return m_name;
345:            }
346:
347:            /**
348:             * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#isEnabled()
349:             */
350:            public boolean isEnabled() {
351:
352:                return m_enabled;
353:            }
354:
355:            /**
356:             * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#isVisible()
357:             */
358:            public boolean isVisible() {
359:
360:                return m_visible;
361:            }
362:
363:            /**
364:             * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#setEnabled(boolean)
365:             */
366:            public void setEnabled(boolean enabled) {
367:
368:                m_enabled = enabled;
369:            }
370:
371:            /**
372:             * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#setHelpText(org.opencms.i18n.CmsMessageContainer)
373:             */
374:            public void setHelpText(CmsMessageContainer helpText) {
375:
376:                if (helpText == null) {
377:                    helpText = EMPTY_MESSAGE;
378:                }
379:                m_helpText = helpText;
380:            }
381:
382:            /**
383:             * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#setIconPath(java.lang.String)
384:             */
385:            public void setIconPath(String iconPath) {
386:
387:                m_iconPath = iconPath;
388:            }
389:
390:            /**
391:             * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#setName(org.opencms.i18n.CmsMessageContainer)
392:             */
393:            public void setName(CmsMessageContainer name) {
394:
395:                if (name == null) {
396:                    name = EMPTY_MESSAGE;
397:                }
398:                m_name = name;
399:            }
400:
401:            /**
402:             * @see org.opencms.workplace.tools.I_CmsHtmlIconButton#setVisible(boolean)
403:             */
404:            public void setVisible(boolean visible) {
405:
406:                m_visible = visible;
407:            }
408:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.