Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 101 Rev 104
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
2
 
2
 
3
 
3
 
4
import java.util.Iterator;
4
import java.util.Iterator;
5
 
5
 
6
import org.tela_botanica.client.modeles.ListeObservation;
6
import org.tela_botanica.client.modeles.ListeObservation;
7
import org.tela_botanica.client.modeles.Observation;
7
import org.tela_botanica.client.modeles.Observation;
8
import org.tela_botanica.client.observation.ObservationMediateur;
8
import org.tela_botanica.client.observation.ObservationMediateur;
9
import org.tela_botanica.client.interfaces.ListePaginable;
9
import org.tela_botanica.client.interfaces.ListePaginable;
10
import org.tela_botanica.client.interfaces.Rafraichissable;
10
import org.tela_botanica.client.interfaces.Rafraichissable;
11
import org.tela_botanica.client.interfaces.VueListable;
11
import org.tela_botanica.client.interfaces.VueListable;
12
 
12
 
13
import com.google.gwt.user.client.Window;
13
import com.google.gwt.user.client.Window;
14
import com.gwtext.client.core.EventObject;
14
import com.gwtext.client.core.EventObject;
15
import com.gwtext.client.core.Ext;
15
import com.gwtext.client.core.Ext;
16
import com.gwtext.client.core.ExtElement;
16
import com.gwtext.client.core.ExtElement;
17
import com.gwtext.client.core.Function;
17
import com.gwtext.client.core.Function;
18
import com.gwtext.client.data.ArrayReader;
18
import com.gwtext.client.data.ArrayReader;
19
import com.gwtext.client.data.FieldDef;
19
import com.gwtext.client.data.FieldDef;
20
import com.gwtext.client.data.MemoryProxy;
20
import com.gwtext.client.data.MemoryProxy;
21
import com.gwtext.client.data.Record;
21
import com.gwtext.client.data.Record;
22
import com.gwtext.client.data.RecordDef;
22
import com.gwtext.client.data.RecordDef;
23
import com.gwtext.client.data.SimpleStore;
23
import com.gwtext.client.data.SimpleStore;
24
import com.gwtext.client.data.Store;
24
import com.gwtext.client.data.Store;
25
import com.gwtext.client.data.StringFieldDef;
25
import com.gwtext.client.data.StringFieldDef;
26
import com.gwtext.client.widgets.Component;
26
import com.gwtext.client.widgets.Component;
27
import com.gwtext.client.widgets.Tool;
27
import com.gwtext.client.widgets.Tool;
28
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
28
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
29
import com.gwtext.client.widgets.form.ComboBox;
29
import com.gwtext.client.widgets.form.ComboBox;
30
import com.gwtext.client.widgets.grid.CellMetadata;
30
import com.gwtext.client.widgets.grid.CellMetadata;
31
import com.gwtext.client.widgets.grid.ColumnConfig;
31
import com.gwtext.client.widgets.grid.ColumnConfig;
32
import com.gwtext.client.widgets.grid.ColumnModel;
32
import com.gwtext.client.widgets.grid.ColumnModel;
33
import com.gwtext.client.widgets.grid.GridPanel;
33
import com.gwtext.client.widgets.grid.GridPanel;
34
import com.gwtext.client.widgets.grid.Renderer;
34
import com.gwtext.client.widgets.grid.Renderer;
35
import com.gwtext.client.widgets.grid.event.GridRowListenerAdapter;
35
import com.gwtext.client.widgets.grid.event.GridRowListenerAdapter;
36
 
36
 
37
/**
37
/**
38
 * Liste d'observation composée de ligne d'observation
38
 * Liste d'observation composée de ligne d'observation
39
 * l'interface rafraichissable et l'interface vueListable
39
 * l'interface rafraichissable et l'interface vueListable
40
 * 
40
 * 
41
 * @author David Delon 2008
41
 * @author David Delon 2008
42
 */
42
 */
