Subversion Repositories eFlore/Applications.coel

Rev

Rev 1292 | Rev 1367 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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