Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 164 Rev 172
Line 2... Line 2...
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.Iterator;
4
import java.util.Iterator;
Line -... Line 5...
-
 
5
import java.util.List;
5
import java.util.List;
6
 
6
 
7
import org.tela_botanica.client.ComposantId;
7
import org.tela_botanica.client.Mediateur;
8
import org.tela_botanica.client.Mediateur;
8
import org.tela_botanica.client.Modele;
9
import org.tela_botanica.client.Modele;
9
import org.tela_botanica.client.RegistreId;
10
import org.tela_botanica.client.RegistreId;
Line 27... Line 28...
27
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
28
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
28
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
29
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
29
import com.extjs.gxt.ui.client.event.SelectionListener;
30
import com.extjs.gxt.ui.client.event.SelectionListener;
30
import com.extjs.gxt.ui.client.event.ToolBarEvent;
31
import com.extjs.gxt.ui.client.event.ToolBarEvent;
31
import com.extjs.gxt.ui.client.store.ListStore;
32
import com.extjs.gxt.ui.client.store.ListStore;
-
 
33
import com.extjs.gxt.ui.client.store.Store;
32
import com.extjs.gxt.ui.client.widget.Component;
34
import com.extjs.gxt.ui.client.widget.Component;
33
import com.extjs.gxt.ui.client.widget.ContentPanel;
35
import com.extjs.gxt.ui.client.widget.ContentPanel;
34
import com.extjs.gxt.ui.client.widget.Info;
36
import com.extjs.gxt.ui.client.widget.Info;
35
import com.extjs.gxt.ui.client.widget.LayoutContainer;
37
import com.extjs.gxt.ui.client.widget.LayoutContainer;
36
import com.extjs.gxt.ui.client.widget.TabItem;
38
import com.extjs.gxt.ui.client.widget.TabItem;
Line 41... Line 43...
41
import com.extjs.gxt.ui.client.widget.form.ComboBox;
43
import com.extjs.gxt.ui.client.widget.form.ComboBox;
42
import com.extjs.gxt.ui.client.widget.form.DateField;
44
import com.extjs.gxt.ui.client.widget.form.DateField;
43
import com.extjs.gxt.ui.client.widget.form.Field;
45
import com.extjs.gxt.ui.client.widget.form.Field;
44
import com.extjs.gxt.ui.client.widget.form.FieldSet;
46
import com.extjs.gxt.ui.client.widget.form.FieldSet;
45
import com.extjs.gxt.ui.client.widget.form.FormPanel;
47
import com.extjs.gxt.ui.client.widget.form.FormPanel;
-
 
48
import com.extjs.gxt.ui.client.widget.form.HiddenField;
46
import com.extjs.gxt.ui.client.widget.form.LabelField;
49
import com.extjs.gxt.ui.client.widget.form.LabelField;
47
import com.extjs.gxt.ui.client.widget.form.NumberField;
50
import com.extjs.gxt.ui.client.widget.form.NumberField;
48
import com.extjs.gxt.ui.client.widget.form.Radio;
51
import com.extjs.gxt.ui.client.widget.form.Radio;
49
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
52
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
50
import com.extjs.gxt.ui.client.widget.form.TextArea;
53
import com.extjs.gxt.ui.client.widget.form.TextArea;
Line 139... Line 142...
139
	private DateField dateFondationChp;
142
	private DateField dateFondationChp;
140
	private TextArea adrChp;
143
	private TextArea adrChp;
141
	private TextField<String> cpChp;
144
	private TextField<String> cpChp;
142
	private TextField<String> villeChp;
145
	private TextField<String> villeChp;
143
	private TextField<String> regionChp;
146
	private TextField<String> regionChp;
144
	private TextField<String> paysChp;
-
 
145
	private TextField<String> telChp;
147
	private TextField<String> telChp;
146
	private TextField<String> faxChp;
148
	private TextField<String> faxChp;
147
	private TextField<String> emailChp;
149
	private TextField<String> emailChp;
148
	private TextField<String> urlChp;
150
	private TextField<String> urlChp;
149
	private ListStore<Valeur> magazinPays;
151
	private ListStore<Valeur> magazinPays;
