Subversion Repositories eFlore/Applications.cel

Rev

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