43
public class ListeObservationVue extends GridPanel implements Rafraichissable,
43
public class ListeObservationVue extends GridPanel implements Rafraichissable,
44
		VueListable, ListePaginable {
44
		VueListable, ListePaginable {
45
 
45
 
46
	/**
46
	/**
47
	 * Le médiateur associé à la vue
47
	 * Le médiateur associé à la vue
48
	 */
48
	 */
49
	private ObservationMediateur	observationMediateur		= null;
49
	private ObservationMediateur	observationMediateur		= null;
50
 
50
 
51
 
51
 
52
	/**
52
	/**
53
	 * Config de colonne
53
	 * Config de colonne
54
	 */
54
	 */
55
	private ColumnConfig	etatObservation;
55
	private ColumnConfig	etatObservation;
56
	/**
56
	/**
57
	 * Config de colonne
57
	 * Config de colonne
58
	 */
58
	 */
59
	private ColumnConfig	nomSaisiObservation;
59
	private ColumnConfig	nomSaisiObservation;
60
	/**
60
	/**
61
	 * Config de colonne
61
	 * Config de colonne
62
	 */
62
	 */
63
	private ColumnConfig	nomRetenuObservation;
63
	private ColumnConfig	nomRetenuObservation;
64
	/**
64
	/**
65
	 * Config de colonne
65
	 * Config de colonne
66
	 */
66
	 */
67
	private ColumnConfig	lieuObservation;
67
	private ColumnConfig	lieuObservation;
68
	/**
68
	/**
69
	 * Config de colonne
69
	 * Config de colonne
70
	 */
70
	 */
71
	private ColumnConfig	dateObservation;
71
	private ColumnConfig	dateObservation;
72
	/**
72
	/**
73
	 * Config de colonne
73
	 * Config de colonne
74
	 */
74
	 */
75
	private ColumnConfig	ordreObservation;
75
	private ColumnConfig	ordreObservation;
76
	/**
76
	/**
77
	 * Modele de colonnes
77
	 * Modele de colonnes
78
	 */
78
	 */
79
	private ColumnModel		modeleColonnes;
79
	private ColumnModel		modeleColonnes;
80
 
80
 
81
	
81
	
82
	/**
82
	/**
83
	 * Store qui contient les données à afficher
83
	 * Store qui contient les données à afficher
84
	 */
84
	 */
85
	private Store			st				= null;
85
	private Store			st				= null;
86
	
86
	
87
	
87
	
88
	/**
88
	/**
89
	 * Barre de pagination
89
	 * Barre de pagination
90
	 */
90
	 */
91
	private BarrePaginationVue bt = null ;
91
	private BarrePaginationVue bt = null ;
92
 
92
 
93
	/**
93
	/**
94
	 * Numéro de page en cours
94
	 * Numéro de page en cours
95
	 */
95
	 */
96
	private int pageEncours = 0 ;
96
	private int pageEncours = 0 ;
97
	/**
97
	/**
98
	 * Nombre de pages totales
98
	 * Nombre de pages totales
99
	 */
99
	 */
100
	private int pageMax = 1 ;
100
	private int pageMax = 1 ;
101
	/**
101
	/**
102
	 * Taille de page (par défaut 20)
102
	 * Taille de page (par défaut 20)
103
	 */
103
	 */
104
	private int taillePage = 20 ;
104
	private int taillePage = 20 ;
105
	/**
105
	/**
106
	 * Nombre d'éléments total correspondant à la requete
106
	 * Nombre d'éléments total correspondant à la requete
107
	 */
107
	 */
108
	private int nbElements = 0 ;
108
	private int nbElements = 0 ;
109
	
109
	
110
	
110
	
111
	private ListeObservation cacheListeObservation = null;
111
	private ListeObservation cacheListeObservation = null;
112
	
112
	
113
	private Tool exporterObservations = null ;
113
	private Tool exporterObservations = null ;
114
	
114
	
115
	/**
115
	/**
116
	 * Constructeur sans arguments (privé car ne doit pas être utilisé)
116
	 * Constructeur sans arguments (privé car ne doit pas être utilisé)
117
	 */
117
	 */
118
	@SuppressWarnings("unused")
118
	@SuppressWarnings("unused")
119
	private ListeObservationVue()
119
	private ListeObservationVue()
120
	{
120
	{
121
		super() ;
121
		super() ;
122
	}
122
	}
123
	
123
	
124
	/**
124
	/**
125
	 * Constructeur avec argument
125
	 * Constructeur avec argument
126
	 * @param im le médiateur à associer
126
	 * @param im le médiateur à associer
127
	 */
127
	 */
128
	public ListeObservationVue(ObservationMediateur obs) {		
128
	public ListeObservationVue(ObservationMediateur obs) {		
129
		
129
		
130
		this.observationMediateur = obs;
130
		this.observationMediateur = obs;
131
		
131
		
132
		setHeader(true);
132
		setHeader(true);
133
		
133
		
134
        
134
        
135
		// on place la barre de pagination
135
		// on place la barre de pagination
136
		bt = new BarrePaginationVue(this);		
136
		bt = new BarrePaginationVue(this);		
137
		bt.setLabelElement("Observations");
137
		bt.setLabelElement("Observations");
138
		bt.setTaillePageParDefaut(20);
138
		bt.setTaillePageParDefaut(20);
139
		bt.setIntervallesPages(new String[] {"400","200",  "100" , "50" , "20"}) ;
139
		bt.setIntervallesPages(new String[] {"400","200",  "100" , "50" , "20"}) ;
140
		this.setBottomToolbar(bt) ;
140
		this.setBottomToolbar(bt) ;
141
		
141
		
142
		exporterObservations = new Tool(Tool.PIN, new Function() {
142
		exporterObservations = new Tool(Tool.PIN, new Function() {
143
 
143
 
144
			public void execute() {
144
			public void execute() {
145
				observationMediateur.exporterObservations() ;				
145
				observationMediateur.exporterObservations() ;				
146
			}
146
			}
147
			
147
			
148
		}, "Exporter des observations") ;
148
		}, "Exporter des observations") ;
149
		
149
		
150
		this.addTool(exporterObservations) ;
150
		this.addTool(exporterObservations) ;
151
		
151
		
152
		this.setTitle("Observations") ;
152
		this.setTitle("Observations") ;
153
 
153
 
154
		// on construit le modèle de colonnes
154
		// on construit le modèle de colonnes
155
 
155
 
156
		// Le store suivant est ensuite remplacé par le store contenant les données obtenus depuis le serveur (cf rafraichir) 
156
		// Le store suivant est ensuite remplacé par le store contenant les données obtenus depuis le serveur (cf rafraichir) 
157
				
157
				
158
		Renderer colRend = new Renderer() {
158
		Renderer colRend = new Renderer() {
159
 
159
 
160
			public String render(Object value, CellMetadata cellMetadata,
160
			public String render(Object value, CellMetadata cellMetadata,
161
					Record record, int rowIndex, int colNum, Store store) {
161
					Record record, int rowIndex, int colNum, Store store) {
162
				
162
				
163
				if(value == null || value.equals("null") || value.equals("000null") || value.equals("0000-00-00 00:00:00")) {
163
				if(value == null || value.equals("null") || value.equals("000null") || value.equals("0000-00-00 00:00:00")) {
164
				
164
				
165
					return "" ;
165
					return "" ;
166
				}	
166
				}	
167
				else
167
				else
168
				{
168
				{
169
					
169
					
170
				}
170
				}
171
				
171
				
172
				return value.toString() ;
172
				return value.toString() ;
173
			}
173
			}
174
			
174
			
175
		} ;
175
		} ;
176
		
176
		
177
		etatObservation = new ColumnConfig("Transmis", "etat_observation", 60, true, new Renderer() {
177
		etatObservation = new ColumnConfig("Transmis", "etat_observation", 60, true, new Renderer() {
178
 
178
 
179
			public String render(Object value, CellMetadata cellMetadata,
179
			public String render(Object value, CellMetadata cellMetadata,
180
					Record record, int rowIndex, int colNum, Store store) {
180
					Record record, int rowIndex, int colNum, Store store) {
181
				if(value.equals("1"))
181
				if(value.equals("1"))
182
				{
182
				{
183
					return "<input type=\"checkbox\" checked =\"checked\" disabled=\"disabled\" />" ;
183
					return "<input type=\"checkbox\" checked =\"checked\" disabled=\"disabled\" />" ;
184
				}
184
				}
185
				else
185
				else
186
				{
186
				{
187
					return "" ;
187
					return "" ;
188
				}
188
				}
189
			}
189
			}
190
			
190
			
191
		});		
191
		});		
192
		nomSaisiObservation = new ColumnConfig("Nom saisi", "nomSaisi_observation", 200, true, colRend);
192
		nomSaisiObservation = new ColumnConfig("Nom saisi", "nomSaisi_observation", 200, true, colRend);
193
		nomRetenuObservation = new ColumnConfig("Nom retenu", "nomRetenu_observation", 200, true, colRend);
193
		nomRetenuObservation = new ColumnConfig("Nom retenu", "nomRetenu_observation", 200, true, colRend);
194
		lieuObservation = new ColumnConfig("Lieu", "lieu_observation", 200, true, colRend);
194
		lieuObservation = new ColumnConfig("Lieu", "lieu_observation", 200, true, colRend);
195
		dateObservation = new ColumnConfig("Date", "date_observation", 120, true, colRend);
195
		dateObservation = new ColumnConfig("Date", "date_observation", 120, true, colRend);
196
		ordreObservation = new ColumnConfig("Ordre", "ordre_observation", 50, true, colRend);
196
		ordreObservation = new ColumnConfig("Ordre", "ordre_observation", 50, true, colRend);
197
			
197
			
198
	
198
	
199
		// on associe le modèle de colonnes
199
		// on associe le modèle de colonnes
200
		
200
		
201
		ColumnConfig[] cm = {etatObservation, nomSaisiObservation, nomRetenuObservation, lieuObservation, dateObservation, ordreObservation};
201
		ColumnConfig[] cm = {etatObservation, nomSaisiObservation, nomRetenuObservation, lieuObservation, dateObservation, ordreObservation};
202
		
202
		
203
		modeleColonnes = new ColumnModel(cm);
203
		modeleColonnes = new ColumnModel(cm);
204
		
204
		
205
		this.setColumnModel(modeleColonnes);
205
		this.setColumnModel(modeleColonnes);
206
		
206
		
207
		this.setAutoScroll(true);
207
		this.setAutoScroll(true);
208
		this.setEnableColumnResize(true);
208
		this.setEnableColumnResize(true);
209
		
209
		
210
		//temp dd viewport desactive ajout de ces 2 lignes
210
		//temp dd viewport desactive ajout de ces 2 lignes
211
	//	this.setAutoWidth(true);
211
	//	this.setAutoWidth(true);
212
		// temp
212
		// temp
213
		
213
		
214
		// creation du store
214
		// creation du store
215
 
215
 
216
		FieldDef defEtatObservation = new StringFieldDef("etat_observation");
216
		FieldDef defEtatObservation = new StringFieldDef("etat_observation");
217
		FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
217
		FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
218
		FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
218
		FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
219
		FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
219
		FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
220
		FieldDef defDateObservation = new StringFieldDef("date_observation");
220
		FieldDef defDateObservation = new StringFieldDef("date_observation");
221
		FieldDef defOrdreObservation = new StringFieldDef("ordre_observation");
221
		FieldDef defOrdreObservation = new StringFieldDef("ordre_observation");
222
		
222
		
223
		
223
		
224
		FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
224
		FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
225
				defLieuObservation, defDateObservation, defOrdreObservation };
225
				defLieuObservation, defDateObservation, defOrdreObservation };
226
		
226
		
227
		RecordDef rd = new RecordDef(defTab);
227
		RecordDef rd = new RecordDef(defTab);
228
		st = new Store(rd);
228
		st = new Store(rd);
229
		
229
		
230
		// on associe le store
230
		// on associe le store
231
		
231
		
232
		this.setStore(st);
232
		this.setStore(st);
233
		this.getView().setAutoFill(true);
233
		this.getView().setAutoFill(true);
234
		this.getView().setForceFit(true) ;
234
		this.getView().setForceFit(true) ;
235
		
235
		
236
		// on crée un masque de chargement qui s'affichera lors des mises à jour
236
		// on crée un masque de chargement qui s'affichera lors des mises à jour
237
		this.setLoadMask("Chargement");
237
		this.setLoadMask("Chargement");
238
	
238
	
239
		// on ajoute les listeners
239
		// on ajoute les listeners
240
		ajouterListeners();
240
		ajouterListeners();
241
		
241
		
242
		
242
		
243
	}
243
	}
