Subversion Repositories eFlore/Applications.cel

Rev

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

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