Subversion Repositories eFlore/Applications.coel

Rev

Rev 1764 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1764 Rev 1779
1
package org.tela_botanica.client.vues.structure;
1
package org.tela_botanica.client.vues.structure;
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.Collection;
4
import java.util.Collection;
5
import java.util.Iterator;
5
import java.util.Iterator;
6
import java.util.List;
6
import java.util.List;
7
 
-
 
8
import org.tela_botanica.client.ComposantClass;
7
 
9
import org.tela_botanica.client.Mediateur;
-
 
10
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
8
import org.tela_botanica.client.Mediateur;
11
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
9
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
12
import org.tela_botanica.client.composants.InfoLogger;
10
import org.tela_botanica.client.composants.InfoLogger;
13
import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
11
import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
14
import org.tela_botanica.client.images.Images;
12
import org.tela_botanica.client.images.Images;
15
import org.tela_botanica.client.interfaces.Rafraichissable;
13
import org.tela_botanica.client.interfaces.Rafraichissable;
16
import org.tela_botanica.client.modeles.Information;
14
import org.tela_botanica.client.modeles.Information;
17
import org.tela_botanica.client.modeles.Valeur;
15
import org.tela_botanica.client.modeles.Valeur;
18
import org.tela_botanica.client.modeles.ValeurListe;
16
import org.tela_botanica.client.modeles.ValeurListe;
19
import org.tela_botanica.client.modeles.aDonnee;
17
import org.tela_botanica.client.modeles.aDonnee;
20
import org.tela_botanica.client.modeles.personne.Personne;
18
import org.tela_botanica.client.modeles.personne.Personne;
-
 
19
import org.tela_botanica.client.modeles.structure.Structure;
21
import org.tela_botanica.client.modeles.structure.StructureAPersonne;
20
import org.tela_botanica.client.modeles.structure.StructureAPersonne;
22
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe;
21
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe;
23
import org.tela_botanica.client.synchronisation.Sequenceur;
22
import org.tela_botanica.client.synchronisation.Sequenceur;
24
import org.tela_botanica.client.util.Debug;
23
import org.tela_botanica.client.util.Debug;
25
import org.tela_botanica.client.util.UtilString;
24
import org.tela_botanica.client.util.UtilString;
-
 
25
import org.tela_botanica.client.vues.FenetreForm;
26
import org.tela_botanica.client.vues.Formulaire;
26
import org.tela_botanica.client.vues.Formulaire;
-
 
27
import org.tela_botanica.client.vues.FormulaireBarreValidation;
27
import org.tela_botanica.client.vues.FormulaireOnglet;
28
import org.tela_botanica.client.vues.FormulaireOnglet;
-
 
29
import org.tela_botanica.client.vues.personne.PersonneForm;
28
 
30
 
29
import com.extjs.gxt.ui.client.Style.Scroll;
31
import com.extjs.gxt.ui.client.Style.Scroll;
30
import com.extjs.gxt.ui.client.data.ModelData;
32
import com.extjs.gxt.ui.client.data.ModelData;
31
import com.extjs.gxt.ui.client.data.ModelType;
33
import com.extjs.gxt.ui.client.data.ModelType;
32
import com.extjs.gxt.ui.client.event.BaseEvent;
34
import com.extjs.gxt.ui.client.event.BaseEvent;
33
import com.extjs.gxt.ui.client.event.ButtonEvent;
35
import com.extjs.gxt.ui.client.event.ButtonEvent;
34
import com.extjs.gxt.ui.client.event.ComponentEvent;
36
import com.extjs.gxt.ui.client.event.ComponentEvent;
35
import com.extjs.gxt.ui.client.event.Events;
37
import com.extjs.gxt.ui.client.event.Events;
36
import com.extjs.gxt.ui.client.event.Listener;
38
import com.extjs.gxt.ui.client.event.Listener;
37
import com.extjs.gxt.ui.client.event.SelectionListener;
39
import com.extjs.gxt.ui.client.event.SelectionListener;
38
import com.extjs.gxt.ui.client.store.ListStore;
40
import com.extjs.gxt.ui.client.store.ListStore;
39
import com.extjs.gxt.ui.client.store.Record;
41
import com.extjs.gxt.ui.client.store.Record;
40
import com.extjs.gxt.ui.client.store.Store;
42
import com.extjs.gxt.ui.client.store.Store;
41
import com.extjs.gxt.ui.client.store.StoreEvent;
43
import com.extjs.gxt.ui.client.store.StoreEvent;
42
import com.extjs.gxt.ui.client.widget.ContentPanel;
44
import com.extjs.gxt.ui.client.widget.ContentPanel;
43
import com.extjs.gxt.ui.client.widget.TabItem;
45
import com.extjs.gxt.ui.client.widget.TabItem;
-
 
46
import com.extjs.gxt.ui.client.widget.Text;
44
import com.extjs.gxt.ui.client.widget.button.Button;
47
import com.extjs.gxt.ui.client.widget.button.Button;
-
 
48
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
45
import com.extjs.gxt.ui.client.widget.form.ComboBox;
49
import com.extjs.gxt.ui.client.widget.form.ComboBox;
46
import com.extjs.gxt.ui.client.widget.form.Field;
50
import com.extjs.gxt.ui.client.widget.form.Field;
-
 
51
import com.extjs.gxt.ui.client.widget.form.FormPanel;
47
import com.extjs.gxt.ui.client.widget.form.NumberField;
52
import com.extjs.gxt.ui.client.widget.form.NumberField;
48
import com.extjs.gxt.ui.client.widget.form.TextArea;
53
import com.extjs.gxt.ui.client.widget.form.TextArea;
49
import com.extjs.gxt.ui.client.widget.form.TextField;
54
import com.extjs.gxt.ui.client.widget.form.TextField;
50
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
55
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
51
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
56
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
52
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
57
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
53
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
58
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
54
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
59
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
55
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
60
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
56
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
61
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
57
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
62
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
58
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
63
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
-
 
64
import com.extjs.gxt.ui.client.widget.layout.FitData;
59
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
65
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
60
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
66
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
61
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
67
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
62
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
68
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
63
import com.google.gwt.core.client.GWT;
69
import com.google.gwt.core.client.GWT;
64
import com.google.gwt.i18n.client.NumberFormat;
70
import com.google.gwt.i18n.client.NumberFormat;
-
 
71
import com.google.gwt.user.client.Window;
65
 
72
 
