Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1417 Rev 1428
1
package org.tela_botanica.client.composants.pagination;
1
package org.tela_botanica.client.composants.pagination;
-
 
2
 
-
 
3
import org.tela_botanica.client.interfaces.Rafraichissable;
-
 
4
import org.tela_botanica.client.modeles.Information;
-
 
5
import org.tela_botanica.client.util.Debug;
2
 
6
 
3
import com.extjs.gxt.ui.client.data.BasePagingLoader;
7
import com.extjs.gxt.ui.client.data.BasePagingLoader;
4
import com.extjs.gxt.ui.client.data.LoadEvent;
8
import com.extjs.gxt.ui.client.data.LoadEvent;
5
import com.extjs.gxt.ui.client.data.PagingLoadResult;
9
import com.extjs.gxt.ui.client.data.PagingLoadResult;
6
import com.google.gwt.user.client.rpc.AsyncCallback;
10
import com.google.gwt.user.client.rpc.AsyncCallback;
7
 
11
 
8
public class ChargeurListe<D extends PagingLoadResult<?>> extends BasePagingLoader<D> {
12
public class ChargeurListe<D extends PagingLoadResult<?>> extends BasePagingLoader<D> {
9
 
13
 
10
	private String recherche = "";
14
	private String recherche = "";
-
 
15
	private Integer id = null;
-
 
16
	private Rafraichissable vueARafraichir = null;
-
 
17
	private boolean rafraichir = false;
11
 
18
 
12
	@SuppressWarnings("unchecked")
19
	@SuppressWarnings("unchecked")
13
	public ChargeurListe(Proxy proxy, TransformateurJSONaModelData reader) {
20
	public ChargeurListe(Proxy proxy, TransformateurJSONaModelData reader, Rafraichissable vueARafraichir) {
-
 
21
		super(proxy, reader);
14
		super(proxy, reader);
22
		this.vueARafraichir = vueARafraichir;
15
	}
23
	}
-
 
24
	
16
	
25
	public boolean load(Object loadConfig, String recherche, boolean rafraichir) {
17
	public boolean load(Object loadConfig, String recherche) {
26
		this.rafraichir = rafraichir;
18
	  if (fireEvent(BeforeLoad, new LoadEvent(this, loadConfig))) {
27
		if (fireEvent(BeforeLoad, new LoadEvent(this, loadConfig))) {
19
	    lastConfig = loadConfig;
28
	    lastConfig = loadConfig;
20
 
29
 
21
		this.recherche = recherche;
30
		this.recherche = recherche;
22
	    
31
	    
23
	    loadData(loadConfig, recherche);
32
	    loadData(loadConfig, recherche);
24
	    return true;
33
	    return true;
25
	  }
34
	  }
26
	  else return false;
35
	  else return false;
27
	}
36
	}
28
	
37
	
29
	public boolean load(Object loadConfig) {
38
	public boolean load(Object loadConfig) {
30
	    if (fireEvent(BeforeLoad, new LoadEvent(this, loadConfig))) {
39
	    if (fireEvent(BeforeLoad, new LoadEvent(this, loadConfig))) {
31
	      lastConfig = loadConfig;
40
	      lastConfig = loadConfig;
32
	      loadData(loadConfig, recherche);
41
	      loadData(loadConfig, recherche);
33
	      return true;
42
	      return true;
34
	    }
43
	    }
35
	    return false;
44
	    return false;
36
	}
45
	}
37
	
46
	
38
	public void load(int offset, int limit) {
47
	public void load(int offset, int limit) {
39
	  this.offset = offset;
48
	  this.offset = offset;
40
	  this.limit = limit;
49
	  this.limit = limit;
41
	  load();
50
	  load();
42
	}
51
	}
43
	
52
	
44
	public boolean load() {
53
	public boolean load() {
45
	  Object config = (reuseConfig && lastConfig != null) ? lastConfig : newLoadConfig();
54
	  Object config = (reuseConfig && lastConfig != null) ? lastConfig : newLoadConfig();
46
	  config = prepareLoadConfig(config);
55
	  config = prepareLoadConfig(config);
47
	  return load(config);
56
	  return load(config);
48
	}
57
	}
49
	
58
	
50
	@SuppressWarnings("unchecked")
59
	@SuppressWarnings("unchecked")
51
	protected void loadData(final Object config, String recherche) {
60
	protected void loadData(final Object config, String recherche) {
52
		AsyncCallback<D> callback = new AsyncCallback<D>() {
61
		AsyncCallback<D> callback = new AsyncCallback<D>() {
-
 
62
			
53
		    public void onFailure(Throwable caught) {
63
		    public void onFailure(Throwable caught) {
54
		      onLoadFailure(config, caught);
64
		      onLoadFailure(config, caught);
55
		    }
65
		    }
-
 
66
		    
56
		    public void onSuccess(D result) {
67
		    public void onSuccess(D result) {
57
		      onLoadSuccess(config, result);
68
		    	onLoadSuccess(config, result);
-
 
69
				
-
 
70
			    if (rafraichir) {				
-
 
71
			    	Information info = new Information("selectionnerValeurCombo");
-
 
72
			    	info.setDonnee(result);
-
 
73
			    	info.setMessage("");
-
 
74
					
-
 
75
					vueARafraichir.rafraichir(info);
58
		    }
76
			    }
-
 
77
			}
59
		};
78
		};
60
		((Proxy)proxy).load((TransformateurJSONaModelData)reader, config, callback, recherche);
79
		((Proxy)proxy).load((TransformateurJSONaModelData)reader, config, callback, recherche);
61
	}
80
	}
62
}
81
}