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


001:        /*******************************************************************************
002:         * Copyright (c) 2007 MyGWT.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *******************************************************************************/package net.mygwt.ui.client.viewer;
008:
009:        import net.mygwt.ui.client.Style;
010:        import net.mygwt.ui.client.data.DataCallback;
011:        import net.mygwt.ui.client.data.LoadConfig;
012:        import net.mygwt.ui.client.data.LoadEvent;
013:        import net.mygwt.ui.client.data.LoadResult;
014:        import net.mygwt.ui.client.data.Loader;
015:        import net.mygwt.ui.client.util.Observable;
016:
017:        /**
018:         * A <code>IStructuredContentProvider</code> implementation that supports the
019:         * remote loading of data and paging.
020:         */
021:        public abstract class RemoteContentProvider extends Observable
022:                implements  Loader, IStructuredContentProvider {
023:
024:            /**
025:             * The owning viewer.
026:             */
027:            protected Viewer viewer;
028:
029:            /**
030:             * The last load config.
031:             */
032:            protected LoadConfig lastConfig;
033:
034:            private String sortField;
035:            private int sortDir = Style.NONE;
036:            private boolean remoteSort;
037:            private Object data;
038:            private int totalLength;
039:
040:            /**
041:             * Returns the last data from the last load.
042:             * 
043:             * @return the current remote data
044:             */
045:            public Object getData() {
046:                return data;
047:            }
048:
049:            /**
050:             * Subclasses must implement and return the remote data based on the given
051:             * load config. The viewer's setInput method will be called, passing the data
052:             * being returned from the callback.
053:             * 
054:             * @param config the load config
055:             * @param callback the callback
056:             */
057:            public abstract void getData(LoadConfig config,
058:                    DataCallback callback);
059:
060:            /* (non-Javadoc)
061:             * @see net.mygwt.ui.client.data.Loader#getLastConfig()
062:             */
063:            public LoadConfig getLastConfig() {
064:                return lastConfig;
065:            }
066:
067:            /*
068:             * (non-Javadoc)
069:             * 
070:             * @see net.mygwt.ui.client.data.Loader#getRemoteSort()
071:             */
072:            public boolean getRemoteSort() {
073:                return remoteSort;
074:            }
075:
076:            /*
077:             * (non-Javadoc)
078:             * 
079:             * @see net.mygwt.ui.client.data.Loader#getSortDir()
080:             */
081:            public int getSortDir() {
082:                return sortDir;
083:            }
084:
085:            /**
086:             * Sets the sort field.
087:             * 
088:             * @return the sort field
089:             */
090:            public String getSortField() {
091:                return sortField;
092:            }
093:
094:            /**
095:             * Returns the total number of records which may not equal the local elements
096:             * when using paging.
097:             * 
098:             * @return the total length
099:             */
100:            public int getTotalLength() {
101:                return totalLength;
102:            }
103:
104:            public void inputChanged(Viewer viewer, Object oldInput,
105:                    Object newInput) {
106:                this .viewer = viewer;
107:            }
108:
109:            /**
110:             * Loads the data.
111:             */
112:            public void load() {
113:                load(new LoadConfig());
114:            }
115:
116:            /**
117:             * Loads the data using the specified start and limit parameters.
118:             * 
119:             * @param start the start mark
120:             * @param limit the limit mark
121:             */
122:            public void load(int start, int limit) {
123:                LoadConfig config = new LoadConfig();
124:                config.start = start;
125:                config.limit = limit;
126:                load(config);
127:            }
128:
129:            /**
130:             * Loads the data using the specified configuation.
131:             * 
132:             * @param config the configuration
133:             */
134:            public void load(LoadConfig config) {
135:                LoadEvent evt = new LoadEvent(this , config, null);
136:                if (fireEvent(BeforeLoad, evt)) {
137:                    lastConfig = config;
138:                    lastConfig.sortField = sortField;
139:                    lastConfig.sortDir = sortDir;
140:                    getData(lastConfig, new DataCallback() {
141:                        public void setResult(LoadResult result) {
142:                            onReceiveResults(result);
143:                        }
144:                    });
145:                }
146:            }
147:
148:            /**
149:             * Reloads using the last load config.
150:             */
151:            public void reload() {
152:                if (lastConfig != null) {
153:                    load(lastConfig);
154:                }
155:            }
156:
157:            /**
158:             * Sets whether sorting should be done server side.
159:             * 
160:             * @param remoteSort <code>true</code> to enable remote sorting
161:             */
162:            public void setRemoteSort(boolean remoteSort) {
163:                this .remoteSort = remoteSort;
164:            }
165:
166:            /**
167:             * Sets the sort direction.
168:             * 
169:             * @param sortDir the sort direction
170:             */
171:            public void setSortDir(int sortDir) {
172:                this .sortDir = sortDir;
173:            }
174:
175:            /**
176:             * Sets the current sort field.
177:             * 
178:             * @param sortField the sort field
179:             */
180:            public void setSortField(String sortField) {
181:                this .sortField = sortField;
182:            }
183:
184:            /**
185:             * Sorts the elements.
186:             * 
187:             * @param sortField the sort field
188:             * @param sortDir the sort direction
189:             */
190:            public void sort(String sortField, int sortDir) {
191:                this .sortField = sortField;
192:                this .sortDir = sortDir;
193:                load(lastConfig);
194:            }
195:
196:            protected void onReceiveResults(LoadResult result) {
197:                LoadEvent evt = new LoadEvent(this, lastConfig, result);
198:                data = result.getData();
199:                if (result.success) {
200:                    totalLength = result.totalLength;
201:                    fireEvent(Load, evt);
202:                } else {
203:                    fireEvent(LoadException, evt);
204:                }
205:            }
206:
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.