Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1322 Rev 1329
Line 4... Line 4...
4
 
4
 
5
import org.tela_botanica.client.ComposantClass;
5
import org.tela_botanica.client.ComposantClass;
6
import org.tela_botanica.client.Mediateur;
6
import org.tela_botanica.client.Mediateur;
7
import org.tela_botanica.client.composants.ChampCaseACocher;
7
import org.tela_botanica.client.composants.ChampCaseACocher;
-
 
8
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
8
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
9
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
-
 
10
import org.tela_botanica.client.composants.ChampMultiValeurs;
9
import org.tela_botanica.client.composants.ChampMultiValeurs;
11
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypesPaginable;
-
 
12
import org.tela_botanica.client.composants.ConteneurMultiChamps;
-
 
13
import org.tela_botanica.client.composants.pagination.ProxyCollections;
-
 
14
import org.tela_botanica.client.composants.pagination.ProxyProjets;
-
 
15
import org.tela_botanica.client.composants.pagination.ProxyStructures;
10
import org.tela_botanica.client.composants.ConteneurMultiChamps;
16
import org.tela_botanica.client.composants.pagination.ProxyValeur;
11
import org.tela_botanica.client.interfaces.Rafraichissable;
17
import org.tela_botanica.client.interfaces.Rafraichissable;
12
import org.tela_botanica.client.modeles.ValeurListe;
18
import org.tela_botanica.client.modeles.ValeurListe;
13
import org.tela_botanica.client.modeles.collection.Collection;
19
import org.tela_botanica.client.modeles.collection.Collection;
14
import org.tela_botanica.client.modeles.collection.CollectionListe;
20
import org.tela_botanica.client.modeles.collection.CollectionListe;
Line 18... Line 24...
18
import org.tela_botanica.client.modeles.structure.StructureListe;
24
import org.tela_botanica.client.modeles.structure.StructureListe;
19
import org.tela_botanica.client.util.Debug;
25
import org.tela_botanica.client.util.Debug;
20
import org.tela_botanica.client.vues.Formulaire;
26
import org.tela_botanica.client.vues.Formulaire;
21
import org.tela_botanica.client.vues.FormulaireOnglet;
27
import org.tela_botanica.client.vues.FormulaireOnglet;
Line -... Line 28...
-
 
28
 
-
 
29
import com.extjs.gxt.ui.client.data.ModelData;
22
 
30
import com.extjs.gxt.ui.client.data.ModelType;
23
import com.extjs.gxt.ui.client.event.BaseEvent;
31
import com.extjs.gxt.ui.client.event.BaseEvent;
24
import com.extjs.gxt.ui.client.event.Events;
32
import com.extjs.gxt.ui.client.event.Events;
25
import com.extjs.gxt.ui.client.event.Listener;
33
import com.extjs.gxt.ui.client.event.Listener;
26
import com.extjs.gxt.ui.client.store.ListStore;
34
import com.extjs.gxt.ui.client.store.ListStore;
Line 45... Line 53...
45
	private Collection collection = null;
53
	private Collection collection = null;
46
	private Collection collectionCollectee = null;
54
	private Collection collectionCollectee = null;
Line 47... Line 55...
47
 
55
 
Line 48... Line 56...
48
	private HiddenField<String> idCollectionChp = null;
56
	private HiddenField<String> idCollectionChp = null;
49
	
57
	
50
	private ComboBox<Projet> projetsCombo = null;
58
	private ChampComboBoxRechercheTempsReelPaginable projetsCombo = null;
Line 51... Line 59...
51
	private ComboBox<Structure> structuresCombo = null;
59
	private ChampComboBoxRechercheTempsReelPaginable structuresCombo = null;
52
	private ComboBox<Collection> collectionsCombo = null;
60
	private ChampComboBoxRechercheTempsReelPaginable collectionsCombo = null;
53
	
61
	
Line 101... Line 109...
101
		FieldSet liaisonFieldSet = new FieldSet();
109
		FieldSet liaisonFieldSet = new FieldSet();
102
		liaisonFieldSet.setHeading(i18nC.liaisonTitreCollection());
110
		liaisonFieldSet.setHeading(i18nC.liaisonTitreCollection());
103
		liaisonFieldSet.setCollapsible(true);
111
		liaisonFieldSet.setCollapsible(true);
104
		liaisonFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
112
		liaisonFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut));
Line -... Line 113...
-
 
113
		
-
 
114
		
-
 
115
		/*********************************/
-
 
116
		/**			Champ Projets		**/
-
 
117
		/*********************************/
-
 
118
		
-
 
119
		ModelType modelTypeProjets = new ModelType();
-
 
120
		modelTypeProjets.setRoot("projets");
-
 
121
		modelTypeProjets.setTotalName("nbElements");
-
 
122
		modelTypeProjets.addField("cpr_nom");