66
public class StructureFormPersonne extends FormulaireOnglet implements Rafraichissable {
73
public class StructureFormPersonne extends FormulaireOnglet implements Rafraichissable {
67
	
74
	
68
	private StructureAPersonneListe personnel = null;
75
	private StructureAPersonneListe personnel = null;
69
	private StructureAPersonneListe personnelAjoute = null;
76
	private StructureAPersonneListe personnelAjoute = null;
70
	private StructureAPersonneListe personnelModifie = null;
77
	private StructureAPersonneListe personnelModifie = null;
71
	private StructureAPersonneListe personnelSupprime = null;
78
	private StructureAPersonneListe personnelSupprime = null;
72
	private NumberField nbreTotalPersonneStructureChp = null;
79
	private NumberField nbreTotalPersonneStructureChp = null;
73
	private EditorGrid<StructureAPersonne> grillePersonnel = null;
80
	private EditorGrid<StructureAPersonne> grillePersonnel = null;
74
	private ListStore<StructureAPersonne> personnelGrilleMagazin = null;
81
	private ListStore<StructureAPersonne> personnelGrilleMagazin = null;
75
	
82
	
76
	public ListStore<Valeur> fonctionsMagazin;
83
	public ListStore<Valeur> fonctionsMagazin;
77
	public ComboBox<Valeur> fonctionsCombo;
84
	public ComboBox<Valeur> fonctionsCombo;
78
	public ListStore<Valeur> magazinLiStatut;
85
	public ListStore<Valeur> magazinLiStatut;
79
	public ComboBox<Valeur> comboLiStatut;
86
	public ComboBox<Valeur> comboLiStatut;
80
	
87
	
81
	private ListStore<Personne> personneExistanteMagazin = null;
88
	private ListStore<Personne> personneExistanteMagazin = null;
82
	private ChampComboBoxRechercheTempsReelPaginable personneExistanteCombo = null;
89
	private ChampComboBoxRechercheTempsReelPaginable personneExistanteCombo = null;
83
	private Button supprimerPersonnelBtn = null;
90
	private Button supprimerPersonnelBtn = null;
84
	private CellEditor fonctionEditor = null;
91
	private CellEditor fonctionEditor = null;
85
	private List<Valeur> fonctionsListe = null;
92
	private List<Valeur> fonctionsListe = null;
86
	
93
	
87
	private String ID = "personnel";
94
	private String ID = "personnel";
88
	private Formulaire formulaireCourant = null;
95
	private Formulaire formulaireCourant = null;
89
	private int decompteRafraichissementPersonnel;
96
	private int decompteRafraichissementPersonnel;
-
 
97
	
-
 
98
	private FenetreForm fenetreFormulaire = null;
90
	
99
	
91
	private Sequenceur sequenceur = null;
100
	private Sequenceur sequenceur = null;
92
	
101
	
93
	final class EtatPersonnelStructure {
102
	final class EtatPersonnelStructure {
94
		public StructureAPersonneListe personnelModifie;
103
		public StructureAPersonneListe personnelModifie;
95
		public StructureAPersonneListe personnelAjoute;
104
		public StructureAPersonneListe personnelAjoute;
96
		public StructureAPersonneListe personnelSupprime;
105
		public StructureAPersonneListe personnelSupprime;
97
		public StructureAPersonneListe personnel;
106
		public StructureAPersonneListe personnel;
98
	}
107
	}
99
 
108
 
100
	public StructureFormPersonne(Formulaire formulaireCourant, Mediateur mediateur) {
109
	public StructureFormPersonne(Formulaire formulaireCourant, Mediateur mediateur) {
101
				
110
				
102
		initialiserOnglet(formulaireCourant);
111
		initialiserOnglet(formulaireCourant);
103
		this.formulaireCourant = formulaireCourant;
112
		this.formulaireCourant = formulaireCourant;
104
		
113
		
105
		// Création des objets contenant les manipulations de la grille
114
		// Création des objets contenant les manipulations de la grille
106
		personnelModifie = new StructureAPersonneListe();
115
		personnelModifie = new StructureAPersonneListe();
107
		personnelAjoute = new StructureAPersonneListe();
116
		personnelAjoute = new StructureAPersonneListe();
108
		personnelSupprime = new StructureAPersonneListe();
117
		personnelSupprime = new StructureAPersonneListe();
109
		
118
		
110
		setId(ID);
119
		setId(ID);
111
		setText(Mediateur.i18nC.personneSingulier());
120
		setText(Mediateur.i18nC.personneSingulier());
112
		FormulaireOnglet.parametrer(this);
121
		FormulaireOnglet.parametrer(this);
113
		
122
		
114
		this.setLayout(Formulaire.creerFormLayout(400, LabelAlign.LEFT));
123
		this.setLayout(Formulaire.creerFormLayout(400, LabelAlign.LEFT));
115
		this.setStyleAttribute("padding", "0");
124
		this.setStyleAttribute("padding", "0");
116
		this.addListener(Events.Select, new Listener<ComponentEvent>() {  
125
		this.addListener(Events.Select, new Listener<ComponentEvent>() {  
117
			public void handleEvent(ComponentEvent be) {  
126
			public void handleEvent(ComponentEvent be) {  
118
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
127
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
119
				setData("acces", true);
128
				setData("acces", true);
120
 
129
 
121
				// Rafraichissement du contenu de la grille du personnel
130
				// Rafraichissement du contenu de la grille du personnel
122
				if (StructureFormPersonne.this.formulaireCourant.mode.equals(Formulaire.MODE_AJOUTER)) {
131
				if (StructureFormPersonne.this.formulaireCourant.mode.equals(Formulaire.MODE_AJOUTER)) {
123
					rafraichirPersonnel();
132
					rafraichirPersonnel();
124
				}
133
				}
125
			}
134
			}
126
		});
135
		});
127
		
136
		
128
		ContentPanel cp = new ContentPanel();
137
		ContentPanel cp = new ContentPanel();
129
		cp.setHeadingHtml("Personnes travaillant sur les collections");
138
		cp.setHeadingHtml("Personnes travaillant sur les collections");
130
		cp.setIcon(Images.ICONES.table());
139
		cp.setIcon(Images.ICONES.table());
131
		cp.setScrollMode(Scroll.AUTO);
140
		cp.setScrollMode(Scroll.AUTO);
132
		cp.setLayout(new FitLayout());
141
		cp.setLayout(new FitLayout());
133
		//cp.setWidth(1250);
142
		//cp.setWidth(1250);
134
		//cp.setHeight("100%");
143
		//cp.setHeight("100%");
135
		cp.setFrame(true);
144
		cp.setFrame(true);
136
		
145
		
137
		personnelGrilleMagazin = new ListStore<StructureAPersonne>();
146
		personnelGrilleMagazin = new ListStore<StructureAPersonne>();
138
		personnelGrilleMagazin.setMonitorChanges(true);
147
		personnelGrilleMagazin.setMonitorChanges(true);
139
		
148
		
140
		personnelGrilleMagazin.addListener(Store.Add, new Listener<StoreEvent<StructureAPersonne>>() {
149
		personnelGrilleMagazin.addListener(Store.Add, new Listener<StoreEvent<StructureAPersonne>>() {
141
			public void handleEvent(StoreEvent<StructureAPersonne> ce) {
150
			public void handleEvent(StoreEvent<StructureAPersonne> ce) {
142
				// Activation du bouton supprimer si la grille contient un élément
151
				// Activation du bouton supprimer si la grille contient un élément
143
				if (grillePersonnel.getStore().getCount() > 0) {  
152
				if (grillePersonnel.getStore().getCount() > 0) {  
144
					supprimerPersonnelBtn.enable();
153
					supprimerPersonnelBtn.enable();
145
				}
154
				}
146
				
155
				
147
			}
156
			}
148
		});
157
		});
149
		
158
		
150
		
159
		
151
		RowNumberer r = new RowNumberer();
160
		RowNumberer r = new RowNumberer();
152
		
161
		
153
		List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
162
		List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
154
 
163
 
155
		GridSelectionModel<StructureAPersonne> sm = new GridSelectionModel<StructureAPersonne>();
164
		GridSelectionModel<StructureAPersonne> sm = new GridSelectionModel<StructureAPersonne>();
156
		configs.add(r);
165
		configs.add(r);
157
		
166
		
158
		ColumnConfig column = new ColumnConfig("fonction", "Fonction", 150);
167
		ColumnConfig column = new ColumnConfig("fonction", "Fonction", 150);
159
		fonctionsMagazin = new ListStore<Valeur>();
168
		fonctionsMagazin = new ListStore<Valeur>();
160
		
169
		
161
		fonctionsCombo = new ComboBox<Valeur>();  
170
		fonctionsCombo = new ComboBox<Valeur>();  
162
		fonctionsCombo.setTriggerAction(TriggerAction.ALL);  
171
		fonctionsCombo.setTriggerAction(TriggerAction.ALL);  
163
		fonctionsCombo.setEditable(true);
172
		fonctionsCombo.setEditable(true);
164
		fonctionsCombo.setDisplayField("nom");
173
		fonctionsCombo.setDisplayField("nom");
165
		fonctionsCombo.setStore(fonctionsMagazin);
174
		fonctionsCombo.setStore(fonctionsMagazin);
166
		mediateur.obtenirListeValeurEtRafraichir(this, "fonction", sequenceur);
175
		mediateur.obtenirListeValeurEtRafraichir(this, "fonction", sequenceur);
167
		
176
		
168
		fonctionEditor = new CellEditor(fonctionsCombo) {  
177
		fonctionEditor = new CellEditor(fonctionsCombo) {  
169
			@Override  
178
			@Override  
170
			public Object preProcessValue(Object valeur) {  
179
			public Object preProcessValue(Object valeur) {  
171
				Valeur retour = null;
180
				Valeur retour = null;
172
				
181
				
173
				if (valeur != null) {
182
				if (valeur != null) {
174
					String chaineTransmise = (String) valeur;
183
					String chaineTransmise = (String) valeur;
175
					if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) {
184
					if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) {
176
						fonctionsMagazin.add(fonctionsListe);
185
						fonctionsMagazin.add(fonctionsListe);
177
					}
186
					}
178
					if (fonctionsMagazin.findModel("id_valeur", chaineTransmise) != null) {
187
					if (fonctionsMagazin.findModel("id_valeur", chaineTransmise) != null) {
179
						retour = fonctionsMagazin.findModel("id_valeur", chaineTransmise);
188
						retour = fonctionsMagazin.findModel("id_valeur", chaineTransmise);
180
					} else if (fonctionsMagazin.findModel("nom", chaineTransmise) != null) {
189
					} else if (fonctionsMagazin.findModel("nom", chaineTransmise) != null) {
181
						retour = fonctionsMagazin.findModel("nom", chaineTransmise);
190
						retour = fonctionsMagazin.findModel("nom", chaineTransmise);
182
					} else {
191
					} else {
183
						retour = new Valeur("", chaineTransmise, "", "");
192
						retour = new Valeur("", chaineTransmise, "", "");
184
					}
193
					}
185
				}
194
				}
186
				
195
				
187
				return retour;
196
				return retour;
188
			}  
197
			}  
189
			
198
			
190
			@Override  
199
			@Override  
191
			public Object postProcessValue(Object valeur) {  
200
			public Object postProcessValue(Object valeur) {  
192
				String retour = "";
201
				String retour = "";
193
				Valeur fonctionTrouvee = null; 
202
				Valeur fonctionTrouvee = null; 
194
				if (valeur == null) {
203
				if (valeur == null) {
195
					String valeurBrute = this.getField().getRawValue();
204
					String valeurBrute = this.getField().getRawValue();
196
					if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) {
205
					if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) {
197
						fonctionsMagazin.add(fonctionsListe);
206
						fonctionsMagazin.add(fonctionsListe);
198
					}
207
					}
199
					if (valeurBrute.matches("^[0-9]+$") && fonctionsMagazin.findModel("id_valeur", valeurBrute) != null) {
208
					if (valeurBrute.matches("^[0-9]+$") && fonctionsMagazin.findModel("id_valeur", valeurBrute) != null) {
200
						fonctionTrouvee = fonctionsMagazin.findModel("id_valeur", valeurBrute);
209
						fonctionTrouvee = fonctionsMagazin.findModel("id_valeur", valeurBrute);
201
					} else {
210
					} else {
202
						retour = valeurBrute;
211
						retour = valeurBrute;
203
					}
212
					}
204
				} else if (valeur instanceof Valeur) {
213
				} else if (valeur instanceof Valeur) {
205
					fonctionTrouvee = (Valeur) valeur;
214
					fonctionTrouvee = (Valeur) valeur;
206
				}
215
				}
207
				
216
				
208
				if (fonctionTrouvee != null) {
217
				if (fonctionTrouvee != null) {
209
					retour = fonctionTrouvee.getNom();
218
					retour = fonctionTrouvee.getNom();
210
				}
219
				}
211
				
220
				
212
				return retour;				
221
				return retour;				
213
			}
222
			}
214
		};
223
		};
