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;
|
1367 |
cyprien |
12 |
import org.tela_botanica.client.synchronisation.Sequenceur;
|
1287 |
cyprien |
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 ProxyValeur<D> extends Proxy {
|
|
|
26 |
|
|
|
27 |
private String nomListe = "";
|
|
|
28 |
|
1367 |
cyprien |
29 |
public ProxyValeur(String nomListe, Sequenceur sequenceur) {
|
|
|
30 |
super(sequenceur);
|
1287 |
cyprien |
31 |
this.nomListe = nomListe;
|
|
|
32 |
}
|
|
|
33 |
|
|
|
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;
|
1367 |
cyprien |
40 |
mediateur.obtenirListeValeurEtRafraichir(this, nomListe, true, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
|
1287 |
cyprien |
41 |
}
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
@SuppressWarnings("unchecked")
|
|
|
45 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
46 |
try
|
|
|
47 |
{
|
|
|
48 |
data = nouvellesDonnees;
|
|
|
49 |
D d = null;
|
|
|
50 |
|
|
|
51 |
if (reader != null)
|
|
|
52 |
{
|
|
|
53 |
d = (D) reader.read(loadConfig, data);
|
|
|
54 |
}
|
|
|
55 |
else
|
|
|
56 |
{
|
|
|
57 |
d = (D) data;
|
|
|
58 |
if (d instanceof List)
|
|
|
59 |
{
|
|
|
60 |
d = (D) new ArrayList((List) d);
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
callback.onSuccess(d);
|
|
|
65 |
}
|
|
|
66 |
catch (Exception e)
|
|
|
67 |
{
|
|
|
68 |
callback.onFailure(e);
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
}
|