Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 218 Rev 221
Line 1... Line 1...
1
package org.tela_botanica.client.vues.observation;
1
package org.tela_botanica.client.vues.observation;
Line 2... Line 2...
2
 
2
 
Line -... Line 3...
-
 
3
// TODO Detecter redim et supprimer ajuster
3
// TODO Detecter redim et supprimer ajuster
4
 
Line 4... Line 5...
4
 
5
import java.util.Date;
5
import java.util.Iterator;
6
import java.util.Iterator;
6
 
7
 
Line 11... Line 12...
11
import org.tela_botanica.client.modeles.Observation;
12
import org.tela_botanica.client.modeles.Observation;
12
import org.tela_botanica.client.modeles.ReferentielCommune;
13
import org.tela_botanica.client.modeles.ReferentielCommune;
13
import org.tela_botanica.client.modeles.ReferentielNom;
14
import org.tela_botanica.client.modeles.ReferentielNom;
14
import org.tela_botanica.client.observation.ObservationMediateur;
15
import org.tela_botanica.client.observation.ObservationMediateur;
Line -... Line 16...
-
 
16
 
15
 
17
import com.google.gwt.core.client.JavaScriptObject;
16
import com.google.gwt.user.client.Window;
18
import com.google.gwt.user.client.Window;
17
import com.gwtext.client.core.EventCallback;
19
import com.gwtext.client.core.EventCallback;
18
import com.gwtext.client.core.EventObject;
20
import com.gwtext.client.core.EventObject;
19
import com.gwtext.client.core.Ext;
21
import com.gwtext.client.core.Ext;
Line 26... Line 28...
26
import com.gwtext.client.data.SimpleStore;
28
import com.gwtext.client.data.SimpleStore;
27
import com.gwtext.client.data.Store;
29
import com.gwtext.client.data.Store;
28
import com.gwtext.client.data.StringFieldDef;
30
import com.gwtext.client.data.StringFieldDef;
29
import com.gwtext.client.widgets.BoxComponent;
31
import com.gwtext.client.widgets.BoxComponent;
30
import com.gwtext.client.widgets.Button;
32
import com.gwtext.client.widgets.Button;
-
 
33
import com.gwtext.client.widgets.Component;
31
import com.gwtext.client.widgets.Container;
34
import com.gwtext.client.widgets.Container;
-
 
35
import com.gwtext.client.widgets.DatePicker;
32
import com.gwtext.client.widgets.Panel;
36
import com.gwtext.client.widgets.Panel;
33
import com.gwtext.client.widgets.Toolbar;
37
import com.gwtext.client.widgets.Toolbar;
34
import com.gwtext.client.widgets.event.BoxComponentListenerAdapter;
38
import com.gwtext.client.widgets.event.BoxComponentListenerAdapter;
35
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
39
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
36
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
40
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
-
 
41
import com.gwtext.client.widgets.event.DatePickerListener;
-
 
42
import com.gwtext.client.widgets.event.DatePickerListenerAdapter;
37
import com.gwtext.client.widgets.event.PanelListenerAdapter;
43
import com.gwtext.client.widgets.event.PanelListenerAdapter;
38
import com.gwtext.client.widgets.form.ComboBox;
44
import com.gwtext.client.widgets.form.ComboBox;
39
import com.gwtext.client.widgets.form.DateField;
45
import com.gwtext.client.widgets.form.DateField;
40
import com.gwtext.client.widgets.form.Field;
46
import com.gwtext.client.widgets.form.Field;
41
import com.gwtext.client.widgets.form.FormPanel;
47
import com.gwtext.client.widgets.form.FormPanel;
Line 121... Line 127...
121
	
127
	
122
	private boolean modification = false ;
128
	private boolean modification = false ;
Line 123... Line 129...
123
	private Toolbar bt = null ;
129
	private Toolbar bt = null ;
124
	
130
	
125
	private final String VALEURS_MULTIPLES = "(Valeurs multiples)";
131
	private final String VALEURS_MULTIPLES = "(Valeurs multiples)";
126
	private final String modeleMessageModif = "commune lieu dit station milieu date espece commentaire";
132
	private final String modeleMessageModif = "commune:lieu-dit:station:milieu:date:espece:commentaire";
127
	private boolean communeModifiee = false;
133
	private boolean communeModifiee = false;
128
	private boolean LieuDitModifie = false;
