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.Date;
4
import java.util.Date;
5
import java.util.Iterator;
5
import java.util.Iterator;
6
import java.util.LinkedList;
6
import java.util.LinkedList;
7
import java.util.List;
7
import java.util.List;
8
 
8
 
9
import org.tela_botanica.client.ComposantClass;
9
import org.tela_botanica.client.ComposantClass;
10
import org.tela_botanica.client.Mediateur;
10
import org.tela_botanica.client.Mediateur;
11
import org.tela_botanica.client.RegistreId;
11
import org.tela_botanica.client.RegistreId;
12
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
12
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
13
import org.tela_botanica.client.composants.GrillePaginable;
13
import org.tela_botanica.client.composants.GrillePaginable;
14
import org.tela_botanica.client.composants.InfoLogger;
14
import org.tela_botanica.client.composants.InfoLogger;
15
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPersonne;
15
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPersonne;
16
import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
16
import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
17
import org.tela_botanica.client.composants.pagination.ProxyStructureAPersonne;
17
import org.tela_botanica.client.composants.pagination.ProxyStructureAPersonne;
18
import org.tela_botanica.client.composants.pagination.ProxyValeur;
18
import org.tela_botanica.client.composants.pagination.ProxyValeur;
19
import org.tela_botanica.client.images.Images;
19
import org.tela_botanica.client.images.Images;
20
import org.tela_botanica.client.interfaces.Rafraichissable;
20
import org.tela_botanica.client.interfaces.Rafraichissable;
21
import org.tela_botanica.client.modeles.Information;
21
import org.tela_botanica.client.modeles.Information;
22
import org.tela_botanica.client.modeles.InterneValeur;
22
import org.tela_botanica.client.modeles.InterneValeur;
23
import org.tela_botanica.client.modeles.InterneValeurListe;
23
import org.tela_botanica.client.modeles.InterneValeurListe;
24
import org.tela_botanica.client.modeles.MenuApplicationId;
24
import org.tela_botanica.client.modeles.MenuApplicationId;
25
import org.tela_botanica.client.modeles.Valeur;
25
import org.tela_botanica.client.modeles.Valeur;
26
import org.tela_botanica.client.modeles.ValeurListe;
26
import org.tela_botanica.client.modeles.ValeurListe;
27
import org.tela_botanica.client.modeles.aDonnee;
27
import org.tela_botanica.client.modeles.aDonnee;
28
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
28
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
29
import org.tela_botanica.client.modeles.personne.Personne;
29
import org.tela_botanica.client.modeles.personne.Personne;
30
import org.tela_botanica.client.modeles.personne.PersonneListe;
30
import org.tela_botanica.client.modeles.personne.PersonneListe;
31
import org.tela_botanica.client.modeles.structure.Structure;
31
import org.tela_botanica.client.modeles.structure.Structure;
32
import org.tela_botanica.client.modeles.structure.StructureAPersonne;
32
import org.tela_botanica.client.modeles.structure.StructureAPersonne;
33
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe;
33
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe;
34
import org.tela_botanica.client.modeles.structure.StructureConservation;
34
import org.tela_botanica.client.modeles.structure.StructureConservation;
35
import org.tela_botanica.client.modeles.structure.StructureValorisation;
35
import org.tela_botanica.client.modeles.structure.StructureValorisation;
36
import org.tela_botanica.client.synchronisation.Sequenceur;
36
import org.tela_botanica.client.synchronisation.Sequenceur;
37
import org.tela_botanica.client.util.Debug;
37
import org.tela_botanica.client.util.Debug;
38
import org.tela_botanica.client.util.Pattern;
38
import org.tela_botanica.client.util.Pattern;
39
import org.tela_botanica.client.util.UtilArray;
39
import org.tela_botanica.client.util.UtilArray;
40
import org.tela_botanica.client.util.UtilString;
40
import org.tela_botanica.client.util.UtilString;
41
import org.tela_botanica.client.vues.Formulaire;
41
import org.tela_botanica.client.vues.Formulaire;
42
import org.tela_botanica.client.vues.structure.StructureFormPersonne.EtatPersonnelStructure;
42
import org.tela_botanica.client.vues.structure.StructureFormPersonne.EtatPersonnelStructure;
43
 
43
 
