1329 |
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;
|
1329 |
cyprien |
13 |
import org.tela_botanica.client.util.Debug;
|
1526 |
jpm |
14 |
import org.tela_botanica.client.util.UtilString;
|
1329 |
cyprien |
15 |
|
|
|
16 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
17 |
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
|
|
|
18 |
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
|
|
|
19 |
import com.extjs.gxt.ui.client.data.DataReader;
|
|
|
20 |
import com.extjs.gxt.ui.client.data.MemoryProxy;
|
|
|
21 |
import com.extjs.gxt.ui.client.data.ModelData;
|
|
|
22 |
import com.google.gwt.json.client.JSONObject;
|
|
|
23 |
import com.google.gwt.json.client.JSONString;
|
|
|
24 |
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
25 |
|
|
|
26 |
public class ProxyStructures<D> extends Proxy {
|
|
|
27 |
|
1367 |
cyprien |
28 |
public ProxyStructures(Sequenceur sequenceur) {
|
|
|
29 |
super(sequenceur);
|
1329 |
cyprien |
30 |
}
|
|
|
31 |
|
|
|
32 |
@Override
|
1526 |
jpm |
33 |
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
|
|
|
34 |
this.reader = reader;
|
|
|
35 |
this.callback = callback;
|
|
|
36 |
this.loadConfig = loadConfig;
|
1329 |
cyprien |
37 |
|
1691 |
raphael |
38 |
String nom = (recherche == null) ? "%" : "%" + recherche + "%";
|
|
|
39 |
|
1526 |
jpm |
40 |
BasePagingLoadConfig lc = (BasePagingLoadConfig) loadConfig;
|
|
|
41 |
if (UtilString.isNumber(recherche, false)) {
|
1764 |
aurelien |
42 |
mediateur.selectionnerStructureAvecPaginationProgressive(this, nom, null, "array", lc.getOffset(), lc.getLimit(), sequenceur, false);
|
1526 |
jpm |
43 |
} else {
|
1691 |
raphael |
44 |
mediateur.selectionnerStructure(this, nom, lc.getOffset(), lc.getLimit(), sequenceur, false);
|
1526 |
jpm |
45 |
}
|
|
|
46 |
}
|
1329 |
cyprien |
47 |
|
|
|
48 |
@Override
|
|
|
49 |
@SuppressWarnings("unchecked")
|
|
|
50 |
public void rafraichir(Object nouvellesDonnees) {
|
1526 |
jpm |
51 |
try {
|
1329 |
cyprien |
52 |
data = nouvellesDonnees;
|
1526 |
jpm |
53 |
Debug.log("Dans ProxyStructure:"+data.toString());
|
1329 |
cyprien |
54 |
D d = null;
|
1526 |
jpm |
55 |
if (reader != null) {
|
|
|
56 |
d = (D) reader.read(loadConfig, data);
|
|
|
57 |
} else {
|
|
|
58 |
d = (D) data;
|
|
|
59 |
if (d instanceof List) {
|
|
|
60 |
d = (D) new ArrayList((List) d);
|
|
|
61 |
}
|
|
|
62 |
}
|
1329 |
cyprien |
63 |
callback.onSuccess(d);
|
1526 |
jpm |
64 |
} catch (Exception e){
|
|
|
65 |
callback.onFailure(e);
|
1329 |
cyprien |
66 |
}
|
|
|
67 |
}
|
1691 |
raphael |
68 |
}
|