-
 
123
		modelTypeProjets.addField("cpr_id_projet");
-
 
124
		
-
 
125
		String displayNameProjets = "cpr_nom";
-
 
126
		ProxyProjets<ModelData> proxyProjets = new ProxyProjets<ModelData>();
-
 
127
		
105
		
128
		projetsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyProjets, modelTypeProjets, displayNameProjets);
106
		projetsCombo = new ComboBox<Projet>();
129
		projetsCombo.setWidth(250, 600);
107
		projetsCombo.setTabIndex(tabIndex++);
130
		projetsCombo.getCombo().setTabIndex(tabIndex++);
108
		projetsCombo.setFieldLabel(i18nC.projetChamp());
131
		projetsCombo.getCombo().setFieldLabel(i18nC.projetChamp());
109
		projetsCombo.setDisplayField("nom");
132
		projetsCombo.getCombo().setForceSelection(true);
-
 
133
		projetsCombo.getCombo().addStyleName(ComposantClass.OBLIGATOIRE);
-
 
134
		projetsCombo.getCombo().addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
110
		projetsCombo.setForceSelection(true);
135
		
111
		projetsCombo.setValidator(new Validator() {
136
		projetsCombo.getCombo().setValidator(new Validator() {
112
			public String validate(Field<?> field, String value) {
137
			public String validate(Field<?> field, String value) {
113
				String retour = null;
138
				String retour = null;
114
				if (field.getRawValue().equals("")) {
139
				if (field.getRawValue().equals("")) {
115
					field.setValue(null);
140
					field.setValue(null);
116
				} else if (projetsCombo.getStore().findModel("nom", field.getRawValue()) == null) {
141
				} else if (projetsCombo.getStore().findModel("cpr_nom", field.getRawValue()) == null) {
117
					String contenuBrut = field.getRawValue();
142
					String contenuBrut = field.getRawValue();
118
					field.setValue(null);
143
					field.setValue(null);
119
					field.setRawValue(contenuBrut);
144
					field.setRawValue(contenuBrut);
120
					retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
145
					retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
121
				}
146
				}
122
				return retour;
147
				return retour;
123
			}
148
			}
-
 
149
		});
-
 
150
 
-
 
151
		liaisonFieldSet.add(projetsCombo, new FormData(600, 0));
-
 
152
		
-
 
153
		
-
 
154
		/*************************************/
-
 
155
		/**			Champ Structures		**/
-
 
156
		/*************************************/
124
		});
157
 
125
		projetsCombo.setTriggerAction(TriggerAction.ALL);
158
		ModelType modelTypeStructures = new ModelType();
126
		projetsCombo.setStore(new ListStore<Projet>());
159
		modelTypeStructures.setRoot("structures");
127
		projetsCombo.addStyleName(ComposantClass.OBLIGATOIRE);
160
		modelTypeStructures.setTotalName("nbElements");
128
		projetsCombo.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
161
		modelTypeStructures.addField("cs_nom");
-
 
162
		modelTypeStructures.addField("cs_id_structure");
129
		liaisonFieldSet.add(projetsCombo, new FormData(450, 0));
163
		
-
 
164
		String displayNameStructures = "cs_nom";
130
		mediateur.selectionnerProjet(this, null, null);
165
		ProxyStructures<ModelData> proxyStructures = new ProxyStructures<ModelData>();
-
 
166
		
131
		
167
		structuresCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyStructures, modelTypeStructures, displayNameStructures);
132
		structuresCombo = new ComboBox<Structure>();
168
		structuresCombo.setWidth(250, 600);
133
		structuresCombo.setTabIndex(tabIndex++);
169
		structuresCombo.getCombo().setTabIndex(tabIndex++);
134
		structuresCombo.setFieldLabel(i18nC.lienStructureCollection());
170
		structuresCombo.getCombo().setFieldLabel(i18nC.lienStructureCollection());
135
		structuresCombo.setDisplayField("nom");
171
		structuresCombo.getCombo().setForceSelection(true);
-
 
172
		structuresCombo.getCombo().addStyleName(ComposantClass.OBLIGATOIRE);
-
 
173
		structuresCombo.getCombo().addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());		
136
		structuresCombo.setForceSelection(true);
174
		