44
import com.extjs.gxt.ui.client.Style.Scroll;
44
import com.extjs.gxt.ui.client.Style.Scroll;
45
import com.extjs.gxt.ui.client.data.ModelData;
45
import com.extjs.gxt.ui.client.data.ModelData;
46
import com.extjs.gxt.ui.client.data.ModelType;
46
import com.extjs.gxt.ui.client.data.ModelType;
47
import com.extjs.gxt.ui.client.event.Events;
47
import com.extjs.gxt.ui.client.event.Events;
48
import com.extjs.gxt.ui.client.Registry;
48
import com.extjs.gxt.ui.client.Registry;
49
import com.extjs.gxt.ui.client.event.BaseEvent;
49
import com.extjs.gxt.ui.client.event.BaseEvent;
50
import com.extjs.gxt.ui.client.event.ButtonEvent;
50
import com.extjs.gxt.ui.client.event.ButtonEvent;
51
import com.extjs.gxt.ui.client.event.ComponentEvent;
51
import com.extjs.gxt.ui.client.event.ComponentEvent;
52
import com.extjs.gxt.ui.client.event.EventType;
52
import com.extjs.gxt.ui.client.event.EventType;
53
import com.extjs.gxt.ui.client.event.KeyListener;
53
import com.extjs.gxt.ui.client.event.KeyListener;
54
import com.extjs.gxt.ui.client.event.Listener;
54
import com.extjs.gxt.ui.client.event.Listener;
55
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
55
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
56
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
56
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
57
import com.extjs.gxt.ui.client.event.SelectionListener;
57
import com.extjs.gxt.ui.client.event.SelectionListener;
58
import com.extjs.gxt.ui.client.store.ListStore;
58
import com.extjs.gxt.ui.client.store.ListStore;
59
import com.extjs.gxt.ui.client.store.Record;
59
import com.extjs.gxt.ui.client.store.Record;
60
import com.extjs.gxt.ui.client.store.Store;
60
import com.extjs.gxt.ui.client.store.Store;
61
import com.extjs.gxt.ui.client.store.StoreEvent;
61
import com.extjs.gxt.ui.client.store.StoreEvent;
62
import com.extjs.gxt.ui.client.widget.Component;
62
import com.extjs.gxt.ui.client.widget.Component;
63
import com.extjs.gxt.ui.client.widget.ContentPanel;
63
import com.extjs.gxt.ui.client.widget.ContentPanel;
64
import com.extjs.gxt.ui.client.widget.Html;
64
import com.extjs.gxt.ui.client.widget.Html;
65
import com.extjs.gxt.ui.client.widget.Info;
65
import com.extjs.gxt.ui.client.widget.Info;
66
import com.extjs.gxt.ui.client.widget.LayoutContainer;
66
import com.extjs.gxt.ui.client.widget.LayoutContainer;
67
import com.extjs.gxt.ui.client.widget.MessageBox;
67
import com.extjs.gxt.ui.client.widget.MessageBox;
68
import com.extjs.gxt.ui.client.widget.TabItem;
68
import com.extjs.gxt.ui.client.widget.TabItem;
69
import com.extjs.gxt.ui.client.widget.TabPanel;
69
import com.extjs.gxt.ui.client.widget.TabPanel;
70
import com.extjs.gxt.ui.client.widget.button.Button;
70
import com.extjs.gxt.ui.client.widget.button.Button;
71
import com.extjs.gxt.ui.client.widget.form.CheckBox;
71
import com.extjs.gxt.ui.client.widget.form.CheckBox;
72
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
72
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
73
import com.extjs.gxt.ui.client.widget.form.ComboBox;
73
import com.extjs.gxt.ui.client.widget.form.ComboBox;
74
import com.extjs.gxt.ui.client.widget.form.DateField;
74
import com.extjs.gxt.ui.client.widget.form.DateField;
75
import com.extjs.gxt.ui.client.widget.form.Field;
75
import com.extjs.gxt.ui.client.widget.form.Field;
76
import com.extjs.gxt.ui.client.widget.form.FieldSet;
76
import com.extjs.gxt.ui.client.widget.form.FieldSet;
77
import com.extjs.gxt.ui.client.widget.form.HiddenField;
77
import com.extjs.gxt.ui.client.widget.form.HiddenField;
78
import com.extjs.gxt.ui.client.widget.form.LabelField;
78
import com.extjs.gxt.ui.client.widget.form.LabelField;
79
import com.extjs.gxt.ui.client.widget.form.NumberField;
79
import com.extjs.gxt.ui.client.widget.form.NumberField;
80
import com.extjs.gxt.ui.client.widget.form.Radio;
80
import com.extjs.gxt.ui.client.widget.form.Radio;
81
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
81
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
82
import com.extjs.gxt.ui.client.widget.form.TextArea;
82
import com.extjs.gxt.ui.client.widget.form.TextArea;
83
import com.extjs.gxt.ui.client.widget.form.TextField;
83
import com.extjs.gxt.ui.client.widget.form.TextField;
84
import com.extjs.gxt.ui.client.widget.form.Validator;
84
import com.extjs.gxt.ui.client.widget.form.Validator;
85
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
85
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
86
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
86
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
87
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
87
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
88
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
88
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
89
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
89
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
90
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
90
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
91
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
91
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
92
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
92
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
93
import com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig;
93
import com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig;
94
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
94
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
95
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
95
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
96
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
96
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
97
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
97
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
98
import com.extjs.gxt.ui.client.widget.layout.FormData;
98
import com.extjs.gxt.ui.client.widget.layout.FormData;
99
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
99
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
100
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
100
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
101
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
101
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
102
import com.google.gwt.core.client.GWT;
102
import com.google.gwt.core.client.GWT;
103
import com.google.gwt.i18n.client.DateTimeFormat;
103
import com.google.gwt.i18n.client.DateTimeFormat;
104
import com.google.gwt.i18n.client.NumberFormat;
104
import com.google.gwt.i18n.client.NumberFormat;
105
import com.google.gwt.user.client.Window;
105
import com.google.gwt.user.client.Window;
106
 
