Subversion Repositories eFlore/Applications.coel

Rev

Rev 615 | Rev 639 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 615 Rev 634
Line 89... Line 89...
89
import com.google.gwt.core.client.GWT;
89
import com.google.gwt.core.client.GWT;
90
import com.google.gwt.i18n.client.DateTimeFormat;
90
import com.google.gwt.i18n.client.DateTimeFormat;
91
import com.google.gwt.i18n.client.NumberFormat;
91
import com.google.gwt.i18n.client.NumberFormat;
92
import com.google.gwt.user.client.ui.AbstractImagePrototype;
92
import com.google.gwt.user.client.ui.AbstractImagePrototype;
Line 93... Line 93...
93
 
93
 
Line 94... Line -...
94
public class StructureForm extends LayoutContainer implements Rafraichissable {
-
 
95
	
-
 
96
	public static final String MODE_AJOUTER = "AJOUT";
-
 
97
	public static final String MODE_MODIFIER = "MODIF";
-
 
98
	
-
 
99
	private Constantes i18nC = null;
-
 
100
	private Mediateur mediateur = null;
-
 
101
 
94
public class StructureForm extends Formulaire implements Rafraichissable {
102
	private String mode = null;
95
	
103
	private static Boolean clicBoutonvalidation = false;
-
 
104
	private static int decompteRafraichissementPersonnel = 0;
-
 
105
	private int tabIndex = 100;
-
 
106
	private FormPanel structureFormPanneau = null;
96
	private static Boolean clicBoutonvalidation = false;
107
	private TabPanel onglets = null;
97
	private static int decompteRafraichissementPersonnel = 0;
108
 
98
	
109
	private TabItem identificationOnglet = null;
99
	private TabItem identificationOnglet = null;
110
	private TabItem personnelOnglet = null;
100
	private TabItem personnelOnglet = null;
Line 220... Line 210...
220
	private Button supprimerPersonnelBtn = null;
210
	private Button supprimerPersonnelBtn = null;
221
	private ListStore<Projet> projetsMagazin = null;
211
	private ListStore<Projet> projetsMagazin = null;
222
	private ComboBox<Projet> projetsCombo = null;
212
	private ComboBox<Projet> projetsCombo = null;
223
	private CellEditor fonctionEditor = null;
213
	private CellEditor fonctionEditor = null;
224
	private List<Valeur> fonctionsListe = null;
214
	private List<Valeur> fonctionsListe = null;
225
	private ButtonBar barreOutilsValidation = null;
-
 
226
 
-
 
Line 227... Line 215...
227
 
215
 
228
	public StructureForm(Mediateur mediateurCourrant, String modeDeCreation) {
-
 
229
		//+-----------------------------------------------------------------------------------------------------------+		
-
 
230
		// Initialisation de variables
216
	public StructureForm(Mediateur mediateurCourrant, String modeDeCreation) {
231
		mode = modeDeCreation;
-
 
232
		mediateur = mediateurCourrant;
-
 
233
		i18nC = Mediateur.i18nC;
-
 
234
			
-
 
235
		// Iniatilisation du layoutContainer
-
 
236
		setLayout(new FitLayout());
-
 
237
		setBorders(false);
-
 
238
		
-
 
239
		// Création du panneau du FORMULAIRE GÉNÉRAL
-
 
240
		structureFormPanneau = new FormPanel();
-
 
241
		structureFormPanneau.setBodyBorder(false);
-
 
242
		structureFormPanneau.setFrame(true);
-
 
243
		structureFormPanneau.setIcon(Images.ICONES.formAjouter());  
-
 
244
		structureFormPanneau.setCollapsible(false);  
-
 
245
		structureFormPanneau.setHeading(i18nC.titreAjoutFormStructurePanneau());
-
 
246
		structureFormPanneau.setButtonAlign(HorizontalAlignment.CENTER);  
-
 
247
		structureFormPanneau.setLayout(new FitLayout());
-
 
248
 
-
 
249
		// Création des onglets
217
		super(mediateurCourrant, modeDeCreation);
250
		creerOnglets();
-
 
251
		
-
 
252
		// Ajout des boutons au panneau formulaire
218
		creerOnglets();
253
		creerBarreOutilsValidation();
-
 
254
		
-
 
255
		// Ajout du panneau Formulaire à la disposition générale
219
		creerBarreOutilsValidation();
256
		add(structureFormPanneau);		
220
		add(panneauFormulaire);
Line 257... Line 221...
257
	}
221
	}
258
	
222
	
259
	private void creerOnglets() {
223
	protected void creerOnglets() {
260
		onglets = new TabPanel();
224
		onglets = new TabPanel();
Line 261... Line 225...
261
		// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner) 
225
		// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner) 
Line 275... Line 239...
275
		
239
		
276
		// Sélection de l'onglet par défaut
240
		// Sélection de l'onglet par défaut
Line 277... Line 241...
277
		//onglets.setSelection(personnelOnglet);
241
		//onglets.setSelection(personnelOnglet);
278
		
242
		
279
		// Ajout des onglets au formulaire général
-
 
280
		structureFormPanneau.add(onglets);
-
 
281
	}
-
 
282
	
-
 
283
	private void creerBarreOutilsValidation() {
-
 
284
		barreOutilsValidation = new ButtonBar();
-
 
285
		barreOutilsValidation.setAlignment(HorizontalAlignment.LEFT);
-
 
286
		
-
 
287
		barreOutilsValidation.add(creerBouton(i18nC.reinitialiser(), Images.ICONES.reinitialiser(), "RE"));
-
 
288
		
-
 
289
		barreOutilsValidation.add(new FillToolItem());
-
 
290
		
-
 
291
		barreOutilsValidation.add(creerBouton(i18nC.appliquer(), Images.ICONES.appliquer(), "AP"));
-
 
292
		
-
 
293
		barreOutilsValidation.add(creerBouton(i18nC.annuler(), Images.ICONES.annuler(), "AN"));
-
 
294
		
-
 
295
		barreOutilsValidation.add(creerBouton(i18nC.valider(), Images.ICONES.valider(), "VA"));
-
 
296
		
243
		// Ajout des onglets au formulaire général
Line 297... Line 244...
297
		structureFormPanneau.setBottomComponent(barreOutilsValidation);
244
		panneauFormulaire.add(onglets);
298
	}
245
	}
299
	
246
	
300
	private Button creerBouton(String nom, AbstractImagePrototype icone, final String code) {
247
	protected SelectionListener<ButtonEvent> creerEcouteurBoutonFormulaire(final String code) {
301
		SelectionListener<ButtonEvent> sl = new SelectionListener<ButtonEvent>() {
248
		SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
302
			@Override
249
			@Override
303
			public void componentSelected(ButtonEvent ce) {
250
			public void componentSelected(ButtonEvent ce) {
304
				if (code.equals("VA")) {
251
				if (code.equals(Formulaire.CODE_BOUTON_VALIDER)) {
305
					soumettreFormulaire();
252
					soumettreFormulaire();
306
					clicBoutonvalidation = true;
253
					clicBoutonvalidation = true;
307
				} else if (code.equals("AP")) {
254
				} else if (code.equals(Formulaire.CODE_BOUTON_APPLIQUER)) {
308
					soumettreFormulaire();
255
					soumettreFormulaire();
309
				} else if (code.equals("AN")) {
256
				} else if (code.equals(Formulaire.CODE_BOUTON_ANNULER)) {
310
					mediateur.clicMenu(MenuApplicationId.STRUCTURE);
257
					mediateur.clicMenu(MenuApplicationId.STRUCTURE);
311
				} else if (code.equals("RE")) {
258
				} else if (code.equals(Formulaire.CODE_BOUTON_REINITIALISER)) {
312
					if (mode.equals(StructureForm.MODE_MODIFIER)) {
259
					if (mode.equals(StructureForm.MODE_MODIFIER)) {
313
						mediateur.afficherFormStructure(identification.getId());
260
						mediateur.afficherFormStructure(identification.getId());
314
					} else {
261
					} else {
315
						mediateur.afficherFormStructure(null);
262
						mediateur.afficherFormStructure(null);
316
					}
263
					}
Line 317... Line -...
317
				}
-
 
318
			}
-
 
319
		};
-
 
320
		
-
 
321
		Button bouton = new Button(nom);
264
				}
322
		bouton.setIcon(icone);
265
			}
Line 323... Line 266...
323
		bouton.addSelectionListener(sl);
266
		};
324
		
267
		
325
		return bouton;
268
		return ecouteur;
Line 332... Line 275...
332
			Structure structure = collecterStructureIdentification();
275
			Structure structure = collecterStructureIdentification();
333
			StructureConservation conservation = collecterStructureConservation();
276
			StructureConservation conservation = collecterStructureConservation();
334
			StructureValorisation valorisation = collecterStructureValorisation();
277
			StructureValorisation valorisation = collecterStructureValorisation();
335
			collecterStructurePersonnel();
278
			collecterStructurePersonnel();
Line 336... Line 279...
336
			
279
			
337
			if (mode.equals("AJOUT")) {
280
			if (mode.equals(MODE_AJOUTER)) {
338
				// Ajout des informations sur la Structure
281
				// Ajout des informations sur la Structure
339
				mediateur.ajouterStructure(this, structure, conservation, valorisation);
282
				mediateur.ajouterStructure(this, structure, conservation, valorisation);
340
				// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée
283
				// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée
341
				// Voir la méthode rafraichir().
284
				// Voir la méthode rafraichir().
342
			} else if (mode.equals("MODIF")) {
285
			} else if (mode.equals(MODE_MODIFIER)) {
343
				// Modification des informations sur la Structure
286
				// Modification des informations sur la Structure
344
				if (structure == null && conservation == null && valorisation == null) {
287
				if (structure == null && conservation == null && valorisation == null) {
345
					Info.display("Modification d'une institution", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
288
					Info.display("Modification d'une institution", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
346
				} else {
289
				} else {
Line 484... Line 427...
484
		if (mode.equals(MODE_MODIFIER) && valorisation != null && valorisationOnglet.getData("acces").equals(false)) {
427
		if (mode.equals(MODE_MODIFIER) && valorisation != null && valorisationOnglet.getData("acces").equals(false)) {
485
			// ACTION : 
428
			// ACTION : 
486
			//TODO : check below:
429
			//TODO : check below:
487
			((Radio) actionMarkRGrpChp.get((valorisation.getAction().equals("1") ? 0 : 1))).setValue(true);
430
			((Radio) actionMarkRGrpChp.get((valorisation.getAction().equals("1") ? 0 : 1))).setValue(true);
Line 488... Line -...
488
			
-
 
489
			
431
			
490
			// ACTION INFO
432
			// ACTION INFO
Line 491... Line 433...
491
			peuplerCasesACocher(valorisation.getActionInfo(), actionTrukCacGrpChp, actionAutreChp);
433
			peuplerCasesACocher(valorisation.getActionInfo(), actionTrukCacGrpChp, actionAutreChp);
492
			
434
			
Line 815... Line 757...
815
			identificationOnglet.setData("acces", true);
757
			identificationOnglet.setData("acces", true);
816
		}
758
		}
817
	}
759
	}
Line 818... Line 760...
818
	
760
	
819
	private TabItem creerOngletValorisation() {
-
 
820
		valorisationOnglet = new TabItem();  
761
	private TabItem creerOngletValorisation() {
821
		valorisationOnglet.setText("Valorisation");
-
 
822
		valorisationOnglet.setScrollMode(Scroll.AUTO);
762
		valorisationOnglet = creerOnglet("Valorisation", "valorisation");
823
		valorisationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP));
-
 
824
		valorisationOnglet.setStyleAttribute("padding", "10px");
-
 
825
		valorisationOnglet.setData("acces", false); // Permet de savoir si l'onblet a été accédé par l'utilisateur
763
		valorisationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP));
826
		valorisationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {
764
		Listener<ComponentEvent> ecouteurSelection = new Listener<ComponentEvent>() {  
827
			public void handleEvent(ComponentEvent be) {
765
			public void handleEvent(ComponentEvent be) {  
-
 
766
				peuplerStructureValorisation();
828
				peuplerStructureValorisation();
767
				valorisationOnglet.layout();
829
			}
768
			}  
-
 
769
		};
Line 830... Line 770...
830
		});
770
		valorisationOnglet.addListener(Events.Select, ecouteurSelection);
831
		
771
		
832
		actionMarkRGrpChp = creerChoixUniqueRadioGroupe("action_mark", "ouiNon");
772
		actionMarkRGrpChp = creerChoixUniqueRadioGroupe("action_mark", "ouiNon");
Line 917... Line 857...
917
		
857
		
918
		return valorisationOnglet;
858
		return valorisationOnglet;
Line 919... Line 859...
919
	}
859
	}
920
	
-
 
921
	private TabItem creerOngletConservation() {
860
	
922
		conservationOnglet = new TabItem();
-
 
923
		conservationOnglet.setText("Conservation");
861
	private TabItem creerOngletConservation() {
924
		conservationOnglet.setScrollMode(Scroll.AUTO);
-
 
925
		conservationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP));
-
 
926
		conservationOnglet.setStyleAttribute("padding", "10px");
862
		conservationOnglet = creerOnglet("Conservation", "conservation");
927
		conservationOnglet.setData("acces", false);
863
		conservationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP));