137
		structuresCombo.setValidator(new Validator() {
175
		structuresCombo.getCombo().setValidator(new Validator() {
138
			public String validate(Field<?> field, String value) {
176
			public String validate(Field<?> field, String value) {
139
				String retour = null;
177
				String retour = null;
140
				if (field.getRawValue().equals("")) {
178
				if (field.getRawValue().equals("")) {
141
					field.setValue(null);
179
					field.setValue(null);
142
				} else if (structuresCombo.getStore().findModel("nom", field.getRawValue()) == null) {
180
				} else if (structuresCombo.getStore().findModel("cs_nom", field.getRawValue()) == null) {
143
					String contenuBrut = field.getRawValue();
181
					String contenuBrut = field.getRawValue();
144
					field.setValue(null);
182
					field.setValue(null);
145
					field.setRawValue(contenuBrut);
183
					field.setRawValue(contenuBrut);
146
					retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
184
					retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
147
				}
185
				}
148
				return retour;
186
				return retour;
149
			}
187
			}
-
 
188
		});
-
 
189
 
-
 
190
		liaisonFieldSet.add(structuresCombo, new FormData(600, 0));
-
 
191
		
-
 
192
		
-
 
193
		/*************************************/
-
 
194
		/**			Champ Collections		**/
-
 
195
		/*************************************/
150
		});
196
		
151
		structuresCombo.setTriggerAction(TriggerAction.ALL);
197
		ModelType modelTypeCollections = new ModelType();
152
		structuresCombo.setStore(new ListStore<Structure>());
198
		modelTypeCollections.setRoot("collections");
-
 
199
		modelTypeCollections.setTotalName("nbElements");
153
		liaisonFieldSet.add(structuresCombo, new FormData(450, 0));
200
		modelTypeCollections.addField("cc_nom");
-
 
201
		modelTypeCollections.addField("cc_id_collection");
-
 
202
		
-
 
203
		String displayNameCollections = "cc_nom";
154
		mediateur.selectionnerStructureParProjet(this, null);
204
		ProxyCollections<ModelData> proxyCollections = new ProxyCollections<ModelData>();
-
 
205
		
155
		
206
		collectionsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyCollections, modelTypeCollections, displayNameCollections);
156
		collectionsCombo = new ComboBox<Collection>();
207
		collectionsCombo.setWidth(250, 600);
157
		collectionsCombo.setTabIndex(tabIndex++);
208
		collectionsCombo.getCombo().setTabIndex(tabIndex++);
158
		collectionsCombo.setFieldLabel(i18nC.lienMereCollection());
209
		collectionsCombo.getCombo().setFieldLabel(i18nC.lienMereCollection());
159
		collectionsCombo.setDisplayField("nom");
210
		collectionsCombo.getCombo().setForceSelection(true);
-
 
211
		collectionsCombo.getCombo().addStyleName(ComposantClass.OBLIGATOIRE);
-
 
212
		collectionsCombo.getCombo().addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());	
160
		collectionsCombo.setForceSelection(true);
213
		
161
		collectionsCombo.setValidator(new Validator() {
214
		collectionsCombo.getCombo().setValidator(new Validator() {
162
			public String validate(Field<?> field, String value) {
215
			public String validate(Field<?> field, String value) {
163
				String retour = null;
216
				String retour = null;
164
				if (field.getRawValue().equals("")) {
217
				if (field.getRawValue().equals("")) {
165
					field.setValue(null);
218
					field.setValue(null);
166
				} else if (collectionsCombo.getStore().findModel("nom", field.getRawValue()) == null) {
219
				} else if (collectionsCombo.getStore().findModel("cc_nom", field.getRawValue()) == null) {
167
					String contenuBrut = field.getRawValue();
220
					String contenuBrut = field.getRawValue();
168
					field.setValue(null);
221
					field.setValue(null);
169
					field.setRawValue(contenuBrut);
222
					field.setRawValue(contenuBrut);
170
					retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
223
					retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
171
				}
224
				}
172
				return retour;
225
				return retour;
173
			}
226
			}
174
		});
-
 
175
		collectionsCombo.setTriggerAction(TriggerAction.ALL);
-
 
-
 
227
		});
176
		collectionsCombo.setStore(new ListStore<Collection>());
228
 
177
		liaisonFieldSet.add(collectionsCombo, new FormData(450, 0));
-
 
Line 178... Line 229...
178
		mediateur.selectionnerCollectionParProjet(this, null);
229
		liaisonFieldSet.add(collectionsCombo, new FormData(600, 0));
179
		
230
		
Line 180... Line 231...
180
		this.add(liaisonFieldSet);
231
		this.add(liaisonFieldSet);
Line 316... Line 367...
316
		}
367
		}
317
	}
368
	}
Line 318... Line 369...
318
	
369
	
319
	public ArrayList<String> verifier() {
370
	public ArrayList<String> verifier() {
320
		ArrayList<String> messages = new ArrayList<String>();
371
		ArrayList<String> messages = new ArrayList<String>();
321
		if (projetsCombo.getValue() == null || !projetsCombo.isValid()) {
372
		if (projetsCombo.getCombo().getValue() == null || !projetsCombo.getCombo().isValid()) {
322
			messages.add(i18nM.selectionObligatoire(i18nC.articleUn()+" "+i18nC.projetSingulier(), i18nC.articleLa()+" "+i18nC.collectionSingulier()));
373
			messages.add(i18nM.selectionObligatoire(i18nC.articleUn()+" "+i18nC.projetSingulier(), i18nC.articleLa()+" "+i18nC.collectionSingulier()));
323
		}
374
		}
324
		return messages;
375
		return messages;
Line 357... Line 408...
357
		}
408
		}