134
	private boolean lieuDitModifie = false;
129
	private boolean StationModifiee = false;
135
	private boolean stationModifiee = false;
130
	private boolean milieuModifie = false;
136
	private boolean milieuModifie = false;
131
	private boolean dateModifiee = false;
137
	private boolean dateModifiee = false;
Line 421... Line 427...
421
		    
427
		    
Line 422... Line 428...
422
		    date.addKeyPressListener(new EventCallback() {
428
		    date.addKeyPressListener(new EventCallback() {
423
 
429
 
424
				public void execute(EventObject e) {
-
 
425
					// TODO Auto-generated method stub
430
				public void execute(EventObject e) {
-
 
431
					// TODO Auto-generated method stub
-
 
432
					switch(e.getKey()) {
-
 
433
					
-
 
434
						case KEY_ALT:
-
 
435
		    	        case KEY_CTRL:
-
 
436
		    	        case KEY_DOWN:
-
 
437
		    	        case KEY_END:
-
 
438
		    	        case KEY_ESCAPE:
-
 
439
		    	        case KEY_HOME:
-
 
440
		    	        case KEY_LEFT:
-
 
441
		    	        case KEY_PAGEDOWN:
-
 
442
		    	        case KEY_PAGEUP:
-
 
443
		    	        case KEY_RIGHT:
-
 
444
		    	        case KEY_SHIFT:
-
 
445
		    	        case KEY_TAB:
-
 
446
		    	        	if(date.getRawValue().equals(VALEURS_MULTIPLES)) {
-
 
447
		    	        		date.clearInvalid();
-
 
448
		    	        	}
-
 
449
		    	        case KEY_UP:
Line 426... Line 450...
426
					dateModifiee = true;
450
		    	    	
427
					switch(e.getKey()) {
451
		    	        break;
428
	  	    	      
452
	  	    	      
Line 429... Line 453...
429
	  	    	      case KEY_ENTER:	  	    	    	  
453
	  	    	      case KEY_ENTER:	  	
-
 
454
	  	    	    		validerSaisie(Champs.DATE); 
430
	  	    	    		validerSaisie(Champs.DATE); 	    	    		 
455
	  	    	    	  break;
431
	  	    	    	  break;
456
	  	    	       
432
	  	    	       
457
	  	    	      default:
Line -... Line 458...
-
 
458
	  					dateModifiee = true;
-
 
459
					}
-
 
460
				}
-
 
461
		    });
-
 
462
		    
-
 
463
		    date.addListener(new DatePickerListenerAdapter() {
-
 
464
 
433
	  	    	      default:
465
				public void onSelect(DatePicker dataPicker, Date date) {
Line 434... Line 466...
434
					}
466
					dateModifiee = true;
435
				}
467
				}
436
		    });
-
 
437
		    
468
		    });
Line -... Line 469...
-
 
469
		    
-
 