106
 
107
public class StructureForm extends Formulaire implements Rafraichissable {
107
public class StructureForm extends Formulaire implements Rafraichissable {
108
		
108
		
109
	private TabPanel onglets = null;
109
	private TabPanel onglets = null;
110
	private StructureFormIdentification identificationOnglet = null;
110
	private StructureFormIdentification identificationOnglet = null;
111
	private StructureFormPersonne personnelOnglet = null;
111
	private StructureFormPersonne personnelOnglet = null;
112
	private StructureFormConservation conservationOnglet = null;
112
	private StructureFormConservation conservationOnglet = null;
113
	private StructureFormValorisation valorisationOnglet = null;
113
	private StructureFormValorisation valorisationOnglet = null;
114
	
114
	
115
	// Onglet IDENTIFICATION
115
	// Onglet IDENTIFICATION
116
	public Structure identification = null;
116
	public Structure identification = null;
117
 
117
 
118
	// Onglet PERSONNEL
118
	// Onglet PERSONNEL
119
	// Vide suite à refactoring
119
	// Vide suite à refactoring
120
	
120
	
121
	// Onglet CONSERVATION
121
	// Onglet CONSERVATION
122
	public StructureConservation conservation = null;
122
	public StructureConservation conservation = null;
123
		
123
		
124
	// Onglet VALORISATION
124
	// Onglet VALORISATION
125
	public StructureValorisation valorisation = null;
125
	public StructureValorisation valorisation = null;
126
	
126
	
127
	private Sequenceur sequenceur;
127
	private Sequenceur sequenceur;
128
	
128
	
129
	private Structure structure = null;
129
	public Structure structure = null;
130
	
130
	
131
	public Rafraichissable vueExterneARafraichirApresValidation = null;
131
	public Rafraichissable vueExterneARafraichirApresValidation = null;
132
	
132
	
133
	public StructureForm(Mediateur mediateurCourrant, String modeDeCreation, Sequenceur sequenceur) {
133
	public StructureForm(Mediateur mediateurCourrant, String modeDeCreation, Sequenceur sequenceur) {
134
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.STRUCTURE);
134
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.STRUCTURE);
135
		this.sequenceur = sequenceur;
135
		this.sequenceur = sequenceur;
136
		
136
		
137
		// Ajout du titre
137
		// Ajout du titre
138
		panneauFormulaire.setHeadingHtml(i18nC.titreAjoutFormStructurePanneau());
138
		panneauFormulaire.setHeadingHtml(i18nC.titreAjoutFormStructurePanneau());
139
		// Création des onglets
139
		// Création des onglets
140
		onglets = creerOnglets();
140
		onglets = creerOnglets();
141
		
141
		
142
		// Ajout des onglets au formulaire général
142
		// Ajout des onglets au formulaire général
143
		panneauFormulaire.add(onglets);
143
		panneauFormulaire.add(onglets);
144
	}
144
	}
145
	
145
	
146
	protected TabPanel creerOnglets() {
146
	protected TabPanel creerOnglets() {
147
		TabPanel ongletsStructure = new TabPanel();
147
		TabPanel ongletsStructure = new TabPanel();
148
		// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner) 
148
		// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner) 
149
		ongletsStructure.setHeight("100%");
149
		ongletsStructure.setHeight("100%");
150
		
150
		
151
		// Onlget formulaire IDENTIFICATION
151
		// Onlget formulaire IDENTIFICATION
152
		ongletsStructure.add(creerOngletIdentification());
152
		ongletsStructure.add(creerOngletIdentification());
153
		
153
		
154
		// Onlget formulaire PERSONNEL
154
		// Onlget formulaire PERSONNEL
155
		ongletsStructure.add(creerOngletPersonnel());
155
		ongletsStructure.add(creerOngletPersonnel());
156
		
156
		
157
		// Onlget formulaire CONSERVATION
157
		// Onlget formulaire CONSERVATION
158
		ongletsStructure.add(creerOngletConservation());
158
		ongletsStructure.add(creerOngletConservation());
159
		
159
		
160
		// Onlget formulaire VALORISATION
160
		// Onlget formulaire VALORISATION
161
		ongletsStructure.add(creerOngletValorisation());
161
		ongletsStructure.add(creerOngletValorisation());
162
		
162
		
163
		// Sélection de l'onglet par défaut
163
		// Sélection de l'onglet par défaut
164
		//ongletsStructure(personnelOnglet);
164
		//ongletsStructure(personnelOnglet);
165
		
165
		
166
		return ongletsStructure;
166
		return ongletsStructure;
167
	}
167
	}
168
	
168
	
169
	private void repandreRafraichissement() {
169
	private void repandreRafraichissement() {
170
		if (vueExterneARafraichirApresValidation != null) {
170
		if (vueExterneARafraichirApresValidation != null) {
171
			String type = "structure_modifiee";
171
			String type = "structure_modifiee";
172
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
172
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
173
				type = "structure_ajoutee";
173
				type = "structure_ajoutee";
174
			}
174
			}
175
			Information info = new Information(type);
175
			Information info = new Information(type);
176
			info.setDonnee(0, structure);
176
			info.setDonnee(0, structure);
177
			vueExterneARafraichirApresValidation.rafraichir(info);
177
			vueExterneARafraichirApresValidation.rafraichir(info);
178
		}
178
		}