928
		conservationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
864
		Listener<ComponentEvent> ecouteurSelection = new Listener<ComponentEvent>() {  
929
			public void handleEvent(ComponentEvent be) {
865
			public void handleEvent(ComponentEvent be) {  
930
				peuplerStructureConservation();
866
				peuplerStructureConservation();
931
				conservationOnglet.layout();
867
				conservationOnglet.layout();
-
 
868
			}  
Line 932... Line 869...
932
			}  
869
		};
933
		});  
870
		conservationOnglet.addListener(Events.Select, ecouteurSelection);
934
		
871
		
Line 1189... Line 1126...
1189
		// Création des objets contenant les manipulations de la grille
1126
		// Création des objets contenant les manipulations de la grille
1190
		personnelModifie = new StructureAPersonneListe();
1127
		personnelModifie = new StructureAPersonneListe();
1191
		personnelAjoute = new StructureAPersonneListe();
1128
		personnelAjoute = new StructureAPersonneListe();
1192
		personnelSupprime = new StructureAPersonneListe();
1129
		personnelSupprime = new StructureAPersonneListe();
Line 1193... Line -...
1193
		
-
 
1194
		personnelOnglet = new TabItem();
1130
		
1195
		personnelOnglet.setText("Personnel");
-
 
1196
		personnelOnglet.setScrollMode(Scroll.AUTO);
