1287 |
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.util.Debug;
|
|
|
13 |
|
|
|
14 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
15 |
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
|
|
|
16 |
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
|
|
|
17 |
import com.extjs.gxt.ui.client.data.DataReader;
|
|
|
18 |
import com.extjs.gxt.ui.client.data.MemoryProxy;
|
|
|
19 |
import com.extjs.gxt.ui.client.data.ModelData;
|
|
|
20 |
import com.google.gwt.json.client.JSONObject;
|
|
|
21 |
import com.google.gwt.json.client.JSONString;
|
|
|
22 |
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
23 |
|
|
|
24 |
public class ProxyValeur<D> extends Proxy {
|
|
|
25 |
|
|
|
26 |
private String nomListe = "";
|
|
|
27 |
|
|
|
28 |
public ProxyValeur(String nomListe) {
|
|
|
29 |
super();
|
|
|
30 |
this.nomListe = nomListe;
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
@Override
|
|
|
34 |
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
|
|
|
35 |
this.reader = reader;
|
|
|
36 |
this.callback = callback;
|
|
|
37 |
this.loadConfig = loadConfig;
|
|
|
38 |
|
|
|
39 |
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
|
|
|
40 |
mediateur.obtenirListeValeurEtRafraichir(this, nomListe, true, recherche, lc.getOffset(), lc.getLimit());
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
@Override
|
|
|
45 |
@SuppressWarnings("unchecked")
|
|
|
46 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
47 |
try
|
|
|
48 |
{
|
|
|
49 |
data = nouvellesDonnees;
|
|
|
50 |
D d = null;
|
|
|
51 |
|
|
|
52 |
if (reader != null)
|
|
|
53 |
{
|
|
|
54 |
d = (D) reader.read(loadConfig, data);
|
|
|
55 |
}
|
|
|
56 |
else
|
|
|
57 |
{
|
|
|
58 |
d = (D) data;
|
|
|
59 |
if (d instanceof List)
|
|
|
60 |
{
|
|
|
61 |
d = (D) new ArrayList((List) d);
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
callback.onSuccess(d);
|
|
|
66 |
}
|
|
|
67 |
catch (Exception e)
|
|
|
68 |
{
|
|
|
69 |
callback.onFailure(e);
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
}
|