179
	}
179
	}
180
	
180
	
181
	public boolean soumettreFormulaire() {
181
	public boolean soumettreFormulaire() {
182
		
182
		
183
		// Vérification de la validité des champs du formulaire
183
		// Vérification de la validité des champs du formulaire
184
		boolean fomulaireValide = verifierFormulaire();
184
		boolean fomulaireValide = verifierFormulaire();
185
		
185
		
186
		Structure identification = collecterStructureIdentification();
186
		Structure identification = collecterStructureIdentification();
187
		
187
		
188
		if(identification != null) {
188
		if(identification != null) {
189
			structure = identification;
189
			structure = identification;
190
		} else {
190
		} else {
191
			structure = this.identification;
191
			structure = this.identification;
192
		}
192
		}
193
		
193
		
194
 
194
 
195
		structure.setConservation(this.conservation);
195
		structure.setConservation(this.conservation);
196
		structure.setValorisation(this.valorisation); 
196
		structure.setValorisation(this.valorisation); 
197
		
197
		
198
		if (fomulaireValide) {
198
		if (fomulaireValide) {
199
			// Collecte des données du formulaire
199
			// Collecte des données du formulaire
200
			StructureConservation conservation = collecterStructureConservation();
200
			StructureConservation conservation = collecterStructureConservation();
201
			StructureValorisation valorisation = collecterStructureValorisation();
201
			StructureValorisation valorisation = collecterStructureValorisation();
202
			
202
			
203
			if(conservation != null) {
203
			if(conservation != null) {
204
				structure.setConservation(conservation);
204
				structure.setConservation(conservation);
205
			}
205
			}
206
			
206
			
207
			if(valorisation != null) {
207
			if(valorisation != null) {
208
				structure.setValorisation(valorisation);
208
				structure.setValorisation(valorisation);
209
			}
209
			}
210
			
210
			
211
			EtatPersonnelStructure etatPersonnel = personnelOnglet.collecter();
211
			EtatPersonnelStructure etatPersonnel = personnelOnglet.collecter();
212
			
212
			
213
			structure.setPersonnel(etatPersonnel.personnel);
213
			structure.setPersonnel(etatPersonnel.personnel);
214
			structure.setConservation(conservation);
214
			structure.setConservation(conservation);
215
			structure.setValorisation(valorisation);
215
			structure.setValorisation(valorisation);
216
			
216
			
217
			if (mode.equals(MODE_AJOUTER)) {
217
			if (mode.equals(MODE_AJOUTER)) {
218
				// Ajout des informations sur la Structure
218
				// Ajout des informations sur la Structure
219
				mediateur.ajouterStructure(this, structure, conservation, valorisation);
219
				mediateur.ajouterStructure(this, structure, conservation, valorisation);
220
				// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée
220
				// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée
221
				// Voir la méthode rafraichir().
221
				// Voir la méthode rafraichir().
222
			} else if (mode.equals(MODE_MODIFIER)) {
222
			} else if (mode.equals(MODE_MODIFIER)) {
223
				
223
				
224
				// Modification des informations sur la Structure
224
				// Modification des informations sur la Structure
225
				if (structure == null && conservation == null && valorisation == null) {
225
				if (structure == null && conservation == null && valorisation == null) {
226
					//InfoLogger.display("Modification d'une institution", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
226
					//InfoLogger.display("Modification d'une institution", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
227
				} else {
227
				} else {
228
					mediateur.modifierStructure(this, structure.getId(), structure, conservation, valorisation);
228
					mediateur.modifierStructure(this, structure.getId(), structure, conservation, valorisation);
229
				}
229
				}
230
				
230
				
231
				if (etatPersonnel.personnelModifie.size() == 0 && etatPersonnel.personnelAjoute.size() == 0 && etatPersonnel.personnelSupprime.size() == 0) {
231
				if (etatPersonnel.personnelModifie.size() == 0 && etatPersonnel.personnelAjoute.size() == 0 && etatPersonnel.personnelSupprime.size() == 0) {
232
					//InfoLogger.display("Modification du personnel", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
232
					//InfoLogger.display("Modification du personnel", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
233
				} else {
233
				} else {
234
					if (etatPersonnel.personnelModifie.size() != 0) {
234
					if (etatPersonnel.personnelModifie.size() != 0) {
235
						personnelOnglet.incrementerDecompteRafraichissementPersonnel();
235
						personnelOnglet.incrementerDecompteRafraichissementPersonnel();
236
						mediateur.modifierStructureAPersonne(this, etatPersonnel.personnelModifie);
236
						mediateur.modifierStructureAPersonne(this, etatPersonnel.personnelModifie);
237
					}
237
					}
238
					// Ajout des relations StructureAPersonne
238
					// Ajout des relations StructureAPersonne
239
					if (etatPersonnel.personnelAjoute.size() != 0) {
239
					if (etatPersonnel.personnelAjoute.size() != 0) {
240
						personnelOnglet.incrementerDecompteRafraichissementPersonnel();
240
						personnelOnglet.incrementerDecompteRafraichissementPersonnel();
241
						mediateur.ajouterStructureAPersonne(this, structure.getId(), etatPersonnel.personnelAjoute);
241
						mediateur.ajouterStructureAPersonne(this, structure.getId(), etatPersonnel.personnelAjoute);
242
					}
242
					}
243
					// Suppression des relations StructureAPersonne
243
					// Suppression des relations StructureAPersonne
244
					if (etatPersonnel.personnelSupprime.size() != 0) {
244
					if (etatPersonnel.personnelSupprime.size() != 0) {
245
						personnelOnglet.incrementerDecompteRafraichissementPersonnel();
245
						personnelOnglet.incrementerDecompteRafraichissementPersonnel();
246
						mediateur.supprimerStructureAPersonne(this, etatPersonnel.personnelSupprime);
246
						mediateur.supprimerStructureAPersonne(this, etatPersonnel.personnelSupprime);
247
					}
247
					}
248
				}
248
				}
249
			}
249
			}
250
		}
250
		}
251
		
251
		
252
		return fomulaireValide;
252
		return fomulaireValide;
253
	}
253
	}