244
 
244
 
245
 
245
 
246
	/**
246
	/**
247
	 * Ajoute les listeners pour la gestion des évènements
247
	 * Ajoute les listeners pour la gestion des évènements
248
	 */
248
	 */
249
	private void ajouterListeners() {
249
	private void ajouterListeners() {
250
		
250
		
251
		this.addGridRowListener(new GridRowListenerAdapter() {
251
		this.addGridRowListener(new GridRowListenerAdapter() {
252
			
252
			
253
			// gestion du clic sur une ligne
253
			// gestion du clic sur une ligne
254
			public void onRowClick(GridPanel grid, int rowIndex,
254
			public void onRowClick(GridPanel grid, int rowIndex,
255
					EventObject e) {
255
					EventObject e) {
256
				// on notifie le médiateur et on lui passe le nuémro de ligne
256
				// on notifie le médiateur et on lui passe le nuémro de ligne
257
				Record rd = getSelectionModel().getSelected();
257
				Record rd = getSelectionModel().getSelected();
258
				String ordreObservation = rd.getAsString("ordre_observation") ;
258
				String ordreObservation = rd.getAsString("ordre_observation") ;
259
				observationMediateur.onClicListeObservation(rowIndex,ordreObservation);
259
				observationMediateur.onClicListeObservation(rowIndex,ordreObservation);
260
				
260
				
261
			}
261
			}
262
 
262
 
263
			// gestion du clic droit
263
			// gestion du clic droit
264
			public void onRowContextMenu(GridPanel grid, int rowIndex,
264
			public void onRowContextMenu(GridPanel grid, int rowIndex,
265
					EventObject e) {
265
					EventObject e) {
266
				// on stoppe l'évenement pour empecher le navigateur d'afficher son propre menu
266
				// on stoppe l'évenement pour empecher le navigateur d'afficher son propre menu
267
				e.stopEvent() ;
267
				e.stopEvent() ;
268
				// on notifie le médiateur en lui passant l'évenement
268
				// on notifie le médiateur en lui passant l'évenement
269
				observationMediateur.montrerContextMenu(e);
269
				observationMediateur.montrerContextMenu(e);
270
			}
270
			}
271
 
271
 
272
			// gestion du double clic
272
			// gestion du double clic
273
			public void onRowDblClick(GridPanel grid, int rowIndex,
273
			public void onRowDblClick(GridPanel grid, int rowIndex,
274
					EventObject e) {
274
					EventObject e) {
275
				// on notifie le médiateur en lui passant le numéro de ligne
275
				// on notifie le médiateur en lui passant le numéro de ligne
276
				observationMediateur.doubleClicListeObservation(rowIndex);
276
				observationMediateur.doubleClicListeObservation(rowIndex);
277
			}
277
			}
278
			
278
			
279
		});
279
		});
280
		
280
		
281
	
281
	
282
		/*this.getSelectionModel().addListener(new RowSelectionListenerAdapter() {
282
		/*this.getSelectionModel().addListener(new RowSelectionListenerAdapter() {
283
 
283
 
284
			// gestion de la sélection
284
			// gestion de la sélection
285
			
285
			
286
			public void onSelectionChange(RowSelectionModel sm) {
286
			public void onSelectionChange(RowSelectionModel sm) {
287
 
287
 
288
				// si on a rien de sélectionné
288
				// si on a rien de sélectionné
289
				if (sm.getCount() <= 0) {
289
				if (sm.getCount() <= 0) {
290
					// on notifie le médiateur (qui désactive notamment l'accès à certaines infos)
290
					// on notifie le médiateur (qui désactive notamment l'accès à certaines infos)
291
		//			getobservationMediateur().aucuneSelection();
291
		//			getobservationMediateur().aucuneSelection();
292
				} else {
292
				} else {
293
					// sinon on notifie le médiateur
293
					// sinon on notifie le médiateur
294
			//		getobservationMediateur().selection();
294
			//		getobservationMediateur().selection();
295
					// et on lui demande de synchroniser la selection avec les autres vues
295
					// et on lui demande de synchroniser la selection avec les autres vues
296
				//	getobservationMediateur().synchroniserSelection("liste");
296
				//	getobservationMediateur().synchroniserSelection("liste");
297
				}
297
				}
298
			}
298
			}
299
		});*/
299
		});*/