150
	private ComboBox<Valeur> comboPays;
152
	private ComboBox<Valeur> comboPays;
-
 
153
	private HiddenField<String> idStructureChp;
Line 151... Line 154...
151
	
154
	
152
	public FormStructureVue() {
155
	public FormStructureVue() {
153
		//+-----------------------------------------------------------------------------------------------------------+		
156
		//+-----------------------------------------------------------------------------------------------------------+		
154
		// Initialisation de variables
157
		// Initialisation de variables
Line 197... Line 200...
197
		// Ajout des onglets au formulaire général
200
		// Ajout des onglets au formulaire général
198
		structureFormPanneau.add(onglets);
201
		structureFormPanneau.add(onglets);
Line 199... Line 202...
199
		
202
		
200
		// Ajout des boutons au panneau formulaire
203
		// Ajout des boutons au panneau formulaire
-
 
204
		Button annulerBtn = new Button("Annuler");
-
 
205
		annulerBtn.addSelectionListener(new SelectionListener<ComponentEvent>() {
-
 
206
 
-
 
207
			@Override
-
 
208
			public void componentSelected(ComponentEvent ce) {
-
 
209
				mediateur.clicMenu("Institutions");
-
 
210
			}
-
 
211
			
201
		Button annulerBtn = new Button("Annuler");
212
		});
202
		structureFormPanneau.addButton(annulerBtn);
213
		structureFormPanneau.addButton(annulerBtn);
203
		Button validerBtn = new Button("Valider");
214
		Button validerBtn = new Button("Valider");
Line 204... Line 215...
204
		validerBtn.addSelectionListener(new SelectionListener<ComponentEvent>() {
215
		validerBtn.addSelectionListener(new SelectionListener<ComponentEvent>() {
Line 218... Line 229...
218
	private void soumettreFormulaire() {
229
	private void soumettreFormulaire() {
219
		GWT.log("Soumission du formulaire", null);
230
		GWT.log("Soumission du formulaire", null);
220
		Structure structure = collecterDonnees();
231
		Structure structure = collecterDonnees();
221
		if (mode == "AJOUT") {
232
		if (mode == "AJOUT") {
222
			//mediateur.ajouterStructure(this, structure);
233
			//mediateur.ajouterStructure(this, structure);
223
			GWT.log(structure.toString(), null);
234
			GWT.log("Structure non ajouté :"+structure.toString(), null);
224
		} else if (mode == "MODIF") {
235
		} else if (mode == "MODIF") {
225
			mediateur.modifierStructure(this, structure);
236
			mediateur.modifierStructure(this, structure);
226
		}
237
		}
227
	}
238
	}
Line 228... Line 239...
228
	
239
	
229
	private Structure collecterDonnees() {
240
	private Structure collecterDonnees() {
-
 
241
		Structure structure = new Structure();
230
		Structure structure = new Structure();
242
		structure.setId(idStructureChp.getValue());
231
		structure.setNom(nomStructureChp.getValue());
243
		structure.setNom(nomStructureChp.getValue());
232
		// Récupération de l'acronyme (= identifiant alternatif)
244
		// Récupération de l'acronyme (= identifiant alternatif)
233
		structure.setIdAlternatif(null);
245
		structure.setIdAlternatif(null);
234
		if (comboAcronyme.getValue() != null) {
246
		if (comboAcronyme.getValue() != null) {
Line 259... Line 271...
259
		structure.setVille(villeChp.getValue());
271
		structure.setVille(villeChp.getValue());
260
		structure.setRegion(regionChp.getValue());
272
		structure.setRegion(regionChp.getValue());
261
		structure.setPays(null);
273
		structure.setPays(null);
262
		if (comboPays.getValue() != null) {
274
		if (comboPays.getValue() != null) {
263
			structure.setPays(comboPays.getValue().getAbreviation());
275
			structure.setPays(comboPays.getValue().getAbreviation());
-
 
276
		} else if (comboPays.getRawValue() != "") {
-
 
277
			structure.setPays(comboPays.getRawValue());
264
		}
278
		}
Line 265... Line 279...
265
		
279
		
266
		structure.setTelephone(telChp.getValue());
280
		structure.setTelephone(telChp.getValue());
267
		structure.setFax(faxChp.getValue());
281
		structure.setFax(faxChp.getValue());
Line 270... Line 284...
270
		
284
		
271
		return structure;
285
		return structure;
Line 272... Line 286...
272
	}
286
	}
-
 
287
	
273
	
288
	private void peuplerFormulaire(Structure str) {
-
 
289
		idStructureChp.setValue(str.getId());
-
 
290
		nomStructureChp.setValue(str.getNom());
-
 
291
		if (!str.getTypePrive().isEmpty()) {
-
 
292
			if (str.getTypePrive().matches("^[0-9]+$")) {
-
 
293
				comboTypeStructure.setValue(InterneValeurListe.getTypePrivee());
-
 
294
				comboLstpr.setValue(comboLstpr.getStore().findModel("id_valeur", str.getTypePrive()));
-
 
295
			}
-
 
296
		} else if (!str.getTypePublic().isEmpty()) {
-
 
297
			if (str.getTypePublic().matches("^[0-9]+$")) {
-
 
298
				comboTypeStructure.setValue(InterneValeurListe.getTypePublique());
-
 
299
				comboLstpu.setValue(comboLstpu.getStore().findModel("id_valeur", str.getTypePublic()));
274
	private void peuplerFormulaire(Structure str) {
300
			}
Line 275... Line 301...
275
		nomStructureChp.setValue(str.getNom());
301
		}
276
		dateFondationChp.setValue(str.getDateFondation());
302
		dateFondationChp.setValue(str.getDateFondation());
277
		
303
		
278
		adrChp.setValue(str.getAdresse());
304
		adrChp.setValue(str.getAdresse());
-
 
305
		cpChp.setValue(str.getCodePostal());
-
 
306
		villeChp.setValue(str.getVille());
-
 
307
		regionChp.setValue(str.getRegion());
279
		cpChp.setValue(str.getCodePostal());
308
		if (str.getPays().matches("^[A-Z]{2}$")) {
-
 
309
			comboPays.setValue(comboPays.getStore().findModel("abreviation", str.getPays()));
Line 280... Line 310...
280
		villeChp.setValue(str.getVille());
310
		} else {
281
		regionChp.setValue(str.getRegion());
311
			comboPays.setRawValue(str.getPays());
282
		paysChp.setValue(str.getPays());
312
		}
283
		
313
		
Line 695... Line 725...
695
		TabItem identificationOnglet = new TabItem();  
725
		TabItem identificationOnglet = new TabItem();  
696
		identificationOnglet.setText("Identification");  
726
		identificationOnglet.setText("Identification");  
697
		identificationOnglet.setLayout(new FormLayout());
727
		identificationOnglet.setLayout(new FormLayout());
Line 698... Line 728...
698
 
728
 
-
 
729
		//+-----------------------------------------------------------------------------------------------------------+
-
 
730
		// Champs cachés
-
 
731
		idStructureChp = new HiddenField<String>();
-
 
732
		
699
		//+-----------------------------------------------------------------------------------------------------------+
733
		//+-----------------------------------------------------------------------------------------------------------+
700
		// Fieldset IDENTITÉ
734
		// Fieldset IDENTITÉ
701
		FieldSet fieldSetIdentite = new FieldSet();
735
		FieldSet fieldSetIdentite = new FieldSet();
702
		fieldSetIdentite.setHeading("Identité");
736
		fieldSetIdentite.setHeading("Identité");
703
		fieldSetIdentite.setCollapsible(true);
737
		fieldSetIdentite.setCollapsible(true);
Line 896... Line 930...
896
		magazinPays = new ListStore<Valeur>();
930
		magazinPays = new ListStore<Valeur>();
897
		magazinPays.add(new ArrayList<Valeur>());
931
		magazinPays.add(new ArrayList<Valeur>());
898
		comboPays = new ComboBox<Valeur>();
932
		comboPays = new ComboBox<Valeur>();
899
		comboPays.setTabIndex(112);
933
		comboPays.setTabIndex(112);
900
		comboPays.setFieldLabel("Pays");
934
		comboPays.setFieldLabel("Pays");
-
 
935
		comboPays.setEmptyText("Sélectioner un pays...");
901
		comboPays.setEditable(true);
936
		comboPays.setEditable(true);
902
		//comboLstpu.setFieldLabel("Statut des structures publiques");
-
 
903
		comboPays.setLabelSeparator("");
937
		comboPays.setLabelSeparator("");
904
		comboPays.setDisplayField("nom");
938
		comboPays.setDisplayField("nom");
-
 
939
		comboPays.setTemplate(getTemplatePays());
905
		comboPays.setEditable(false);
940
		comboPays.setTypeAhead(true);
906
		comboPays.setTriggerAction(TriggerAction.ALL);
941
		comboPays.setTriggerAction(TriggerAction.ALL);
907
		comboPays.setStore(magazinPays);
942
		comboPays.setStore(magazinPays);
908
		droiteFdAdresse.add(comboPays);
943
		droiteFdAdresse.add(comboPays);
Line 909... Line 944...
909
		
944
		
Line 956... Line 991...
956
		identificationOnglet.add(fieldSetTelMail);
991
		identificationOnglet.add(fieldSetTelMail);
Line 957... Line 992...
957
		
992
		
958
		return identificationOnglet;
993
		return identificationOnglet;
Line -... Line 994...
-
 
994
	}
-
 
995
	
-
 
996
	private native String getTemplatePays() /*-{ 
-
 
997
		return  [ 
-
 
998
		'<tpl for=".">', 
-
 
999
		'<div class="x-combo-list-item">{nom} ({abreviation})</div>', 
-
 
1000
		'</tpl>' 
-
 
1001
		].join(""); 
959
	}
1002
		}-*/;
960
	
1003
	
961
	/** Méthode simplifiant la création de FormLayout.
1004
	/** Méthode simplifiant la création de FormLayout.
962
	 * Chacun des paramètres peut prendre la valeur null pour utiliser la valeur par défaut.
1005
	 * Chacun des paramètres peut prendre la valeur null pour utiliser la valeur par défaut.
963
	 * 
1006
	 * 
Line 1146... Line 1189...
1146
		if (nouvelleDonnees instanceof Information) {
1189
		if (nouvelleDonnees instanceof Information) {
1147
			Information info = (Information) nouvelleDonnees;
1190
			Information info = (Information) nouvelleDonnees;
1148
			if (info.getMessages() != null) {
1191
			if (info.getMessages() != null) {
1149
				GWT.log(info.getMessages().toString(), null);
1192
				GWT.log(info.getMessages().toString(), null);
1150
			}
1193
			}
1151
			if (info.getType().equals("ajout_structure")) {
1194
			if (info.getType().equals("modif_structure")) {
-
 
1195
				Info.display("Modification d'une institution", info.toString());
-
 
1196
			} else if (info.getType().equals("ajout_structure")) {
1152
				Info.display("Ajout d'une Institution", info.toString());
1197
				Info.display("Ajout d'une Institution", info.toString());
1153
			} else if (info.getType().equals("selection_structure")) {
1198
			} else if (info.getType().equals("selection_structure")) {
1154
				Info.display("Modification d'une Institution", info.toString());
1199
				Info.display("Modification d'une institution", info.toString());
1155
				Structure str = (Structure) info.getDonnee(0);
1200
				Structure str = (Structure) info.getDonnee(0);
1156
				mode = "MODIF";
1201
				mode = "MODIF";
-
 
1202
				GWT.log(mode, null);
1157
				structureFormPanneau.setHeading(i18nC.titreModifFormStructurePanneau());
1203
				structureFormPanneau.setHeading(i18nC.titreModifFormStructurePanneau()+" - ID : "+str.getId());
1158
				peuplerFormulaire(str);
1204
				peuplerFormulaire(str);
1159
			}
1205
			}
1160
		} else if (nouvelleDonnees instanceof ValeurListe) {
1206
		} else if (nouvelleDonnees instanceof ValeurListe) {
1161
			ValeurListe listeValeurs = (ValeurListe) nouvelleDonnees;
1207
			ValeurListe listeValeurs = (ValeurListe) nouvelleDonnees;