254
	
254
	
255
	public boolean verifierFormulaire() {
255
	public boolean verifierFormulaire() {
256
		ArrayList<String> messages = new ArrayList<String>();
256
		ArrayList<String> messages = new ArrayList<String>();
257
		messages.addAll(verifierOnglets());
257
		messages.addAll(verifierOnglets());
258
		
258
		
259
		// Affichage des messages d'alerte
259
		// Affichage des messages d'alerte
260
		if (messages.size() != 0) {
260
		if (messages.size() != 0) {
261
			String[] a = {};
261
			String[] a = {};
262
			a = messages.toArray(a);
262
			a = messages.toArray(a);
263
			MessageBox.alert("Erreurs de saisies", UtilArray.implode(a, "\n\n"), null);
263
			MessageBox.alert("Erreurs de saisies", UtilArray.implode(a, "\n\n"), null);
264
			return false;
264
			return false;
265
		}
265
		}
266
		
266
		
267
		return true;
267
		return true;
268
	}
268
	}
269
		
269
		
270
	private ArrayList<String> verifierOnglets() {
270
	private ArrayList<String> verifierOnglets() {
271
		ArrayList<String> messages = new ArrayList<String>();
271
		ArrayList<String> messages = new ArrayList<String>();
272
		messages.addAll(identificationOnglet.verifier());
272
		messages.addAll(identificationOnglet.verifier());
273
		messages.addAll(personnelOnglet.verifier());
273
		messages.addAll(personnelOnglet.verifier());
274
		return messages;
274
		return messages;
275
	}
275
	}
276
	
276
	
277
	private StructureValorisation collecterStructureValorisation() {
277
	private StructureValorisation collecterStructureValorisation() {
278
		return valorisationOnglet.collecter();
278
		return valorisationOnglet.collecter();
279
	}
279
	}
280
	
280
	
281
	private void peuplerStructureValorisation() {
281
	private void peuplerStructureValorisation() {
282
		valorisationOnglet.peupler();
282
		valorisationOnglet.peupler();
283
	}
283
	}
284
	
284
	
285
	private StructureConservation collecterStructureConservation() {
285
	private StructureConservation collecterStructureConservation() {
286
		return conservationOnglet.collecter();
286
		return conservationOnglet.collecter();
287
	}
287
	}
288
	
288
	
289
	private void peuplerStructureConservation() {
289
	private void peuplerStructureConservation() {
290
		conservationOnglet.peupler();
290
		conservationOnglet.peupler();
291
	}
291
	}
292
	
292
	
293
	private Structure collecterStructureIdentification() {
293
	private Structure collecterStructureIdentification() {
294
		Structure structureARetourner = identificationOnglet.collecter();
294
		Structure structureARetourner = identificationOnglet.collecter();
295
		return structureARetourner;
295
		return structureARetourner;
296
	}
296
	}
297
	
297
	
298
	private TabItem creerOngletValorisation() {
298
	private TabItem creerOngletValorisation() {
299
		valorisationOnglet = new StructureFormValorisation(mediateur, this, sequenceur);
299
		valorisationOnglet = new StructureFormValorisation(mediateur, this, sequenceur);
300
		return valorisationOnglet;
300
		return valorisationOnglet;
301
	}
301
	}
302
	
302
	
303
	private TabItem creerOngletConservation() {
303
	private TabItem creerOngletConservation() {
304
		conservationOnglet = new StructureFormConservation(mediateur, this, sequenceur);
304
		conservationOnglet = new StructureFormConservation(mediateur, this, sequenceur);
305
		return conservationOnglet;
305
		return conservationOnglet;
306
	}
306
	}
307
	
307
	
308
	private EtatPersonnelStructure collecterStructurePersonnel() {
308
	private EtatPersonnelStructure collecterStructurePersonnel() {
309
		return personnelOnglet.collecter();
309
		return personnelOnglet.collecter();
310
	}
310
	}
311
	
311
	