300
	}
300
	}
301
 
301
 
302
	/**
302
	/**
303
	 * Méthode héritée de l'interface VueListable
303
	 * Méthode héritée de l'interface VueListable
304
	 * Sélectionne les observations  dans la liste suivant les identifiants donnés en paramètres
304
	 * Sélectionne les observations  dans la liste suivant les identifiants donnés en paramètres
305
	 */
305
	 */
306
	
306
	
307
	public String[] getIdSelectionnees() {
307
	public String[] getIdSelectionnees() {
308
		
308
		
309
		Record[] selection = this.getSelectionModel().getSelections();
309
		Record[] selection = this.getSelectionModel().getSelections();
310
		int taille = selection.length;
310
		int taille = selection.length;
311
		String id_selection[] = new String[taille];
311
		String id_selection[] = new String[taille];
312
 
312
 
313
		for (int i = 0; i < selection.length; i++) {
313
		for (int i = 0; i < selection.length; i++) {
314
 
314
 
315
			id_selection[i] = selection[i].getAsString("ordre_observation");
315
			id_selection[i] = selection[i].getAsString("ordre_observation");
316
		}
316
		}
317
 
317
 
318
		return id_selection;
318
		return id_selection;
319
	}
319
	}
320
	
320
	
321
 
321
 
322
	
322
	
