Source Code Cross Referenced for DataLoader.java in  » Ajax » MyGWT » net » mygwt » ui » client » data » 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 » MyGWT » net.mygwt.ui.client.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * MyGWT Widget Library
003:         * Copyright(c) 2007, MyGWT.
004:         * licensing@mygwt.net
005:         * 
006:         * http://mygwt.net/license
007:         */
008:        package net.mygwt.ui.client.data;
009:
010:        import java.util.List;
011:
012:        import net.mygwt.ui.client.Style;
013:        import net.mygwt.ui.client.util.Observable;
014:
015:        /**
016:         * <code>DataLoaders</code> are used to retrieve and convert raw data. Data is
017:         * retrieved using a <code>DataProxy</code> and optionally read and parsed
018:         * using a <code>DataReader</code>.
019:         * 
020:         * <dl>
021:         * <dt><b>Events:</b></dt>
022:         * 
023:         * <dd><b>BeforeLoad</b> : (loader, config)<br>
024:         * <div>Fires before a load operation. Listeners can set the <code>doit</code>
025:         * field to <code>false</code> to cancel the action.</div>
026:         * <ul>
027:         * <li>loader : this</li>
028:         * <li>config : the load config</li>
029:         * </ul>
030:         * </dd>
031:         * 
032:         * <dd><b>Load</b> : (loader, config, result)<br>
033:         * <div>Fires after the button is selected.</div>
034:         * <ul>
035:         * <li>loader : this</li>
036:         * <li>config : the load config</li>
037:         * <li>result : the load result</li>
038:         * </ul>
039:         * </dd>
040:         * 
041:         * <dd><b>LoadException</b> : (loader, config, result)<br>
042:         * <div>Fires after the button is selected.</div>
043:         * <ul>
044:         * <li>loader : this</li>
045:         * <li>config : the load config</li>
046:         * <li>result : the load result</li>
047:         * </ul>
048:         * </dd>
049:         * </dl>
050:         * 
051:         * @see DataProxy
052:         * @see DataReader
053:         */
054:        public class DataLoader extends Observable implements  Loader {
055:
056:            /**
057:             * totalLength specifies the total number of records which may not equal the
058:             * local elements when using paging.
059:             */
060:            public int totalLength;
061:            private boolean remoteSort;
062:
063:            private String sortField;
064:            private int sortDir = Style.NONE;
065:
066:            private Object data;
067:            private LoadConfig lastConfig;
068:            private DataProxy proxy;
069:            private DataReader reader;
070:
071:            /**
072:             * Creates a new loader instance with the given proxy. A reader is not
073:             * specified and will not be passed to the proxy at load time.
074:             * 
075:             * @param proxy the data proxy
076:             */
077:            public DataLoader(DataProxy proxy) {
078:                this .proxy = proxy;
079:            }
080:
081:            /**
082:             * Creates a new loader with the given proxy and reader.
083:             * 
084:             * @param proxy the data proxy
085:             * @param reader the data reader
086:             */
087:            public DataLoader(DataProxy proxy, DataReader reader) {
088:                this .proxy = proxy;
089:                this .reader = reader;
090:            }
091:
092:            /**
093:             * Returns the last data from the last load.
094:             * 
095:             * @return the remote data
096:             */
097:            public Object getData() {
098:                return data;
099:            }
100:
101:            /**
102:             * Returns the elements from the last load as a list.
103:             * 
104:             * @deprecated Use {@link #getData()}.
105:             * @return the elements
106:             */
107:            public List getElements() {
108:                if (data instanceof  List) {
109:                    return (List) data;
110:                }
111:                return null;
112:            }
113:
114:            public LoadConfig getLastConfig() {
115:                return lastConfig;
116:            }
117:
118:            public boolean getRemoteSort() {
119:                return remoteSort;
120:            }
121:
122:            public int getSortDir() {
123:                return sortDir;
124:            }
125:
126:            public String getSortField() {
127:                return sortField;
128:            }
129:
130:            public int getTotalLength() {
131:                return totalLength;
132:            }
133:
134:            /**
135:             * Loads the data.
136:             */
137:            public void load() {
138:                load(new LoadConfig());
139:            }
140:
141:            /**
142:             * Loads the data using the specified start and limit parameters.
143:             * 
144:             * @param start the start mark
145:             * @param limit the limit mark
146:             */
147:            public void load(int start, int limit) {
148:                LoadConfig config = new LoadConfig();
149:                config.start = start;
150:                config.limit = limit;
151:                load(config);
152:            }
153:
154:            public void load(LoadConfig config) {
155:                LoadEvent evt = new LoadEvent(this , config, null);
156:                if (fireEvent(BeforeLoad, evt)) {
157:                    lastConfig = config;
158:                    lastConfig.sortField = sortField;
159:                    lastConfig.sortDir = sortDir;
160:                    proxy.load(reader, config, new DataCallback() {
161:                        public void setResult(LoadResult result) {
162:                            onReceivedResult(result);
163:                        }
164:                    });
165:                }
166:
167:            }
168:
169:            /**
170:             * Reloads using the last load config.
171:             */
172:            public void reload() {
173:                if (lastConfig != null) {
174:                    load(lastConfig);
175:                }
176:            }
177:
178:            /**
179:             * Sets if sorting is handled by the server. Defult value is
180:             * <code>false</code>.
181:             * 
182:             * @param remoteSort <code>true</code> to enable server side sorting
183:             */
184:            public void setRemoteSort(boolean remoteSort) {
185:                this .remoteSort = remoteSort;
186:            }
187:
188:            public void setSortDir(int sortDir) {
189:                this .sortDir = sortDir;
190:            }
191:
192:            public void setSortField(String sortField) {
193:                this .sortField = sortField;
194:            }
195:
196:            public void sort(String sortField, int sortDir) {
197:                this .sortField = sortField;
198:                this .sortDir = sortDir;
199:                load(lastConfig);
200:            }
201:
202:            protected void onReceivedResult(LoadResult result) {
203:                LoadEvent evt = new LoadEvent(this, lastConfig, result);
204:                evt.result = result;
205:                data = result.data;
206:                if (result.success) {
207:                    totalLength = result.totalLength;
208:                    fireEvent(Load, evt);
209:                } else {
210:                    fireEvent(LoadException, evt);
211:                }
212:            }
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.