Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 877 Rev 878
Line 3... Line 3...
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.Iterator;
4
import java.util.Iterator;
5
import java.util.List;
5
import java.util.List;
Line 6... Line 6...
6
 
6
 
-
 
7
import org.tela_botanica.client.Mediateur;
7
import org.tela_botanica.client.Mediateur;
8
import org.tela_botanica.client.i18n.Constantes;
8
import org.tela_botanica.client.images.Images;
9
import org.tela_botanica.client.images.Images;
-
 
10
import org.tela_botanica.client.interfaces.Rafraichissable;
9
import org.tela_botanica.client.interfaces.Rafraichissable;
11
import org.tela_botanica.client.modeles.Configuration;
10
import org.tela_botanica.client.modeles.Information;
12
import org.tela_botanica.client.modeles.Information;
11
import org.tela_botanica.client.modeles.MenuApplicationId;
13
import org.tela_botanica.client.modeles.MenuApplicationId;
12
import org.tela_botanica.client.modeles.Personne;
14
import org.tela_botanica.client.modeles.Personne;
13
import org.tela_botanica.client.modeles.PersonneListe;
15
import org.tela_botanica.client.modeles.PersonneListe;
14
import org.tela_botanica.client.modeles.Projet;
16
import org.tela_botanica.client.modeles.Projet;
15
import org.tela_botanica.client.modeles.Structure;
17
import org.tela_botanica.client.modeles.Structure;
-
 
18
import org.tela_botanica.client.modeles.StructureListe;
-
 
19
import org.tela_botanica.client.modeles.Valeur;
16
import org.tela_botanica.client.modeles.StructureListe;
20
import org.tela_botanica.client.modeles.ValeurListe;
17
import org.tela_botanica.client.util.Pattern;
21
import org.tela_botanica.client.util.Pattern;
Line -... Line 22...
-
 
22
import org.tela_botanica.client.util.UtilArray;
18
import org.tela_botanica.client.util.UtilArray;
23
 
19
 
24
import com.extjs.gxt.ui.client.Style.SortDir;
20
import com.extjs.gxt.ui.client.event.ButtonEvent;
25
import com.extjs.gxt.ui.client.event.ButtonEvent;
21
import com.extjs.gxt.ui.client.event.SelectionListener;
26
import com.extjs.gxt.ui.client.event.SelectionListener;
22
import com.extjs.gxt.ui.client.store.ListStore;
27
import com.extjs.gxt.ui.client.store.ListStore;
Line 32... Line 37...
32
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
37
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
33
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
38
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
34
import com.extjs.gxt.ui.client.widget.layout.FormData;
39
import com.extjs.gxt.ui.client.widget.layout.FormData;
35
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
40
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
36
import com.google.gwt.core.client.GWT;
41
import com.google.gwt.core.client.GWT;
-
 
42
import com.google.gwt.user.client.Window;
Line 37... Line 43...
37
 
43
 
Line 38... Line 44...
38
 
44
 
