Subversion Repositories eFlore/Applications.coel

Rev

Rev 1415 | Rev 1428 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1287 cyprien 1
package org.tela_botanica.client.composants.pagination;
2
 
3
import com.extjs.gxt.ui.client.data.BasePagingLoader;
4
import com.extjs.gxt.ui.client.data.LoadEvent;
5
import com.extjs.gxt.ui.client.data.PagingLoadResult;
6
import com.google.gwt.user.client.rpc.AsyncCallback;
7
 
8
public class ChargeurListe<D extends PagingLoadResult<?>> extends BasePagingLoader<D> {
9
 
10
	private String recherche = "";
11
 
12
	@SuppressWarnings("unchecked")
13
	public ChargeurListe(Proxy proxy, TransformateurJSONaModelData reader) {
14
		super(proxy, reader);
15
	}
16
 
17
	public boolean load(Object loadConfig, String recherche) {
18
	  if (fireEvent(BeforeLoad, new LoadEvent(this, loadConfig))) {
19
	    lastConfig = loadConfig;
20
 
21
		this.recherche = recherche;
22
 
23
	    loadData(loadConfig, recherche);
24
	    return true;
25
	  }
26
	  else return false;
27
	}
28
 
29
	public boolean load(Object loadConfig) {
30
	    if (fireEvent(BeforeLoad, new LoadEvent(this, loadConfig))) {
31
	      lastConfig = loadConfig;
32
	      loadData(loadConfig, recherche);
33
	      return true;
34
	    }
35
	    return false;
36
	}
37
 
38
	public void load(int offset, int limit) {
39
	  this.offset = offset;
40
	  this.limit = limit;
41
	  load();
42
	}
43
 
44
	public boolean load() {
45
	  Object config = (reuseConfig && lastConfig != null) ? lastConfig : newLoadConfig();
46
	  config = prepareLoadConfig(config);
47
	  return load(config);
48
	}
49
 
50
	@SuppressWarnings("unchecked")
51
	protected void loadData(final Object config, String recherche) {
52
		AsyncCallback<D> callback = new AsyncCallback<D>() {
53
		    public void onFailure(Throwable caught) {
54
		      onLoadFailure(config, caught);
55
		    }
56
		    public void onSuccess(D result) {
57
		      onLoadSuccess(config, result);
58
		    }
59
		};
60
		((Proxy)proxy).load((TransformateurJSONaModelData)reader, config, callback, recherche);
61
	}
62
}