1446 |
cyprien |
1 |
package org.tela_botanica.client.composants.pagination;
|
|
|
2 |
|
|
|
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.HashMap;
|
|
|
5 |
import java.util.List;
|
|
|
6 |
|
|
|
7 |
import org.tela_botanica.client.Mediateur;
|
|
|
8 |
import org.tela_botanica.client.RegistreId;
|
|
|
9 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
10 |
import org.tela_botanica.client.modeles.ValeurListe;
|
|
|
11 |
import org.tela_botanica.client.modeles.ValeurListeAsyncDao;
|
|
|
12 |
import org.tela_botanica.client.synchronisation.Sequenceur;
|
|
|
13 |
import org.tela_botanica.client.util.Debug;
|
|
|
14 |
|
|
|
15 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
16 |
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
|
|
|
17 |
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
|
|
|
18 |
import com.extjs.gxt.ui.client.data.DataReader;
|
|
|
19 |
import com.extjs.gxt.ui.client.data.MemoryProxy;
|
|
|
20 |
import com.extjs.gxt.ui.client.data.ModelData;
|
|
|
21 |
import com.google.gwt.json.client.JSONObject;
|
|
|
22 |
import com.google.gwt.json.client.JSONString;
|
|
|
23 |
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
24 |
|
|
|
25 |
public class ProxyCollectionAPersonne<D> extends Proxy {
|
|
|
26 |
|
|
|
27 |
String collectionId = null;
|
|
|
28 |
String roleId = null;
|
|
|
29 |
|
|
|
30 |
public ProxyCollectionAPersonne(Sequenceur sequenceur, String collectionId, String roleId) {
|
|
|
31 |
super(sequenceur);
|
|
|
32 |
|
|
|
33 |
this.collectionId = collectionId;
|
|
|
34 |
this.roleId = roleId;
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
@Override
|
|
|
38 |
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
|
|
|
39 |
this.reader = reader;
|
|
|
40 |
this.callback = callback;
|
|
|
41 |
this.loadConfig = loadConfig;
|
|
|
42 |
|
|
|
43 |
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
|
|
|
44 |
mediateur.selectionnerCollectionAPersonne(this, this.collectionId, this.roleId, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
@Override
|
|
|
48 |
@SuppressWarnings("unchecked")
|
|
|
49 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
50 |
|
|
|
51 |
try
|
|
|
52 |
{
|
|
|
53 |
data = nouvellesDonnees;
|
|
|
54 |
D d = null;
|
|
|
55 |
|
|
|
56 |
if (reader != null)
|
|
|
57 |
{
|
|
|
58 |
d = (D) reader.read(loadConfig, data);
|
|
|
59 |
}
|
|
|
60 |
else
|
|
|
61 |
{
|
|
|
62 |
d = (D) data;
|
|
|
63 |
if (d instanceof List)
|
|
|
64 |
{
|
|
|
65 |
d = (D) new ArrayList((List) d);
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
callback.onSuccess(d);
|
|
|
70 |
}
|
|
|
71 |
catch (Exception e)
|
|
|
72 |
{
|
|
|
73 |
callback.onFailure(e);
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
}
|