470
		    station.addKeyPressListener(new EventCallback() {
-
 
471
 
-
 
472
				public void execute(EventObject e) {
-
 
473
					// TODO Auto-generated method stub
-
 
474
					switch(e.getKey()) {
-
 
475
	  	    	      
-
 
476
						case KEY_ALT:
-
 
477
		    	        case KEY_CTRL:
-
 
478
		    	        case KEY_DOWN:
-
 
479
		    	        case KEY_END:
-
 
480
		    	        case KEY_ESCAPE:
-
 
481
		    	        case KEY_HOME:
-
 
482
		    	        case KEY_LEFT:
-
 
483
		    	        case KEY_PAGEDOWN:
438
		    station.addKeyPressListener(new EventCallback() {
484
		    	        case KEY_PAGEUP:
439
 
485
		    	        case KEY_RIGHT:
440
				public void execute(EventObject e) {
486
		    	        case KEY_SHIFT:
Line 441... Line 487...
441
					// TODO Auto-generated method stub
487
		    	        case KEY_TAB:
-
 
488
		    	        case KEY_UP:
442
					StationModifiee = true;
489
		    	      break;
443
					switch(e.getKey()) {
490
		    	      
444
	  	    	      
491
	  	    	      case KEY_ENTER:	  	    	    	  
Line 525... Line 572...
525
		    
572
		    
Line 526... Line 573...
526
			lieudit.addKeyPressListener(new EventCallback() {
573
			lieudit.addKeyPressListener(new EventCallback() {
527
 
574
 
528
				public void execute(EventObject e) {
-
 
529
					// TODO Auto-generated method stub
575
				public void execute(EventObject e) {
Line -... Line 576...
-
 
576
					// TODO Auto-generated method stub
-
 
577
					switch(e.getKey()) {
-
 
578
	  	    	      
-
 
579
					case KEY_ALT:
-
 
580
	  	    	      case KEY_CTRL:
-
 
581
	  	    	      case KEY_DOWN:
-
 
582
	  	    	      case KEY_END:
-
 
583
	  	    	      case KEY_ESCAPE:
-
 
584
	  	    	      case KEY_HOME:
-
 
585
	  	    	      case KEY_LEFT:
-
 
586
	  	    	      case KEY_PAGEDOWN:
-
 
587
	  	    	      case KEY_PAGEUP:
-
 
588
	  	    	      case KEY_RIGHT:
-
 
589
	  	    	      case KEY_SHIFT:
-
 
590
	  	    	      case KEY_TAB:
-
 
591
	  	    	      case KEY_UP:
530
					LieuDitModifie = true;
592
  	    	    	
531
					switch(e.getKey()) {
593
  	    	        break;
532
	  	    	      
594
					
Line 533... Line 595...
533
	  	    	      case KEY_ENTER:	  	    	    	  
595
	  	    	      case KEY_ENTER:	  	    	    	  
-
 
596
	  	    	    		validerSaisie(Champs.LIEUDIT); 	    	    		 
534
	  	    	    		validerSaisie(Champs.LIEUDIT); 	    	    		 
597
	  	    	    	  break;
535
	  	    	    	  break;
598
	  	    	       
536
	  	    	       
599
	  	    	      default:
Line 537... Line 600...
537
	  	    	      default:
600
	  					lieuDitModifie = true;
Line 538... Line 601...
538
					}
601
					}
539
				}
602
				}
540
		    });
-
 
541
			
603
		    });
-
 
604
			
-
 
605
			milieu.addKeyPressListener(new EventCallback() {
-
 
606
 
-
 
607
				public void execute(EventObject e) {
-
 
608
					// TODO Auto-generated method stub
-
 
609
					switch(e.getKey()) {
-
 
610
					
-
 
611
						case KEY_ALT:
-
 
612
	  	    	      case KEY_CTRL:
-
 
613
	  	    	      case KEY_DOWN:
-
 
614
	  	    	      case KEY_END:
-
 
615
	  	    	      case KEY_ESCAPE:
-
 
616
	  	    	      case KEY_HOME:
-
 
617
	  	    	      case KEY_LEFT:
-
 
618
	  	    	      case KEY_PAGEDOWN:
-
 
619
	  	    	      case KEY_PAGEUP:
Line 542... Line 620...
542
			milieu.addKeyPressListener(new EventCallback() {
620
	  	    	      case KEY_RIGHT:
543
 
621
	  	    	      case KEY_SHIFT:
544
				public void execute(EventObject e) {
622
	  	    	      case KEY_TAB:
Line 545... Line 623...
545
					// TODO Auto-generated method stub
623
	  	    	      case KEY_UP:
-
 
624
	  	    	    	
546
					milieuModifie = true;
625
	  	    	        break;
547
					switch(e.getKey()) {
626
	  	    	      
548
	  	    	      
627
	  	    	      case KEY_ENTER:	  	    	    	  
Line 549... Line 628...
549
	  	    	      case KEY_ENTER:	  	    	    	  
628
	  	    	    		validerSaisie(Champs.MILIEU); 	    	    		 
Line 550... Line 629...
550
	  	    	    		validerSaisie(Champs.MILIEU); 	    	    		 
629
	  	    	    	  break;
-
 
630
	  	    	       
-
 
631
	  	    	      default:
-
 
632
	  					milieuModifie = true;
-
 
633
					}
-
 
634
				}
551
	  	    	    	  break;
635
		    });
-
 
636
			
-
 
637
			comment.addKeyPressListener(new EventCallback() {
-
 
638
 
-
 
639
				public void execute(EventObject e) {
-
 
640
					switch(e.getKey()) { 
-
 
641
						case KEY_ALT:
-
 
642
			    	      case KEY_CTRL:
-
 
643
			    	      case KEY_DOWN:
-
 
644
			    	      case KEY_END:
-
 
645
			    	      case KEY_ESCAPE:
-
 
646
			    	      case KEY_HOME:
-
 
647
			    	      case KEY_LEFT:
552
	  	    	       
648
			    	      case KEY_PAGEDOWN:
-
 
649
			    	      case KEY_PAGEUP:
553
	  	    	      default:
650
			    	      case KEY_RIGHT:
554
					}
651
			    	      case KEY_SHIFT:
Line 822... Line 919...
822
	}
919
	}
Line 823... Line 920...
823
	
920
	
824
	private void modifierObservationEnMasse(Champs champModifie) {
921
	private void modifierObservationEnMasse(Champs champModifie) {
825
		String communeM = null;
922
		String communeM = null;
-
 
923
		String departementM = null;
826
		String departementM = null;
924
		String numNomSelM = null;
827
		String lieuDitM = null;
925
		String lieuDitM = null;
828
		String stationM = null;
926
		String stationM = null;
829
		String milieuM = null;
927
		String milieuM = null;
830
		String dateM = null;
928
		String dateM = null;
Line 833... Line 931...
833
		
931
		
Line 834... Line 932...
834
		String champs = modeleMessageModif;
932
		String champs = modeleMessageModif;
835
			
933
			
-
 
934
		if(communeModifiee) {
-
 
935
			communeM = commune.getText();
-
 
936
			
-
 
937
			if(departement.equals("000null") || departement.equals("")) {
-
 
938
				String[] depCom = commune.getText().split(" ");
-
 
939
				if(depCom.length > 1) {
-
 
940
					String dep = depCom[1].replace('(', ' ');
-
 
941
					dep =dep.replace(')', ' ');
-
 
942
					dep = dep.trim();
-
 
943
					dep = dep.replace('\\',' ');
-
 
944
					dep = dep.trim();
-
 
945
					
-
 
946
					try
-
 
947
					{
-
 
948
						int nDep = Integer.parseInt(dep);
-
 
949
						if(nDep > 0 && nDep < 110) {
-
 
950
							departement = dep ;
-
 
951
						}
-
 
952
					}
-
 
953
					catch(NumberFormatException e)
-
 
954
					{
-
 
955
						departement = "" ;
-
 
956
					}
-
 
957
				}
-
 
958
			}
836
		if(communeModifiee) {
959
			
837
			communeM = commune.getText();
960
			departementM = departement;
838
		} else {
961
		} else {
Line 839... Line 962...
839
			champs = champs.replaceAll("commune ", "");
962
			champs = champs.replaceAll("commune", "");
840
		}
963
		}
841
		
964
		
842
		if(LieuDitModifie) {
965
		if(lieuDitModifie) {
843
			lieuDitM = lieudit.getText();
966
			lieuDitM = lieudit.getText();
Line 844... Line 967...
844
		}else {
967
		}else {
845
			champs = champs.replaceAll("lieu dit ", "");
968
			champs = champs.replaceAll(":lieu-dit", "");
846
		}
969
		}
847
		
970
		
848
		if(StationModifiee) {
971
		if(stationModifiee) {
Line 849... Line 972...
849
			stationM = station.getText();
972
			stationM = station.getText();
850
		}else {
973
		}else {
851
			champs = champs.replaceAll("station ", "");
974
			champs = champs.replaceAll(":station", "");
852
		}
975
		}
853
 
976
 
Line 854... Line 977...
854
		if(milieuModifie) {
977
		if(milieuModifie) {
855
			milieuM = milieu.getText();
978
			milieuM = milieu.getText();
856
		}else {
979
		}else {
857
			champs = champs.replaceAll("milieu ", "");
980
			champs = champs.replaceAll(":milieu", "");
858
		}
981
		}
Line 859... Line 982...
859
 
982
 
860
		if(dateModifiee) {
983
		if(dateModifiee && !date.getRawValue().equals(VALEURS_MULTIPLES)) {
-
 
984
			dateM = date.getRawValue();
861
			dateM = date.getRawValue();
985
		}else {
862
		}else {
986
			champs = champs.replaceAll(":date", "");
863
			champs = champs.replaceAll("date ", "");
987
		}
Line 864... Line 988...
864
		}
988
 
865
 
989
		if(especeModifiee) {
866
		if(especeModifiee) {
990
			especeM = espece.getText();
867
			especeM = espece.getText();
991
			numNomSelM = numeroNom;
-
 
992
		}else {
-
 
993
			champs = champs.replaceAll(":espece", "");
-
 
994
		}
-
 
995
 
-
 
996
		if(commModifie) {
868
		}else {
997
			commM = comment.getText();
Line 869... Line 998...
869
			champs = champs.replaceAll("espece ", "");
998
		}else {
Line 870... Line 999...
870
		}
999
			champs = champs.replaceAll(":commentaire", "");
871
 
1000
		}
872
		if(commModifie) {
1001
		
873
			commM = comment.getText();
1002
		champs = champs.replaceAll(":",", ");
874
		}else {
1003
		if(champs.startsWith(",")) {
875
			champs = champs.replaceAll("commentaire", "");
1004
			champs = champs.replaceFirst(",", "");
876
		}
1005
		}
-
 
1006
		
877
		
1007
		String message = "Voulez vous modifier le(s) champ(s) suivant(s) : "+champs+"   pour les observations selectionnées ?" ;
878
		String message = "Voulez vous modifier les champs suivants : "+champs+" pour les observations selectionnées ?" ;
1008
		
879
		
1009
		if(champs.trim().equals("")) {
Line 880... Line 1010...
880
		if(champs.trim().equals("")) {
1010
			Window.alert("Aucun champ n'a été modifié");
Line 906... Line 1036...
906
			idLoc = idLoc.trim();
1036
			idLoc = idLoc.trim();
907
		} else {
1037
		} else {
908
			idLoc = obs.getIdentifiantLocalite();
1038
			idLoc = obs.getIdentifiantLocalite();
909
		}
1039
		}
Line 910... Line 1040...
910
		
1040
		
911
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) {
1041
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null") && !obs.getDate().equals(VALEURS_MULTIPLES)) {
912
			String[] dateEtHeure = obs.getDate().split(" ", 2);
1042
			String[] dateEtHeure = obs.getDate().split(" ", 2);
913
			if(verifierFormatDate(dateEtHeure[0])) {
1043
			if(verifierFormatDate(dateEtHeure[0])) {
914
				date.setValue(dateEtHeure[0]) ;
1044
				date.setValue(dateEtHeure[0]) ;
915
			}
1045
			}
916
			else
1046
			else
917
			{
1047
			{
918
				date.setRawValue(""); 
1048
				date.setRawValue(""); 
-
 
1049
			}
-
 
1050
		} else {
-
 
1051
			date.setRawValue(VALEURS_MULTIPLES);
919
			}
1052
			date.clearInvalid();
920
		}
1053
		}
921
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
1054
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
922
			lieudit.setValue(obs.getLieudit()) ;
1055
			lieudit.setValue(obs.getLieudit()) ;
923
		}
1056
		}
Line 929... Line 1062...
929
		}
1062
		}
930
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
1063
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
931
			comment.setValue(obs.getCommentaire()) ;
1064
			comment.setValue(obs.getCommentaire()) ;
932
		}
1065
		}
933
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
1066
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
-
 
1067
			if(!idLoc.equals("000null")) {
934
			if(!idLoc.equals("000null") && !idLoc.equals(VALEURS_MULTIPLES)) {
1068
				if(!idLoc.equals(VALEURS_MULTIPLES)) {
935
				commune.setValue(obs.getLocalite()+" ("+idLoc+")") ;
1069
					commune.setValue(obs.getLocalite()+" ("+idLoc+")") ;
-
 
1070
				} else {
-
 
1071
					commune.setValue(VALEURS_MULTIPLES);
-
 
1072
				}
936
			}
1073
			}
937
			else
1074
			else
938
			{
1075
			{
939
				commune.setValue(obs.getLocalite());
1076
				commune.setValue(obs.getLocalite());
940
			}
1077
			}
Line 1125... Line 1262...
1125
	}
1262
	}
Line 1126... Line 1263...
1126
	
1263
	
Line 1127... Line 1264...
1127
	private void reinitialiserValeurModifiees() {
1264
	private void reinitialiserValeurModifiees() {
1128
		
1265
		
1129
		communeModifiee = false;
1266
		communeModifiee = false;
1130
		LieuDitModifie = false;
1267
		lieuDitModifie = false;
1131
		StationModifiee = false;
1268
		stationModifiee = false;
1132
		milieuModifie = false;
1269
		milieuModifie = false;
1133
		dateModifiee = false;
1270
		dateModifiee = false;
1134
		especeModifiee = false;
1271
		especeModifiee = false;