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 |
|
1526 |
jpm |
38 |
BasePagingLoadConfig lc = (BasePagingLoadConfig) loadConfig;
|
|
|
39 |
if (UtilString.isNumber(recherche, false)) {
|
|
|
40 |
mediateur.selectionnerStructureAvecPaginationProgressive(this, recherche, null, null, "array", lc.getOffset(), lc.getLimit(), sequenceur);
|
|
|
41 |
} else {
|
|
|
42 |
mediateur.selectionnerStructure(this, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
|
|
|
43 |
}
|
|
|
44 |
}
|
1329 |
cyprien |
45 |
|
|
|
46 |
@Override
|
|
|
47 |
@SuppressWarnings("unchecked")
|
|
|
48 |
public void rafraichir(Object nouvellesDonnees) {
|
1526 |
jpm |
49 |
try {
|
1329 |
cyprien |
50 |
data = nouvellesDonnees;
|
1526 |
jpm |
51 |
Debug.log("Dans ProxyStructure:"+data.toString());
|
1329 |
cyprien |
52 |
D d = null;
|
1526 |
jpm |
53 |
if (reader != null) {
|
|
|
54 |
d = (D) reader.read(loadConfig, data);
|
|
|
55 |
} else {
|
|
|
56 |
d = (D) data;
|
|
|
57 |
if (d instanceof List) {
|
|
|
58 |
d = (D) new ArrayList((List) d);
|
|
|
59 |
}
|
|
|
60 |
}
|
1329 |
cyprien |
61 |
callback.onSuccess(d);
|
1526 |
jpm |
62 |
} catch (Exception e){
|
|
|
63 |
callback.onFailure(e);
|
1329 |
cyprien |
64 |
}
|
|
|
65 |
}
|
1526 |
jpm |
66 |
}
|