215
		column.setEditor(fonctionEditor);
224
		column.setEditor(fonctionEditor);
216
		configs.add(column);
225
		configs.add(column);
217
		
226
		
218
		column = new ColumnConfig("prenom", "Prénom", 100);  
227
		column = new ColumnConfig("prenom", "Prénom", 100);  
219
		TextField<String> prenomChp = new TextField<String>();  
-
 
220
		prenomChp.setAllowBlank(false);
-
 
221
		prenomChp.getMessages().setBlankText("Ce champ est obligatoire.");
-
 
222
		prenomChp.setAutoValidate(true);
-
 
223
		prenomChp.addStyleName(ComposantClass.OBLIGATOIRE);
-
 
224
		prenomChp.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
-
 
225
		column.setEditor(new CellEditor(prenomChp));
-
 
226
		configs.add(column);  
228
		configs.add(column);  
227
		
229
		
228
		column = new ColumnConfig("nom", "Nom", 100);
230
		column = new ColumnConfig("nom", "Nom", 100);
229
		TextField<String> nomChp = new TextField<String>();  
-
 
230
		nomChp.setAllowBlank(false);
-
 
231
		nomChp.getMessages().setBlankText("Ce champ est obligatoire.");
-
 
232
		nomChp.setAutoValidate(true);
-
 
233
		nomChp.addStyleName(ComposantClass.OBLIGATOIRE);
-
 
234
		nomChp.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
-
 
235
		column.setEditor(new CellEditor(nomChp));
-
 
236
		configs.add(column);  
231
		configs.add(column);  
237
 
232
 
238
		column = new ColumnConfig("tel_fix", "Téléphone fixe", 100);
-
 
239
		TextField<String> telChp = new TextField<String>();  
-
 
240
		column.setEditor(new CellEditor(telChp));
233
		column = new ColumnConfig("tel_fix", "Téléphone", 100);
241
		configs.add(column);
234
		configs.add(column);
242
 
235
 
243
		column = new ColumnConfig("tel_fax", "Fax", 100);
236
		column = new ColumnConfig("tel_fax", "Fax", 100);
244
		TextField<String> faxChp = new TextField<String>();  
-
 
245
		column.setEditor(new CellEditor(faxChp));
-
 
246
		configs.add(column);
237
		configs.add(column);
247
		
238
		
248
		column = new ColumnConfig("courriel", "Courriel principal", 200);
239
		column = new ColumnConfig("courriel", "Courriel principal", 200);
249
		TextField<String> emailChp = new TextField<String>();  
-
 
250
		column.setEditor(new CellEditor(emailChp));
-
 
251
		configs.add(column);
240
		configs.add(column);
252
		
241
		
253
		magazinLiStatut = new ListStore<Valeur>();
242
		magazinLiStatut = new ListStore<Valeur>();
254
		magazinLiStatut.add(new ArrayList<Valeur>());
243
		magazinLiStatut.add(new ArrayList<Valeur>());
255
		
244
		
256
		comboLiStatut = new ComboBox<Valeur>();  
245
		comboLiStatut = new ComboBox<Valeur>();  
257
		comboLiStatut.setTriggerAction(TriggerAction.ALL);  
246
		comboLiStatut.setTriggerAction(TriggerAction.ALL);  
258
		comboLiStatut.setEditable(false);
247
		comboLiStatut.setEditable(false);
259
		comboLiStatut.disableTextSelection(true);
248
		comboLiStatut.disableTextSelection(true);
260
		comboLiStatut.setDisplayField("nom");
249
		comboLiStatut.setDisplayField("nom");
261
		comboLiStatut.setStore(magazinLiStatut);
250
		comboLiStatut.setStore(magazinLiStatut);
262
		mediateur.obtenirListeValeurEtRafraichir(this, "statut", sequenceur);
251
		mediateur.obtenirListeValeurEtRafraichir(this, "statut", sequenceur);
263
		
252
		
264
		CellEditor statutEditor = new CellEditor(comboLiStatut) {  
253
		CellEditor statutEditor = new CellEditor(comboLiStatut) {  
265
			@Override  
254
			@Override  
266
			public Object preProcessValue(Object value) {  
255
			public Object preProcessValue(Object value) {  
267
				if (value == null) {  
256
				if (value == null) {  
268
					return value;  
257
					return value;  
269
				}
258
				}
270
				return comboLiStatut.getStore().findModel("nom", (String) value);  
259
				return comboLiStatut.getStore().findModel("nom", (String) value);  
271
			}  
260
			}  
272
			
261
			
273
			@Override  
262
			@Override  
274
			public Object postProcessValue(Object value) {  
263
			public Object postProcessValue(Object value) {  
275
				if (value == null) {  
264
				if (value == null) {  
276
					return value;  
265
					return value;  
277
				}
266
				}
278
				return ((Valeur) value).get("nom");  
267
				return ((Valeur) value).get("nom");  
279
			}  
268
			}  
280
		};
269
		};
281
		column = new ColumnConfig("statut", "Statut", 100);
270
		column = new ColumnConfig("statut", "Statut", 100);
282
		column.setEditor(statutEditor);
271
		column.setEditor(statutEditor);
283
		configs.add(column);
272
		configs.add(column);
284
		
273
		
285
		column = new ColumnConfig("travail", "Travail hebdo (%)", 100);
274
		column = new ColumnConfig("travail", "Travail hebdo (%)", 100);
286
		column.setNumberFormat(NumberFormat.getFormat("##"));
275
		column.setNumberFormat(NumberFormat.getFormat("##"));
287
		NumberField tpsWChp = new NumberField();
276
		NumberField tpsWChp = new NumberField();