323
	/**
323
	/**
324
	 * Sélectionne des enregistrements donné 
324
	 * Sélectionne des enregistrements donné 
325
	 * @param sel un tableau d'enregistrement à selectionner
325
	 * @param sel un tableau d'enregistrement à selectionner
326
	 */
326
	 */
327
	public void selectionnerEnregistrements(Record[] sel) {
327
	public void selectionnerEnregistrements(Record[] sel) {
328
 
328
 
329
			getSelectionModel().clearSelections();
329
			getSelectionModel().clearSelections();
330
			getSelectionModel().selectRecords(sel);
330
			getSelectionModel().selectRecords(sel);
331
		
331
		
332
	}
332
	}
333
	
333
	
334
	/**
334
	/**
335
	 * Accesseur pour la toolbar de pagination
335
	 * Accesseur pour la toolbar de pagination
336
	 * @return la toolbar de pagination
336
	 * @return la toolbar de pagination
337
	 */
337
	 */
338
	
338
	
339
	public BarrePaginationVue getToolBarVue()
339
	public BarrePaginationVue getToolBarVue()
340
	{
340
	{
341
		return bt ;
341
		return bt ;
342
	}
342
	}
343
 
343
 
344
 
344
 
345
	/**
345
	/**
346
	 * Recherche l'élement actuellement affiché et affiche son message de chargement
346
	 * Recherche l'élement actuellement affiché et affiche son message de chargement
347
	 */
347
	 */
348
	public void masquerChargement()
348
	public void masquerChargement()
349
	{
349
	{
350
			ExtElement masked = Ext.get(getId()) ;
350
			ExtElement masked = Ext.get(getId()) ;
351
 
351
 
352
 
352
 
353
			if (masked!=null) {
353
			if (masked!=null) {
354
				masked.mask("Chargement") ;
354
				masked.mask("Chargement") ;
355
			}
355
			}
356
 
356
 
357
	}
357
	}
358
	
358
	
359
	/**
359
	/**
360
	 * Recherche l'élement actuellement affiché et retire son message de chargement si l'était affiché
360
	 * Recherche l'élement actuellement affiché et retire son message de chargement si l'était affiché
361
	 */
361
	 */
362
	public void demasquerChargement()
362
	public void demasquerChargement()
363
	{
363
	{
364
			ExtElement masked = Ext.get(getId()) ;
364
			ExtElement masked = Ext.get(getId()) ;
365
			
365
			
366
 
366
 
367
			if (masked!=null) {
367
			if (masked!=null) {
368
				
368
				
369
				if(masked.isMasked())
369
				if(masked.isMasked())
370
				{
370
				{
371
					masked.unmask() ;
371
					masked.unmask() ;
372
				}
372
				}
373
			}
373
			}
374
	}
374
	}
375
	
375
	
376
 
376
 
377
 
377
 
378
	/**
378
	/**
379
	 * Méthode héritée de l'interface rafraichissable
379
	 * Méthode héritée de l'interface rafraichissable
380
	 * @param nouvelleDonnees les nouvelles données
380
	 * @param nouvelleDonnees les nouvelles données
381
	 * @param repandreRafraichissement le booleen de notification du rafraichissement
381
	 * @param repandreRafraichissement le booleen de notification du rafraichissement
382
	 */
382
	 */
383
	
383
	
384
 
384
 
385
 
385
 
386
	public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
386
	public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
387
	
387
	
388
	
388
	
389
	
389
	
390
		
390
		
391
//		 si l'on a reçu une liste d'observation
391
//		 si l'on a reçu une liste d'observation
392
		if(nouvelleDonnees instanceof ListeObservation)
392
		if(nouvelleDonnees instanceof ListeObservation)
393
		{
393
		{
394
			
394
			
395
				ListeObservation data = (ListeObservation) nouvelleDonnees ;
395
				ListeObservation data = (ListeObservation) nouvelleDonnees ;
396
				Object[][] observationData = new Object[data.size()][7];
396
				Object[][] observationData = new Object[data.size()][7];
397
				int i = 0 ;
397
				int i = 0 ;
398
				
398
				
399
				if(data.size() == 0)
399
				if(data.size() == 0)
400
				{
400
				{
401
					pageEncours = 0 ;
401
					pageEncours = 0 ;
402
				}
402
				}
403
				
403
				
404
				// on la parse et on récupère les informations qui nous interessent
404
				// on la parse et on récupère les informations qui nous interessent
405
				for (Iterator it = data.keySet().iterator(); it.hasNext();) 
405
				for (Iterator it = data.keySet().iterator(); it.hasNext();) 
406
				{
406
				{
407
					
407
					
408
					Observation obs=(Observation) data.get(it.next());
408
					Observation obs=(Observation) data.get(it.next());
409
					
409
					
410
					observationData[i][0]= obs.getTransmis();
410
					observationData[i][0]= obs.getTransmis();
411
					observationData[i][1]= obs.getNomSaisi();
411
					observationData[i][1]= obs.getNomSaisi();
412
					observationData[i][2]= obs.getNomRetenu();
412
					observationData[i][2]= obs.getNomRetenu();
413
					observationData[i][3]= obs.getLieudit();
413
					observationData[i][3]= obs.getLieudit();
414
					observationData[i][4]= obs.getDate();
414
					observationData[i][4]= obs.getDate();
415
					observationData[i][5]= obs.getNumeroOrdre();		
415
					observationData[i][5]= obs.getNumeroOrdre();		
416
					observationData[i][6]= obs.getNumeroNomenclaturalSaisi();
416
					observationData[i][6]= obs.getNumeroNomenclaturalSaisi();
417
									
417
									
418
				
418
				
419
					i++ ;
419
					i++ ;
420
				}
420
				}
421
		
421
		
422
				// creation du store qui les contient
422
				// creation du store qui les contient
423
				
423
				
424
				FieldDef defEtatObservation = new StringFieldDef("etat_observation");
424
				FieldDef defEtatObservation = new StringFieldDef("etat_observation");
425
				FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
425
				FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
426
				FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
426
				FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
427
				FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
427
				FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
428
				FieldDef defDateObservation = new StringFieldDef("date_observation");
428
				FieldDef defDateObservation = new StringFieldDef("date_observation");
429
				FieldDef defOrdreObservation = new StringFieldDef("ordre_observation");
429
				FieldDef defOrdreObservation = new StringFieldDef("ordre_observation");
430
				
430
				
431
				// Non affiches :
431
				// Non affiches :
432
				FieldDef defNumeroNomenclaturalSaisiObservation = new StringFieldDef("numeroNomenclaturalSaisi_observation");
432
				FieldDef defNumeroNomenclaturalSaisiObservation = new StringFieldDef("numeroNomenclaturalSaisi_observation");
433
				
433
				
434
				
434
				
435
				// on associe le store
435
				// on associe le store
436
 
436
 
437
				FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
437
				FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
438
						defLieuObservation, defDateObservation, defOrdreObservation, defNumeroNomenclaturalSaisiObservation };
438
						defLieuObservation, defDateObservation, defOrdreObservation, defNumeroNomenclaturalSaisiObservation };