39
public class ProjetForm extends Formulaire implements Rafraichissable {
45
public class ProjetForm extends Formulaire implements Rafraichissable {
-
 
46
	
-
 
47
	private Projet projet;
-
 
48
	
-
 
49
	private String listeValeurIndexationDureeId = "dureesIndexation";
-
 
50
	private int listeValeurIndexationDureeInt = 1072;
-
 
51
	private String listeValeurIndexationFrequenceId = "frequencesIndexation";
-
 
52
	private int listeValeurIndexationFrequenceInt = 1073;
-
 
53
	
-
 
54
	
40
	
55
	private ListStore<Valeur> listeIndexationDuree = null;
41
	private Projet projet;
56
	private ListStore<Valeur> listeIndexationFrequence = null;
42
		
57
	
43
	private FieldSet generalitesFieldset = null;
58
	private FieldSet generalitesFieldset = null;
44
	private TextField<String> nomChp = null;
59
	private TextField<String> nomChp = null;
Line 53... Line 68...
53
	private TextField<String> licenceChp = null;
68
	private TextField<String> licenceChp = null;
54
	private CheckBox markPublicChp = null;
69
	private CheckBox markPublicChp = null;
Line 55... Line 70...
55
	
70
	
56
	private FieldSet indexationFieldset = null;
71
	private FieldSet indexationFieldset = null;
57
	private TextField<String> indexationHeureChp = null;
72
	private TextField<String> indexationHeureChp = null;
58
	private TextField<String> indexationDureeChp = null;
73
	private ComboBox<Valeur> indexationDureeChp = null;
Line -... Line 74...
-
 
74
	private ComboBox<Valeur> indexationFrequenceChp = null;
-
 
75
	
Line 59... Line 76...
59
	private TextField<String> indexationFrequenceChp = null;
76
	private boolean listeIndexationDureeChargee = false;
60
	
77
	private boolean listeIndexationFrequenceChargee = false;
Line 61... Line 78...
61
 
78
 
Line 72... Line 89...
72
	public ProjetForm(Mediateur mediateurCourrant, String projetId, Rafraichissable vueARafraichirApresValidation) {
89
	public ProjetForm(Mediateur mediateurCourrant, String projetId, Rafraichissable vueARafraichirApresValidation) {
73
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
90
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
74
		initialiserProjetForm(mediateurCourrant, projetId);
91
		initialiserProjetForm(mediateurCourrant, projetId);
75
	}
92
	}
Line 76... Line 93...
76
	
93
	
77
	private void initialiserProjetForm(Mediateur mediateurCourrant, String projetId) {
94
	private void initialiserProjetForm(Mediateur mediateurCourant, String projetId) {
78
		projet = new Projet();
95
		projet = new Projet();
Line 79... Line 96...
79
		projet.setId(projetId);
96
		projet.setId(projetId);
80
		
97
		
Line 81... Line 98...
81
		String modeDeCreation = (projet.getId().isEmpty() ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
98
		String modeDeCreation = (projet.getId().isEmpty() ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
82
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PUBLICATION);
99
		initialiserFormulaire(mediateurCourant, modeDeCreation, MenuApplicationId.PROJET);
83
		
100
		
Line 93... Line 110...
93
		
110
		
94
		creerZoneIndexation();
111
		creerZoneIndexation();
Line 95... Line 112...
95
		panneauFormulaire.add(indexationFieldset);
112
		panneauFormulaire.add(indexationFieldset);
96
		
113
		
97
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
114
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
-
 
115
			mediateurCourant.selectionnerProjet(this, projetId);
-
 
116
		}
-
 
117
		
98
			mediateurCourrant.selectionnerProjet(this, projetId);
118
		mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationDureeId);
Line 99... Line 119...
99
		}
119
		mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationFrequenceId);
100
	}
120
	}
101
	
121
	
102
	private String genererTitreFormulaire() {
122
	private String genererTitreFormulaire() {
103
		String titre = "Ajout d'une projet";
123
		String titre = "Ajout d'une projet";
104
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
124
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
105
			 titre = "Modification d'une projet - "+i18nC.id()+": "+projet.getId();
125
			 titre = "Modification d'un projet - "+i18nC.id()+": "+projet.getId();
Line 106... Line 126...
106
		}
126
		}
Line 179... Line 199...
179
		indexationFieldset.setHeading("Indexation");
199
		indexationFieldset.setHeading("Indexation");
180
		indexationFieldset.setCollapsible(true);
200
		indexationFieldset.setCollapsible(true);
181
		indexationFieldset.setLayout(layout);
201
		indexationFieldset.setLayout(layout);
Line 182... Line 202...
182
		
202
		
183
		indexationHeureChp = new TextField<String>();
203
		indexationHeureChp = new TextField<String>();
Line 184... Line 204...
184
		indexationHeureChp.setFieldLabel("Heure d'indexation");
204
		indexationHeureChp.setFieldLabel(i18nC.projetIndexationHeure());
Line 185... Line 205...
185
		
205
		
-
 
206
		indexationFieldset.add(indexationHeureChp, new FormData(80, 0));
186
		indexationFieldset.add(indexationHeureChp, new FormData(80, 0));
207
		
-
 
208
		// liste 1073
-
 
209
		listeIndexationFrequence = new ListStore<Valeur>();
-
 
210
		indexationFrequenceChp = new ComboBox<Valeur>();
187
		
211
		indexationFrequenceChp.setStore(listeIndexationFrequence);
Line 188... Line 212...
188
		// liste 1072
212
		indexationFrequenceChp.setDisplayField("nom");
Line 189... Line 213...
189
		indexationDureeChp = new TextField<String>();
213
		indexationFrequenceChp.setEditable(false);
-
 
214
		indexationFrequenceChp.setFieldLabel(i18nC.projetIndexationFrequence());
190
		indexationDureeChp.setFieldLabel("Durée d'indexation");
215
		
-
 
216
		indexationFieldset.add(indexationFrequenceChp, new FormData(120, 0));
-
 
217
		
-
 
218
		// liste 1072
191
		
219
		listeIndexationDuree = new ListStore<Valeur>();
Line 192... Line 220...
192
		indexationFieldset.add(indexationDureeChp, new FormData(80, 0));
220
		indexationDureeChp = new ComboBox<Valeur>();
Line 193... Line 221...
193
		
221
		indexationDureeChp.setStore(listeIndexationDuree);
Line 194... Line 222...
194
		// liste 1073
