Source Code Cross Referenced for Messagebox.java in  » Ajax » zk » org » zkoss » zul » 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 » Ajax » zk » org.zkoss.zul 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Messagebox.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Mon Jul 18 19:07:13     2005, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2004 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        	This program is distributed under GPL Version 2.0 in the hope that
016:        	it will be useful, but WITHOUT ANY WARRANTY.
017:        }}IS_RIGHT
018:         */
019:        package org.zkoss.zul;
020:
021:        import java.util.Map;
022:        import java.util.HashMap;
023:
024:        import org.zkoss.mesg.Messages;
025:
026:        import org.zkoss.zk.ui.WebApp;
027:        import org.zkoss.zk.ui.Executions;
028:        import org.zkoss.zk.ui.UiException;
029:
030:        import org.zkoss.zul.impl.MessageboxDlg;
031:
032:        /**
033:         * Represents the message box.
034:         *
035:         * <p>You don't create {@link Messagebox} directly. Rather, use {@link #show}.
036:         *
037:         * <p>A non-XUL extension.
038:         *
039:         * @author tomyeh
040:         */
041:        public class Messagebox {
042:            private static String _templ = "~./zul/html/messagebox.zul";
043:
044:            /** A symbol consisting of a question mark in a circle. */
045:            public static final String QUESTION = "~./zul/img/question.gif";
046:            /** A symbol consisting of an exclamation point in a triangle with
047:             * a yellow background.
048:             */
049:            public static final String EXCLAMATION = "~./zul/img/exclamation.gif";
050:            /** A symbol of a lowercase letter i in a circle.
051:             */
052:            public static final String INFORMATION = "~./zul/img/information.gif";
053:            /** A symbol consisting of a white X in a circle with a red background. */
054:            public static final String ERROR = "~./zul/img/error.gif";
055:            /** Contains no symbols. */
056:            public static final String NONE = null;
057:
058:            /** A OK button. */
059:            public static final int OK = 0x0001;
060:            /** A Cancel button. */
061:            public static final int CANCEL = 0x0002;
062:            /** A Yes button. */
063:            public static final int YES = 0x0010;
064:            /** A No button. */
065:            public static final int NO = 0x0020;
066:            /** A Abort button. */
067:            public static final int ABORT = 0x0100;
068:            /** A Retry button. */
069:            public static final int RETRY = 0x0200;
070:            /** A IGNORE button. */
071:            public static final int IGNORE = 0x0400;
072:
073:            /** Shows a message box and returns what button is pressed.
074:             *
075:             * @param title the title. If null, {@link WebApp#getAppName} is used.
076:             * @param buttons a combination of {@link #OK}, {@link #CANCEL},
077:             * {@link #YES}, {@link #NO}, {@link #ABORT}, {@link #RETRY},
078:             * and {@link #IGNORE}. If zero, {@link #OK} is assumed
079:             * @param icon one of predefined images: {@link #QUESTION},
080:             * {@link #EXCLAMATION}, {@link #ERROR}, {@link #NONE}, or any URI of
081:             * an image.
082:             * @return the button being pressed (one of {@link #OK}, {@link #CANCEL},
083:             * {@link #YES}, {@link #NO}, {@link #ABORT}, {@link #RETRY},
084:             * and {@link #IGNORE}).
085:             */
086:            public static final int show(String message, String title,
087:                    int buttons, String icon) throws InterruptedException {
088:                return show(message, title, buttons, icon, 0);
089:            }
090:
091:            /** Shows a message box and returns what button is pressed.
092:             *
093:             * @param title the title. If null, {@link WebApp#getAppName} is used.
094:             * @param buttons a combination of {@link #OK}, {@link #CANCEL},
095:             * {@link #YES}, {@link #NO}, {@link #ABORT}, {@link #RETRY},
096:             * and {@link #IGNORE}. If zero, {@link #OK} is assumed
097:             * @param icon one of predefined images: {@link #QUESTION},
098:             * {@link #EXCLAMATION}, {@link #ERROR}, {@link #NONE}, or any URI of
099:             * an image.
100:             * @param focus one of button to have to focus. If 0, the first button
101:             * will gain the focus. One of {@link #OK}, {@link #CANCEL},
102:             * {@link #YES}, {@link #NO}, {@link #ABORT}, {@link #RETRY},
103:             * and {@link #IGNORE}.
104:             * @return the button being pressed (one of {@link #OK}, {@link #CANCEL},
105:             * {@link #YES}, {@link #NO}, {@link #ABORT}, {@link #RETRY},
106:             * and {@link #IGNORE}).
107:             * @since 3.0.0
108:             */
109:            public static final int show(String message, String title,
110:                    int buttons, String icon, int focus)
111:                    throws InterruptedException {
112:                final Map params = new HashMap();
113:                params.put("message", message);
114:                params.put("title", title != null ? title : Executions
115:                        .getCurrent().getDesktop().getWebApp().getAppName());
116:                params.put("icon", icon);
117:                params.put("buttons", new Integer((buttons & (OK | CANCEL | YES
118:                        | NO | ABORT | RETRY | IGNORE)) != 0 ? buttons : OK));
119:                if ((buttons & OK) != 0)
120:                    params.put("OK", new Integer(OK));
121:                if ((buttons & CANCEL) != 0)
122:                    params.put("CANCEL", new Integer(CANCEL));
123:                if ((buttons & YES) != 0)
124:                    params.put("YES", new Integer(YES));
125:                if ((buttons & NO) != 0)
126:                    params.put("NO", new Integer(NO));
127:                if ((buttons & RETRY) != 0)
128:                    params.put("RETRY", new Integer(RETRY));
129:                if ((buttons & ABORT) != 0)
130:                    params.put("ABORT", new Integer(ABORT));
131:                if ((buttons & IGNORE) != 0)
132:                    params.put("IGNORE", new Integer(IGNORE));
133:
134:                final MessageboxDlg dlg = (MessageboxDlg) Executions
135:                        .createComponents(_templ, null, params);
136:                dlg.setButtons(buttons);
137:                if (focus > 0)
138:                    dlg.setFocus(focus);
139:
140:                if (dlg.getDesktop().getWebApp().getConfiguration()
141:                        .isEventThreadEnabled()) {
142:                    try {
143:                        dlg.doModal();
144:                    } catch (Throwable ex) {
145:                        dlg.detach();
146:                        if (ex instanceof  InterruptedException)
147:                            throw (InterruptedException) ex;
148:                        throw UiException.Aide.wrap(ex);
149:                    }
150:                    return dlg.getResult();
151:                } else {
152:                    dlg.doHighlighted();
153:                    return OK;
154:                }
155:            }
156:
157:            /** Shows a message box and returns what button is pressed.
158:             * A shortcut to show(message, null, OK, INFORMATION).
159:             */
160:            public static final int show(String message)
161:                    throws InterruptedException {
162:                return show(message, null, OK, INFORMATION, 0);
163:            }
164:
165:            /** Shows a message box by specifying a message code, and returns what
166:             * button is pressed.
167:             *
168:             * @param titleCode the message code for the title. If non-positive,
169:             * the default title is used.
170:             */
171:            public static final int show(int messageCode, Object[] args,
172:                    int titleCode, int buttons, String icon)
173:                    throws InterruptedException {
174:                return show(messageCode, args, titleCode, buttons, icon, 0);
175:            }
176:
177:            /** Shows a message box by specifying a message code, and returns what
178:             * button is pressed.
179:             *
180:             * @param titleCode the message code for the title. If non-positive,
181:             * the default title is used.
182:             * @param focus one of button to have to focus. If 0, the first button
183:             * will gain the focus. One of {@link #OK}, {@link #CANCEL},
184:             * {@link #YES}, {@link #NO}, {@link #ABORT}, {@link #RETRY},
185:             * and {@link #IGNORE}.
186:             * @since 3.0.0
187:             */
188:            public static final int show(int messageCode, Object[] args,
189:                    int titleCode, int buttons, String icon, int focus)
190:                    throws InterruptedException {
191:                return show(Messages.get(messageCode, args),
192:                        titleCode > 0 ? Messages.get(titleCode) : null,
193:                        buttons, icon, focus);
194:            }
195:
196:            /** Shows a message box by specifying a message code, and returns what
197:             * button is pressed.
198:             *
199:             * @param titleCode the message code for the title. If non-positive,
200:             * the default title is used.
201:             */
202:            public static final int show(int messageCode, Object arg,
203:                    int titleCode, int buttons, String icon)
204:                    throws InterruptedException {
205:                return show(messageCode, arg, titleCode, buttons, icon, 0);
206:            }
207:
208:            /** Shows a message box by specifying a message code, and returns what
209:             * button is pressed.
210:             *
211:             * @param titleCode the message code for the title. If non-positive,
212:             * the default title is used.
213:             * @param focus one of button to have to focus. If 0, the first button
214:             * will gain the focus. One of {@link #OK}, {@link #CANCEL},
215:             * {@link #YES}, {@link #NO}, {@link #ABORT}, {@link #RETRY},
216:             * and {@link #IGNORE}.
217:             * @since 3.0.0
218:             */
219:            public static final int show(int messageCode, Object arg,
220:                    int titleCode, int buttons, String icon, int focus)
221:                    throws InterruptedException {
222:                return show(Messages.get(messageCode, arg),
223:                        titleCode > 0 ? Messages.get(titleCode) : null,
224:                        buttons, icon, focus);
225:            }
226:
227:            /** Shows a message box by specifying a message code, and returns what
228:             * button is pressed.
229:             *
230:             * @param titleCode the message code for the title. If non-positive,
231:             * the default title is used.
232:             */
233:            public static final int show(int messageCode, int titleCode,
234:                    int buttons, String icon) throws InterruptedException {
235:                return show(messageCode, titleCode, buttons, icon, 0);
236:            }
237:
238:            /** Shows a message box by specifying a message code, and returns what
239:             * button is pressed.
240:             *
241:             * @param titleCode the message code for the title. If non-positive,
242:             * the default title is used.
243:             * @param focus one of button to have to focus. If 0, the first button
244:             * will gain the focus. One of {@link #OK}, {@link #CANCEL},
245:             * {@link #YES}, {@link #NO}, {@link #ABORT}, {@link #RETRY},
246:             * and {@link #IGNORE}.
247:             * @since 3.0.0
248:             */
249:            public static final int show(int messageCode, int titleCode,
250:                    int buttons, String icon, int focus)
251:                    throws InterruptedException {
252:                return show(Messages.get(messageCode), titleCode > 0 ? Messages
253:                        .get(titleCode) : null, buttons, icon, focus);
254:            }
255:
256:            /** Sets the template used to create the message dialog.
257:             *
258:             * <p>The template must follow the default template:
259:             * ~./zul/html/messagebox.zul
260:             *
261:             * <p>In other words, just adjust the label and layout and don't
262:             * change the component's ID.
263:             */
264:            public static void setTemplate(String uri) {
265:                if (uri == null || uri.length() == 0)
266:                    throw new IllegalArgumentException("empty");
267:                _templ = uri;
268:            }
269:
270:            /** Returns the template used to create the message dialog.
271:             */
272:            public static String getTemplate() {
273:                return _templ;
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.