439
				
439
				
440
				RecordDef rd = new RecordDef(defTab);
440
				RecordDef rd = new RecordDef(defTab);
441
				
441
				
442
				final MemoryProxy dataProxy = new MemoryProxy(observationData);
442
				final MemoryProxy dataProxy = new MemoryProxy(observationData);
443
				final ArrayReader reader = new ArrayReader(rd);
443
				final ArrayReader reader = new ArrayReader(rd);
444
		
444
		
445
				final Store observationStore = new Store(dataProxy, reader);
445
				final Store observationStore = new Store(dataProxy, reader);
446
				
446
				
447
				
447
				
448
				st = observationStore ;
448
				st = observationStore ;
449
				st.load() ;
449
				st.load() ;
450
				
450
				
451
				
451
				
452
				// et on reconfigure et rafraichit la vue
452
				// et on reconfigure et rafraichit la vue
453
				this.reconfigure(st, this.getColumnModel());
453
				this.reconfigure(st, this.getColumnModel());
454
				
454
				
455
				demasquerChargement();
455
				demasquerChargement();
456
				
456
				
457
			    cacheListeObservation=data;
457
			    cacheListeObservation=data;
458
			    
458
			    
459
				observationMediateur.onRafraichissementListeObservations();
459
				observationMediateur.onRafraichissementListeObservations();
460
				
460
				
461
				
461
				
462
		}
462
		}
463
		
463
		
464
		
464
		
465
		// Si on reçoit un tableau d'entiers
465
		// Si on reçoit un tableau d'entiers
466
		// c'est un tableau d'un seul entier qui est le nombre d'observation correspondant aux critères
466
		// c'est un tableau d'un seul entier qui est le nombre d'observation correspondant aux critères
467
		if(nouvelleDonnees instanceof int[])
467
		if(nouvelleDonnees instanceof int[])
468
		{
468
		{
469
			int[] pages = (int[])nouvelleDonnees ;
469
			int[] pages = (int[])nouvelleDonnees ;
470
			
470
			
471
			// on calcule le nombre de pages nécessaires et on les met à jour dans le modèle
471
			// on calcule le nombre de pages nécessaires et on les met à jour dans le modèle
472
			pageMax  = calculerNbPages(pages[0]) ;
472
			pageMax  = calculerNbPages(pages[0]) ;
473
			nbElements = pages[0] ;
473
			nbElements = pages[0] ;
474
			
474
			
475
			
475
			
476
			// et on notifie de le mediateur du changement des valeurs
476
			// et on notifie de le mediateur du changement des valeurs
477
			changerPageMaxEtCourante(pageMax,pageEncours,taillePage,pages[0]) ;
477
			changerPageMaxEtCourante(pageMax,pageEncours,taillePage,pages[0]) ;
478
			
478
			
479
			masquerChargement();
479
			masquerChargement();
480
			observationMediateur.obtenirListeObservation(this);
480
			observationMediateur.obtenirListeObservation(this);
481
		}
481
		}
482
		
482
		
483
		
483
		
484
//		 si l'on a reçu une Observation 
484
//		 si l'on a reçu une Observation 
485
		
485
		
486
		if(nouvelleDonnees instanceof Observation) {
486
		if(nouvelleDonnees instanceof Observation) {
487
		
487
		
488
			Observation obs= (Observation) nouvelleDonnees;
488
			Observation obs= (Observation) nouvelleDonnees;
489
			if (obs.getNumeroOrdre()==null) { // Nouvelle observation
489
			if (obs.getNumeroOrdre()==null) { // Nouvelle observation
490
			// On affiche la dernière page
490
			// On affiche la dernière page
491
			
491
			
492
			pageEncours = pageMax ;
492
			pageEncours = pageMax ;
493
			masquerChargement();
493
			masquerChargement();
494
 
494
 
495
			observationMediateur.obtenirNombreObservation();
495
			observationMediateur.obtenirNombreObservation();
496
			
496
			
497
			}
497
			}
498
			else { // Modification d'une observation
498
			else { // Modification d'une observation
499
				
499
				
500
				
500
				
501
				masquerChargement();
501
				masquerChargement();
502
 
502
 
503
				observationMediateur.obtenirNombreObservation();		
503
				observationMediateur.obtenirNombreObservation();		
504
				
504
				
505
			}
505
			}
506
		}			
506
		}			