288
		tpsWChp.setFormat(NumberFormat.getFormat("##"));
277
		tpsWChp.setFormat(NumberFormat.getFormat("##"));
289
		tpsWChp.setToolTip("Ce champ doit contenir un nombre");
278
		tpsWChp.setToolTip("Ce champ doit contenir un nombre");
290
		column.setEditor(new CellEditor(tpsWChp));
279
		column.setEditor(new CellEditor(tpsWChp));
291
		configs.add(column);
280
		configs.add(column);
292
		
281
		
293
		column = new ColumnConfig("specialite", "Spécialité principale", 150);
-
 
294
		TextField<String> speChp = new TextField<String>();  
-
 
295
		column.setEditor(new CellEditor(speChp));
282
		column = new ColumnConfig("specialite", "Spécialité botanique principale", 150);
296
		configs.add(column);
283
		configs.add(column);
297
		
284
		
298
		CheckColumnConfig checkColumn = new CheckColumnConfig("contact", "Contact ?", 60);
285
		CheckColumnConfig checkColumn = new CheckColumnConfig("contact", "Contact ?", 60);
299
		configs.add(checkColumn);
286
		configs.add(checkColumn);
300
		
287
		
301
		ToolBar toolBar = new ToolBar();  
288
		ToolBar toolBar = new ToolBar();  
-
 
289
		
302
		
290
		
-
 
291
		personneExistanteMagazin = new ListStore<Personne>();
-
 
292
		personneExistanteMagazin.add(new ArrayList<Personne>());
-
 
293
		
-
 
294
		ModelType modelTypePersonnes = new ModelType();
303
		Button ajouterPersonnelBtn = new Button("Ajouter");
295
		modelTypePersonnes.setRoot("personnes");
-
 
296
		modelTypePersonnes.setTotalName("nbElements");
-
 
297
		modelTypePersonnes.addField("cp_fmt_nom_complet");
-
 
298
		modelTypePersonnes.addField("cp_nom");
-
 
299
		modelTypePersonnes.addField("cp_prenom");
-
 
300
		modelTypePersonnes.addField("cp_truk_courriel");
-
 
301
		modelTypePersonnes.addField("cp_truk_telephone");
-
 
302
		modelTypePersonnes.addField("cp_ce_truk_specialite");
-
 
303
		modelTypePersonnes.addField("cp_id_personne");
-
 
304
		
304
		ajouterPersonnelBtn.setIcon(Images.ICONES.vcardAjouter());
305
		String displayNamePersonnes = "cp_fmt_nom_complet";
-
 
306
		ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(null);
-
 
307
		
-
 
308
		personneExistanteCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes);
-
 
309
		personneExistanteCombo.getCombo().setEmptyText("Rechercher et sélectionner une personne existante dans la base");
-
 
310
		
305
		ajouterPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {  
311
		// TODO : dans GXT 2.0 plus besoin de l'adaptateur, on peut ajouter la combobox directement sur la toolbar
-
 
312
			//> CHECK
-
 
313
		toolBar.add(personneExistanteCombo);
-
 
314
		
306
			@Override  
315
		personneExistanteCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
-
 
316
			public void handleEvent(BaseEvent be) {
-
 
317
				if (personneExistanteCombo.getValeur() instanceof ModelData) {
307
			public void componentSelected(ButtonEvent ce) {  
318
					Personne personneExistante = new Personne(personneExistanteCombo.getValeur());
308
				StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
319
					StructureAPersonne membreDuPersonnel = new StructureAPersonne(personneExistante, "", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
-
 
320
					ajouterMembreAGrillePersonnel(membreDuPersonnel);
-
 
321
					personneExistanteCombo.getCombo().setValue(null);
309
				ajouterMembreAGrillePersonnel(membreDuPersonnel);
322
				}
310
			}  
323
			}
-
 
324
		});
-
 
325
 
-
 
326
		toolBar.add(new Text(" ou "));
-
 
327
		
311
		});
328
		Button ajouterPersonnelBtn = creerBoutonAjouter();
-
 
329
		toolBar.add(ajouterPersonnelBtn);		
-
 
330
		
-
 
331
		toolBar.add(new SeparatorToolItem());
-
 
332
		
-
 
333
		Button modifierPersonnelBtn = creerBoutonModifier();
312
		toolBar.add(ajouterPersonnelBtn);
334
		toolBar.add(modifierPersonnelBtn);
313
		
335
		
314
		toolBar.add(new SeparatorToolItem());
336
		toolBar.add(new SeparatorToolItem());
315
		
337
		
316
		supprimerPersonnelBtn = new Button("Supprimer");
338
		supprimerPersonnelBtn = new Button("Supprimer");
317
		supprimerPersonnelBtn.setIcon(Images.ICONES.vcardSupprimer());
339
		supprimerPersonnelBtn.setIcon(Images.ICONES.vcardSupprimer());
318
		supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {  
340
		supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {  
319
			@Override
341
			@Override
320
			public void componentSelected(ButtonEvent ce) {
342
			public void componentSelected(ButtonEvent ce) {
321
				StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
343
				StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
322
				if (personne != null) {
344
				if (personne != null) {
323
					// Ajout de la personne supprimée à la liste
345
					// Ajout de la personne supprimée à la liste
324
					if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
346
					if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
325
						personnelSupprime.put(personne.getId(), personne);
347
						personnelSupprime.put(personne.getId(), personne);
326
					}
348
					}
327
	
349
	
328
					// Suppression de l'enregistrement de la grille
350
					// Suppression de l'enregistrement de la grille
329
					grillePersonnel.getStore().remove(personne);
351
					grillePersonnel.getStore().remove(personne);
330
					
352
					
331
					// Désactivation du bouton supprimer si la grille contient plus d'élément
353
					// Désactivation du bouton supprimer si la grille contient plus d'élément
332
					if (grillePersonnel.getStore().getCount() == 0) {  
354
					if (grillePersonnel.getStore().getCount() == 0) {  
333
						//TODO : check : Item -> component
355
						//TODO : check : Item -> component
334
						ce.getComponent().disable();  
356
						ce.getComponent().disable();  
335
					}
357
					}
336
				}
358
				}
337
			}   
359
			}   
338
		});
360
		});
339
		toolBar.add(supprimerPersonnelBtn);
361
		toolBar.add(supprimerPersonnelBtn);
340
		
362
		
341
		toolBar.add(new SeparatorToolItem());
363
		toolBar.add(new SeparatorToolItem());
342
		
364
		
343
		Button rafraichirPersonnelBtn = new Button("Rafraichir");
365
		Button rafraichirPersonnelBtn = new Button("Rafraichir");
344
		rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir());
366
		rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir());
345
		rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {  
367
		rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {  
346
			@Override
368
			@Override
347
			public void componentSelected(ButtonEvent ce) {
369
			public void componentSelected(ButtonEvent ce) {
348
				rafraichirPersonnel();
370
				rafraichirPersonnel();
349
			}   
371
			}   
350
		});
372
		});
351
		toolBar.add(rafraichirPersonnelBtn);
373
		toolBar.add(rafraichirPersonnelBtn);
352
		
374
		
353
		toolBar.add(new SeparatorToolItem());
375
		toolBar.add(new SeparatorToolItem());
354
		
-
 
355
		personneExistanteMagazin = new ListStore<Personne>();
-
 
356
		personneExistanteMagazin.add(new ArrayList<Personne>());
-
 
357
		
-
 
358
		ModelType modelTypePersonnes = new ModelType();
-
 
359
		modelTypePersonnes.setRoot("personnes");
-
 
360
		modelTypePersonnes.setTotalName("nbElements");
-
 
361
		modelTypePersonnes.addField("cp_fmt_nom_complet");
-
 
362
		modelTypePersonnes.addField("cp_nom");
-
 
363
		modelTypePersonnes.addField("cp_prenom");
-
 
364
		modelTypePersonnes.addField("cp_truk_courriel");
-
 
365
		modelTypePersonnes.addField("cp_truk_telephone");
-
 
366
		modelTypePersonnes.addField("cp_ce_truk_specialite");
-
 
367
		modelTypePersonnes.addField("cp_id_personne");
-
 
368
		
-
 
369
		String displayNamePersonnes = "cp_fmt_nom_complet";
-
 
370
		ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(null);
-
 
371
		
-
 
372
		personneExistanteCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes);
-
 
373
 
-
 
