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