Subversion Repositories eFlore/Applications.cel

Rev

Rev 175 | Rev 206 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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