Subversion Repositories eFlore/Applications.cel

Rev

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

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