1287 |
cyprien |
1 |
package org.tela_botanica.client.composants.pagination;
|
|
|
2 |
|
|
|
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.List;
|
|
|
5 |
|
|
|
6 |
import org.tela_botanica.client.Mediateur;
|
|
|
7 |
import org.tela_botanica.client.RegistreId;
|
|
|
8 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
1367 |
cyprien |
9 |
import org.tela_botanica.client.synchronisation.Sequenceur;
|
1287 |
cyprien |
10 |
import org.tela_botanica.client.util.Debug;
|
|
|
11 |
|
|
|
12 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
13 |
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
|
|
|
14 |
import com.extjs.gxt.ui.client.data.DataReader;
|
|
|
15 |
import com.extjs.gxt.ui.client.data.MemoryProxy;
|
|
|
16 |
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
17 |
|
|
|
18 |
public abstract class Proxy<D> extends MemoryProxy<D> implements Rafraichissable {
|
|
|
19 |
|
|
|
20 |
protected Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
|
|
|
21 |
|
|
|
22 |
protected DataReader<D> reader = null;
|
|
|
23 |
protected Object loadConfig = null;
|
|
|
24 |
protected AsyncCallback<D> callback = null;
|
|
|
25 |
|
|
|
26 |
protected static Object data;
|
|
|
27 |
|
1367 |
cyprien |
28 |
protected Sequenceur sequenceur = null;
|
|
|
29 |
|
|
|
30 |
public Proxy(Sequenceur sequenceur) {
|
1287 |
cyprien |
31 |
super(data);
|
1367 |
cyprien |
32 |
this.sequenceur = sequenceur;
|
1287 |
cyprien |
33 |
}
|
|
|
34 |
|
|
|
35 |
public abstract void load(TransformateurJSONaModelData<D> reader, Object loadConfig, AsyncCallback<D> callback, String recherche);
|
|
|
36 |
|
|
|
37 |
@SuppressWarnings("unchecked")
|
|
|
38 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
39 |
|
|
|
40 |
try {
|
|
|
41 |
data = nouvellesDonnees;
|
|
|
42 |
|
|
|
43 |
D d = null;
|
|
|
44 |
if (reader != null) {
|
|
|
45 |
d = reader.read(loadConfig, data);
|
|
|
46 |
} else {
|
|
|
47 |
d = (D) data;
|
|
|
48 |
if (d instanceof List) {
|
|
|
49 |
d = (D) new ArrayList((List) d);
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
callback.onSuccess(d);
|
|
|
53 |
} catch (Exception e) {
|
|
|
54 |
callback.onFailure(e);
|
|
|
55 |
}
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
}
|