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


001:        /* AuRequest.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Tue May 31 11:31:13     2005, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2005 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.zk.au;
020:
021:        import java.util.Map;
022:        import java.util.HashMap;
023:        import java.util.Set;
024:        import java.util.HashSet;
025:
026:        import org.zkoss.zk.ui.Desktop;
027:        import org.zkoss.zk.ui.Page;
028:        import org.zkoss.zk.ui.Component;
029:        import org.zkoss.zk.ui.Execution;
030:        import org.zkoss.zk.ui.Executions;
031:        import org.zkoss.zk.ui.UiException;
032:        import org.zkoss.zk.ui.ComponentNotFoundException;
033:        import org.zkoss.zk.ui.event.Events;
034:        import org.zkoss.zk.ui.sys.PageCtrl;
035:        import org.zkoss.zk.ui.sys.ComponentsCtrl;
036:        import org.zkoss.zk.au.in.*;
037:
038:        /**
039:         * A request sent from the client to {@link org.zkoss.zk.ui.sys.UiEngine}.
040:         *
041:         * @author tomyeh
042:         */
043:        public class AuRequest {
044:            private final Desktop _desktop;
045:            private Page _page;
046:            private Component _comp;
047:            /** Component's UUID. Used only if _comp is not specified directly. */
048:            private final String _uuid;
049:            private final Command _cmd;
050:            private final String[] _data;
051:
052:            //-- static --//
053:            private static final Map _cmds = new HashMap();
054:
055:            /** Returns whether the specified request name is valid.
056:             * A request is a  event that are sent from the browser.
057:             *
058:             * <p>An request name is the ID of a command
059:             * ({@link Command#getId}) which starts with "on".
060:             */
061:            public static final boolean hasRequest(String cmdnm) {
062:                return _cmds.containsKey(cmdnm);
063:            }
064:
065:            /** Returns the command of the specified name.
066:             * @exception CommandNotFoundException if the command is not found
067:             */
068:            public static final Command getCommand(String name) {
069:                final Command cmd = (Command) _cmds.get(name);
070:                if (cmd == null)
071:                    throw new CommandNotFoundException("Unknown command: "
072:                            + name);
073:                return cmd;
074:            }
075:
076:            /** Adds a new command. Called only by Command's contructor. */
077:            /*package*/static final void addCommand(Command cmd) {
078:                if (_cmds.put(cmd.getId(), cmd) != null)
079:                    throw new InternalError("Replicated command: " + cmd);
080:            }
081:
082:            /** Constructor for a request sent from a component.
083:             * Since we cannot invoke {@link Desktop#getComponentByUuid} without
084:             * activating an execution, we have to use this method.
085:             *
086:             * @param desktop the desktop containing the component; never null.
087:             * @param uuid the component ID (never null)
088:             * @param cmd the command; never null.
089:             * @param data the data; might be null.
090:             */
091:            public AuRequest(Desktop desktop, String uuid, Command cmd,
092:                    String[] data) {
093:                if (desktop == null || uuid == null || cmd == null)
094:                    throw new IllegalArgumentException("null");
095:
096:                _desktop = desktop;
097:                _uuid = uuid;
098:                _cmd = cmd;
099:                _data = data;
100:            }
101:
102:            /** Constructor for a general request sent from client.
103:             * This is usully used to ask server to log or report status.
104:             *
105:             * @param cmd the command; never null.
106:             * @param data the data; might be null.
107:             */
108:            public AuRequest(Desktop desktop, Command cmd, String[] data) {
109:                if (desktop == null || cmd == null)
110:                    throw new IllegalArgumentException("null");
111:                _desktop = desktop;
112:                _uuid = null;
113:                _cmd = cmd;
114:                _data = data;
115:            }
116:
117:            /** Returns the desktop; never null. */
118:            public final Desktop getDesktop() {
119:                return _desktop;
120:            }
121:
122:            /** Returns the page that this request is applied for, or null
123:             * if this reqeuest is a general request -- regardless any page or
124:             * component.
125:             * @exception ComponentNotFoundException if the page is not found
126:             */
127:            public final Page getPage() {
128:                init();
129:                return _page;
130:            }
131:
132:            private void init() {
133:                if (_page == null && _uuid != null) {
134:                    _comp = _desktop.getComponentByUuidIfAny(_uuid);
135:                    if (_comp != null) {
136:                        _page = _comp.getPage();
137:                    } else if (!ComponentsCtrl.isUuid(_uuid)) {
138:                        _page = _desktop.getPage(_uuid);
139:                    } else {
140:                        throw new ComponentNotFoundException(
141:                                "Component not found: " + _uuid);
142:                    }
143:                }
144:            }
145:
146:            /** Returns the component that this request is applied for, or null
147:             * if it applies to the whole page or a general request.
148:             * @exception ComponentNotFoundException if the component is not found
149:             */
150:            public final Component getComponent() {
151:                init();
152:                return _comp;
153:            }
154:
155:            /** Returns the UUID.
156:             */
157:            public final String getComponentUuid() {
158:                return _uuid != null ? _uuid : _comp != null ? _comp.getUuid()
159:                        : null;
160:            }
161:
162:            /** Returns the command; never null.
163:             */
164:            public final Command getCommand() {
165:                return _cmd;
166:            }
167:
168:            /** Returns the data of the command, might be null.
169:             */
170:            public final String[] getData() {
171:                return _data;
172:            }
173:
174:            //-- Object --//
175:            public final boolean equals(Object o) { //prevent override
176:                return this  == o;
177:            }
178:
179:            public String toString() {
180:                if (_uuid != null)
181:                    return "[uuid=" + _uuid + ", cmd=" + _cmd + ']';
182:                else if (_comp != null)
183:                    return "[comp=" + _comp + ", cmd=" + _cmd + ']';
184:                else
185:                    return "[page=" + _page + ", cmd=" + _cmd + ']';
186:            }
187:
188:            //-- predefined commands --//
189:            static {
190:                new BookmarkChangedCommand(Events.ON_BOOKMARK_CHANGED,
191:                        Command.IGNORE_OLD_EQUIV);
192:                new CheckCommand(Events.ON_CHECK, 0);
193:                new ClientInfoCommand(Events.ON_CLIENT_INFO,
194:                        Command.IGNORE_OLD_EQUIV);
195:                new UpdateResultCommand("updateResult", 0);
196:                new DropCommand(Events.ON_DROP, 0);
197:
198:                new DummyCommand("dummy", Command.IGNORABLE
199:                        | Command.IGNORE_OLD_EQUIV | Command.SKIP_IF_EVER_ERROR);
200:                new EchoCommand("echo", Command.SKIP_IF_EVER_ERROR);
201:
202:                new ErrorCommand(Events.ON_ERROR, Command.IGNORE_OLD_EQUIV);
203:
204:                new GenericCommand(Events.ON_BLUR, Command.IGNORE_OLD_EQUIV);
205:                new GenericCommand(Events.ON_CLOSE, 0);
206:                new GenericCommand(Events.ON_FOCUS, Command.IGNORE_OLD_EQUIV);
207:                new GenericCommand(Events.ON_NOTIFY, 0);
208:                new GenericCommand(Events.ON_SORT, Command.SKIP_IF_EVER_ERROR
209:                        | Command.IGNORE_OLD_EQUIV);
210:                new TimerCommand(Events.ON_TIMER, Command.IGNORE_OLD_EQUIV);
211:                new GenericCommand(Events.ON_USER, 0);
212:
213:                new GetUploadInfoCommand("getUploadInfo", Command.IGNORABLE);
214:
215:                new InputCommand(Events.ON_CHANGE,
216:                        Command.IGNORE_IMMEDIATE_OLD_EQUIV);
217:                new InputCommand(Events.ON_CHANGING, Command.SKIP_IF_EVER_ERROR
218:                        | Command.IGNORABLE);
219:
220:                new KeyCommand(Events.ON_CANCEL, Command.SKIP_IF_EVER_ERROR
221:                        | Command.CTRL_GROUP);
222:                new KeyCommand(Events.ON_CTRL_KEY, Command.SKIP_IF_EVER_ERROR
223:                        | Command.CTRL_GROUP);
224:                new KeyCommand(Events.ON_OK, Command.SKIP_IF_EVER_ERROR
225:                        | Command.CTRL_GROUP);
226:
227:                new MoveCommand(Events.ON_MOVE, Command.IGNORE_OLD_EQUIV);
228:                new SizeCommand(Events.ON_SIZE, Command.IGNORE_OLD_EQUIV);
229:                new InnerWidthCommand("onInnerWidth", Command.IGNORE_OLD_EQUIV);
230:
231:                new MouseCommand(Events.ON_CLICK, Command.SKIP_IF_EVER_ERROR
232:                        | Command.CTRL_GROUP);
233:                new MouseCommand(Events.ON_DOUBLE_CLICK,
234:                        Command.SKIP_IF_EVER_ERROR | Command.CTRL_GROUP);
235:                new MouseCommand(Events.ON_RIGHT_CLICK,
236:                        Command.SKIP_IF_EVER_ERROR | Command.CTRL_GROUP);
237:
238:                new OpenCommand(Events.ON_OPEN, 0);
239:                new RemoveCommand("remove", 0);
240:                new RedrawCommand("redraw", 0);
241:                new RemoveDesktopCommand("rmDesktop", 0);
242:                new RenderCommand(Events.ON_RENDER, Command.IGNORE_OLD_EQUIV);
243:                //z.loaded is set only if replied from server, so it is OK
244:                //to drop if any previous -- which means users are scrolling fast
245:
246:                new ScrollCommand(Events.ON_SCROLLING,
247:                        Command.SKIP_IF_EVER_ERROR | Command.IGNORABLE);
248:                new ScrollCommand(Events.ON_SCROLL,
249:                        Command.IGNORE_IMMEDIATE_OLD_EQUIV);
250:
251:                new SelectCommand(Events.ON_SELECT, 0);
252:                new SelectionCommand(Events.ON_SELECTION,
253:                        Command.IGNORE_OLD_EQUIV);
254:
255:                new ZIndexCommand(Events.ON_Z_INDEX, Command.IGNORE_OLD_EQUIV);
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.