374
		// TODO : dans GXT 2.0 plus besoin de l'adaptateur, on peut ajouter la combobox directement sur la toolbar
-
 
375
			//> CHECK
-
 
376
		toolBar.add(personneExistanteCombo);
-
 
377
		
-
 
378
		Button ajouterPersonneExistanteBtn = new Button("Ajouter à la grille");
-
 
379
		ajouterPersonneExistanteBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {  
-
 
380
			@Override  
-
 
381
			public void componentSelected(ButtonEvent ce) {
-
 
382
				
-
 
383
				Personne personneExistante = new Personne(personneExistanteCombo.getValeur());
-
 
384
				
-
 
385
				if (personneExistante != null) {
-
 
386
					StructureAPersonne membreDuPersonnel = new StructureAPersonne(personneExistante, "", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
-
 
387
					ajouterMembreAGrillePersonnel(membreDuPersonnel);
-
 
388
				}
-
 
389
			}  
-
 
390
		});
-
 
391
		toolBar.add(ajouterPersonneExistanteBtn);
-
 
392
		
376
		
393
		cp.setTopComponent(toolBar);  
377
		cp.setTopComponent(toolBar);  
394
 
378
 
395
		ColumnModel cm = new ColumnModel(configs);
379
		ColumnModel cm = new ColumnModel(configs);
396
		
380
		
397
		grillePersonnel = new EditorGrid<StructureAPersonne>(personnelGrilleMagazin, cm);
381
		grillePersonnel = new EditorGrid<StructureAPersonne>(personnelGrilleMagazin, cm);
398
		grillePersonnel.setHeight("100%");
382
		//grillePersonnel.setHeight("100%");
-
 
383
		grillePersonnel.setAutoHeight(true);
399
		grillePersonnel.setBorders(true);
384
		grillePersonnel.setBorders(true);
400
		grillePersonnel.setSelectionModel(sm);
385
		grillePersonnel.setSelectionModel(sm);
401
		grillePersonnel.addPlugin(checkColumn);
386
		grillePersonnel.addPlugin(checkColumn);
402
		grillePersonnel.addPlugin(r);
387
		grillePersonnel.addPlugin(r);
403
		grillePersonnel.getView().setForceFit(true);
388
		grillePersonnel.getView().setForceFit(true);
404
  		grillePersonnel.setAutoExpandColumn("specialite");
389
  		grillePersonnel.setAutoExpandColumn("specialite");
405
  		grillePersonnel.setStripeRows(true);
390
  		grillePersonnel.setStripeRows(true);
406
  		grillePersonnel.setTrackMouseOver(true);
391
  		grillePersonnel.setTrackMouseOver(true);
407
  		
392
  		
408
  		
393
  		
409
		personnelGrilleMagazin.addListener(Store.Update, new Listener<StoreEvent<StructureAPersonne>>() {
394
		personnelGrilleMagazin.addListener(Store.Update, new Listener<StoreEvent<StructureAPersonne>>() {
410
			public void handleEvent(StoreEvent<StructureAPersonne> ce) {
395
			public void handleEvent(StoreEvent<StructureAPersonne> ce) {
411
				StructureAPersonne structureAPersonne = ce.getModel();
396
				StructureAPersonne structureAPersonne = ce.getModel();
412
				String etat = structureAPersonne.get("etat");
397
				String etat = structureAPersonne.get("etat");
413
				if ((etat==null || !etat.equals(aDonnee.ETAT_AJOUTE)) && structureAPersonne!=null && !UtilString.isEmpty(structureAPersonne.getId()))	{
398
				if ((etat==null || !etat.equals(aDonnee.ETAT_AJOUTE)) && structureAPersonne!=null && !UtilString.isEmpty(structureAPersonne.getId()))	{
414
					ce.getModel().set("etat", aDonnee.ETAT_MODIFIE);
399
					ce.getModel().set("etat", aDonnee.ETAT_MODIFIE);
415
				}
400
				}
416
			}
401
			}
417
		});
402
		});
418
  		
403
  		
419
		
404
		
420
  		cp.add(grillePersonnel);
405
  		cp.add(grillePersonnel);
421
		this.add(cp);
406
		this.add(cp);
-
 
407
		
-
 
408
		this.setAutoHeight(true);
-
 
409
	}
-
 
410
	
-
 
411
	private Button creerBoutonAjouter() {
-
 
412
		Button bouton = new Button(i18nC.ajouter());
-
 
413
		bouton.setIcon(Images.ICONES.vcardAjouter());
-
 
414
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
-
 
415
			public void componentSelected(ButtonEvent ce) {  
-
 
416
				fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
-
 
417
				fenetreFormulaire.show();
-
 
418
			}  
-
 
419
		});
-
 
420
		return bouton;
-
 
421
	}
-
 
422
	
-
 
423
	private Button creerBoutonModifier() {
-
 
424
		Button bouton = new Button(i18nC.modifier());
-
 
425
		bouton.setIcon(Images.ICONES.vcardModifier());
-
 
426
		bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {  
-
 
427
			public void componentSelected(ButtonEvent ce) {  
-
 
428
				String IdpersonneSaisieSelectionnee = (grillePersonnel.getSelectionModel().getSelectedItem()).getIdPersonne();
-
 
429
				
-
 
430
				if (IdpersonneSaisieSelectionnee == null) {
-
 
431
					InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPersonne());
-
 
432
				} else {
-
 
433
					fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
-
 
434
					fenetreFormulaire.show();
-
 
435
				}
-
 
436
			}  
-
 
437
		});
-
 
438
		return bouton;
-
 
439
	}
-
 
440
	
-
 
441
	private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
-
 
442
		String personneId = null;
-
 
443
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
-
 
444
			personneId = (grillePersonnel.getSelectionModel().getSelectedItem()).getIdPersonne();
-
 
445
		}
-
 
446
		
-
 
447
		final FenetreForm fenetre = new FenetreForm("");
-
 
448
		final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId);
-
 
449
		fenetre.add(formulaire);
-
 
450
		return fenetre;
-
 
451
	}
-
 
452
	
-
 
453
	private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, final String personneId) {
-
 
454
		PersonneForm formulairePersonne = new PersonneForm(mediateur, personneId, this);
-
 
455
		FormPanel panneauFormulaire = formulairePersonne.getFormulaire();
-
 
456
		fenetre.setHeadingHtml(panneauFormulaire.getHeadingHtml());
-
 
457
		panneauFormulaire.setHeaderVisible(false);
-
 
458
		panneauFormulaire.setTopComponent(null);
-
 
459
		
-
 
460
		// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
-
 
461
		panneauFormulaire.getBottomComponent().hide();
-
 
462
		SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulairePersonne);
-
 
463
		final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
-
 
464
		fenetre.setBottomComponent(barreValidation);
-
 
465
		
-
 
466
		return formulairePersonne;
-
 
467
	}
-
 
468
	
-
 
469
	private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePersonne(final FenetreForm fenetre, final PersonneForm formulaire) {
-
 
470
		SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
-
 
471
			public void componentSelected(ButtonEvent ce) {
-
 
472
				String code = ((Button) ce.getComponent()).getData("code");
-
 
473
				if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
-
 
474
					if (formulaire.soumettreFormulaire()) {
-
 
475
						fenetre.hide();
-
 
476
					}
-
 
477
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
-
 
478
					formulaire.soumettreFormulaire();
-
 
479
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
-
 
480
					fenetre.hide();
-
 
481
				}
-
 
482
			}
-
 
483
		};
-
 
484
		
-
 
485
		return ecouteur;
422
	}
486
	}
423
	
487
	
424
	public Collection<? extends String> verifier() {
488
	public Collection<? extends String> verifier() {
425
		ArrayList<String> messages = new ArrayList<String>();
489
		ArrayList<String> messages = new ArrayList<String>();
426
		// Vérification du Personnel
490
		// Vérification du Personnel
427
		if (getData("acces").equals(true)) {
491
		if (getData("acces").equals(true)) {
428
			String personnelNumero = "";
492
			String personnelNumero = "";
429
			int nbrePersonne = personnelGrilleMagazin.getCount();
493
			int nbrePersonne = personnelGrilleMagazin.getCount();
430
			for (int i = 0; i < nbrePersonne; i++) {
494
			for (int i = 0; i < nbrePersonne; i++) {
431
				StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
495
				StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
432
				if (personne.getNom().equals("") || personne.getPrenom().equals("")) {
496
				if (personne.getNom().equals("") || personne.getPrenom().equals("")) {
433
					personnelNumero += (i != 0 ? ", " : "")+(i+1);
497
					personnelNumero += (i != 0 ? ", " : "")+(i+1);
434
				}
498
				}
435
			}
499
			}
436
			if (!personnelNumero.equals("")) {
500
			if (!personnelNumero.equals("")) {
437
				messages.add("Veuillez indiquez un prénom et un nom au personnel numéro : "+personnelNumero);
501
				messages.add("Veuillez indiquez un prénom et un nom au personnel numéro : "+personnelNumero);
438
			}
502
			}
439
		}
503
		}
440
		return messages;
504
		return messages;
441
	}
505
	}
