Subversion Repositories eFlore/Applications.cel

Rev

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

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