Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 218 Rev 231
Line 1... Line 1...
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
Line 2... Line 2...
2
 
2
 
-
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.Arrays;
4
import java.util.Iterator;
5
import java.util.Iterator;
-
 
6
import java.util.List;
Line 5... Line 7...
5
import java.util.List;
7
import java.util.Map;
6
 
8
 
7
import org.tela_botanica.client.ComposantId;
9
import org.tela_botanica.client.ComposantId;
8
import org.tela_botanica.client.Mediateur;
10
import org.tela_botanica.client.Mediateur;
Line 26... Line 28...
26
 
28
 
27
import com.extjs.gxt.ui.client.Events;
29
import com.extjs.gxt.ui.client.Events;
28
import com.extjs.gxt.ui.client.Registry;
30
import com.extjs.gxt.ui.client.Registry;
29
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
31
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
-
 
32
import com.extjs.gxt.ui.client.Style.Scroll;
30
import com.extjs.gxt.ui.client.Style.Scroll;
33
import com.extjs.gxt.ui.client.Style.SelectionMode;
31
import com.extjs.gxt.ui.client.event.BaseEvent;
34
import com.extjs.gxt.ui.client.event.BaseEvent;
32
import com.extjs.gxt.ui.client.event.ComponentEvent;
35
import com.extjs.gxt.ui.client.event.ComponentEvent;
33
import com.extjs.gxt.ui.client.event.EditorEvent;
36
import com.extjs.gxt.ui.client.event.EditorEvent;
34
import com.extjs.gxt.ui.client.event.GridEvent;
37
import com.extjs.gxt.ui.client.event.GridEvent;
35
import com.extjs.gxt.ui.client.event.Listener;
38
import com.extjs.gxt.ui.client.event.Listener;
36
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
39
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
37
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
40
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
38
import com.extjs.gxt.ui.client.event.SelectionListener;
41
import com.extjs.gxt.ui.client.event.SelectionListener;
39
import com.extjs.gxt.ui.client.event.ToolBarEvent;
42
import com.extjs.gxt.ui.client.event.ToolBarEvent;
-
 
43
import com.extjs.gxt.ui.client.store.ListStore;
40
import com.extjs.gxt.ui.client.store.ListStore;
44
import com.extjs.gxt.ui.client.store.Record;
41
import com.extjs.gxt.ui.client.store.Store;
45
import com.extjs.gxt.ui.client.store.Store;
42
import com.extjs.gxt.ui.client.widget.Component;
46
import com.extjs.gxt.ui.client.widget.Component;
43
import com.extjs.gxt.ui.client.widget.ContentPanel;
47
import com.extjs.gxt.ui.client.widget.ContentPanel;
44
import com.extjs.gxt.ui.client.widget.Info;
48
import com.extjs.gxt.ui.client.widget.Info;
45
import com.extjs.gxt.ui.client.widget.LayoutContainer;
49
import com.extjs.gxt.ui.client.widget.LayoutContainer;
46
import com.extjs.gxt.ui.client.widget.TabItem;
50
import com.extjs.gxt.ui.client.widget.TabItem;
-
 
51
import com.extjs.gxt.ui.client.widget.TabPanel;
47
import com.extjs.gxt.ui.client.widget.TabPanel;
52
import com.extjs.gxt.ui.client.widget.VerticalPanel;
48
import com.extjs.gxt.ui.client.widget.WidgetComponent;
53
import com.extjs.gxt.ui.client.widget.WidgetComponent;
49
import com.extjs.gxt.ui.client.widget.button.Button;
54
import com.extjs.gxt.ui.client.widget.button.Button;
50
import com.extjs.gxt.ui.client.widget.form.CheckBox;
55
import com.extjs.gxt.ui.client.widget.form.CheckBox;
51
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
56
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
Line 67... Line 72...
67
import com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel;
72
import com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel;
68
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
73
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
69
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
74
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
70
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
75
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
71
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
76
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
-
 
77
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
-
 
78
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
72
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
79
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
73
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
80
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
74
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
81
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
75
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
82
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
76
import com.extjs.gxt.ui.client.widget.layout.FormData;
83
import com.extjs.gxt.ui.client.widget.layout.FormData;
Line 132... Line 139...
132
	private TextField<String> urlChp;
139
	private TextField<String> urlChp;
133
	private ListStore<Valeur> magazinPays;
140
	private ListStore<Valeur> magazinPays;
134
	private ComboBox<Valeur> comboPays;
141
	private ComboBox<Valeur> comboPays;
Line 135... Line 142...
135
 
142
 
136
	// Onglet PERSONNEL
143
	// Onglet PERSONNEL
-
 
144
	private StructureAPersonneListe personnel;
-
 
145
	private StructureAPersonneListe personnelAjoute = null;
-
 
146
	private StructureAPersonneListe personnelModifie = null;
137
	private StructureAPersonneListe  personnel;
147
	private StructureAPersonneListe personnelSupprime = null;
138
	private NumberField nbreTotalPersonneStructureChp = null;
148
	private NumberField nbreTotalPersonneStructureChp = null;