442
 
506
 
443
	@Override
507
	@Override
444
	public void rafraichir(Object nouvellesDonnees) {
508
	public void rafraichir(Object nouvellesDonnees) {
445
		if (nouvellesDonnees instanceof ValeurListe) {
509
		if (nouvellesDonnees instanceof ValeurListe) {
446
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
510
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
447
			rafraichirValeurListe(listeValeurs);
511
			rafraichirValeurListe(listeValeurs);
448
		} else if (nouvellesDonnees instanceof Information) {
512
		} else if (nouvellesDonnees instanceof Information) {
449
			Information info = (Information) nouvellesDonnees;
513
			Information info = (Information) nouvellesDonnees;
450
			rafraichirInformation(info);
514
			rafraichirInformation(info);
451
		} else {
515
		} else {
452
			Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
516
			Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
453
		}
517
		}
454
	}
518
	}
455
	
519
	
456
	public void rafraichirInformation(Information info) {
520
	public void rafraichirInformation(Information info) {
457
		if (info.getType().equals("ajout_structure")) {
521
		if (info.getType().equals("ajout_structure")) {
458
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
522
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
459
				String structureId = (String) info.getDonnee(0);
523
				String structureId = (String) info.getDonnee(0);
460
				// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons le personnel
524
				// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons le personnel
461
				mediateur.ajouterStructureAPersonne(this, structureId, getPersonnelAjoute());
525
				mediateur.ajouterStructureAPersonne(this, structureId, getPersonnelAjoute());
462
			}
526
			}
463
		} else if (info.getType().equals("modif_structure_a_personne")) {
527
		} else if (info.getType().equals("modif_structure_a_personne")) {
464
			InfoLogger.display("Modification du Personnel", info.toString());
528
			InfoLogger.display("Modification du Personnel", info.toString());
465
			testerLancementRafraichirPersonnel();
529
			testerLancementRafraichirPersonnel();
466
		} else if (info.getType().equals("suppression_structure_a_personne")) {
530
		} else if (info.getType().equals("suppression_structure_a_personne")) {
467
			InfoLogger.display("Suppression du Personnel", info.toString());
531
			InfoLogger.display("Suppression du Personnel", info.toString());
468
			testerLancementRafraichirPersonnel();
532
			testerLancementRafraichirPersonnel();
469
		} else if (info.getType().equals("ajout_structure_a_personne")) {
533
		} else if (info.getType().equals("ajout_structure_a_personne")) {
470
			InfoLogger.display("Ajout du Personnel", info.toString());
534
			InfoLogger.display("Ajout du Personnel", info.toString());
471
			testerLancementRafraichirPersonnel();
535
			testerLancementRafraichirPersonnel();
472
		} else if (info.getType().equals("liste_structure_a_personne")) {
536
		} else if (info.getType().equals("liste_structure_a_personne")) {
473
			if (info.getDonnee(0) != null) {
537
			if (info.getDonnee(0) != null) {
474
				StructureAPersonneListe personnel = (StructureAPersonneListe) info.getDonnee(0);
538
				StructureAPersonneListe personnel = (StructureAPersonneListe) info.getDonnee(0);
475
				peupler(personnel);
539
				peupler(personnel);
476
				layout();
540
				layout();
477
				InfoLogger.display("Chargement du Personnel", "ok");
541
				InfoLogger.display("Chargement du Personnel", "ok");
478
			}
542
			}
-
 
543
		} else if (info.getType().equals("personne_modifiee")) {
-
 
544
			if (info.getDonnee(0) != null) {
-
 
545
				Personne personne = (Personne) info.getDonnee(0);				
-
 
546
				StructureAPersonne personneDansGrille = grillePersonnel.getStore().findModel("id_personne", personne.getId());
-
 
547
				StructureAPersonne personneDansGrilleModif = new StructureAPersonne(personne, personneDansGrille.getFonction(), personneDansGrille.getIdRole(), personneDansGrille.getIdEtat());
-
 
548
				int index = grillePersonnel.getStore().indexOf(personneDansGrille);
-
 
549
				grillePersonnel.getStore().remove(personneDansGrille);
-
 
550
				grillePersonnel.getStore().insert(personneDansGrilleModif, index);
-
 
551
				personnelModifie.put(personne.getId()+"", personneDansGrilleModif);
-
 
552
			}
-
 
553
		} else if (info.getType().equals("personne_ajoutee")) {
-
 
554
			if (info.getDonnee(0) != null) {
-
 
555
				Personne personne = (Personne) info.getDonnee(0);
-
 
556
				StructureAPersonne structAPersonne = new StructureAPersonne(personne,"",StructureAPersonne.ROLE_EQUIPE, "");				
-
 
557
				Structure structure = ((StructureForm) formulaire).identification;
-
 
558
				structAPersonne.setIdStructure(structure.getId());
-
 
559
				personnelAjoute.put(personne.getId(), structAPersonne);
-
 
560
				ajouterMembreAGrillePersonnel(structAPersonne);
-
 
561
			}
479
		}
562
		}
480
	}
563
	}
481
	
564
	
482
	public void rafraichirValeurListe(ValeurListe listeValeurs) {
565
	public void rafraichirValeurListe(ValeurListe listeValeurs) {
483
		List<Valeur> liste = listeValeurs.toList();
566
		List<Valeur> liste = listeValeurs.toList();
484
		if (listeValeurs.getId().equals(config.getListeId("statut"))) {
567
		if (listeValeurs.getId().equals(config.getListeId("statut"))) {
485
			magazinLiStatut.removeAll();
568
			magazinLiStatut.removeAll();
486
			magazinLiStatut.add(liste);
569
			magazinLiStatut.add(liste);
487
			comboLiStatut.setStore(magazinLiStatut);
570
			comboLiStatut.setStore(magazinLiStatut);
488
		}
571
		}
489
		if (listeValeurs.getId().equals(config.getListeId("fonction"))) {
572
		if (listeValeurs.getId().equals(config.getListeId("fonction"))) {
490
			// FIXME : le store ne contient pas tout le temps les données, chose étrange.
573
			// FIXME : le store ne contient pas tout le temps les données, chose étrange.
491
			// On stocke donc les données dans une variables de la classe pour recharger le store si besoin.
574
			// On stocke donc les données dans une variables de la classe pour recharger le store si besoin.
492
			fonctionsListe = liste;
575
			fonctionsListe = liste;
493
			fonctionsMagazin.removeAll();
576
			fonctionsMagazin.removeAll();
494
			fonctionsMagazin.add(liste);
577
			fonctionsMagazin.add(liste);
495
			fonctionsCombo.setStore(fonctionsMagazin);
578
			fonctionsCombo.setStore(fonctionsMagazin);
496
		}
579
		}
497
	}
580
	}
498
 
581
 
