Subversion Repositories eFlore/Applications.coel

Rev

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

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