507
		
507
		
508
	}
508
	}
509
	
509
	
510
	
510
	
511
	// GESTION DE LA PAGINATION
511
	// GESTION DE LA PAGINATION
512
 
512
 
513
	
513
	
514
	public ListeObservation getCacheListeObservation() {
514
	public ListeObservation getCacheListeObservation() {
515
		return cacheListeObservation;
515
		return cacheListeObservation;
516
	}
516
	}
517
 
517
 
518
	/**
518
	/**
519
	 * Calcule le nombre de pages nécessaires pour afficher un nombre d'élements donnés en fonction de la taille de page
519
	 * Calcule le nombre de pages nécessaires pour afficher un nombre d'élements donnés en fonction de la taille de page
520
	 * en cours
520
	 * en cours
521
	 * @param nbElements le nombre d'élements total
521
	 * @param nbElements le nombre d'élements total
522
	 * @return le nombre de pages 
522
	 * @return le nombre de pages 
523
	 */
523
	 */
524
	public int calculerNbPages(int nbElements)
524
	public int calculerNbPages(int nbElements)
525
	{
525
	{
526
		// A cause de la betise de java pour les conversion implicite on fait quelques conversions manuellement
526
		// A cause de la betise de java pour les conversion implicite on fait quelques conversions manuellement
527
		// pour eviter qu'il arrondisse mal la division
527
		// pour eviter qu'il arrondisse mal la division
528
		// nombre de pages = (nombre d'element / taille de la page) arrondie à l'entier superieur
528
		// nombre de pages = (nombre d'element / taille de la page) arrondie à l'entier superieur
529
		
529
		
530
		double nPage = (1.0*nbElements)/(1.0*taillePage) ; 
530
		double nPage = (1.0*nbElements)/(1.0*taillePage) ; 
531
		double nPageRound = Math.ceil(nPage) ;
531
		double nPageRound = Math.ceil(nPage) ;
532
		Double nPageInt = new Double(nPageRound) ;
532
		Double nPageInt = new Double(nPageRound) ;
533
		
533
		
534
		// on convertit en entier
534
		// on convertit en entier
535
		return nPageInt.intValue() ; 
535
		return nPageInt.intValue() ; 
536
	}
536
	}
537
 
537
 
538
	
538
	
539
	/**
539
	/**
540
	 * Recalcule la page en cours lors du changement du nombre d'élements
540
	 * Recalcule la page en cours lors du changement du nombre d'élements
541
	 * @param nbElements le nombre d'élements total
541
	 * @param nbElements le nombre d'élements total
542
	 * @return la nouvelle page encours
542
	 * @return la nouvelle page encours
543
	 */
543
	 */
544
	public int calculerPageCourante(int nbElements)
544
	public int calculerPageCourante(int nbElements)
545
	{
545
	{
546
		// on calcule le nombre de page
546
		// on calcule le nombre de page
547
		int nouvelNbPages = calculerNbPages(nbElements) ;
547
		int nouvelNbPages = calculerNbPages(nbElements) ;
548
		// la nouvelle page en cours
548
		// la nouvelle page en cours
549
		double nPageCourante = (1.0*pageEncours)/(1.0*pageMax) * (1.0*nouvelNbPages) ;
549
		double nPageCourante = (1.0*pageEncours)/(1.0*pageMax) * (1.0*nouvelNbPages) ;
550
		
550
		
551
		// on arrondit au supérieur
551
		// on arrondit au supérieur
552
		double nPageRound = Math.ceil(nPageCourante) ;
552
		double nPageRound = Math.ceil(nPageCourante) ;
553
		Double nPageInt = new Double(nPageRound) ;
553
		Double nPageInt = new Double(nPageRound) ;
554
		
554
		
555
		// on convertit en entier
555
		// on convertit en entier
556
		return Math.abs(nPageInt.intValue()) ; 
556
		return Math.abs(nPageInt.intValue()) ; 
557
	}
557
	}
558
	
558
	
559
 
559
 
560
	/**
560
	/**
561
	 * Appelle le modèle pour lui demander les données d'une page à afficher
561
	 * Appelle le modèle pour lui demander les données d'une page à afficher
562
	 * @param pageCourante le numéro de page à affciher
562
	 * @param pageCourante le numéro de page à affciher
563
	 */
563
	 */
564
	public void changerNumeroPage(int pageCourante) {
564
	public void changerNumeroPage(int pageCourante) {
565
		
565
		
566
		
566
		
567
		
567
		
568
		pageEncours = pageCourante ;
568
		pageEncours = pageCourante ;
569
		
569
		
570
		masquerChargement();
570
		masquerChargement();
571
 
571
 
572
		// On lance le chargerment des observations
572
		// On lance le chargerment des observations
573
		observationMediateur.obtenirNombreObservation();
573
		observationMediateur.obtenirNombreObservation();
574
		
574
		
575
		getToolBarVue().changerPageCourante(pageCourante);
575
		getToolBarVue().changerPageCourante(pageCourante);
576
		
576
		
577
	}
577
	}
578
	
578
	
579
	
579
	
580
	/**
580
	/**
581
	 * Appelle le modèle pour qu'il change la taille de page utilisée
581
	 * Appelle le modèle pour qu'il change la taille de page utilisée
582
	 * @param nouvelleTaillePage la nouvelle taille de page
582
	 * @param nouvelleTaillePage la nouvelle taille de page
583
	 */
583
	 */
584
	
584
	
585
	public void changerTaillePage(int nouvelleTaillePage)