139
	private EditorGrid<StructureAPersonne> grillePersonnel = null;
149
	private EditorGrid<StructureAPersonne> grillePersonnel = null;
140
	private ListStore<StructureAPersonne> personnelGrilleMagazin = null;
-
 
Line 141... Line 150...
141
	private LabelField nbreTotalPersonnelChp = null;
150
	private ListStore<StructureAPersonne> personnelGrilleMagazin = null;
142
	
151
	
143
	// Onglet CONSERVATION
152
	// Onglet CONSERVATION
144
	private StructureConservation conservation = null;
153
	private StructureConservation conservation = null;
Line 205... Line 214...
205
	private RadioGroup sansMotifAccesMarkRGrpChp;
214
	private RadioGroup sansMotifAccesMarkRGrpChp;
206
	private RadioGroup avecMotifAccesMarkRGrpChp;
215
	private RadioGroup avecMotifAccesMarkRGrpChp;
207
	private TextField<String> publicationChp;
216
	private TextField<String> publicationChp;
208
	private ContentPanel materielConservationCp;
217
	private ContentPanel materielConservationCp;
Line -... Line 218...
-
 
218
 
209
 
219
 
210
	public FormStructureVue() {
220
	public FormStructureVue() {
211
		//+-----------------------------------------------------------------------------------------------------------+		
221
		//+-----------------------------------------------------------------------------------------------------------+		
212
		// Initialisation de variables
222
		// Initialisation de variables
213
		i18nC = GWT.create(Constantes.class);
223
		i18nC = GWT.create(Constantes.class);
Line 285... Line 295...
285
	private void soumettreFormulaire() {
295
	private void soumettreFormulaire() {
286
		GWT.log("Soumission du formulaire", null);
296
		GWT.log("Soumission du formulaire", null);
287
		Structure structure = collecterStructureIdentification();
297
		Structure structure = collecterStructureIdentification();
288
		StructureConservation conservation = collecterStructureConservation();
298
		StructureConservation conservation = collecterStructureConservation();
289
		StructureValorisation valorisation = collecterStructureValorisation();
299
		StructureValorisation valorisation = collecterStructureValorisation();
290
		// JAMAIS DE COMPARAISONS DE STRING AVEC == !!!!!! ON UTILISE equals ou compareTo
300
		collecterStructurePersonnel();
-
 
301
		
291
		if (mode.equals("AJOUT")) {
302
		if (mode.equals("AJOUT")) {
-
 
303
			// Ajout des informations sur la Structure
292
			//mediateur.ajouterStructure(this, structure);
304
			//mediateur.ajouterStructure(this, structure);
-
 
305
			// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée
-
 
306
			// Voir la méthode rafraichir().
293
		} else if (mode.equals("MODIF")) {
307
		} else if (mode.equals("MODIF")) {
-
 
308
			// Modification des informations sur la Structure
294
			mediateur.modifierStructure(this, structure, conservation, valorisation);
309
			mediateur.modifierStructure(this, structure, conservation, valorisation);
-
 
310
			// Modification des relations StructureAPersonne
-
 
311
			GWT.log("Personnel modifié :"+personnelModifie.size(), null);
-
 
312
			mediateur.modifierStructureAPersonne(this, personnelModifie);
-
 
313
			// Ajout des relations StructureAPersonne
-
 
314
			GWT.log("Personnel ajouté :"+personnelAjoute.size(), null);
-
 
315
			mediateur.ajouterStructureAPersonne(this, identification.getId(), personnelAjoute);
-
 
316
			// Suppression des relations StructureAPersonne
-
 
317
			GWT.log("Personnel supprimé :"+personnelSupprime.size(), null);
-
 
318
			mediateur.supprimerStructureAPersonne(this, personnelSupprime);
-
 
319
			// Nous rechargeons la liste
-
 
320
			mediateur.selectionnerStructureAPersonne(this, identification.getId(), StructureAPersonne.ROLE_EQUIPE);
295
		}
321
		}
296
		GWT.log("Info Structure envoyées :\n"+conservation.toString(), null);
-
 
297
	}
322
	}
Line 298... Line 323...
298
	
323
	
299
	private StructureValorisation collecterStructureValorisation() {
324
	private StructureValorisation collecterStructureValorisation() {
300
		if (valorisationOnglet.getData("acces").equals(false)) {
325
		if (valorisationOnglet.getData("acces").equals(false)) {
Line 598... Line 623...
598
			structure.setTelephone(telChp.getValue());
623
			structure.setTelephone(telChp.getValue());
599
			structure.setFax(faxChp.getValue());
624
			structure.setFax(faxChp.getValue());
600
			structure.setCourriel(emailChp.getValue());
625
			structure.setCourriel(emailChp.getValue());
601
			structure.setUrl(Structure.URL_SITE, urlChp.getValue());
626
			structure.setUrl(Structure.URL_SITE, urlChp.getValue());
Line -... Line 627...
-
 
627
			
-
 
628
			structure.setNbrePersonne(nbreTotalPersonneStructureChp.getValue().intValue());
602
			
629
			
603
			return structure;
630
			return structure;
604
		}
631
		}
Line 605... Line 632...
605
	}
632
	}
Line 644... Line 671...
644
			telChp.setValue(identification.getTelephone());
671
			telChp.setValue(identification.getTelephone());
645
			faxChp.setValue(identification.getFax());
672
			faxChp.setValue(identification.getFax());
646
			emailChp.setValue(identification.getCourriel());
673
			emailChp.setValue(identification.getCourriel());
647
			urlChp.setValue(identification.getUrl("WEB"));
674
			urlChp.setValue(identification.getUrl("WEB"));
Line -... Line 675...
-
 
675
			
-
 
676
			nbreTotalPersonneStructureChp.setValue(identification.getNbrePersonne());
648
			
677
			
649
			identificationOnglet.layout();
678
			identificationOnglet.layout();
650
		}
679
		}
