Rev 1417 | Rev 1468 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.client.composants.pagination;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.util.Debug;
import com.extjs.gxt.ui.client.data.BasePagingLoader;
import com.extjs.gxt.ui.client.data.LoadEvent;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.google.gwt.user.client.rpc.AsyncCallback;
public class ChargeurListe<D extends PagingLoadResult<?>> extends BasePagingLoader<D> {
private String recherche = "";
private Integer id = null;
private Rafraichissable vueARafraichir = null;
private boolean rafraichir = false;
@SuppressWarnings("unchecked")
public ChargeurListe(Proxy proxy, TransformateurJSONaModelData reader, Rafraichissable vueARafraichir) {
super(proxy, reader);
this.vueARafraichir = vueARafraichir;
}
public boolean load(Object loadConfig, String recherche, boolean rafraichir) {
this.rafraichir = rafraichir;
if (fireEvent(BeforeLoad, new LoadEvent(this, loadConfig))) {
lastConfig = loadConfig;
this.recherche = recherche;
loadData(loadConfig, recherche);
return true;
}
else return false;
}
public boolean load(Object loadConfig) {
if (fireEvent(BeforeLoad, new LoadEvent(this, loadConfig))) {
lastConfig = loadConfig;
loadData(loadConfig, recherche);
return true;
}
return false;
}
public void load(int offset, int limit) {
this.offset = offset;
this.limit = limit;
load();
}
public boolean load() {
Object config = (reuseConfig && lastConfig != null) ? lastConfig : newLoadConfig();
config = prepareLoadConfig(config);
return load(config);
}
@SuppressWarnings("unchecked")
protected void loadData(final Object config, String recherche) {
AsyncCallback<D> callback = new AsyncCallback<D>() {
public void onFailure(Throwable caught) {
onLoadFailure(config, caught);
}
public void onSuccess(D result) {
onLoadSuccess(config, result);
if (rafraichir) {
Information info = new Information("selectionnerValeurCombo");
info.setDonnee(result);
info.setMessage("");
vueARafraichir.rafraichir(info);
}
}
};
((Proxy)proxy).load((TransformateurJSONaModelData)reader, config, callback, recherche);
}
}