Subversion Repositories eFlore/Applications.cel

Rev

Rev 2568 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2568 Rev 2622
Line 1... Line 1...
1
package org.tela_botanica.client.vues.observation.filtres;
1
package org.tela_botanica.client.vues.observation.filtres;
Line 2... Line 2...
2
 
2
 
3
import java.util.Comparator;
3
import java.util.Comparator;
Line -... Line 4...
-
 
4
import java.util.Iterator;
4
import java.util.Iterator;
5
 
5
 
6
import org.tela_botanica.client.i18n.Msg;
6
import org.tela_botanica.client.interfaces.Filtrable;
7
import org.tela_botanica.client.interfaces.Filtrable;
7
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.modeles.objets.EntiteGeographiqueObservation;
9
import org.tela_botanica.client.modeles.objets.EntiteGeographiqueObservation;
Line 79... Line 80...
79
	 *            le médiateur à associer
80
	 *            le médiateur à associer
80
	 */
81
	 */
81
	public ArbreEntiteGeographiqueObservationFiltreVue(ObservationMediateur obs) {
82
	public ArbreEntiteGeographiqueObservationFiltreVue(ObservationMediateur obs) {
Line 82... Line 83...
82
 
83
 
83
		// on crée le panel
84
		// on crée le panel
Line 84... Line 85...
84
		super("Localités");
85
		super(Msg.get("localites"));
Line 85... Line 86...
85
		
86
		
Line 114... Line 115...
114
				// on interdit le drag and drop dans l'arbre
115
				// on interdit le drag and drop dans l'arbre
115
				arbreEntitesGeographiques.setEnableDD(false);
116
				arbreEntitesGeographiques.setEnableDD(false);
116
				arbreEntitesGeographiques.setId("x-view-tree-filter-entity");
117
				arbreEntitesGeographiques.setId("x-view-tree-filter-entity");
Line 117... Line 118...
117
 
118
 
118
				// on crée une racine pour l'arbre
119
				// on crée une racine pour l'arbre
119
				TreeNode root = new TreeNode("Localités");
120
				TreeNode root = new TreeNode(Msg.get("localites"));
120
				root.setId("racine_entite");
121
				root.setId("racine_entite");
121
				String[] usObject = { "Localités" };
122
				String[] usObject = { Msg.get("localites") };
Line 122... Line 123...
122
				root.setUserObject(usObject);
123
				root.setUserObject(usObject);
123
 
124
 
124
				arbreEntitesGeographiques.setRootNode(root);
125
				arbreEntitesGeographiques.setRootNode(root);
Line 243... Line 244...
243
		
244
		
244
				// on crée un arbre vide
245
				// on crée un arbre vide
245
				Tree nouvelArbre = new Tree() ;
246
				Tree nouvelArbre = new Tree() ;
246
				TreeNode root = new TreeNode();
247
				TreeNode root = new TreeNode();
247
				root.setId("racine_entite");
248
				root.setId("racine_entite");
248
				root.setText("Localités");
249
				root.setText(Msg.get("localites"));
249
				String[] usObjRoot = { "Localités"};
250
				String[] usObjRoot = { Msg.get("localites") };
250
				root.setUserObject(usObjRoot);
251
				root.setUserObject(usObjRoot);
Line 251... Line 252...
251
				nouvelArbre.setRootNode(root);
252
				nouvelArbre.setRootNode(root);
252
				
253
				
Line 283... Line 284...
283
				
284
				
284
				//show() ;
285
				//show() ;
Line 285... Line 286...
285
				arbreEntitesGeographiques.doLayout();
286
				arbreEntitesGeographiques.doLayout();
286
 
287
 
287
			}
288
			}
288
		
289
 
289
		if(nouvelleDonnees instanceof Observation)
290
		if(nouvelleDonnees instanceof Observation)