Line 651... Line 680...
651
	}
680
	}
Line 853... Line 882...
853
		conservationOnglet.add(insecteTraitementTrukCp);
882
		conservationOnglet.add(insecteTraitementTrukCp);
Line 854... Line 883...
854
		
883
		
855
		return conservationOnglet;
884
		return conservationOnglet;
Line -... Line 885...
-
 
885
	}
-
 
886
	
-
 
887
	private void collecterStructurePersonnel() {
-
 
888
		if (personnelOnglet.getData("acces").equals(true)) {
-
 
889
			int nbrePersonne = personnelGrilleMagazin.getCount();
-
 
890
			for (int i = 0; i < nbrePersonne; i++) {
-
 
891
				StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
-
 
892
				
-
 
893
				// Seules les lignes ajoutées ou modifiées sont prises en compte.
-
 
894
				if (personnelGrilleMagazin.getModifiedRecords().contains(personnelGrilleMagazin.getRecord(personne)) == true) {
-
 
895
					// Gestion de la fonction
-
 
896
					String fonction = personne.get("fonction");
-
 
897
					if (fonction != null && !fonction.equals("")) {
-
 
898
						Valeur valeurRecherche = comboLiFonction.getStore().findModel("nom", fonction);
-
 
899
						if (valeurRecherche != null) {
-
 
900
							personne.setFonction(valeurRecherche.getId());
-
 
901
						} else {
-
 
902
							personne.setFonction("AUTRE", fonction);
-
 
903
						}
-
 
904
					}
-
 
905
					
-
 
906
					// Gestion de la notion de "contact"
-
 
907
					personne.setContact(false);
-
 
908
					if (personne.get("contact").equals(true)) {
-
 
909
						personne.setContact(true);
-
 
910
					}
-
 
911
					
-
 
912
					// Gestion du statut
-
 
913
					String statut = personne.get("statut");
-
 
914
					if (statut != null && !statut.equals("")) {
-
 
915
						Valeur valeurRecherche = comboLiStatut.getStore().findModel("nom", statut);
-
 
916
						if (valeurRecherche != null) {
-
 
917
							personne.setStatut(valeurRecherche.getId());
-
 
918
						} else {
-
 
919
							personne.setStatut("AUTRE", statut);
-
 
920
						}
-
 
921
					}
-
 
922
					
-
 
923
					// Gestion du temps de travail
-
 
924
					if (personne.get("travail") != null && !personne.get("travail").equals(0)) {
-
 
925
						personne.setBotaTravailHebdoTps(personne.get("travail").toString());
-
 
926
					}
-
 
927
					
-
 
928
					// Gestion du téléphone
-
 
929
					String telephone = personne.get("telephone");
-
 
930
					if (telephone != null && !telephone.equals("")) {
-
 
931
						personne.setTelephone(telephone);
-
 
932
					}
-
 
933
					
-
 
934
					// Gestion du fax
-
 
935
					String fax = personne.get("fax");
-
 
936
					if (fax != null && !fax.equals("")) {
-
 
937
						personne.setFax(fax);
-
 
938
					}
-
 
939
					
-
 
940
					// Gestion du courriel
-
 
941
					String courriel = personne.get("courriel");
-
 
942
					if (courriel != null && !courriel.equals("")) {
-
 
943
						personne.setCourriel(courriel);
-
 
944
					}
-
 
945
					
-
 
946
					// Gestion de la sépcialité
-
 
947
					String specialite = personne.get("specialite");
-
 
948
					if (specialite != null && !specialite.equals("")) {
-
 
949
						personne.setSpecialite(specialite);
-
 
950
					}
-
 
951
					
-
 
952
					// Ajout de la personne dans la liste correspondant à son état (ajouté ou modifié)
-
 
953
					if (personne.getIdPersonne().equals("")) {// Une personne ajoutée
-
 
954
						personnelAjoute.put(""+i, personne);
-
 
955
					} else {// Une personne modifiée
-
 
956
						personnelModifie.put(personne.getId(), personne);
-
 
957
					}
-
 
958
				}
-
 
959
			}
Line 856... Line 960...
856
	}
960
		}
857
	
-
 
858
	
-
 
