Subversion Repositories eFlore/Applications.coel

Rev

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

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