Subversion Repositories eFlore/Applications.coel

Rev

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

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