222
		indexationDureeChp.setDisplayField("nom");
195
		indexationFrequenceChp = new TextField<String>();
223
		indexationDureeChp.setEditable(false);
196
		indexationFrequenceChp.setFieldLabel("Fréquence d'indexation");
224
		indexationDureeChp.setFieldLabel(i18nC.projetIndexationDuree());
197
		
225
		
198
		indexationFieldset.add(indexationFrequenceChp, new FormData(50, 0));
226
		indexationFieldset.add(indexationDureeChp, new FormData(80, 0));
-
 
227
				
-
 
228
	}
-
 
229
 
-
 
230
	public void rafraichir(Object nouvellesDonnees) {
-
 
231
		if (nouvellesDonnees instanceof Projet) {
-
 
232
			// Si on a reçu les details d'une projet
-
 
233
			rafraichirProjet((Projet) nouvellesDonnees);
-
 
234
			GWT.log("Un projet est arrivé : "+((Projet) nouvellesDonnees).getNom(), null);
-
 
235
		}
-
 
236
		
-
 
237
		if(nouvellesDonnees instanceof ValeurListe) {
-
 
238
			ValeurListe nValeurListe = (ValeurListe)nouvellesDonnees;
-
 
239
			
-
 
240
			if(nValeurListe.getId() == listeValeurIndexationDureeInt) {
-
 
241
				for(Iterator<String> it  = nValeurListe.keySet().iterator(); it.hasNext();) {
-
 
242
					listeIndexationDuree.add(nValeurListe.get(it.next()));
-
 
243
					listeIndexationDuree.sort("id_valeur", SortDir.ASC);
-
 
244
					listeIndexationDureeChargee = true;
-
 
245
				}
-
 
246
 
-
 
247
			}
199
				
248
			
Line 200... Line 249...
200
	}
249
			if(nValeurListe.getId() == listeValeurIndexationFrequenceInt) {
201
 
250
				for(Iterator<String> it  = nValeurListe.keySet().iterator(); it.hasNext();) {
202
	public void rafraichir(Object nouvellesDonnees) {
251
					listeIndexationFrequence.add(nValeurListe.get(it.next()));
Line 232... Line 281...
232
		projetValideOk = false;
281
		projetValideOk = false;
233
	}
282
	}
Line 234... Line 283...
234
	
283
	
235
	private void repandreRafraichissement() {
284
	private void repandreRafraichissement() {
236
		if (vueExterneARafraichirApresValidation != null) {
285
		if (vueExterneARafraichirApresValidation != null) {
237
			String type = "projet_modifiee";
286
			String type = "projet_modifie";
238
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
287
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
239
				type = "projet_ajoutee";
288
				type = "projet_ajoute";
240
			}
289
			}
241
			Information info = new Information(type);
290
			Information info = new Information(type);
242
			info.setDonnee(0, projet);
291
			info.setDonnee(0, projet);
243
			vueExterneARafraichirApresValidation.rafraichir(info);
292
			vueExterneARafraichirApresValidation.rafraichir(info);
Line 284... Line 333...
284
		return valide;		
333
		return valide;		
285
	}
334
	}
Line 286... Line 335...
286
	
335
	
Line -... Line 336...
-
 
336
	private void peuplerFormulaire() {
-
 
337
		
-
 
338
		nomChp.setValue(projet.getNom());
-
 
339
		abreviationChp.setValue(projet.getAbreviation());
-
 
340
		descriptionChp.setValue(projet.getDescription());
-
 
341
		resumeChp.setValue(projet.getResume());
-
 
342
		urlChp.setValue(projet.getUrl());
-
 
343
		
-
 
344
		motsClesChp.setValue(projet.getMotsCles());
-
 
345
		citationChp.setValue(projet.getCitation());
-
 
346
		licenceChp.setValue(projet.getLicence());
-
 
347
		markPublicChp.setValue(Boolean.parseBoolean(projet.getMarkPublic()));
-
 
348
		
-
 
349
		indexationHeureChp.setValue(projet.getIndexationHeure());
-
 
350
		indexationFrequenceChp.select(listeIndexationFrequence.findModel(projet.getIndexationFreq()));
-
 
351
		indexationDureeChp.select(listeIndexationDuree.findModel(projet.getIndexationDuree()));
-
 
352
		
-
 
353
		doLayout(true);
-
 
354
		
287
	private void peuplerFormulaire() {
355
		Window.alert("Gna !!");
Line 288... Line 356...
288
		
356
		
289
	}
357
	}
290
	
358
	
Line 328... Line 396...
328
			}
396
			}
329
		};
397
		};
Line 330... Line 398...
330
		
398
		
331
		return ecouteur;
399
		return ecouteur;
332
	}
-
 
333
	
400
	}
334
}
401
}