Subversion Repositories eFlore/Applications.cel

Rev

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

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