Subversion Repositories eFlore/Applications.cel

Rev

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

Rev Author Line No. Line
199 david 1
package org.tela_botanica.client.vues.observation.filtres;
54 david 2
 
90 jpm 3
import java.util.Comparator;
68 david 4
import java.util.Iterator;
5
 
54 david 6
import org.tela_botanica.client.interfaces.Filtrable;
7
import org.tela_botanica.client.interfaces.Rafraichissable;
68 david 8
import org.tela_botanica.client.modeles.EntiteGeographiqueObservation;
9
import org.tela_botanica.client.modeles.ListeEntiteGeographiqueObservation;
89 jpm 10
import org.tela_botanica.client.modeles.Observation;
54 david 11
import org.tela_botanica.client.observation.ObservationMediateur;
12
 
72 david 13
import com.google.gwt.core.client.GWT;
54 david 14
import com.gwtext.client.data.Node;
15
import com.gwtext.client.data.NodeTraversalCallback;
16
import com.gwtext.client.data.Tree;
17
import com.gwtext.client.widgets.Component;
18
import com.gwtext.client.widgets.Panel;
19
import com.gwtext.client.widgets.event.PanelListenerAdapter;
20
import com.gwtext.client.widgets.tree.TreeNode;
21
import com.gwtext.client.widgets.tree.TreePanel;
87 jpm 22
import com.gwtext.client.widgets.tree.event.TreeNodeListenerAdapter;
85 jpm 23
import com.gwtext.client.widgets.tree.event.TreePanelListenerAdapter;
24
import com.gwtext.client.core.EventObject;
54 david 25
 
26
/**
199 david 27
 * Arbre Filtrant sur les entites geographiques
28
 *
54 david 29
 *
199 david 30
 * @author aurelien + david
54 david 31
 *
32
 */
199 david 33
 
34
 
