Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/datatables/DeferredListTableModel.java

Diff revisions: vs.
  @@ -1,61 +1,52 @@
1 1 // This Source Code is in the Public Domain per: http://unlicense.org
2 2 package org.litesoft.GWT.client.widgets.datatables;
3 3
4 - import java.util.*;
5 -
6 4 import org.litesoft.GWT.client.*;
7 5 import org.litesoft.bo.views.*;
8 6 import org.litesoft.core.util.*;
9 7
10 8 import com.google.gwt.gen2.table.client.TableModelHelper.*;
11 9
10 + import java.util.*;
11 +
12 12 public class DeferredListTableModel<RowType extends IViewObject> extends ListTableModel<RowType> implements FetchRowsDataProviderCallBack<RowType>
13 13
14 14 {
15 15 private VoDataProvider<RowType> mDataProvider;
16 16
17 - public DeferredListTableModel( VoDataProvider<RowType> pDataProvider )
18 - {
17 + public DeferredListTableModel( VoDataProvider<RowType> pDataProvider ) {
19 18 mDataProvider = pDataProvider;
20 19 }
21 20
22 21 @Override
23 - public void success( ImmutableArrayList<RowType> pRows )
24 - {
22 + public void success( ImmutableArrayList<RowType> pRows ) {
25 23 requestResponse( pRows );
26 24 }
27 25
28 26 @Override
29 - public void tooMany( long pCount )
30 - {
27 + public void tooMany( long pCount ) {
31 28 AlertManager.alert( this.getClass().getName(), "Too Many Rows", "" + pCount + " is Too Many Rows" );
32 29 requestResponse( null );
33 30 }
34 31
35 32 @Override
36 - public void error( String pError )
37 - {
33 + public void error( String pError ) {
38 34 AlertManager.alert( this.getClass().getName(), "Error Fetching Data", pError + "\noccured when attempting to fetch the table data" );
39 35 requestResponse( null );
40 36 }
41 37
42 - protected void requestResponse( ArrayList<RowType> pList )
43 - {
38 + protected void requestResponse( ArrayList<RowType> pList ) {
44 39 if ( pList != null ) // Stupid Generics will not let me use a ?:
45 40 {
46 41 Collections.sort( mNewList = new ArrayList<RowType>( pList ) );
47 - }
48 - else
49 - {
42 + } else {
50 43 mNewList = Collections.emptyList();
51 44 }
52 45 updateTable();
53 46 }
54 47
55 - protected void updateTable()
56 - {
57 - if ( (mNewList != null) && (mAsyncPending != null) )
58 - {
48 + protected void updateTable() {
49 + if ( (mNewList != null) && (mAsyncPending != null) ) {
59 50 clear();
60 51 addAll( mNewList );
61 52 mNewList = null;
  @@ -69,37 +60,29 @@
69 60 private AsyncPending<RowType> mAsyncPending = null;
70 61
71 62 @Override
72 - public void requestRows( Request pRequest, Callback<RowType> pCallback )
73 - {
63 + public void requestRows( Request pRequest, Callback<RowType> pCallback ) {
74 64 mAsyncPending = new AsyncPending<RowType>( pRequest, pCallback );
75 - if ( mDataProvider != null )
76 - {
65 + if ( mDataProvider != null ) {
77 66 mDataProvider.requestAllRows( this );
78 - }
79 - else
80 - {
67 + } else {
81 68 updateTable();
82 69 }
83 70 }
84 71
85 - private static class AsyncPending<RowType>
86 - {
72 + private static class AsyncPending<RowType> {
87 73 private Request mRequest;
88 74 private Callback<RowType> mCallback;
89 75
90 - private AsyncPending( Request pRequest, Callback<RowType> pCallback )
91 - {
76 + private AsyncPending( Request pRequest, Callback<RowType> pCallback ) {
92 77 mRequest = pRequest;
93 78 mCallback = pCallback;
94 79 }
95 80
96 - public Request getRequest()
97 - {
81 + public Request getRequest() {
98 82 return mRequest;
99 83 }
100 84
101 - public Callback<RowType> getCallback()
102 - {
85 + public Callback<RowType> getCallback() {
103 86 return mCallback;
104 87 }
105 88 }