859
	private void peuplerStructurePersonnel() {
-
 
860
		if (identification != null) {
-
 
861
			// NBRE PERSONNE
-
 
862
			nbreTotalPersonneStructureChp.setValue(identification.getNbrePersonne());
961
	}
863
		}
962
	
864
		
963
	private void peuplerStructurePersonnel() {
865
		if (personnel != null) {
964
		if (personnel != null) {
-
 
965
			ArrayList<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>();
-
 
966
			for (Iterator<String> it = personnel.keySet().iterator(); it.hasNext();) {
866
			ArrayList<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>();
967
				String index = it.next();
867
			for (Iterator<String> it = personnel.keySet().iterator(); it.hasNext();) {
968
				
868
				String index = it.next();
969
				// Gestion de la fonction
869
				if (magazinLiFonction != null && ((String) personnel.get(index).getFonction()).matches("^[0-9]+$")) {
970
				if (magazinLiFonction != null && ((String) personnel.get(index).getFonction()).matches("^[0-9]+$")) {
870
					GWT.log(personnel.get(index).getFonction(), null);
971
					GWT.log(personnel.get(index).getFonction(), null);
871
					personnel.get(index).set("fonction", magazinLiFonction.findModel("id_valeur", personnel.get(index).getFonction()).getNom());
972
					personnel.get(index).set("fonction", magazinLiFonction.findModel("id_valeur", personnel.get(index).getFonction()).getNom());
-
 
973
				} else {
-
 
974
					personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", ""));
-
 
975
				}
-
 
976
				
-
 
977
				// Gestion de la notion de "contact"
-
 
978
				personnel.get(index).set("contact", (personnel.get(index).getContact().equals("1") ? true : false));
-
 
979
				
-
 
980
				// Gestion du statut
-
 
981
				if (magazinLiStatut != null && ((String) personnel.get(index).getStatut()).matches("^[0-9]+$")) {
-
 
982
					GWT.log(personnel.get(index).getStatut(), null);
-
 
983
					personnel.get(index).set("statut", magazinLiStatut.findModel("id_valeur", personnel.get(index).getStatut()).getNom());
-
 
984
				} else {
-
 
985
					personnel.get(index).set("statut", personnel.get(index).getStatut().replaceFirst("AUTRE##", ""));
-
 
986
				}
-
 
987
				
-
 
988
				// Gestion du temps de travail
872
				} else {
989
				String tps = personnel.get(index).getBotaTravailHebdoTps();
873
					personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", ""));
990
				personnel.get(index).set("travail", (tps.matches("^[0-9]+$")  ? Integer.parseInt(tps) : 0));
874
				}
991
				
875
				personnes.add(personnel.get(index));
992
				personnes.add(personnel.get(index));
-
 
993
			}
876
			}
994
			personnelGrilleMagazin.removeAll();
877
			personnelGrilleMagazin.removeAll();
995
			personnelGrilleMagazin.add(personnes);
878
			personnelGrilleMagazin.add(personnes);
996
			
879
			personnelOnglet.layout();
997
			personnelOnglet.layout();
880
			// Nous vidons la variable personnel une fois qu'elle a remplie la grille
998
			// Nous vidons la variable personnel une fois qu'elle a remplie la grille
Line 881... Line 999...
881
			personnel = null;
999
			personnel = null;
882
		}
1000
		}
883
	}
-
 
884
	
1001
	}
885
	private TabItem creerOngletPersonnel() {
1002
	
886
		personnelOnglet = new TabItem();
1003
	private TabItem creerOngletPersonnel() {
887
		
1004
		personnelOnglet = new TabItem();
888
		personnelOnglet.setText("Personnel");
1005
		personnelOnglet.setText("Personnel");
889
		personnelOnglet.setScrollMode(Scroll.AUTO);
1006
		personnelOnglet.setScrollMode(Scroll.AUTO);
890
		personnelOnglet.setLayout(creerFormLayout(400, LabelAlign.LEFT, null));
1007
		personnelOnglet.setLayout(creerFormLayout(400, LabelAlign.LEFT, 0));
891
		personnelOnglet.setData("acces", false); // Permet de savoir si l'onblet a été accédé par l'utilisateur
1008
		personnelOnglet.setData("acces", false); // Permet de savoir si l'onblet a été accédé par l'utilisateur
-
 
1009
		personnelOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {
-
 
1010
			public void handleEvent(ComponentEvent be) {
-
 
1011
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
-
 
1012
				personnelOnglet.setData("acces", true);
-
 
1013
				
-
 
1014
				// Création des objets de la grille
-
 
1015
				personnelModifie = new StructureAPersonneListe();
892
		personnelOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {
1016
				personnelAjoute = new StructureAPersonneListe();
893
			public void handleEvent(ComponentEvent be) {
1017
				personnelSupprime = new StructureAPersonneListe();
Line 894... Line 1018...
894
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
1018
				
Line 895... Line -...
895
				personnelOnglet.setData("acces", true);
-
 
896
				peuplerStructurePersonnel();
-
 
897
			}
-
 
898
 
-
 
899
		});
-
 
900
		
-
 
901
		nbreTotalPersonneStructureChp = new NumberField();  
-
 
902
		nbreTotalPersonneStructureChp.setFieldLabel("Nombre de personne travaillant dans l'institution");
-
 
903
		nbreTotalPersonneStructureChp.setFormat(NumberFormat.getFormat("#"));
-
 
904
		nbreTotalPersonneStructureChp.setToolTip("Ce champ doit contenir un nombre");
-
 
905
		personnelOnglet.add(nbreTotalPersonneStructureChp);
-
 
906
		
-
 
907
		personnelOnglet.add(this.creerGrillePersonnel());
-
 
908
		
-
 
909
		nbreTotalPersonnelChp = new LabelField();  
-
 
910
		nbreTotalPersonnelChp.setFieldLabel("Nombre de personne travaillant sur les collections");
-
 
911
		nbreTotalPersonnelChp.setLabelSeparator(":");
-
 
912
		nbreTotalPersonnelChp.setValue(""+grillePersonnel.getStore().getCount());
-
 
913
		personnelOnglet.add(nbreTotalPersonnelChp);
1019
				// Peuplement du formulaire
-
 
1020
				peuplerStructurePersonnel();
-
 
1021
			}
-
 
1022
 
-
 
1023
		});
