Subversion Repositories eFlore/Applications.cel

Rev

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