1131
		personnelOnglet = creerOnglet("Personnel", "personnel");
1197
		personnelOnglet.setLayout(creerFormLayout(400, LabelAlign.LEFT));
-
 
1198
		identificationOnglet.setStyleAttribute("padding", "10px");
-
 
1199
		personnelOnglet.setData("acces", false); // Permet de savoir si l'onblet a été accédé par l'utilisateur
1132
		personnelOnglet.setLayout(creerFormLayout(400, LabelAlign.LEFT));
1200
		personnelOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {
1133
		personnelOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
1201
			public void handleEvent(ComponentEvent be) {
1134
			public void handleEvent(ComponentEvent be) {  
1202
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
1135
				// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter...
Line 1203... Line 1136...
1203
				personnelOnglet.setData("acces", true);
1136
				personnelOnglet.setData("acces", true);
1204
 
1137
 
Line 1505... Line 1438...
1505
	}
1438
	}
Line 1506... Line 1439...
1506
	
1439
	
1507
	private TabItem creerOngletIdentification() {
1440
	private TabItem creerOngletIdentification() {
1508
		//+-----------------------------------------------------------------------------------------------------------+
1441
		//+-----------------------------------------------------------------------------------------------------------+
1509
		// Onlget formulaire IDENTIFICATION
-
 
1510
		identificationOnglet = new TabItem();
1442
		// Onlget formulaire IDENTIFICATION
1511
		identificationOnglet.setId("identification");
-
 
1512
		identificationOnglet.setText("Identification");
-
 
1513
		identificationOnglet.setLayout(new FormLayout());
-
 
1514
		identificationOnglet.setStyleAttribute("padding", "10px");
-
 
1515
		identificationOnglet.setScrollMode(Scroll.AUTO);
1443
		identificationOnglet = creerOnglet("Identification", "identification");
1516
		identificationOnglet.setData("acces", false);
1444
		GWT.log(identificationOnglet.getItemId(), null);
1517
		identificationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
1445
		identificationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
1518
			public void handleEvent(ComponentEvent be) {  
1446
			public void handleEvent(ComponentEvent be) {  
1519
				peuplerStructureIdentification();
1447
				peuplerStructureIdentification();
1520
				identificationOnglet.layout();
1448
				identificationOnglet.layout();
Line 1537... Line 1465...
1537
		nomStructureChp.setFieldLabel("Nom de la structure");
1465
		nomStructureChp.setFieldLabel("Nom de la structure");
1538
		nomStructureChp.setAllowBlank(false);
1466
		nomStructureChp.setAllowBlank(false);
1539
		nomStructureChp.getMessages().setBlankText("Ce champ est obligatoire.");
1467
		nomStructureChp.getMessages().setBlankText("Ce champ est obligatoire.");
1540
		fieldSetIdentite.add(nomStructureChp, new FormData(450, 0));
1468
		fieldSetIdentite.add(nomStructureChp, new FormData(450, 0));
Line 1541... Line -...
1541
		
-
 
-
 
1469
		
1542
		mediateur.selectionnerProjets(this);
1470
		
-
 
1471
		projetsMagazin = new ListStore<Projet>();
1543
		projetsMagazin = new ListStore<Projet>();
1472
		mediateur.selectionnerProjets(this);
1544
		projetsCombo = new ComboBox<Projet>();
1473
		projetsCombo = new ComboBox<Projet>();
1545
		projetsCombo.setTabIndex(tabIndex++);
1474
		projetsCombo.setTabIndex(tabIndex++);
1546
		projetsCombo.setFieldLabel("Projet");
1475
		projetsCombo.setFieldLabel("Projet");
1547
		projetsCombo.setLabelSeparator("");
1476
		projetsCombo.setLabelSeparator("");
Line 2043... Line 1972...
2043
			cp.add(conteneur);
1972
			cp.add(conteneur);
2044
		}
1973
		}
2045
		cp.layout();
1974
		cp.layout();
2046
	}
1975
	}
Line 2047... Line 1976...
2047
	
1976
	
2048
	public void rafraichir(Object nouvelleDonnees) {
1977
	public void rafraichir(Object nouvellesDonnees) {
2049
		try {
1978
		try {
2050
			if (nouvelleDonnees instanceof Information) {
1979
			if (nouvellesDonnees instanceof Information) {
2051
				Information info = (Information) nouvelleDonnees;
1980
				Information info = (Information) nouvellesDonnees;
2052
				if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
1981
				if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
2053
					GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
1982
					GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
Line 2054... Line 1983...
2054
				}
1983
				}
Line 2102... Line 2031...
2102
							if (onglets.getSelectedItem().equals(valorisationOnglet)) {
2031
							if (onglets.getSelectedItem().equals(valorisationOnglet)) {
2103
								peuplerStructureValorisation();
2032
								peuplerStructureValorisation();
2104
							}
2033
							}
2105
						}
2034
						}
2106
					}
2035
					}
2107
					structureFormPanneau.setHeading(titre);
2036
					panneauFormulaire.setHeading(titre);
2108
				} else if (info.getType().equals("liste_structure_a_personne")) {
2037
				} else if (info.getType().equals("liste_structure_a_personne")) {
2109
					if (info.getDonnee(0) != null) {
2038
					if (info.getDonnee(0) != null) {
2110
						personnel = (StructureAPersonneListe) info.getDonnee(0);
2039
						personnel = (StructureAPersonneListe) info.getDonnee(0);
Line 2111... Line 2040...
2111
 
2040
 
Line 2134... Line 2063...
2134
						personneExistanteMagazin.add(liste);
2063
						personneExistanteMagazin.add(liste);
2135
						personneExistanteCombo.setStore(personneExistanteMagazin);
2064
						personneExistanteCombo.setStore(personneExistanteMagazin);
2136
						personneExistanteCombo.expand();
2065
						personneExistanteCombo.expand();
2137
					}
2066
					}
2138
				}
