Subversion Repositories eFlore/Applications.coel

Rev

Rev 1680 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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