Permalink
Browse files

Adding Smart GWT test

git-svn-id: https://flexapps.svn.sourceforge.net/svnroot/flexapps/census2@648 381d3abc-5231-0410-a0e4-b068e20cbb11
  • Loading branch information...
jlward4
jlward4 committed Jun 8, 2010
1 parent 6cb6f57 commit 66ec8d8776c3dee9859ac2c3f4abad529534e3f3
Showing 931 changed files with 84,662 additions and 0 deletions.
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" output="test-classes" path="test"/>
+ <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="war/WEB-INF/lib/smartgwt-skins.jar"/>
+ <classpathentry kind="lib" path="war/WEB-INF/lib/smartgwt.jar"/>
+ <classpathentry kind="output" path="war/WEB-INF/classes"/>
+</classpath>
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>census2-gwt</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>com.google.gwt.eclipse.core.gwtNature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,4 @@
+#Thu Jun 03 10:26:20 MDT 2010
+eclipse.preferences.version=1
+warSrcDir=war
+warSrcDirIsOutput=true
@@ -0,0 +1,3 @@
+#Fri Jun 04 08:16:32 MDT 2010
+eclipse.preferences.version=1
+gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+UFJFVFRZPC9vdXRwdXQtc3R5bGU+PGV4dHJhLWFyZ3M+PCFbQ0RBVEFbXV0+PC9leHRyYS1hcmdzPjx2bS1hcmdzPjwhW0NEQVRBWy1YbXg1MTJtXV0+PC92bS1hcmdzPjwvZ3d0LWNvbXBpbGUtc2V0dGluZ3M+
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module rename-to='census2_gwt'>
+
+ <inherits name='com.google.gwt.user.User'/>
+ <inherits name="com.google.gwt.http.HTTP" />
+ <inherits name='com.smartgwt.SmartGwt'/>
+
+ <entry-point class='com.jamesward.census2.client.Census2_gwt'/>
+
+ <source path='client'/>
+ <source path='shared'/>
+
+</module>
@@ -0,0 +1,73 @@
+package com.jamesward.census2.client;
+
+import java.util.Date;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.user.client.Window.Location;
+import com.smartgwt.client.types.FetchMode;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.events.DrawAreaChangedEvent;
+import com.smartgwt.client.widgets.grid.events.DrawAreaChangedHandler;
+
+public class Census2_gwt implements EntryPoint
+{
+ public static final String TESTID = "smartgwt_rpc";
+
+ //public static Date startRenderTime;
+ public static Date endRenderTime;
+
+ public void onModuleLoad()
+ {
+ final ListGrid censusGrid = new ListGrid();
+
+ censusGrid.setDataSource(CensusDataSource.getInstance());
+ censusGrid.setWidth100();
+ censusGrid.setHeight100();
+
+ ListGridField idField = new ListGridField("id", "id");
+ ListGridField ageField = new ListGridField("age", "age");
+ ListGridField classOfWorkerField = new ListGridField("classOfWorker", "classOfWorker");
+ ListGridField educationField = new ListGridField("education", "education");
+ ListGridField maritalStatusField = new ListGridField("maritalStatus", "maritalStatus");
+ ListGridField raceField = new ListGridField("race", "race");
+ ListGridField sexField = new ListGridField("sex", "sex");
+ censusGrid.setFields(idField, ageField, classOfWorkerField, educationField, maritalStatusField, raceField, sexField);
+
+ censusGrid.setAutoFetchData(false);
+ censusGrid.setDataFetchMode(FetchMode.BASIC); // sets server-side paging and sorting
+
+ CensusDataSource.getInstance().numRows = new Integer(Location.getParameter("numRows"));
+ CensusDataSource.getInstance().clientId = Location.getParameter("clientId");
+ CensusDataSource.getInstance().sendCensusResultURL = Location.getParameter("sendCensusResultURL");
+ CensusDataSource.getInstance().gzip = false;
+
+ if ((Location.getParameter("enableGZip") != null) && (Location.getParameter("enableGZip").equals("true")))
+ {
+ CensusDataSource.getInstance().gzip = true;
+ }
+
+ censusGrid.fetchData();
+
+ censusGrid.draw();
+
+ censusGrid.addDrawAreaChangedHandler(new DrawAreaChangedHandler() {
+ @Override
+ public void onDrawAreaChanged(DrawAreaChangedEvent event) {
+ if (endRenderTime == null)
+ {
+ endRenderTime = new Date();
+
+ SendCensusResult.sendResult(CensusDataSource.getInstance().sendCensusResultURL,
+ CensusDataSource.getInstance().clientId,
+ TESTID,
+ "renderTime",
+ endRenderTime.getTime() - CensusDataSource.getInstance().startRenderTime.getTime(),
+ CensusDataSource.getInstance().gzip,
+ CensusDataSource.getInstance().numRows);
+ }
+ }
+ });
+
+ }
+}
@@ -0,0 +1,99 @@
+package com.jamesward.census2.client;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Window.Location;
+import com.google.gwt.user.client.rpc.ServiceDefTarget;
+import com.jamesward.census2.shared.CensusEntryVO;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+public class CensusDataSource extends GenericGwtRpcDataSource<CensusEntryVO, ListGridRecord, CensusGWTServiceAsync>
+{
+
+ private static CensusDataSource instance;
+
+ // forces to use the singleton through getInstance();
+ private CensusDataSource() {};
+
+ public static CensusDataSource getInstance() {
+ if (instance == null) {
+ instance = new CensusDataSource();
+ }
+ return (instance);
+ }
+
+ @Override
+ public void copyValues(ListGridRecord from, CensusEntryVO to) {
+ to.setId(from.getAttributeAsInt("id"));
+ to.setAge(from.getAttributeAsInt("age"));
+ to.setClassOfWorker(from.getAttributeAsString("classOfWorker"));
+ to.setEducation(from.getAttributeAsString("education"));
+ to.setMaritalStatus(from.getAttributeAsString("maritalStatus"));
+ to.setRace(from.getAttributeAsString("race"));
+ to.setSex(from.getAttributeAsString("sex"));
+ }
+
+ @Override
+ public void copyValues(CensusEntryVO from, ListGridRecord to) {
+ to.setAttribute("id", from.getId());
+ to.setAttribute("age", from.getAge());
+ to.setAttribute("classOfWorker", from.getClassOfWorker());
+ to.setAttribute("education", from.getEducation());
+ to.setAttribute("maritalStatus", from.getMaritalStatus());
+ to.setAttribute("race", from.getRace());
+ to.setAttribute("sex", from.getSex());
+ }
+
+ @Override
+ public List<DataSourceField> getDataSourceFields()
+ {
+
+ List<DataSourceField> fields = new ArrayList<DataSourceField>();
+
+ DataSourceIntegerField idField = new DataSourceIntegerField("id");
+ idField.setPrimaryKey(true);
+ fields.add(idField);
+
+ DataSourceIntegerField ageField = new DataSourceIntegerField("age");
+ fields.add(ageField);
+
+ DataSourceTextField classOfWorkerField = new DataSourceTextField("classOfWorker", "classOfWorker");
+ fields.add(classOfWorkerField);
+
+ DataSourceTextField educationField = new DataSourceTextField("education", "education");
+ fields.add(educationField);
+
+ DataSourceTextField maritalStatusField = new DataSourceTextField("maritalStatus", "maritalStatus");
+ fields.add(maritalStatusField);
+
+ DataSourceTextField raceField = new DataSourceTextField("race", "race");
+ fields.add(raceField);
+
+ DataSourceTextField sexField = new DataSourceTextField("sex", "sex");
+ fields.add(sexField);
+
+ return fields;
+ }
+
+ @Override
+ public CensusEntryVO getNewDataObjectInstance() {
+ return new CensusEntryVO();
+ }
+
+ @Override
+ public ListGridRecord getNewRecordInstance() {
+ return new ListGridRecord();
+ }
+
+ @Override
+ public CensusGWTServiceAsync getServiceAsync() {
+ return GWT.create(CensusGWTService.class);
+ }
+
+
+}
@@ -0,0 +1,12 @@
+package com.jamesward.census2.client;
+
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+import com.jamesward.census2.shared.CensusEntryVO;
+
+/**
+ * The client side stub for the RPC service.
+ */
+@RemoteServiceRelativePath("getElements")
+public interface CensusGWTService extends GenericGwtRpcService<CensusEntryVO> {
+
+}
@@ -0,0 +1,8 @@
+package com.jamesward.census2.client;
+
+import com.jamesward.census2.shared.CensusEntryVO;
+
+public interface CensusGWTServiceAsync extends GenericGwtRpcServiceAsync<CensusEntryVO>
+{
+
+}
Oops, something went wrong.

0 comments on commit 66ec8d8

Please sign in to comment.