2067
				}
2139
			} else if (nouvelleDonnees instanceof ValeurListe) {
2068
			} else if (nouvellesDonnees instanceof ValeurListe) {
2140
				ValeurListe listeValeurs = (ValeurListe) nouvelleDonnees;
2069
				ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
Line 2141... Line 2070...
2141
				
2070
				
Line 2142... Line 2071...
2142
				List<Valeur> liste = listeValeurs.toList();
2071
				List<Valeur> liste = listeValeurs.toList();
2143
 
2072
 
Line 2239... Line 2168...
2239
					}
2168
					}
2240
					//GWT.log("La liste #"+listeValeurs.getId()+" a été reçue!", null);
2169
					//GWT.log("La liste #"+listeValeurs.getId()+" a été reçue!", null);
2241
				} else {
2170
				} else {
2242
					GWT.log("La liste #"+listeValeurs.getId()+" ne contient aucune valeurs!", null);
2171
					GWT.log("La liste #"+listeValeurs.getId()+" ne contient aucune valeurs!", null);
2243
				}
2172
				}
2244
			} else if (nouvelleDonnees instanceof ProjetListe) {
2173
			} else if (nouvellesDonnees instanceof ProjetListe) {
2245
				ProjetListe projets = (ProjetListe) nouvelleDonnees;
2174
				ProjetListe projets = (ProjetListe) nouvellesDonnees;
Line 2246... Line 2175...
2246
				
2175
				
2247
				List<Projet> liste = new ArrayList<Projet>();
2176
				List<Projet> liste = new ArrayList<Projet>();
2248
				for (Iterator<String> it = projets.keySet().iterator(); it.hasNext();) {
2177
				for (Iterator<String> it = projets.keySet().iterator(); it.hasNext();) {
2249
					liste.add(projets.get(it.next()));
2178
					liste.add(projets.get(it.next()));
2250
				}
2179
				}
2251
				projetsMagazin.removeAll();
2180
				projetsMagazin.removeAll();
2252
				projetsMagazin.add(liste);
2181
				projetsMagazin.add(liste);
2253
				projetsCombo.setStore(projetsMagazin);
2182
				projetsCombo.setStore(projetsMagazin);
2254
			} else {
2183
			} else {
2255
				GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null);
2184
				GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
2256
			}
2185
			}
2257
		} catch (Exception e) {
2186
		} catch (Exception e) {
2258
			GWT.log("rafraichir()", e);
2187
			GWT.log("rafraichir()", e);