499
	public EtatPersonnelStructure collecter() {
582
	public EtatPersonnelStructure collecter() {
500
		StructureForm formulaire = (StructureForm)formulaireCourant;
583
		StructureForm formulaire = (StructureForm)formulaireCourant;
501
		
584
		
502
		if (getData("acces").equals(true)) {
585
		if (getData("acces").equals(true)) {
503
			personnelGrilleMagazin.commitChanges();
586
			personnelGrilleMagazin.commitChanges();
504
			int nbrePersonne = personnelGrilleMagazin.getCount();
587
			int nbrePersonne = personnelGrilleMagazin.getCount();
505
			for (int i = 0; i < nbrePersonne; i++) {
588
			for (int i = 0; i < nbrePersonne; i++) {
506
				StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
589
				StructureAPersonne personne = personnelGrilleMagazin.getAt(i);
507
				
590
				
508
				// Seules les lignes ajoutées ou modifiées sont prises en compte.
591
				// Seules les lignes ajoutées ou modifiées sont prises en compte.
509
				Record record = personnelGrilleMagazin.getRecord(personne);
592
				Record record = personnelGrilleMagazin.getRecord(personne);
510
				if (personnelGrilleMagazin.getModifiedRecords().contains(record) == true 
593
				if (personnelGrilleMagazin.getModifiedRecords().contains(record) == true 
511
						|| (personne.get("etat") != null && (personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE) || personne.get("etat").equals(StructureAPersonne.ETAT_MODIFIE)) )) {
594
						|| (personne.get("etat") != null && (personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE) || personne.get("etat").equals(StructureAPersonne.ETAT_MODIFIE)) )) {
512
					
595
					
513
					// Gestion de l'id de la structure
596
					// Gestion de l'id de la structure
514
					if (mode.equals("MODIF")) {
597
					if (mode.equals("MODIF")) {
515
						personne.setIdStructure(getIdIdentification());
598
						personne.setIdStructure(getIdIdentification());
516
					}
599
					}
517
					
600
					
518
					// Gestion de la fonction
601
					// Gestion de la fonction
519
					String fonction = personne.get("fonction");
602
					String fonction = personne.get("fonction");
520
					if (fonction != null && !fonction.equals("")) {
603
					if (fonction != null && !fonction.equals("")) {
521
						Valeur valeurRecherche = fonctionsCombo.getStore().findModel("nom", fonction);
604
						Valeur valeurRecherche = fonctionsCombo.getStore().findModel("nom", fonction);
522
						if (valeurRecherche != null) {
605
						if (valeurRecherche != null) {
523
							personne.setFonction(valeurRecherche.getId());
606
							personne.setFonction(valeurRecherche.getId());
524
						} else {
607
						} else {
525
							personne.setFonction("AUTRE", fonction);
608
							personne.setFonction("AUTRE", fonction);
526
						}
609
						}
527
					} else {
610
					} else {
528
						personne.setFonction("");
611
						personne.setFonction("");
529
					}
612
					}
530
 
613
 
531
					// Gestion du nom complet
614
					// Gestion du nom complet
532
					String nomComplet = personne.getPrenom()+" "+personne.getNom();
615
					String nomComplet = personne.getPrenom()+" "+personne.getNom();
533
					personne.setNomComplet(nomComplet);					
616
					personne.setNomComplet(nomComplet);					
534
					
617
					
535
					// Gestion de la notion de "contact"
618
					// Gestion de la notion de "contact"
536
					personne.setContact(false);
619
					personne.setContact(false);
537
					if (personne.get("contact").equals(true)) {
620
					if (personne.get("contact").equals(true)) {
538
						personne.setContact(true);
621
						personne.setContact(true);
539
					}
622
					}
540
					
623
					
541
					// Gestion du statut
624
					// Gestion du statut
542
					String statut = personne.get("statut");
625
					String statut = personne.get("statut");
543
					if (statut != null && !statut.equals("")) {
626
					if (statut != null && !statut.equals("")) {
544
						Valeur valeurRecherche = comboLiStatut.getStore().findModel("nom", statut);
627
						Valeur valeurRecherche = comboLiStatut.getStore().findModel("nom", statut);
545
						if (valeurRecherche != null) {
628
						if (valeurRecherche != null) {
546
							personne.setStatut(valeurRecherche.getId());
629
							personne.setStatut(valeurRecherche.getId());
547
						} else {
630
						} else {
548
							personne.setStatut("AUTRE", statut);
631
							personne.setStatut("AUTRE", statut);
549
						}
632
						}
550
					} else {
633
					} else {
551
						personne.setStatut("");
634
						personne.setStatut("");
552
					}
635
					}
553
					
636
					
554
					// Gestion du temps de travail
637
					// Gestion du temps de travail
555
					String personneTravail = "";
638
					String personneTravail = "";
556
					if(personne.get("travail") != null) {
639
					if(personne.get("travail") != null) {
557
						personneTravail = personne.get("travail").toString();
640
						personneTravail = personne.get("travail").toString();
558
					}
641
					}
559
					personne.setBotaTravailHebdoTps(personneTravail);
642
					personne.setBotaTravailHebdoTps(personneTravail);
560
					
643
					
561
					// Gestion du téléphone
644
					// Gestion du téléphone
562
					String telephoneFixe = personne.get("tel_fix");
645
					String telephoneFixe = personne.get("tel_fix");
563
					personne.setTelephoneFixe(telephoneFixe);
646
					personne.setTelephoneFixe(telephoneFixe);
564
					
647
					
565
					// Gestion du fax
648
					// Gestion du fax
566
					String fax = personne.get("tel_fax");
649
					String fax = personne.get("tel_fax");
567
					personne.setFax(fax);
650
					personne.setFax(fax);
568
									
651
									
569
					// Gestion du courriel
652
					// Gestion du courriel
570
					String courriel = personne.get("courriel");
653
					String courriel = personne.get("courriel");
571
					personne.setCourriel(courriel);
654
					personne.setCourriel(courriel);
572
					
655
					
573
					// Gestion de la spécialité
656
					// Gestion de la spécialité
574
					String specialite = personne.get("specialite");
657
					String specialite = personne.get("specialite");
575
					personne.setSpecialite(specialite);
658
					personne.setSpecialite(specialite);
576
					
659
					
577
					// On met à faux le décès
660
					// On met à faux le décès
578
					personne.setDeces(Personne.ETRE_VIVANT);
661
					personne.setDeces(Personne.ETRE_VIVANT);
579
					
662
					
580
					// Ajout de la personne dans la liste correspondant à son état (ajouté ou modifié)
663
					// Ajout de la personne dans la liste correspondant à son état (ajouté ou modifié)
581
					if (personne.get("etat") != null && personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE)) { // Une personne ajoutée
664
					if (personne.get("etat") != null && personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE)) { // Une personne ajoutée						
582
						personnelAjoute.put(""+i, personne);
665
						personnelAjoute.put(""+i, personne);
583
					} else {// Une personne modifiée
666
					} else {// Une personne modifiée
584
						personnelModifie.put(personne.getId(), personne);
667
						personnelModifie.put(personne.getId(), personne);
585
					}
668
					}
586
				} else {
669
				} else {
587
					GWT.log("Personne non modifiées : "+personne.getPrenom()+" "+personne.getNom(), null);
670
					GWT.log("Personne non modifiées : "+personne.getPrenom()+" "+personne.getNom(), null);
588
				}
671
				}
589
			}
672
			}
590
		}
673
		}
591
		
674
		
592
		EtatPersonnelStructure etatPersonnel = new EtatPersonnelStructure();
675
		EtatPersonnelStructure etatPersonnel = new EtatPersonnelStructure();
593
		etatPersonnel.personnelAjoute = personnelAjoute;
676
		etatPersonnel.personnelAjoute = personnelAjoute;
594
		etatPersonnel.personnelModifie = personnelModifie;
677
		etatPersonnel.personnelModifie = personnelModifie;
595
		etatPersonnel.personnelSupprime = personnelSupprime;
678
		etatPersonnel.personnelSupprime = personnelSupprime;
596
		
679
		
597
		// Remise à zéro des modification dans la liste du personnel
680
		// Remise à zéro des modification dans la liste du personnel
598
		personnelModifie = new StructureAPersonneListe();
681
		personnelModifie = new StructureAPersonneListe();
599
		personnelAjoute = new StructureAPersonneListe();
682
		personnelAjoute = new StructureAPersonneListe();
600
		personnelSupprime = new StructureAPersonneListe();
683
		personnelSupprime = new StructureAPersonneListe();
601
		
684
		
602
		return etatPersonnel;
685
		return etatPersonnel;
603
	}
686
	}
604
 
687
 
