Subversion Repositories eFlore/Applications.coel

Rev

Rev 1292 | 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
	@Override
34
	@SuppressWarnings("unchecked")
35
	public void rafraichir(Object nouvellesDonnees) {
36
 
37
		try {
38
			  data = nouvellesDonnees;
39
 
40
		      D d = null;
41
		      if (reader != null) {
42
		        d = reader.read(loadConfig, data);
43
		      } else {
44
		        d = (D) data;
45
		        if (d instanceof List) {
46
		          d = (D) new ArrayList((List) d);
47
		        }
48
		      }
49
		      callback.onSuccess(d);
50
		    } catch (Exception e) {
51
		      callback.onFailure(e);
52
		 }
53
	}
54
 
55
}