312
	private void peuplerStructurePersonnel(StructureAPersonneListe personnel) {
312
	private void peuplerStructurePersonnel(StructureAPersonneListe personnel) {
313
		personnelOnglet.peupler(personnel);
313
		personnelOnglet.peupler(personnel);
314
	}
314
	}
315
	
315
	
316
	private TabItem creerOngletPersonnel() {
316
	private TabItem creerOngletPersonnel() {
317
		personnelOnglet = new StructureFormPersonne(this, mediateur);
317
		personnelOnglet = new StructureFormPersonne(this, mediateur);
318
		return personnelOnglet;
318
		return personnelOnglet;
319
	}
319
	}
320
	
320
	
321
	private TabItem creerOngletIdentification() {
321
	private TabItem creerOngletIdentification() {
322
		identificationOnglet = new StructureFormIdentification(this);
322
		identificationOnglet = new StructureFormIdentification(this);
323
		return identificationOnglet;
323
		return identificationOnglet;
324
	}
324
	}
325
		
325
		
326
	public void peuplerCasesACocher(String donnees, CheckBoxGroup groupeCac, TextField<String> champAutre) {
326
	public void peuplerCasesACocher(String donnees, CheckBoxGroup groupeCac, TextField<String> champAutre) {
327
		String[] valeurs = donnees.split(";;");
327
		String[] valeurs = donnees.split(";;");
328
		for (int i = 0; i < valeurs.length; i++) {
328
		for (int i = 0; i < valeurs.length; i++) {
329
			if (valeurs[i].startsWith("AUTRE##")) {
329
			if (valeurs[i].startsWith("AUTRE##")) {
330
				champAutre.setValue(valeurs[i].replaceFirst("^AUTRE##", ""));
330
				champAutre.setValue(valeurs[i].replaceFirst("^AUTRE##", ""));
331
			} else {
331
			} else {
332
				//TODO : check : List<CheckBox> cases = groupeCac.getAll();
332
				//TODO : check : List<CheckBox> cases = groupeCac.getAll();
333
				List<Field<?>> cases = groupeCac.getAll();
333
				List<Field<?>> cases = groupeCac.getAll();
334
				for (int j = 0; j < cases.size(); j++) {
334
				for (int j = 0; j < cases.size(); j++) {
335
					if (cases.get(j).getId().equals("val-"+valeurs[i])) {
335
					if (cases.get(j).getId().equals("val-"+valeurs[i])) {
336
						((CheckBox) cases.get(j)).setValue(true);
336
						((CheckBox) cases.get(j)).setValue(true);
337
					}
337
					}
338
				}
338
				}
339
			}
339
			}
340
		}
340
		}
341
	}
341
	}
342
	
342
	
343
	public void peuplerBoutonsRadio(String valeur, RadioGroup groupeBr) {
343
	public void peuplerBoutonsRadio(String valeur, RadioGroup groupeBr) {
344
		//List<Radio> boutons = groupeBr.getAll();
344
		//List<Radio> boutons = groupeBr.getAll();
345
		List<Field<?>> boutons = groupeBr.getAll();
345
		List<Field<?>> boutons = groupeBr.getAll();
346
		String id = valeur+"_"+groupeBr.getName().replace("_grp", "");
346
		String id = valeur+"_"+groupeBr.getName().replace("_grp", "");
347
		for (int i = 0; i < boutons.size(); i++) {
347
		for (int i = 0; i < boutons.size(); i++) {
348
			if (boutons.get(i).getId().equals(id)) {
348
			if (boutons.get(i).getId().equals(id)) {
349
				((Radio) boutons.get(i)).setValue(true);
349
				((Radio) boutons.get(i)).setValue(true);
350
			}
350
			}
351
		}
351
		}
352
	}
352
	}
353
	
353
	
354
	public String creerChaineDenormalisee(List<CheckBox> liste) {
354
	public String creerChaineDenormalisee(List<CheckBox> liste) {
355
		String identifiants = "";
355
		String identifiants = "";
356
		if (liste != null) {
356
		if (liste != null) {
357
			int taille = liste.size();
357
			int taille = liste.size();
358
			for (int i = 0; i < taille; i++) {
358
			for (int i = 0; i < taille; i++) {
359
				CheckBox cac = liste.get(i);
359
				CheckBox cac = liste.get(i);
360
				if (cac.isEnabled()) {
360
				if (cac.isEnabled()) {
361
					identifiants = identifiants.concat(";;"+cac.getData("id"));
361
					identifiants = identifiants.concat(";;"+cac.getData("id"));
362
				}
362
				}
363
			}
363
			}
364
			identifiants.replaceFirst("^;;", "");
364
			identifiants.replaceFirst("^;;", "");
365
		}
365
		}
366
		return identifiants;
366
		return identifiants;
367
	}
367
	}
368
	
368
	
369
	public void afficherChampSupplementaire(Radio radioBtn) {	
369
	public void afficherChampSupplementaire(Radio radioBtn) {	
370
		valorisationOnglet.afficherChampSupplementaire(radioBtn) ;
370
		valorisationOnglet.afficherChampSupplementaire(radioBtn) ;
371
		conservationOnglet.afficherChampSupplementaires(radioBtn);
371
		conservationOnglet.afficherChampSupplementaires(radioBtn);
372
	}
372
	}