605
	public void peupler(StructureAPersonneListe personnel) {
688
	public void peupler(StructureAPersonneListe personnel) {
606
		//this.personnel = personnel;
689
		//this.personnel = personnel;
607
		if (formulaireCourant.mode.equals(Formulaire.MODE_MODIFIER) && personnel != null) {
690
		if (formulaireCourant.mode.equals(Formulaire.MODE_MODIFIER) && personnel != null) {
608
			ArrayList<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>();
691
			ArrayList<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>();
609
			for (Iterator<String> it = personnel.keySet().iterator(); it.hasNext();) {
692
			for (Iterator<String> it = personnel.keySet().iterator(); it.hasNext();) {
610
				String index = it.next();
693
				String index = it.next();
611
				
694
				
612
				// Gestion de la fonction
695
				// Gestion de la fonction
613
				if (fonctionsMagazin != null && !((String) personnel.get(index).getFonction()).startsWith("AUTRE##")) {
696
				if (fonctionsMagazin != null && !((String) personnel.get(index).getFonction()).startsWith("AUTRE##")) {
614
					if (fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()) != null) {
697
					if (fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()) != null) {
615
						personnel.get(index).set("fonction", fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()).getNom());
698
						personnel.get(index).set("fonction", fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()).getNom());
616
					}
699
					}
617
				} else {
700
				} else {
618
					personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", ""));
701
					personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", ""));
619
				}
702
				}
620
				
703
				
621
				// Gestion de la notion de "contact"
704
				// Gestion de la notion de "contact"
622
				personnel.get(index).set("contact", (personnel.get(index).getContact().equals("1") ? true : false));
705
				personnel.get(index).set("contact", (personnel.get(index).getContact().equals("1") ? true : false));
623
				
706
				
624
				// Gestion du statut
707
				// Gestion du statut
625
				if (magazinLiStatut != null && ((String) personnel.get(index).getStatut()).matches("^[0-9]+$")) {
708
				if (magazinLiStatut != null && ((String) personnel.get(index).getStatut()).matches("^[0-9]+$")) {
626
					personnel.get(index).set("statut", magazinLiStatut.findModel("id_valeur", personnel.get(index).getStatut()).getNom());
709
					personnel.get(index).set("statut", magazinLiStatut.findModel("id_valeur", personnel.get(index).getStatut()).getNom());
627
				} else {
710
				} else {
628
					personnel.get(index).set("statut", personnel.get(index).getStatut().replaceFirst("AUTRE##", ""));
711
					personnel.get(index).set("statut", personnel.get(index).getStatut().replaceFirst("AUTRE##", ""));
629
				}
712
				}
630
				// Gestion de la specialite
713
				// Gestion de la specialite
631
				if (((String) personnel.get(index).getSpecialite()).matches("^[0-9]+$")) {
714
				if (((String) personnel.get(index).getSpecialite()).matches("^[0-9]+$")) {
632
					// Author : Cyprien
715
					// Author : Cyprien
633
					// TODO
716
					// TODO
634
					// Ici faire un combobox ?
717
					// Ici faire un combobox ?
635
					// ...
718
					// ...
636
				} else {
719
				} else {
637
					personnel.get(index).set("specialite", personnel.get(index).getSpecialite().replaceFirst("AUTRE##", ""));
720
					personnel.get(index).set("specialite", personnel.get(index).getSpecialite().replaceFirst("AUTRE##", ""));
638
				}				
721
				}				
639
				
722
				
640
				// Gestion du temps de travail
723
				// Gestion du temps de travail
641
				String tps = personnel.get(index).getBotaTravailHebdoTps();
724
				String tps = personnel.get(index).getBotaTravailHebdoTps();
642
				personnel.get(index).set("travail", (tps.matches("^[0-9]+$")  ? Integer.parseInt(tps) : 0));
725
				personnel.get(index).set("travail", (tps.matches("^[0-9]+$")  ? Integer.parseInt(tps) : 0));
643
				
726
				
644
				personnes.add(personnel.get(index));
727
				personnes.add(personnel.get(index));
645
			}
728
			}
646
			personnelGrilleMagazin.removeAll();
729
			personnelGrilleMagazin.removeAll();
647
			personnelGrilleMagazin.add(personnes);
730
			personnelGrilleMagazin.add(personnes);
648
			
731
			
649
			// Remise à zéro des modification dans la liste du personnel
732
			// Remise à zéro des modification dans la liste du personnel
650
			personnelModifie = new StructureAPersonneListe();
733
			personnelModifie = new StructureAPersonneListe();
651
			personnelAjoute = new StructureAPersonneListe();
734
			personnelAjoute = new StructureAPersonneListe();
652
			personnelSupprime = new StructureAPersonneListe();
735
			personnelSupprime = new StructureAPersonneListe();
653
			
736
			
654
			// Nous vidons la variable personnel une fois qu'elle a remplie la grille
737
			// Nous vidons la variable personnel une fois qu'elle a remplie la grille
655
			personnel = null;
738
			personnel = null;
656
		}
739
		}
657
	}
740
	}
658
	
741
	
659
	public StructureAPersonneListe getPersonnelAjoute() {
742
	public StructureAPersonneListe getPersonnelAjoute() {
660
		return personnelAjoute;
743
		return personnelAjoute;
661
	}
744
	}
662
	
745
	
663
	private void ajouterMembreAGrillePersonnel(StructureAPersonne personnel) {
746
	private void ajouterMembreAGrillePersonnel(StructureAPersonne personnel) {
664
		grillePersonnel.stopEditing();
747
		grillePersonnel.stopEditing();
665
		personnelGrilleMagazin.insert(personnel, 0);
748
		personnelGrilleMagazin.insert(personnel, 0);
666
		grillePersonnel.startEditing(0, 0);
749
		grillePersonnel.startEditing(0, 0);
667
	}
750
	}
668
	
751
	
669
	public void testerLancementRafraichirPersonnel() {
752
	public void testerLancementRafraichirPersonnel() {
670
		decompteRafraichissementPersonnel--;
753
		decompteRafraichissementPersonnel--;
671
		if (decompteRafraichissementPersonnel <= 0) {
754
		if (decompteRafraichissementPersonnel <= 0) {
672
			// Nous rechargeons la liste du Personnel
755
			// Nous rechargeons la liste du Personnel
673
			rafraichirPersonnel();
756
			rafraichirPersonnel();
674
		}		
757
		}		
675
	}
758
	}
676
	
759
	
677
	private void rafraichirPersonnel() {
760
	private void rafraichirPersonnel() {
678
		decompteRafraichissementPersonnel = 0;
761
		decompteRafraichissementPersonnel = 0;
679
		if (formulaireCourant.mode.equals(Formulaire.MODE_MODIFIER)) {
762
		if (formulaireCourant.mode.equals(Formulaire.MODE_MODIFIER)) {
680
			initialiserGrillePersonnelEnModification();
763
			initialiserGrillePersonnelEnModification();
681
		} else if (formulaireCourant.mode.equals(Formulaire.MODE_AJOUTER)) {
764
		} else if (formulaireCourant.mode.equals(Formulaire.MODE_AJOUTER)) {
682
			initialiserGrillePersonnelEnAjout();
765
			initialiserGrillePersonnelEnAjout();
683
		}
766
		}
684
	}
767
	}
685
	
768
	
686
	private void rafraichirPersonneExistante(String nom) {
769
	private void rafraichirPersonneExistante(String nom) {
687
		mediateur.selectionnerPersonneParNomComplet(this, nom+"%", null); 
770
		mediateur.selectionnerPersonneParNomComplet(this, nom+"%", null); 
688
	}
771
	}
689
	
772
	
690
	public void incrementerDecompteRafraichissementPersonnel() {
773
	public void incrementerDecompteRafraichissementPersonnel() {
691
		decompteRafraichissementPersonnel++;
774
		decompteRafraichissementPersonnel++;
692
	}
775
	}
693
	
776
	
694
	private void initialiserGrillePersonnelEnAjout() {
777
	private void initialiserGrillePersonnelEnAjout() {
695
		personnelGrilleMagazin.removeAll();
778
		personnelGrilleMagazin.removeAll();
696
		layout();
779
		layout();
697
	}
780
	}
698
	
781
	
699
	private String getIdIdentification() {
782
	private String getIdIdentification() {
700
		return ((StructureForm)formulaireCourant).getIdIdentification();
783
		return ((StructureForm)formulaireCourant).getIdIdentification();
701
	}
784
	}
702
	
785
	
703
	private void initialiserGrillePersonnelEnModification() {		
786
	private void initialiserGrillePersonnelEnModification() {		
704
		mediateur.selectionnerStructureAPersonne(this, getIdIdentification(), StructureAPersonne.ROLE_EQUIPE, null);			
787
		mediateur.selectionnerStructureAPersonne(this, getIdIdentification(), StructureAPersonne.ROLE_EQUIPE, null);			
705
	}
788
	}
706
}
789
}