Line 290... Line 291...
290
		{	
291
		{	
291
			// Cas d'ajout unitaire d'une observation
292
			// Cas d'ajout unitaire d'une observation
292
			
293
			
293
			// si l'arbre n'est pas encore chargé, on ne tient pas compte de l'ajout
294
			// si l'arbre n'est pas encore chargé, on ne tient pas compte de l'ajout
294
			// l'arbre complet sera de toute façon renvoyé plus tard lors du premier chargement
295
			// l'arbre complet sera de toute façon renvoyé plus tard lors du premier chargement
295
			// de l'arbre
296
			// de l'arbre
296
			if(!arbreCharge) {
297
			if(!arbreCharge) {
297
				return;
298
				return;
298
			}
299
			}
299
			
300
 
300
			Observation obs = (Observation)nouvelleDonnees ;
301
			Observation obs = (Observation)nouvelleDonnees ;
301
			EntiteGeographiqueObservation ent = new EntiteGeographiqueObservation(obs.getIdentifiantLocalite(),obs.getLocalite(),obs.getLieudit(),obs.getStation());
302
			EntiteGeographiqueObservation ent = new EntiteGeographiqueObservation(obs.getIdentifiantLocalite(),obs.getLocalite(),obs.getLieudit(),obs.getStation());
302
			ent.setPays(obs.getPays());
303
			ent.setPays(obs.getPays());
303
			
304
 
304
			creerHierarchieNoeud(arbreEntitesGeographiques.getTree(), arbreEntitesGeographiques.getRootNode(), ent);
305
			creerHierarchieNoeud(arbreEntitesGeographiques.getTree(), arbreEntitesGeographiques.getRootNode(), ent);
305
						
306
 
306
			doLayout();				
307
			doLayout();
Line 322... Line 323...
322
	 * Méthode héritée de Filtrable renvoie le nom du filtre
323
	 * Méthode héritée de Filtrable renvoie le nom du filtre
323
	 */
324
	 */
324
	@Override
325
	@Override
325
	public String renvoyerNomFiltre() {
326
	public String renvoyerNomFiltre() {
Line 326... Line 327...
326
 
327
 
327
		return "Localités";
328
		return Msg.get("localites");
Line 328... Line 329...
328
	}
329
	}
329
 
330
 
330
	/**
331
	/**
Line 385... Line 386...
385
		
386
		
Line 386... Line 387...
386
		if (estInstancie) {
387
		if (estInstancie) {
387
			
388
			
388
		}
389
		}
389
	}
390
	}
390
	
391
 
391
	public Comparator<TreeNode> comparerNoeuds()
392
	public Comparator<TreeNode> comparerNoeuds()
Line 392... Line 393...
392
	{
393
	{
Line 445... Line 446...
445
		arbreCharge = false ;
446
		arbreCharge = false ;
446
		arbreEntitesGeographiques.collapseAll();
447
		arbreEntitesGeographiques.collapseAll();
447
		arbreEntitesGeographiques.clear() ;
448
		arbreEntitesGeographiques.clear() ;
Line 448... Line 449...
448
		
449
		
449
		// on crée une racine pour l'arbre
450
		// on crée une racine pour l'arbre
450
		TreeNode root = new TreeNode("Localités");
451
		TreeNode root = new TreeNode(Msg.get("localites"));
451
		root.setId("racine_entite");
452
		root.setId("racine_entite");
452
		String[] usObject = { "Localités" };
453
		String[] usObject = { Msg.get("localites") };
Line 453... Line 454...
453
		root.setUserObject(usObject);
454
		root.setUserObject(usObject);
Line 454... Line 455...
454
 
455
 
Line 535... Line 536...
535
		String[] idLocalites = {id_pays, id_zone_geo, zone_geo, lieuDit, station};
536
		String[] idLocalites = {id_pays, id_zone_geo, zone_geo, lieuDit, station};
Line 536... Line 537...
536
		
537
		
537
		Node noeudMemeId = null;
538
		Node noeudMemeId = null;
538
		String idNoeud = "";
539
		String idNoeud = "";
539
		String locNiveau = "";
540
		String locNiveau = "";
540
		
541
 
541
		Node noeudParent = root;
542
		Node noeudParent = root;
542
		
543
 
543
		for(int i = 0; i < idLocalites.length; i++) {
544
		for(int i = 0; i < idLocalites.length; i++) {
544
			// Recherche des noeuds correspondant à chacun des niveaux de la hierarchie
545
			// Recherche des noeuds correspondant à chacun des niveaux de la hierarchie
545
			locNiveau = idLocalites[i];
546
			locNiveau = idLocalites[i];
546
			idNoeud += idLocalites[i];
547
			idNoeud += idLocalites[i];
547
			
548
 
548
			noeudMemeId = arbre.getNodeById(idNoeud);	
549
			noeudMemeId = arbre.getNodeById(idNoeud);	
549
			
550
 
550
			// Si le noeud n'existe pas on le crée
551
			// Si le noeud n'existe pas on le crée
551
			if(noeudMemeId == null) {
552
			if(noeudMemeId == null) {
552
				noeudMemeId = creerNoeud(idNoeud, locNiveau);
553
				noeudMemeId = creerNoeud(idNoeud, locNiveau);
553
				noeudParent.appendChild(noeudMemeId) ;
554
				noeudParent.appendChild(noeudMemeId) ;
554
			}
555
			}
555
			
556
 
556
			noeudParent = noeudMemeId;
557
			noeudParent = noeudMemeId;
557
		}
558
		}
558
				
559
 
559
		root.sort(comparerNoeuds()) ;
560
		root.sort(comparerNoeuds()) ;
Line 560... Line 561...
560
	}
561
	}
561
 
562
 
Line 587... Line 588...
587
						noeudArbreEncours = (TreeNode)noeudArbreEncours.getParentNode();
588
						noeudArbreEncours = (TreeNode)noeudArbreEncours.getParentNode();
588
					}
589
					}
Line 589... Line 590...
589
					
590
					
590
					arbreEntitesGeographiques.getSelectionModel().select(noeudArbreEncours); 
591
					arbreEntitesGeographiques.getSelectionModel().select(noeudArbreEncours); 
591
					mettreAJourValeurEnCours(noeudArbreEncours);
592
					mettreAJourValeurEnCours(noeudArbreEncours);
592
					
593
 
593
					continuer = false;
594
					continuer = false;
594
				}
595
				}
595
				
596
 
596
				return continuer;
597
				return continuer;
Line 597... Line 598...
597
			}
598
			}
598
 
599
 
599
		});
600
		});
600
	}
601
	}
601
	
602
 
602
	private int calculerProfondeurPourNomFiltre(String nom) {
603
	private int calculerProfondeurPourNomFiltre(String nom) {
603
		
604
 
604
		int profondeur = 0;
605
		int profondeur = 0;
605
		
606
 
606
		if(nom.equals("pays")) {
607
		if(nom.equals("pays")) {
607
			profondeur = 1;
608
			profondeur = 1;
608
		}
609
		}
609
		
610
 
610
		if(nom.equals("departement")) {
611
		if(nom.equals("departement")) {
611
			profondeur = 2;
612
			profondeur = 2;
612
		}
613
		}
613
		
614
 
614
		if(nom.equals("localite")) {
615
		if(nom.equals("localite")) {
615
			profondeur = 3;
616
			profondeur = 3;
616
		}
617
		}
617
		
618
 
618
		if(nom.equals("lieudit")) {
619
		if(nom.equals("lieudit")) {
619
			profondeur = 4;
620
			profondeur = 4;
620
		}
621
		}
621
		
622
 
622
		if(nom.equals("station")) {
623
		if(nom.equals("station")) {
623
			profondeur = 5;
624
			profondeur = 5;
624
		}
625
		}
625
		
626
 
626
		return profondeur;
627
		return profondeur;
627
	}
628
	}