373
	
373
	
374
	public void rafraichir(Object nouvellesDonnees) {
374
	public void rafraichir(Object nouvellesDonnees) {
375
		try {
375
		try {
376
			if (nouvellesDonnees instanceof Information) {
376
			if (nouvellesDonnees instanceof Information) {
377
				Information info = (Information) nouvellesDonnees;
377
				Information info = (Information) nouvellesDonnees;
378
				rafraichirInformation(info);
378
				rafraichirInformation(info);
379
				if(!info.getType().equals("selection_structure") && !info.getType().equals("selection_structure")) {
379
				if(!info.getType().equals("selection_structure") && !info.getType().equals("selection_structure")) {
380
					repandreRafraichissement();
380
					repandreRafraichissement();
381
				}
381
				}
382
			} else if (nouvellesDonnees instanceof ValeurListe) {
382
			} else if (nouvellesDonnees instanceof ValeurListe) {
383
				ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
383
				ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
384
				rafraichirValeurListe(listeValeurs);
384
				rafraichirValeurListe(listeValeurs);
385
			} else {
385
			} else {
386
				GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
386
				GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
387
			}
387
			}
388
		} catch (Exception e) {
388
		} catch (Exception e) {
389
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), e);
389
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), e);
390
		}
390
		}
391
		
391
		
392
		controlerFermeture();
392
		controlerFermeture();
393
	}
393
	}
394
	
394
	
395
	public void rafraichirInformation(Information info) {		
395
	public void rafraichirInformation(Information info) {		
396
		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
396
		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
397
			GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
397
			GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
398
		}
398
		}
399
		
399
		
