Subversion Repositories eFlore/Applications.coel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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