Subversion Repositories eFlore/Applications.cel

Rev

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

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