358
	}
409
	}
Line 359... Line 410...
359
	
410
	
360
	private String getValeurComboProjets() {
411
	private String getValeurComboProjets() {
361
		String valeur = "";
412
		String valeur = "";
-
 
413
		if (projetsCombo.getCombo().getValue() != null) {
362
		if (projetsCombo.getValue() != null) {
414
			Projet projet = new Projet(projetsCombo.getValeur());
363
			valeur = projetsCombo.getValue().getId();
415
			valeur = projet.getId();
364
		}
416
		}
365
		return valeur;
417
		return valeur;
366
	}
418
	}
367
	private void setValeurComboProjets() {
419
	private void setValeurComboProjets() {
368
		if (projetsCombo.getStore() != null && collection != null) {
420
		if (projetsCombo.getStore() != null && collection != null) {
369
			projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", collection.getIdProjet()));
421
			projetsCombo.getCombo().setValue(projetsCombo.getStore().findModel("cpr_id_projet", collection.getIdProjet()));
370
		}
422
		}
Line 371... Line 423...
371
	}
423
	}
372
	
424
	
373
	private String getValeurComboStructures() {
425
	private String getValeurComboStructures() {
-
 
426
		String valeur = "";
374
		String valeur = "";
427
		if (structuresCombo.getCombo().getValue() != null) {
375
		if (structuresCombo.getValue() != null) {
428
			Structure structure = new Structure(structuresCombo.getValeur());
376
			valeur = structuresCombo.getValue().getId();
429
			valeur = structure.getId();
377
		}
430
		}
378
		return valeur;
431
		return valeur;
379
	}
432
	}
380
	private void setValeurComboStructures() {
433
	private void setValeurComboStructures() {
381
		if (structuresCombo.getStore() != null && collection != null) {
434
		if (structuresCombo.getStore() != null && collection != null) {
382
			structuresCombo.setValue(structuresCombo.getStore().findModel("id_structure", collection.getIdStructure()));
435
			structuresCombo.getCombo().setValue(structuresCombo.getStore().findModel("cs_id_structure", collection.getIdStructure()));
Line 383... Line 436...
383
		}
436
		}
384
	}
437
	}
385
	
438
	
-
 
439
	private String getValeurComboCollections() {
386
	private String getValeurComboCollections() {
440
		String valeur = "";
387
		String valeur = "";
441
		if (collectionsCombo.getCombo().getValue() != null) {
388
		if (collectionsCombo.getValue() != null) {
442
			Collection collection = new Collection(collectionsCombo.getValeur());
389
			valeur = collectionsCombo.getValue().getId();
443
			valeur = collection.getId();
390
		}
444
		}
391
		return valeur;
445
		return valeur;
392
	}
446
	}
393
	private void setValeurComboCollections() {
447
	private void setValeurComboCollections() {
394
		if (collectionsCombo.getStore() != null && collection != null) {
448
		if (collectionsCombo.getCombo().getStore() != null && collection != null) {
Line 395... Line 449...
395
			collectionsCombo.setValue(collectionsCombo.getStore().findModel("id_collection", collection.getCollectionMereId()));
449
			collectionsCombo.getCombo().setValue(collectionsCombo.getStore().findModel("id_collection", collection.getCollectionMereId()));
396
		}
450
		}
397
	}
-
 
398
	
-
 
399
	public void rafraichir(Object nouvellesDonnees) {
-
 
400
		if (nouvellesDonnees instanceof ProjetListe) {
-
 
401
			ProjetListe projets = (ProjetListe) nouvellesDonnees;
-
 
402
			Formulaire.rafraichirComboBox(projets, projetsCombo);
-
 
403
			setValeurComboProjets();
-
 
404
		} else if (nouvellesDonnees instanceof StructureListe) {
-
 
405
			StructureListe structures = (StructureListe) nouvellesDonnees;
-
 
406
			Formulaire.rafraichirComboBox(structures, structuresCombo);
-
 
407
			setValeurComboStructures();
-
 
408
		} else if (nouvellesDonnees instanceof CollectionListe) {
-
 
409
			CollectionListe collections = (CollectionListe) nouvellesDonnees;
451
	}
410
			Formulaire.rafraichirComboBox(collections, collectionsCombo);
452
	
411
			setValeurComboCollections();
453
	public void rafraichir(Object nouvellesDonnees) {
412
		} else if (nouvellesDonnees instanceof ValeurListe) {
454
		if (nouvellesDonnees instanceof ValeurListe) {
413
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
455
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;