-
 
1024
		
-
 
1025
		ContentPanel cp = new ContentPanel();
-
 
1026
		cp.setHeading("Personnes travaillant sur les collections");
Line 914... Line 1027...
914
 
1027
		cp.setIconStyle("icone-table");
915
		return personnelOnglet;
1028
		//cp.setScrollMode(Scroll.AUTO);
916
	}
1029
		cp.setLayout(new FitLayout());
Line 917... Line 1030...
917
	
1030
		cp.setWidth(1250);
918
	private ContentPanel creerGrillePersonnel() {  
1031
		cp.setHeight("100%");
919
		ContentPanel cp = new ContentPanel();
1032
		cp.setFrame(true);
-
 
1033
		
-
 
1034
		List<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>();
920
		
1035
		personnes.add(new StructureAPersonne(Valeur.FONCTION_DIRECTEUR, StructureAPersonne.ROLE_EQUIPE));
Line 921... Line 1036...
921
		List<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>();
1036
		personnes.add(new StructureAPersonne(Valeur.FONCTION_CONSERVATEUR, StructureAPersonne.ROLE_EQUIPE));
922
		personnes.add(new StructureAPersonne(Valeur.FONCTION_DIRECTEUR));
1037
		
Line 923... Line 1038...
923
		personnes.add(new StructureAPersonne(Valeur.FONCTION_CONSERVATEUR));
1038
		personnelGrilleMagazin = new ListStore<StructureAPersonne>();
924
		
1039
		personnelGrilleMagazin.add(personnes);  
925
		personnelGrilleMagazin = new ListStore<StructureAPersonne>();  
1040
		
926
		personnelGrilleMagazin.add(personnes);  
1041
		RowNumberer r = new RowNumberer();
Line 943... Line 1058...
943
		
1058
		
944
		CellEditor fonctionEditor = new CellEditor(comboLiFonction) {  
1059
		CellEditor fonctionEditor = new CellEditor(comboLiFonction) {  
945
			@Override  
1060
			@Override  
946
			public Object preProcessValue(Object valeur) {  
1061
			public Object preProcessValue(Object valeur) {  
947
				if (valeur == null) {
1062
				if (valeur == null) {
948
					//GWT.log("pre null :"+this.getValue()+"-"+this.row, null);
1063
					GWT.log("pre null :"+this.getValue()+"-"+this.row, null);
949
					return null;
1064
					return null;
950
				}
1065
				}
951
				//GWT.log("pre : "+valeur.toString(), null);
1066
				GWT.log("pre : "+valeur.toString(), null);
952
				Object retour = null;
1067
				Object retour = null;
953
				if (((String) valeur).matches("^[0-9]+$")) {
1068
				if (((String) valeur).matches("^[0-9]+$")) {
954
					Valeur valeurRecherche = comboLiFonction.getStore().findModel("id_valeur", (String) valeur);
1069
					Valeur valeurRecherche = comboLiFonction.getStore().findModel("id_valeur", (String) valeur);
955
					if (valeurRecherche != null) {
1070
					if (valeurRecherche != null) {
956
						retour = valeurRecherche;
1071
						retour = valeurRecherche;
957
						//GWT.log("pre - retour valeur par chiffre : \n"+retour.toString(), null);
1072
						GWT.log("pre - retour valeur par chiffre : \n"+retour.toString(), null);
958
					} else {
1073
					} else {
959
						this.getField().setRawValue((String) valeur);
1074
						this.getField().setRawValue((String) valeur);
960
						retour = null;
1075
						retour = null;
961
					}
1076
					}
962
				} else if (valeur instanceof String) {
1077
				} else if (valeur instanceof String) {
963
					this.getField().setRawValue((String) valeur);
1078
					this.getField().setRawValue((String) valeur);
964
					retour = new Valeur("", (String) valeur, "", "");
1079
					retour = new Valeur("", (String) valeur, "", "");
965
				} else {
1080
				} else {
966
					retour = comboLiFonction.getStore().findModel("nom", (String) valeur);
1081
					retour = comboLiFonction.getStore().findModel("nom", (String) valeur);
967
					//GWT.log("pre - retour valeur par chaine : \n"+retour.toString(), null);
1082
					GWT.log("pre - retour valeur par chaine : \n"+retour.toString(), null);
Line 968... Line 1083...
968
				}
1083
				}
969
				
1084
				
Line 970... Line 1085...
970
				return retour;
1085
				return retour;
971
			}  
1086
			}  
972
			
1087
			
973
			@Override  
1088
			@Override  
974
			public Object postProcessValue(Object valeur) {  
1089
			public Object postProcessValue(Object valeur) {  
975
				if (valeur == null) {
1090
				if (valeur == null) {
976
					// Si la combobox n'a pas été utilisé, nous renvoyons la valeur brute saisie par l'utilisateur
1091
					// Si la combobox n'a pas été utilisé, nous renvoyons la valeur brute saisie par l'utilisateur
977
					//GWT.log("post raw : \n"+this.getField().getRawValue(), null);
1092
					GWT.log("post raw : \n"+this.getField().getRawValue(), null);
978
					String retour = this.getField().getRawValue();
1093
					String retour = this.getField().getRawValue();
979
					if (retour.matches("^[0-9]+$")) {
1094
					if (retour.matches("^[0-9]+$")) {
980
						//GWT.log("ici", null);
1095
						GWT.log("ici", null);
981
						Valeur valeurRecherche = comboLiFonction.getStore().findModel("id_valeur", (String) retour);
1096
						Valeur valeurRecherche = comboLiFonction.getStore().findModel("id_valeur", (String) retour);
982
						if (valeurRecherche != null) {
1097
						if (valeurRecherche != null) {
983
							retour = valeurRecherche.getNom();
1098
							retour = valeurRecherche.getNom();
984
						}
1099
						}
985
					}
1100
					}
986
					return retour;
1101
					return retour;
987
				} else {
1102
				} else {
988
					//GWT.log("post : \n"+valeur.toString(), null);
1103
					GWT.log("post : \n"+valeur.toString(), null);
989
					String nom = "";
1104
					String nom = "";
990
					if (valeur instanceof Valeur) {
1105
					if (valeur instanceof Valeur) {
-
 
1106
						nom = (((Valeur) valeur).getNom());
991
						nom = (((Valeur) valeur).getNom());
1107
						GWT.log("la "+nom, null);
992
						//GWT.log("la "+nom, null);
1108
					}
993
					}
1109
					
994
					return nom;
1110
					return nom;
995
				}
1111
				}
Line 1083... Line 1199...
1083
		configs.add(column);
1199
		configs.add(column);
Line 1084... Line 1200...
1084
		
1200
		
1085
		CheckColumnConfig checkColumn = new CheckColumnConfig("contact", "Contact ?", 60);
1201
		CheckColumnConfig checkColumn = new CheckColumnConfig("contact", "Contact ?", 60);
Line 1086... Line -...
1086
		configs.add(checkColumn);
-
 
1087
		
-
 
1088
		
-
 
1089
		cp.setHeading("Personnes travaillant sur les collections");
-
 
1090
		cp.setIconStyle("icone-table");
-
 
1091
		cp.setScrollMode(Scroll.AUTO);
-
 
1092
		cp.setLayout(new FitLayout());
-
 
1093
		cp.setSize(1250, 200);
-
 
1094
		cp.setFrame(true);
1202
		configs.add(checkColumn);
Line 1095... Line 1203...
1095
		
1203
		
1096
		ToolBar toolBar = new ToolBar();  
1204
		ToolBar toolBar = new ToolBar();  
1097
		
1205
		
1098
		TextToolItem ajouterPersonnelBtn = new TextToolItem("Ajouter", "icone-vcard-ajouter");
1206
		TextToolItem ajouterPersonnelBtn = new TextToolItem("Ajouter", "icone-vcard-ajouter");
1099
		ajouterPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {  
1207
		ajouterPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {  
1100
			@Override  
1208
			@Override  
1101
			public void componentSelected(ToolBarEvent ce) {  
1209
			public void componentSelected(ToolBarEvent ce) {  
1102
				StructureAPersonne personne = new StructureAPersonne();
1210
				StructureAPersonne personne = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE);
1103
				grillePersonnel.stopEditing();
1211
				grillePersonnel.stopEditing();
1104
				int numNouveau = grillePersonnel.getData("nouveau");
1212
				int numNouveau = grillePersonnel.getData("nouveau");
1105
				grillePersonnel.setData("nouveau", ++numNouveau);
-
 
1106
				personnelGrilleMagazin.insert(personne, 0);  
-
 
-
 
1213
				grillePersonnel.setData("nouveau", ++numNouveau);
1107
				grillePersonnel.startEditing(0, 0);
1214
				personnelGrilleMagazin.insert(personne, 0);  
1108
				// Mise à jour du nombre de personnel travaillant sur les collections
1215
				grillePersonnel.startEditing(0, 0);
1109
				nbreTotalPersonnelChp.setValue(""+grillePersonnel.getStore().getCount());
1216
 
1110
				// Activation du bouton supprimer si la grille contient un élément
1217
				// Activation du bouton supprimer si la grille contient un élément
1111
				if (grillePersonnel.getStore().getCount() > 0) {  
1218
				if (grillePersonnel.getStore().getCount() > 0) {  
Line 1117... Line 1224...
1117
		toolBar.add(new SeparatorToolItem());
1224
		toolBar.add(new SeparatorToolItem());
1118
		TextToolItem supprimerPersonnelBtn = new TextToolItem("Supprimer", "icone-vcard-supprimer");
1225
		TextToolItem supprimerPersonnelBtn = new TextToolItem("Supprimer", "icone-vcard-supprimer");
1119
		supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {  
1226
		supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() {  
1120
			@Override
1227
			@Override
1121
			public void componentSelected(ToolBarEvent ce) {
1228
			public void componentSelected(ToolBarEvent ce) {
1122
				grillePersonnel.getStore().remove(grillePersonnel.getStore().getAt(0));
1229
				StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
-
 
1230
				if (personne != null) {
1123
				// Mise à jour du nombre de personnel travaillant sur les collections
1231
					// Ajout de la personne supprimée à la liste
-
 
1232
					if (personne.getIdPersonne() != null) {
1124
				nbreTotalPersonnelChp.setValue(""+grillePersonnel.getStore().getCount());
1233
						personnelSupprime.put(personne.getId(), personne);
-
 
1234
					}
-
 
1235
	
-
 
1236
					// Suppression de l'enregistrement de la grille
-
 
1237
					grillePersonnel.getStore().remove(personne);
-
 
1238
					
1125
				// Désactivation du bouton supprimer si la grille contient plus d'élément
1239
					// Désactivation du bouton supprimer si la grille contient plus d'élément
1126
				if (grillePersonnel.getStore().getCount() == 0) {  
1240
					if (grillePersonnel.getStore().getCount() == 0) {  
1127
					ce.item.disable();  
1241
						ce.item.disable();  
-
 
1242
					}
1128
				}  
1243
				}
1129
			}   
1244
			}   
1130
		});
1245
		});
1131
		toolBar.add(supprimerPersonnelBtn);  
1246
		toolBar.add(supprimerPersonnelBtn);  
1132
		cp.setTopComponent(toolBar);  
1247
		cp.setTopComponent(toolBar);  
Line 1135... Line 1250...
1135
		
1250
		
1136
		grillePersonnel = new EditorGrid<StructureAPersonne>(personnelGrilleMagazin, cm);  
1251
		grillePersonnel = new EditorGrid<StructureAPersonne>(personnelGrilleMagazin, cm);  
1137
		grillePersonnel.setData("nouveau", 0);
1252
		grillePersonnel.setData("nouveau", 0);
1138
		grillePersonnel.setBorders(true);
1253
		grillePersonnel.setBorders(true);
1139
		grillePersonnel.setSelectionModel(sm);
-
 
1140
		grillePersonnel.addPlugin(sm);
1254
		grillePersonnel.setSelectionModel(sm);
-
 
1255
		grillePersonnel.addPlugin(checkColumn);
-
 
1256
		grillePersonnel.addPlugin(r);
1141
		grillePersonnel.addPlugin(checkColumn);
1257
		grillePersonnel.getView().setForceFit(true);
1142
  		grillePersonnel.setAutoExpandColumn("specialite");
1258
  		grillePersonnel.setAutoExpandColumn("specialite");
1143
  		grillePersonnel.setStripeRows(true);
1259
  		grillePersonnel.setStripeRows(true);
1144
  		grillePersonnel.setTrackMouseOver(true);
1260
  		grillePersonnel.setTrackMouseOver(true);
Line 1145... Line 1261...
1145
  		grillePersonnel.addListener(Events.ValidateEdit, new Listener<GridEvent>() {
1261
  		grillePersonnel.addListener(Events.Change, new Listener<GridEvent>() {
1146
 
-
 
1147
			public void handleEvent(GridEvent ge) {
-
 
1148
			
-
 
1149
				GWT.log(ge.property+" : "+ge.value, null);
1262
 
1150
				List<StructureAPersonne> personnes = personnelGrilleMagazin.getModels();
-
 
1151
				StructureAPersonneListe  personnelModifie = new StructureAPersonneListe();
1263
			public void handleEvent(GridEvent ge) {
1152
				for (int i = 0; i < personnes.size(); i++) {
-
 
1153
					personnelModifie.put(""+i, personnes.get(i));
-
 
1154
				}
1264
				// CommitChanges évite que la grille perde la valeur des combobox éditables
Line 1155... Line 1265...
1155
				personnel = personnelModifie;
1265
				personnelGrilleMagazin.commitChanges();
-
 
1266
			}
-
 
1267
  			
1156
			}
1268
  		});
-
 
1269
  		
1157
  			
1270
  		
1158
  		});
1271
		cp.add(grillePersonnel);
1159
		cp.add(grillePersonnel);
1272
		personnelOnglet.add(cp);
Line 1160... Line 1273...
1160
			
1273
		
1161
		return cp;
1274
		return personnelOnglet;
1162
	}  
1275
	}
1163
	
1276
	
Line 1333... Line 1446...
1333
		dateFondationChp.getPropertyEditor().getFormat();
1446
		dateFondationChp.getPropertyEditor().getFormat();
1334
		dateFondationChp.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
1447
		dateFondationChp.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
1335
		dateFondationChp.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
1448
		dateFondationChp.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
1336
		fieldSetIdentite.add(dateFondationChp);
1449
		fieldSetIdentite.add(dateFondationChp);
Line -... Line 1450...
-
 
1450
		
-
 
1451
		nbreTotalPersonneStructureChp = new NumberField();  
-
 
1452
		nbreTotalPersonneStructureChp.setFieldLabel("Nombre de personne travaillant dans l'institution");
-
 
1453
		nbreTotalPersonneStructureChp.setFormat(NumberFormat.getFormat("#"));
-
 
1454
		nbreTotalPersonneStructureChp.setToolTip("Ce champ doit contenir un nombre");
-
 
1455
		fieldSetIdentite.add(nbreTotalPersonneStructureChp);
-
 
1456
 
1337
		
1457
		
Line 1338... Line 1458...
1338
		identificationOnglet.add(fieldSetIdentite);
1458
		identificationOnglet.add(fieldSetIdentite);
1339
 
1459
 
1340
		//+-----------------------------------------------------------------------------------------------------------+		
1460
		//+-----------------------------------------------------------------------------------------------------------+		
Line 1683... Line 1803...
1683
					GWT.log(info.getMessages().toString(), null);
1803
					GWT.log(info.getMessages().toString(), null);
1684
				}
1804
				}
1685
				if (info.getType().equals("modif_structure")) {
1805
				if (info.getType().equals("modif_structure")) {
1686
					Info.display("Modification d'une institution", info.toString());
1806
					Info.display("Modification d'une institution", info.toString());
1687
				} else if (info.getType().equals("ajout_structure")) {
1807
				} else if (info.getType().equals("ajout_structure")) {
-
 
1808
					if (info.toString().matches("^[0-9]+$")) {
-
 
1809
						Info.display("Ajout d'une Institution", "L'intitution a bien été ajoutée");
-
 
1810
						// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons le personnel
-
 
1811
						mediateur.ajouterStructureAPersonne(this, info.toString(), personnelAjoute);
-
 
1812
					} else {
1688
					Info.display("Ajout d'une Institution", info.toString());
1813
						Info.display("Ajout d'une Institution", info.toString());
-
 
1814
					}
-
 
1815
				} else if (info.getType().equals("modif_structure_a_personne")) {
-
 
1816
					Info.display("Modification du Personnel", info.toString());
-
 
1817
				} else if (info.getType().equals("suppression_structure_a_personne")) {
-
 
1818
					Info.display("Suppression du Personnel", info.toString());
-
 
1819
				} else if (info.getType().equals("ajout_structure_a_personne")) {
-
 
1820
					Info.display("Ajout du Personnel", info.toString());
1689
				} else if (info.getType().equals("selection_structure")) {
1821
				} else if (info.getType().equals("selection_structure")) {
1690
					Info.display("Modification d'une institution", info.toString());
1822
					Info.display("Modification d'une institution", info.toString());
1691
					mode = "MODIF";
1823
					mode = "MODIF";
1692
					GWT.log("Mode du formulaire : "+mode, null);
1824
					GWT.log("Mode du formulaire : "+mode, null);
1693
					String titre = i18nC.titreModifFormStructurePanneau();
1825
					String titre = i18nC.titreModifFormStructurePanneau();
Line 1719... Line 1851...
1719
						personnel = (StructureAPersonneListe) info.getDonnee(0);
1851
						personnel = (StructureAPersonneListe) info.getDonnee(0);
Line 1720... Line 1852...
1720
						
1852
						
1721
						//GWT.log(personnel.toString(), null);
1853
						//GWT.log(personnel.toString(), null);
1722
						if (onglets.getSelectedItem().equals(personnelOnglet)) {
1854
						if (onglets.getSelectedItem().equals(personnelOnglet)) {
-
 
1855
							peuplerStructurePersonnel();
1723
							peuplerStructurePersonnel();
1856
							Info.display("Peuplement", "ok");
1724
						}
1857
						}
-
 
1858
					}
-
 
1859
					if (info.getDonnee(1) != null) {
-
 
1860
						Info.display("Debug", info.getDonnee(1).toString());
1725
					}
1861
					}
1726
				}
1862
				}
1727
			} else if (nouvelleDonnees instanceof ValeurListe) {
1863
			} else if (nouvelleDonnees instanceof ValeurListe) {
Line 1728... Line 1864...
1728
				ValeurListe listeValeurs = (ValeurListe) nouvelleDonnees;
1864
				ValeurListe listeValeurs = (ValeurListe) nouvelleDonnees;