Subversion Repositories eFlore/Applications.cel

Rev

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

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