68 david 35
public class ArbreEntiteGeographiqueObservationFiltreVue extends Panel implements Rafraichissable,
54 david 36
		Filtrable {
37
 
38
	/**
39
	 * Le médiateur associé à la vue
40
	 */
41
	private ObservationMediateur	observationMediateur		= null;
42
 
43
	/**
44
	 * Les localites en cours
45
	 */
68 david 46
	private String entitesGeographiquesEncours = "";
54 david 47
 
48
	/**
49
	 * Le treepanel qui affiche l'arbre
50
	 */
68 david 51
	private TreePanel arbreEntitesGeographiques = null;
54 david 52
 
68 david 53
 
54 david 54
	/**
55
	 * booléen d'initialisation
56
	 */
57
	private boolean estInstancie = false;
58
 
59
	/**
60
	 * booléen d'etat
61
	 */
62
	private boolean filtreModifie = false;
85 jpm 63
	private boolean arbreCharge = false ;
64
 
86 jpm 65
	private String nomFiltre = "" ;
66
 
54 david 67
	/**
68
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
69
	 */
70
	@SuppressWarnings("unused")
68 david 71
	private ArbreEntiteGeographiqueObservationFiltreVue() {
54 david 72
		super();
73
	}
74
 
75
	/**
76
	 * Constructeur avec paramètres
77
	 *
78
	 * @param im
79
	 *            le médiateur à associer
80
	 */
68 david 81
	public ArbreEntiteGeographiqueObservationFiltreVue(ObservationMediateur obs) {
54 david 82
 
83
		// on crée le panel
168 aurelien 84
		super("Localités");
54 david 85
 
86
		this.observationMediateur = obs;
87
 
68 david 88
		arbreEntitesGeographiques = new TreePanel();
54 david 89
 
90
		this.setPaddings(5);
91
 
92
		this.setCollapsible(true);
93
		this.setAutoWidth(true);
128 aurelien 94
 
95
		if (GWT.isScript()) {
96
			setAutoScroll(true);
97
		}
54 david 98
 
99
 
100
		// on ajoute les listeners
101
		ajouterListenersPanel();
102
		estInstancie = false;
103
	}
104
 
105
	/**
106
	 * Ajoute les listeners pour le rendu du panel
107
	 */
108
	private void ajouterListenersPanel() {
68 david 109
		  this.addListener(new PanelListenerAdapter() {
54 david 110
 
111
			// on instancie réellement les composants au moment du rendu pour
112
			// accélérer l'affichage
113
			// et éviter des bugs
114
			public void onRender(Component component) {
115
 
116
				// on interdit le drag and drop dans l'arbre
68 david 117
				arbreEntitesGeographiques.setEnableDD(false);
73 david 118
				arbreEntitesGeographiques.setId("x-view-tree-filter-entity");
72 david 119
				arbreEntitesGeographiques.setAutoWidth(false);
54 david 120
 
121
				// on crée une racine pour l'arbre
72 david 122
				TreeNode root = new TreeNode("Localités");
70 david 123
				root.setId("racine_entite");
72 david 124
				String[] usObject = { "Localités" };
54 david 125
				root.setUserObject(usObject);
126
 
68 david 127
				arbreEntitesGeographiques.setRootNode(root);
128
				arbreEntitesGeographiques.setRootVisible(true);
129
				arbreEntitesGeographiques.setBorder(false);
85 jpm 130
				root.setExpandable(true) ;
54 david 131
 
68 david 132
				add(arbreEntitesGeographiques);
54 david 133
 
134
				// on ajoute les listeners d'évenements
135
				ajouterListeners();
136
 
137
 
138
				// enfin on considère le composant comme instancié
139
				estInstancie = true;
140
 
68 david 141
 
54 david 142
			}
143
 
144
		});
145
	}
146
 
68 david 147
 
148
 
54 david 149
	/**
70 david 150
	 * ajoute les listeners pour les boutons et le cochage des entites
54 david 151
	 */
152
	private void ajouterListeners() {
85 jpm 153
 
154
		arbreEntitesGeographiques.addListener(new TreePanelListenerAdapter() {
155
 
156
			public void onClick(TreeNode node, EventObject e) {
157
 
86 jpm 158
				nomFiltre = "" ;
87 jpm 159
				entitesGeographiquesEncours = "" ;
160
				String nomPere = "" ;
161
				String nomGrandPere = "" ;
85 jpm 162
 
163
				switch(node.getDepth())
164
				{
165
					case 0:
166
						if(!arbreCharge)
167
						{
128 aurelien 168
							arbreEntitesGeographiques.getRootNode().expand();
85 jpm 169
						}
86 jpm 170
						else
171
						{
172
							observationMediateur.obtenirNombreObservation() ;
173
						}
85 jpm 174
						return ;
87 jpm 175
					case 3: nomFiltre += "lieudit,location,id_location";
176
						nomPere = ((String[])node.getParentNode().getUserObject())[0] ;
177
						nomGrandPere = ((String[])node.getParentNode().getParentNode().getUserObject())[0] ;
178
						entitesGeographiquesEncours += node.getText()+","+nomPere+","+nomGrandPere ;
85 jpm 179
						break;
87 jpm 180
					case 2: nomFiltre += "location,id_location";
181
						nomPere = ((String[])node.getParentNode().getUserObject())[0] ;
182
						entitesGeographiquesEncours += node.getText()+","+nomPere ;
85 jpm 183
						break;
87 jpm 184
					case 1: nomFiltre += "id_location";
185
						entitesGeographiquesEncours += node.getText() ;
85 jpm 186
						break;
187
					default:
188
						break;
189
				}
190
 
191
				filtreModifie = true ;
199 david 192
 
193
				// Le filtre est modifie : on lance un rafraaaichissement de la liste des observations affichees
194
 
86 jpm 195
				observationMediateur.obtenirNombreObservation() ;
85 jpm 196
 
197
			}
198
 
199
		}) ;
87 jpm 200
 
201
		arbreEntitesGeographiques.getRootNode().addListener(new TreeNodeListenerAdapter() {
202
 
203
			public void onExpand(Node node) {
204
				if(!arbreCharge)
205
				{
206
					observationMediateur.obtenirListeEntiteGeographique() ;
207
					arbreCharge = true ;
208
				}
209
			}
210
 
211
		}) ;
54 david 212
	}
140 aurelien 213
 
214
	public void initialiser() {
215
 
216
		arbreCharge = false ;
217
		arbreEntitesGeographiques.collapseAll();
218
		// on vide l'ancien arbre
219
		Node[] rootChild = arbreEntitesGeographiques.getRootNode().getChildNodes();
220
		for (int i = 0; i < rootChild.length; i++) {
221
 
222
			rootChild[i].remove();
223
		}
224
 
225
		arbreEntitesGeographiques.getRootNode().addListener(new TreeNodeListenerAdapter() {
226
 
227
			public void onExpand(Node node) {
228
				if(!arbreCharge)
229
				{
230
					observationMediateur.obtenirListeEntiteGeographique() ;
231
					arbreCharge = true ;
232
				}
233
			}
234
 
235
		}) ;
236
	}
54 david 237
 
238
	/**
239
	 * Méthode héritée de l'interface rafraichissable
240
	 */
241
	public void rafraichir(Object nouvelleDonnees,
242
			boolean repandreRaffraichissement) {
243
 
128 aurelien 244
 
68 david 245
		if (nouvelleDonnees instanceof ListeEntiteGeographiqueObservation) {
246
 
89 jpm 247
			String id_location=null;
248
			String location=null;
249
			String lieuDit=null;
68 david 250
 
251
			ListeEntiteGeographiqueObservation data = (ListeEntiteGeographiqueObservation) nouvelleDonnees ;
252
 
253
				// on crée un arbre vide
166 aurelien 254
				Tree nouvelArbre = new Tree() ;
68 david 255
				TreeNode root = new TreeNode();
72 david 256
				root.setId("racine_entite");
257
				root.setText("Localités");
89 jpm 258
				String[] usObjRoot = { "Localités"};
259
				root.setUserObject(usObjRoot);
166 aurelien 260
				nouvelArbre.setRootNode(root);
68 david 261
 
83 david 262
			// on la parse et on récupère les informations qui nous interessent
68 david 263
			for (Iterator<String> it= data.keySet().iterator(); it.hasNext();) {
264
 
265
				EntiteGeographiqueObservation ent=(EntiteGeographiqueObservation) data.get(it.next());
266
 
89 jpm 267
				id_location=ent.getIdLocation();
128 aurelien 268
				id_location = id_location.replaceAll("\"", "");
140 aurelien 269
				id_location = id_location.replace('\\',' ');
270
				id_location = id_location.trim();
89 jpm 271
				location=ent.getLocation();
272
				lieuDit=ent.getLieuDit();
73 david 273
 
128 aurelien 274
				if(id_location.contains("000null") || id_location.equals(null) || (id_location.trim()).equals("")) {
89 jpm 275
					id_location="Inconnue" ;
85 jpm 276
				}
73 david 277
 
128 aurelien 278
				if(location.contains("000null") || location.equals(null) || (location.trim().equals(""))) {
89 jpm 279
					location="Inconnue" ;
280
				}
68 david 281
 
128 aurelien 282
				if(lieuDit.contains("000null") || lieuDit.equals(null) || (lieuDit.trim().equals(""))) {
89 jpm 283
					lieuDit="Inconnue" ;
284
				}
285
 
166 aurelien 286
				Node noeudMemeId = nouvelArbre.getNodeById(""+id_location);
287
 
89 jpm 288
				// si la région existe déjà
289
					if(noeudMemeId != null)
290
					{
291
						// on teste si la localité existe
166 aurelien 292
						Node noeudMemeLoc = nouvelArbre.getNodeById(""+(id_location+location));
89 jpm 293
						if(noeudMemeLoc != null)
85 jpm 294
						{
89 jpm 295
							// enfin on teste si le lieu dit existe
166 aurelien 296
							Node noeudMemeLieu = nouvelArbre.getNodeById(""+(id_location+location+lieuDit));
89 jpm 297
							if(noeudMemeLieu != null)
298
							{
299
								// tous les noeuds existent déjà, normalement ça ne devrait pas arriver
300
							}
301
							else
302
							{
303
								// enfin on ne crée que le noeud du lieu dit
304
								TreeNode node_lieu = new TreeNode();
305
								node_lieu.setId(""+(id_location+location+lieuDit));
306
								node_lieu.setText(lieuDit);
307
								noeudMemeLoc.appendChild(node_lieu) ;
166 aurelien 308
								String[] usObj = {lieuDit,id_location+location+lieuDit};
89 jpm 309
								node_lieu.setUserObject(usObj);
310
							}
85 jpm 311
						}
89 jpm 312
						else
313
						{
199 david 314
							//  on  crée  le noeud de la location
89 jpm 315
							TreeNode node_loc = new TreeNode();
316
							node_loc.setId(""+(id_location+location));
317
							node_loc.setText(location);
318
							noeudMemeId.appendChild(node_loc) ;
166 aurelien 319
							String[] usObj = {location,id_location+location};
89 jpm 320
							node_loc.setUserObject(usObj);
321
 
322
							TreeNode node_lieu = new TreeNode();
323
							node_lieu.setId(""+(id_location+location+lieuDit));
324
							node_lieu.setText(lieuDit);
325
							node_loc.appendChild(node_lieu) ;
166 aurelien 326
							String[] usObj2 = {lieuDit,id_location+location+lieuDit};
89 jpm 327
							node_lieu.setUserObject(usObj2);
328
 
329
						}
68 david 330
					}
89 jpm 331
					else
332
					{
199 david 333
						//  on  crée  le noeud de l'identifiant  location
89 jpm 334
						TreeNode node_id_loc = new TreeNode();
335
						node_id_loc.setId(""+id_location);
336
						node_id_loc.setText(id_location);
337
						root.appendChild(node_id_loc) ;
166 aurelien 338
						String[] usObj = {id_location,id_location};
89 jpm 339
						node_id_loc.setUserObject(usObj);
340
 
341
						TreeNode node_loc = new TreeNode();
342
						node_loc.setId(""+(id_location+location));
343
						node_loc.setText(location);
344
						node_id_loc.appendChild(node_loc) ;
166 aurelien 345
						String[] usObj2 = {location,id_location+location};
89 jpm 346
						node_loc.setUserObject(usObj2);
347
 
348
						TreeNode node_lieu = new TreeNode();
349
						node_lieu.setId(""+(id_location+location+lieuDit));
350
						node_lieu.setText(lieuDit);
351
						node_loc.appendChild(node_lieu) ;
166 aurelien 352
						String[] usObj3 = {lieuDit,id_location+location+lieuDit};
89 jpm 353
						node_lieu.setUserObject(usObj3);
354
					}
109 aurelien 355
 
356
					root.sort(comparerNoeuds()) ;
357
					doLayout();
89 jpm 358
 
68 david 359
				}
360
 
89 jpm 361
				// on vide tous les noeuds
362
				arbreEntitesGeographiques.getRootNode().eachChild(new NodeTraversalCallback() {
363
 
364
					public boolean execute(Node node) {
365
 
366
						node.remove();
367
						return true;
368
					}
369
 
370
				});
199 david 371
 
166 aurelien 372
				copierFilsNoeud(root, arbreEntitesGeographiques.getRootNode());
54 david 373
 
89 jpm 374
 
375
				// si l'arbre n'était pas encore considéré comme instancié
199 david 376
 
89 jpm 377
				if (!estInstancie) {
378
					// on signale que oui
379
					estInstancie = true;
54 david 380
				}
89 jpm 381
 
382
				// l'état du filtre est réinitialisé
383
				filtreModifie = false;
109 aurelien 384
 
89 jpm 385
				//show() ;
166 aurelien 386
				arbreEntitesGeographiques.doLayout();
54 david 387
 
388
			}
89 jpm 389
 
390
		if(nouvelleDonnees instanceof Observation)
128 aurelien 391
		{
199 david 392
			// Cas d'ajout unitaire d'une observation
393
 
128 aurelien 394
			// si l'arbre n'est pas encore chargé, on ne tient pas compte de l'ajout
395
			// l'arbre complet sera de toute façon renvoyé plus tard lors du premier chargement
396
			// de l'arbre
397
			if(!arbreCharge) {
398
				return;
399
			}
400
 
89 jpm 401
			Observation obs = (Observation)nouvelleDonnees ;
402
 
403
			String id_location= obs.getIdentifiantLocalite();
128 aurelien 404
			id_location = id_location.replaceAll("\"", "");
140 aurelien 405
			id_location = id_location.replace('\\',' ');
406
			id_location = id_location.trim();
407
 
89 jpm 408
			String location=obs.getLocalite();
409
			String lieuDit=obs.getLieudit();
410
 
411
			Node root = arbreEntitesGeographiques.getRootNode() ;
412
 
128 aurelien 413
			if(id_location.contains("000null") || id_location.equals(null) || (id_location.trim()).equals("")) {
89 jpm 414
				id_location="Inconnue" ;
415
			}
416
 
128 aurelien 417
			if(location.contains("000null") || location.equals(null) || (location.trim().equals(""))) {
89 jpm 418
				location="Inconnue" ;
419
			}
420
 
128 aurelien 421
			if(lieuDit.contains("000null") || lieuDit.equals(null) || (lieuDit.trim().equals(""))) {
89 jpm 422
				lieuDit="Inconnue" ;
423
			}
424
 
166 aurelien 425
			Node noeudMemeId = arbreEntitesGeographiques.getNodeById(""+id_location);
89 jpm 426
			// si la région existe déjà
427
				if(noeudMemeId != null)
428
				{
429
					// on teste si la localité existe
166 aurelien 430
					Node noeudMemeLoc = arbreEntitesGeographiques.getNodeById(""+(id_location+location));
89 jpm 431
					if(noeudMemeLoc != null)
432
					{
433
						// enfin on teste si le lieu dit existe
166 aurelien 434
						Node noeudMemeLieu = arbreEntitesGeographiques.getNodeById(""+(id_location+location+lieuDit));
89 jpm 435
						if(noeudMemeLieu != null)
436
						{
437
							// tous les noeuds existent déjà, normalement ça ne devrait pas arriver
438
						}
439
						else
440
						{
441
							// enfin on ne crée que le noeud du lieu dit
442
							TreeNode node_lieu = new TreeNode();
443
							node_lieu.setId(""+(id_location+location+lieuDit));
444
							node_lieu.setText(lieuDit);
166 aurelien 445
							String[] usObj = {lieuDit,id_location+location+lieuDit};
89 jpm 446
							node_lieu.setUserObject(usObj);
447
							noeudMemeLoc.appendChild(node_lieu) ;
109 aurelien 448
 
449
							root.sort(comparerNoeuds()) ;
89 jpm 450
						}
451
					}
452
					else
453
					{
199 david 454
						//  on  crée  le noeud de la location
89 jpm 455
						TreeNode node_loc = new TreeNode();
456
						node_loc.setId(""+(id_location+location));
457
						node_loc.setText(location);
166 aurelien 458
						String[] usObj = {location,id_location+location};
89 jpm 459
						node_loc.setUserObject(usObj);
460
						noeudMemeId.appendChild(node_loc) ;
461
 
462
						TreeNode node_lieu = new TreeNode();
463
						node_lieu.setId(""+(id_location+location+lieuDit));
464
						node_lieu.setText(lieuDit);
166 aurelien 465
						String[] usObj2 = {lieuDit,id_location+location+lieuDit};
89 jpm 466
						node_lieu.setUserObject(usObj2);
467
						node_loc.appendChild(node_lieu) ;
468
 
109 aurelien 469
						root.sort(comparerNoeuds()) ;
470
 
89 jpm 471
					}
472
			}
473
			else
474
			{
91 jpm 475
				// TODO: Pourquoi l'ajout ne marche que sur la racine ?
476
 
199 david 477
				//  on  crée  le noeud de l'id location
478
 
89 jpm 479
				TreeNode node_id_loc = new TreeNode();
480
				node_id_loc.setId(""+id_location);
481
				node_id_loc.setText(id_location);
166 aurelien 482
				String[] usObj = {id_location,id_location};
89 jpm 483
				node_id_loc.setUserObject(usObj);
484
				root.appendChild(node_id_loc) ;
485
 
486
				TreeNode node_loc = new TreeNode();
487
				node_loc.setId(""+(id_location+location));
488
				node_loc.setText(location);
166 aurelien 489
				String[] usObj2 = {location,id_location+location};
89 jpm 490
				node_loc.setUserObject(usObj2);
491
				node_id_loc.appendChild(node_loc) ;
492
 
493
				TreeNode node_lieu = new TreeNode();
494
				node_lieu.setId(""+(id_location+location+lieuDit));
495
				node_lieu.setText(lieuDit);
166 aurelien 496
				String[] usObj3 = {lieuDit,id_location+location+lieuDit};
89 jpm 497
				node_lieu.setUserObject(usObj3);
498
				node_loc.appendChild(node_lieu) ;
90 jpm 499
 
500
				root.sort(comparerNoeuds()) ;
89 jpm 501
 
109 aurelien 502
			}
89 jpm 503
				arbreEntitesGeographiques.doLayout() ;
504
		}
68 david 505
	}
54 david 506
 
507
 
508
	/**
509
	 * Accesseur pour le panneau contenant l'arbre
510
	 *
511
	 * @return le panneau de l'arbre des mots clés
512
	 */
513
	public TreePanel getArbreMotsCles() {
68 david 514
		return arbreEntitesGeographiques;
54 david 515
	}
516
 
517
	/**
518
	 * Méthode héritée de Filtrable renvoie le nom du filtre
519
	 */
520
	public String renvoyerNomFiltre() {
521
 
522
		return "Localités";
523
	}
524
 
525
	/**
526
	 * Renvoie un tableau contenant le nom du champ à filtrer et la valeur
527
	 *
528
	 * @return un tableau contenant le nom du champ à filtrer et sa valeur
529
	 */
530
	public String[] renvoyerValeursAFiltrer() {
531
 
532
		valider();
85 jpm 533
 
86 jpm 534
		String valeursFiltrees[] = {nomFiltre, entitesGeographiquesEncours } ;
54 david 535
 
536
		return valeursFiltrees;
537
	}
538
 
539
	/**
540
	 * Fonction récursive qui prend deux noeuds d'arbre en paramètre et crée un
541
	 * copie du sous arbre du premier noeud, qu'elle concatène au deuxième
542
	 *
543
	 * @param ndPereOriginal
544
	 *            le père des noeuds de l'arbre original
545
	 * @param ndPereCopie
546
	 *            le père qui va recevoir les copies
547
	 */
548
	private void copierFilsNoeud(Node ndPereOriginal, TreeNode ndPereCopie) {
549
		if (ndPereCopie != null && ndPereOriginal != null) {
550
			Node[] ndNodeFils = ndPereOriginal.getChildNodes();
551
 
552
			for (int i = 0; i < ndNodeFils.length; i++) {
553
 
554
				String[] usObj = (String[]) ndNodeFils[i].getUserObject();
555
				TreeNode child = new TreeNode(usObj[0]);
556
				child.setUserObject(usObj);
166 aurelien 557
				child.setId(""+usObj[1]);
54 david 558
				ndPereCopie.appendChild(child);
559
 
560
				if (!ndNodeFils[i].isLeaf()) {
561
					copierFilsNoeud(ndNodeFils[i], child);
562
				}
563
 
564
			}
565
		}
566
	}
567
 
568
	/**
569
	 * Méthode héritée de Filtrable Renvoie l'état du filtre (modifié ou non)
570
	 */
571
	public boolean renvoyerEtatFiltre() {
572
 
573
		return filtreModifie;
574
	}
575
 
576
	public void valider() {
86 jpm 577
 
54 david 578
		if (estInstancie) {
86 jpm 579
 
54 david 580
		}
581
	}
90 jpm 582
 
583
	public Comparator<TreeNode> comparerNoeuds()
584
	{
585
		return new Comparator<TreeNode>() {
54 david 586
 
90 jpm 587
			public int compare(TreeNode o1, TreeNode o2) {
588
 
109 aurelien 589
				if(o1.getText().equals("Inconnue")) {
590
					return -1 ;
591
				}
592
 
593
				if(o2.getText().equals("Inconnue")) {
594
					return 1 ;
595
				}
596
 
597
				if(o1.getDepth() == 1 && o2.getDepth() == 1)
91 jpm 598
				{
109 aurelien 599
					String l1 = o1.getText() ;
600
					String l2 = o2.getText() ;
601
					if(l1.length() == 1) {
602
						l1 = "0"+l1;
603
					}
91 jpm 604
 
109 aurelien 605
					if(l2.length() == 1) {
606
						l2 = "0"+l2;
607
					}
608
 
128 aurelien 609
					Integer n1 = 0;
610
					Integer n2 = 0;
109 aurelien 611
 
128 aurelien 612
					try{
613
						n1 = Integer.parseInt(l1) ;
614
						n2 = Integer.parseInt(l2) ;
615
					} catch(NumberFormatException ne)  {
616
						n1 = 0;
617
						n2 = 0;
618
					}
619
 
91 jpm 620
					return n1.compareTo(n2) ;
621
				}
622
				else
94 jpm 623
				{
91 jpm 624
					String n1 = o1.getText() ;
625
					String n2 = o2.getText() ;
90 jpm 626
 
91 jpm 627
					return n1.compareTo(n2) ;
628
				}
90 jpm 629
			}
630
		} ;
631
	}
104 jpm 632
 
633
	public void raz() {
634
 
635
		arbreCharge = false ;
140 aurelien 636
		arbreEntitesGeographiques.collapseAll();
104 jpm 637
		arbreEntitesGeographiques.clear() ;
638
 
639
		// on crée une racine pour l'arbre
640
		TreeNode root = new TreeNode("Localités");
641
		root.setId("racine_entite");
642
		String[] usObject = { "Localités" };
643
		root.setUserObject(usObject);
644
 
645
		arbreEntitesGeographiques.setRootNode(root);
646
 
647
		arbreEntitesGeographiques.getRootNode().addListener(new TreeNodeListenerAdapter() {
648
 
649
			public void onExpand(Node node) {
650
				if(!arbreCharge)
651
				{
652
					observationMediateur.obtenirDatesObservation() ;
653
					arbreCharge = true ;
654
				}
655
			}
656
 
657
		}) ;
658
 
659
		arbreCharge = false ;
660
 
661
		this.doLayout() ;
662
 
663
	}
91 jpm 664
 
54 david 665
}