400
		if (info.getType().equals("modif_structure")) {
400
		if (info.getType().equals("modif_structure")) {
401
			InfoLogger.display("Modification d'une institution", info.toString());
401
			InfoLogger.display("Modification d'une institution", info.toString());
402
			Structure structureMaj = (Structure)(info.getDonnee(0));
402
			Structure structureMaj = (Structure)(info.getDonnee(0));
403
			if(structureMaj != null) {
403
			if(structureMaj != null) {
404
				// TRUE uniquement si la modification a retourné un objet JSON pour mise à jour
404
				// TRUE uniquement si la modification a retourné un objet JSON pour mise à jour
405
				// (contenant les coordonnées générées, cf r1673)
405
				// (contenant les coordonnées générées, cf r1673)
406
				structure.setLatitude(structureMaj.getLatitude());
406
				structure.setLatitude(structureMaj.getLatitude());
407
				structure.setLongitude(structureMaj.getLongitude());
407
				structure.setLongitude(structureMaj.getLongitude());
408
			}
408
			}
409
			
409
			
410
			controlerFermeture();
410
			controlerFermeture();
411
		} else if (info.getType().equals("ajout_structure")) {
411
		} else if (info.getType().equals("ajout_structure")) {
412
			if (info.getDonnee(0) != null && ( info.getDonnee(0) instanceof String || info.getDonnee(0) instanceof Object) ) {
412
			if (info.getDonnee(0) != null && ( info.getDonnee(0) instanceof String || info.getDonnee(0) instanceof Object) ) {
413
				this.mode = MODE_MODIFIER;
413
				this.mode = MODE_MODIFIER;
414
				String structureId;
414
				String structureId;
415
 
415
 
416
				if(info.getDonnee(0) instanceof String) {
416
				if(info.getDonnee(0) instanceof String) {
417
					structureId = (String) info.getDonnee(0);
417
					structureId = (String) info.getDonnee(0);
418
				}
418
				}
419
				else {
419
				else {
420
					// le backend renvoie un objet si longitude et latitude ont
420
					// le backend renvoie un objet si longitude et latitude ont
421
					// été générés
421
					// été générés
422
					Structure structureMaj = (Structure)(info.getDonnee(0));
422
					Structure structureMaj = (Structure)(info.getDonnee(0));
423
					// structureMaj == null ? erreur horriblement impensable
423
					// structureMaj == null ? erreur horriblement impensable
424
					structure.setLatitude(structureMaj.getLatitude());
424
					structure.setLatitude(structureMaj.getLatitude());
425
					structure.setLongitude(structureMaj.getLongitude());
425
					structure.setLongitude(structureMaj.getLongitude());
426
					structureId = structureMaj.getId();
426
					structureId = structureMaj.getId();
427
				}
427
				}
428
 
428
 
429
				structure.setId(structureId);
429
				structure.setId(structureId);
430
				identification = structure;
430
				identification = structure;
431
				identificationOnglet.rafraichir(info);
431
				identificationOnglet.rafraichir(info);
432
				personnelOnglet.rafraichir(info);
432
				personnelOnglet.rafraichir(info);
433
				conservationOnglet.rafraichir(info);
433
				conservationOnglet.rafraichir(info);
434
				valorisationOnglet.rafraichir(info);
434
				valorisationOnglet.rafraichir(info);
435
				InfoLogger.display("Ajout d'une Institution", "L'intitution '"+structureId+"' a bien été ajoutée");
435
				InfoLogger.display("Ajout d'une Institution", "L'intitution '"+structureId+"' a bien été ajoutée");
436
			} else {
436
			} else {
437
				InfoLogger.display("Ajout d'une Institution", info.toString());
437
				InfoLogger.display("Ajout d'une Institution", info.toString());
438
			}
438
			}
439
		} else if (info.getType().equals("modif_structure_a_personne")) {
439
		} else if (info.getType().equals("modif_structure_a_personne")) {
440
			InfoLogger.display("Modification du Personnel", info.toString());
440
			InfoLogger.display("Modification du Personnel", info.toString());
441
			personnelOnglet.rafraichir(info);
441
			personnelOnglet.rafraichir(info);
442
		} else if (info.getType().equals("suppression_structure_a_personne")) {
442
		} else if (info.getType().equals("suppression_structure_a_personne")) {
443
			InfoLogger.display("Suppression du Personnel", info.toString());
443
			InfoLogger.display("Suppression du Personnel", info.toString());
444
			personnelOnglet.rafraichir(info);
444
			personnelOnglet.rafraichir(info);
445
		} else if (info.getType().equals("ajout_structure_a_personne")) {
445
		} else if (info.getType().equals("ajout_structure_a_personne")) {
446
			InfoLogger.display("Ajout du Personnel", info.toString());
446
			InfoLogger.display("Ajout du Personnel", info.toString());
447
			personnelOnglet.rafraichir(info);
447
			personnelOnglet.rafraichir(info);
448
		} else if (info.getType().equals("selection_structure")) {
448
		} else if (info.getType().equals("selection_structure")) {
449
			InfoLogger.display("Modification d'une institution", info.toString());
449
			InfoLogger.display("Modification d'une institution", info.toString());
450
			String titre = i18nC.titreModifFormStructurePanneau();
450
			String titre = i18nC.titreModifFormStructurePanneau();
451
			if (info.getDonnee(0) != null) {
451
			if (info.getDonnee(0) != null) {
452
				identification = (Structure)info.getDonnee(0);
452
				identification = (Structure)info.getDonnee(0);
453
				identificationOnglet.rafraichir(info);
453
				identificationOnglet.rafraichir(info);
454
				// Composition du titre
454
				// Composition du titre
455
				titre += " - ID : "+identification.getId();
455
				titre += " - ID : "+identification.getId();
456
			}
456
			}
457
			if (info.getDonnee(1) != null) {
457
			if (info.getDonnee(1) != null) {
458
				conservation = (StructureConservation)info.getDonnee(1);
458
				conservation = (StructureConservation)info.getDonnee(1);
459
				conservationOnglet.rafraichir(info);
459
				conservationOnglet.rafraichir(info);
460
			}
460
			}
461
			if (info.getDonnee(2) != null) {
461
			if (info.getDonnee(2) != null) {
462
				valorisation = (StructureValorisation)info.getDonnee(2);
462
				valorisation = (StructureValorisation)info.getDonnee(2);
463
				valorisationOnglet.rafraichir(info);
463
				valorisationOnglet.rafraichir(info);
464
			}
464
			}
465
		} else if (info.getType().equals("liste_structure_a_personne")) {
465
		} else if (info.getType().equals("liste_structure_a_personne")) {
466
				personnelOnglet.rafraichir(info);
466
				personnelOnglet.rafraichir(info);
467
		}
467
		}
468
	}
468
	}
469
	
469
	
470
	public void rafraichirValeurListe(ValeurListe listeValeurs) {
470
	public void rafraichirValeurListe(ValeurListe listeValeurs) {
471
		List<Valeur> liste = listeValeurs.toList();
471
		List<Valeur> liste = listeValeurs.toList();
472
 
472
 
473
		// Test pour savoir si la liste contient des éléments
473
		// Test pour savoir si la liste contient des éléments
474
		if (liste.size() > 0) {
474
		if (liste.size() > 0) {
475
			identificationOnglet.rafraichir(listeValeurs);
475
			identificationOnglet.rafraichir(listeValeurs);
476
			personnelOnglet.rafraichir(listeValeurs);
476
			personnelOnglet.rafraichir(listeValeurs);
477
			conservationOnglet.rafraichir(listeValeurs);
477
			conservationOnglet.rafraichir(listeValeurs);
478
			valorisationOnglet.rafraichir(listeValeurs);
478
			valorisationOnglet.rafraichir(listeValeurs);
479
			//GWT.log("La liste #"+listeValeurs.getId()+" a été reçue!", null);
479
			//GWT.log("La liste #"+listeValeurs.getId()+" a été reçue!", null);
480
		} else {
480
		} else {
481
			GWT.log("La liste #"+listeValeurs.getId()+" ne contient aucune valeurs!", null);
481
			GWT.log("La liste #"+listeValeurs.getId()+" ne contient aucune valeurs!", null);
482
		}
482
		}
483
	}
483
	}
484
 
484
 
485
	public String getIdIdentification() {
485
	public String getIdIdentification() {
486
		return identification.getId();
486
		return identification.getId();
487
	}
487
	}
488
}
488
}