585
	public void changerTaillePage(int nouvelleTaillePage)
586
	{
586
	{
587
	
587
	
588
		taillePage = nouvelleTaillePage ;
588
		taillePage = nouvelleTaillePage ;
589
		pageEncours = calculerPageCourante(nbElements) ;
589
		pageEncours = calculerPageCourante(nbElements) ;
590
 
590
 
591
		masquerChargement();
591
		masquerChargement();
592
 
592
 
593
		// 	On lance le chargement des observations
593
		// 	On lance le chargement des observations
594
		observationMediateur.obtenirNombreObservation();
594
		observationMediateur.obtenirNombreObservation();
595
		
595
		
596
		
596
		
597
		// et on met à jour la taille de page dans les barres d'outils
597
		// et on met à jour la taille de page dans les barres d'outils
598
		getToolBarVue().selectionnerTaillePage(nouvelleTaillePage);
598
		getToolBarVue().selectionnerTaillePage(nouvelleTaillePage);
599
		
599
		
600
		
600
		
601
	}
601
	}
602
 
602
 
603
	
603
	
604
	/**
604
	/**
605
	 * Met à jour les barre d'outils avec des nouvelles valeurs
605
	 * Met à jour les barre d'outils avec des nouvelles valeurs
606
	 * @param pageMax le nombre de pages
606
	 * @param pageMax le nombre de pages
607
	 * @param pageEncours la page en cours
607
	 * @param pageEncours la page en cours
608
	 * @param taillePage la taille de page
608
	 * @param taillePage la taille de page
609
	 * @param nbElement le nombre d'élements par page
609
	 * @param nbElement le nombre d'élements par page
610
	 */
610
	 */
611
	public void changerPageMaxEtCourante(int pageMax, int pageEncours, int taillePage, int nbElement) 
611
	public void changerPageMaxEtCourante(int pageMax, int pageEncours, int taillePage, int nbElement) 
612
	{
612
	{
613
				
613
				
614
		int[] pages = {pageMax,pageEncours, taillePage, nbElement} ;
614
		int[] pages = {pageMax,pageEncours, taillePage, nbElement} ;
615
		getToolBarVue().rafraichir(pages, false) ;
615
		getToolBarVue().rafraichir(pages, false) ;
616
		
616
		
617
	}
617
	}
618
	
618
	
619
	/**
619
	/**
620
	 * Renvoie la taille de page en cours d'utilisation
620
	 * Renvoie la taille de page en cours d'utilisation
621
	 * @return la taille de page
621
	 * @return la taille de page
622
	 */
622
	 */
623
	public int getTaillePage() {
623
	public int getTaillePage() {
624
		
624
		
625
		return taillePage;
625
		return taillePage;
626
	}
626
	}
627
	
627
	
628
	/**
628
	/**
629
	 * Renvoie le numéro de la page encours (attention on commence à 0)
629
	 * Renvoie le numéro de la page encours (attention on commence à 0)
630
	 * @return le numéro de la page en cours
630
	 * @return le numéro de la page en cours
631
	 */
631
	 */
632
	public int getPageEncours() {
632
	public int getPageEncours() {
633
		
633
		
634
		return pageEncours;
634
		return pageEncours;
635
	}
635
	}
636
	
636
	
637
	public void afficherFiltres(String nLieu, String nDate)
637
	public void afficherFiltres(String nLieu, String nDate)
638
	{
638
	{
639
		
639
		
640
		String titre = "Observations " ;
640
		String titre = "Observations " ;
641
		
641
		
642
		if(!nLieu.equals(""))
642
		if(!nLieu.equals(""))
643
		{
643
		{
644
			titre += "  -  Lieu : "+nLieu ;
644
			titre += "  -  Lieu : "+nLieu ;
645
			
645
			
646
		}
646
		}
647
			
647
			
648
		if(!nDate .equals(""))
648
		if(!nDate .equals(""))
649
		{
649
		{
650
			titre += "  -  Date : "+nDate ;
650
			titre += "  -  Date : "+nDate ;
651
		}
651
		}
652
		
652
		
653
		this.setTitle(titre) ;
653
		this.setTitle(titre) ;
654
	}
654
	}
-
 
655
 
-
 
656
	public void raz() {
-
 
657
		
-
 
658
		
-
 
659
		// creation du store qui les contient
-
 
660
		
-
 
661
		FieldDef defEtatObservation = new StringFieldDef("etat_observation");
-
 
662
		FieldDef defNomSaisiObservation = new StringFieldDef("nomSaisi_observation");
-
 
663
		FieldDef defNomRetenuObservation = new StringFieldDef("nomRetenu_observation");
-
 
664
		FieldDef defLieuObservation = new StringFieldDef("lieu_observation");
-
 
665
		FieldDef defDateObservation = new StringFieldDef("date_observation");
-
 
666
		FieldDef defOrdreObservation = new StringFieldDef("ordre_observation");
-
 
667
		
-
 
668
		// Non affiches :
-
 
669
		FieldDef defNumeroNomenclaturalSaisiObservation = new StringFieldDef("numeroNomenclaturalSaisi_observation");
-
 
670
		
-
 
671
		FieldDef[] defTab = { defEtatObservation, defNomSaisiObservation, defNomRetenuObservation,
-
 
672
				defLieuObservation, defDateObservation, defOrdreObservation };
-
 
673
		
-
 
674
		RecordDef rd = new RecordDef(defTab);
-
 
675
		st = new Store(rd);
-
 
676
		
-
 
677
		// on associe le store
-
 
678
		
-
 
679
		this.setStore(st);
-
 
680
		
-
 
681
	}
655
 
682
 
656
}
683
}