Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 902 Rev 907
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
2
 
2
 
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;
6
 
6
 
7
import org.tela_botanica.client.Mediateur;
7
import org.tela_botanica.client.Mediateur;
-
 
8
import org.tela_botanica.client.configuration.Configuration;
8
import org.tela_botanica.client.i18n.Constantes;
9
import org.tela_botanica.client.i18n.Constantes;
9
import org.tela_botanica.client.images.Images;
10
import org.tela_botanica.client.images.Images;
10
import org.tela_botanica.client.interfaces.Rafraichissable;
11
import org.tela_botanica.client.interfaces.Rafraichissable;
11
import org.tela_botanica.client.modeles.Configuration;
-
 
12
import org.tela_botanica.client.modeles.Information;
12
import org.tela_botanica.client.modeles.Information;
13
import org.tela_botanica.client.modeles.MenuApplicationId;
13
import org.tela_botanica.client.modeles.MenuApplicationId;
14
import org.tela_botanica.client.modeles.Personne;
14
import org.tela_botanica.client.modeles.Personne;
15
import org.tela_botanica.client.modeles.PersonneListe;
15
import org.tela_botanica.client.modeles.PersonneListe;
16
import org.tela_botanica.client.modeles.Projet;
16
import org.tela_botanica.client.modeles.Projet;
17
import org.tela_botanica.client.modeles.Structure;
17
import org.tela_botanica.client.modeles.Structure;
18
import org.tela_botanica.client.modeles.StructureListe;
18
import org.tela_botanica.client.modeles.StructureListe;
19
import org.tela_botanica.client.modeles.Valeur;
19
import org.tela_botanica.client.modeles.Valeur;
20
import org.tela_botanica.client.modeles.ValeurListe;
20
import org.tela_botanica.client.modeles.ValeurListe;
21
import org.tela_botanica.client.util.Pattern;
21
import org.tela_botanica.client.util.Pattern;
22
import org.tela_botanica.client.util.UtilArray;
22
import org.tela_botanica.client.util.UtilArray;
23
 
23
 
24
import com.extjs.gxt.ui.client.Style.SortDir;
24
import com.extjs.gxt.ui.client.Style.SortDir;
25
import com.extjs.gxt.ui.client.event.ButtonEvent;
25
import com.extjs.gxt.ui.client.event.ButtonEvent;
26
import com.extjs.gxt.ui.client.event.SelectionListener;
26
import com.extjs.gxt.ui.client.event.SelectionListener;
27
import com.extjs.gxt.ui.client.store.ListStore;
27
import com.extjs.gxt.ui.client.store.ListStore;
28
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
28
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
29
import com.extjs.gxt.ui.client.widget.LayoutContainer;
29
import com.extjs.gxt.ui.client.widget.LayoutContainer;
30
import com.extjs.gxt.ui.client.widget.MessageBox;
30
import com.extjs.gxt.ui.client.widget.MessageBox;
31
import com.extjs.gxt.ui.client.widget.button.Button;
31
import com.extjs.gxt.ui.client.widget.button.Button;
32
import com.extjs.gxt.ui.client.widget.form.CheckBox;
32
import com.extjs.gxt.ui.client.widget.form.CheckBox;
33
import com.extjs.gxt.ui.client.widget.form.ComboBox;
33
import com.extjs.gxt.ui.client.widget.form.ComboBox;
34
import com.extjs.gxt.ui.client.widget.form.Field;
34
import com.extjs.gxt.ui.client.widget.form.Field;
35
import com.extjs.gxt.ui.client.widget.form.FieldSet;
35
import com.extjs.gxt.ui.client.widget.form.FieldSet;
36
import com.extjs.gxt.ui.client.widget.form.TextArea;
36
import com.extjs.gxt.ui.client.widget.form.TextArea;
37
import com.extjs.gxt.ui.client.widget.form.TextField;
37
import com.extjs.gxt.ui.client.widget.form.TextField;
38
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
38
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
39
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
39
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
40
import com.extjs.gxt.ui.client.widget.layout.FormData;
40
import com.extjs.gxt.ui.client.widget.layout.FormData;
41
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
41
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
42
import com.google.gwt.core.client.GWT;
42
import com.google.gwt.core.client.GWT;
43
import com.google.gwt.user.client.Window;
43
import com.google.gwt.user.client.Window;
44
 
44
 
45
 
45
 
46
public class ProjetForm extends Formulaire implements Rafraichissable {
46
public class ProjetForm extends Formulaire implements Rafraichissable {
47
	
47
	
48
	private Projet projet;
48
	private Projet projet;
49
	
49
	
50
	private String listeValeurIndexationDureeId = "dureesIndexation";
50
	private String listeValeurIndexationDureeId = "dureesIndexation";
51
	private int listeValeurIndexationDureeInt = 1072;
51
	private int listeValeurIndexationDureeInt = 1072;
52
	private String listeValeurIndexationFrequenceId = "frequencesIndexation";
52
	private String listeValeurIndexationFrequenceId = "frequencesIndexation";
53
	private int listeValeurIndexationFrequenceInt = 1073;
53
	private int listeValeurIndexationFrequenceInt = 1073;
54
	private String listeLanguesId = "langues";
54
	private String listeLanguesId = "langues";
55
	private int listeLanguesInt = 1071;	
55
	private int listeLanguesInt = 1071;	
56
	
56
	
57
	private ListStore<Valeur> listeIndexationDuree = null;
57
	private ListStore<Valeur> listeIndexationDuree = null;
58
	private ListStore<Valeur> listeIndexationFrequence = null;
58
	private ListStore<Valeur> listeIndexationFrequence = null;
59
	private ListStore<Valeur> listeLangue = null;
59
	private ListStore<Valeur> listeLangue = null;
60
	
60
	
61
	private ValeurListe valeurListeIndexationDuree = null;
61
	private ValeurListe valeurListeIndexationDuree = null;
62
	private ValeurListe valeurListeIndexationFrequence = null;
62
	private ValeurListe valeurListeIndexationFrequence = null;
63
	private ValeurListe valeurListeLangue = null;
63
	private ValeurListe valeurListeLangue = null;
64
	
64
	
65
	private FieldSet generalitesFieldset = null;
65
	private FieldSet generalitesFieldset = null;
66
	private TextField<String> nomChp = null;
66
	private TextField<String> nomChp = null;
67
	private TextField<String> abreviationChp = null;
67
	private TextField<String> abreviationChp = null;
68
	private TextArea descriptionChp = null;
68
	private TextArea descriptionChp = null;
69
	private TextArea resumeChp = null;
69
	private TextArea resumeChp = null;
70
	private TextField<String> urlChp = null;
70
	private TextField<String> urlChp = null;
71
			
71
			
72
	private FieldSet complementFieldset = null;
72
	private FieldSet complementFieldset = null;
73
	private TextField<String> motsClesChp = null;
73
	private TextField<String> motsClesChp = null;
74
	private TextField<String> citationChp = null;
74
	private TextField<String> citationChp = null;
75
	private TextField<String> licenceChp = null;
75
	private TextField<String> licenceChp = null;
76
	private ComboBox<Valeur> langueChp = null;
76
	private ComboBox<Valeur> langueChp = null;
77
	private CheckBox markPublicChp = null;
77
	private CheckBox markPublicChp = null;
78
	
78
	
79
	private FieldSet indexationFieldset = null;
79
	private FieldSet indexationFieldset = null;
80
	private TextField<String> indexationHeureChp = null;
80
	private TextField<String> indexationHeureChp = null;
81
	private ComboBox<Valeur> indexationDureeChp = null;
81
	private ComboBox<Valeur> indexationDureeChp = null;
82
	private ComboBox<Valeur> indexationFrequenceChp = null;
82
	private ComboBox<Valeur> indexationFrequenceChp = null;
83
 
83
 
84
	private boolean formulaireValideOk = false;
84
	private boolean formulaireValideOk = false;
85
	private boolean projetValideOk = false;
85
	private boolean projetValideOk = false;
86
 
86
 
87
	private Rafraichissable vueExterneARafraichirApresValidation = null;
87
	private Rafraichissable vueExterneARafraichirApresValidation = null;
88
 
88
 
89
 
89
 
90
	public ProjetForm(Mediateur mediateurCourrant, String projetId) {
90
	public ProjetForm(Mediateur mediateurCourrant, String projetId) {
91
		initialiserProjetForm(mediateurCourrant, projetId);
91
		initialiserProjetForm(mediateurCourrant, projetId);
92
	}
92
	}
93
 
93
 
94
	public ProjetForm(Mediateur mediateurCourrant, String projetId, Rafraichissable vueARafraichirApresValidation) {
94
	public ProjetForm(Mediateur mediateurCourrant, String projetId, Rafraichissable vueARafraichirApresValidation) {
95
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
95
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
96
		initialiserProjetForm(mediateurCourrant, projetId);
96
		initialiserProjetForm(mediateurCourrant, projetId);
97
	}
97
	}
98
	
98
	
99
	private void initialiserProjetForm(Mediateur mediateurCourant, String projetId) {
99
	private void initialiserProjetForm(Mediateur mediateurCourant, String projetId) {
100
		projet = new Projet();
100
		projet = new Projet();
101
		projet.setId(projetId);
101
		projet.setId(projetId);
102
		
102
		
103
		String modeDeCreation = (projet.getId().isEmpty() ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
103
		String modeDeCreation = (projet.getId().isEmpty() ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
104
		initialiserFormulaire(mediateurCourant, modeDeCreation, MenuApplicationId.PROJET);
104
		initialiserFormulaire(mediateurCourant, modeDeCreation, MenuApplicationId.PROJET);
105
		
105
		
106
		panneauFormulaire.setLayout(new FlowLayout());
106
		panneauFormulaire.setLayout(new FlowLayout());
107
		String titre = genererTitreFormulaire();
107
		String titre = genererTitreFormulaire();
108
		panneauFormulaire.setHeading(titre);
108
		panneauFormulaire.setHeading(titre);
109
		
109
		
110
		creerZoneGeneralites();
110
		creerZoneGeneralites();
111
		panneauFormulaire.add(generalitesFieldset);
111
		panneauFormulaire.add(generalitesFieldset);
112
		
112
		
113
		creerZoneComplement();
113
		creerZoneComplement();
114
		panneauFormulaire.add(complementFieldset);
114
		panneauFormulaire.add(complementFieldset);
115
		
115
		
116
		creerZoneIndexation();
116
		creerZoneIndexation();
117
		panneauFormulaire.add(indexationFieldset);
117
		panneauFormulaire.add(indexationFieldset);
118
		
118
		
119
		creerTabIndex();
119
		creerTabIndex();
120
		
120
		
121
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
121
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
122
			mediateurCourant.selectionnerProjet(this, projetId);
122
			mediateurCourant.selectionnerProjet(this, projetId);
123
		}
123
		}
124
		
124
		
125
		mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationDureeId);
125
		mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationDureeId);
126
		mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationFrequenceId);
126
		mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationFrequenceId);
127
		mediateurCourant.obtenirListeValeurEtRafraichir(this, listeLanguesId);
127
		mediateurCourant.obtenirListeValeurEtRafraichir(this, listeLanguesId);
128
	}
128
	}
129
	
129
	
130
	private String genererTitreFormulaire() {
130
	private String genererTitreFormulaire() {
131
		String titre = "Ajout d'un projet";
131
		String titre = "Ajout d'un projet";
132
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
132
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
133
			 titre = "Modification d'un projet - "+i18nC.id()+": "+projet.getId();
133
			 titre = "Modification d'un projet - "+i18nC.id()+": "+projet.getId();
134
		}
134
		}
135
		return titre;
135
		return titre;
136
	}
136
	}
137
			
137
			
138
	private void creerZoneGeneralites() {
138
	private void creerZoneGeneralites() {
139
		FormLayout layout = new FormLayout();
139
		FormLayout layout = new FormLayout();
140
		layout.setLabelWidth(100);
140
		layout.setLabelWidth(100);
141
		
141
		
142
		// Fieldset Infos Générales
142
		// Fieldset Infos Générales
143
		generalitesFieldset = new FieldSet();
143
		generalitesFieldset = new FieldSet();
144
		generalitesFieldset.setHeading("Informations générales");
144
		generalitesFieldset.setHeading("Informations générales");
145
		generalitesFieldset.setCollapsible(true);
145
		generalitesFieldset.setCollapsible(true);
146
		generalitesFieldset.setLayout(layout);
146
		generalitesFieldset.setLayout(layout);
147
		
147
		
148
		nomChp = new TextField<String>();
148
		nomChp = new TextField<String>();
149
		nomChp.setName("cpu");
149
		nomChp.setName("cpu");
150
		nomChp.setFieldLabel("Nom");
150
		nomChp.setFieldLabel("Nom");
151
		generalitesFieldset.add(nomChp, new FormData(450, 0));
151
		generalitesFieldset.add(nomChp, new FormData(450, 0));
152
		
152
		
153
		abreviationChp = new TextField<String>();
153
		abreviationChp = new TextField<String>();
154
		abreviationChp.setFieldLabel("Abréviation");
154
		abreviationChp.setFieldLabel("Abréviation");
155
		generalitesFieldset.add(abreviationChp, new FormData(450, 0));
155
		generalitesFieldset.add(abreviationChp, new FormData(450, 0));
156
		
156
		
157
		descriptionChp = new TextArea();
157
		descriptionChp = new TextArea();
158
		descriptionChp.setFieldLabel("Description");
158
		descriptionChp.setFieldLabel("Description");
159
		generalitesFieldset.add(descriptionChp, new FormData(450, 0));
159
		generalitesFieldset.add(descriptionChp, new FormData(450, 0));
160
		
160
		
161
		resumeChp = new TextArea();
161
		resumeChp = new TextArea();
162
		resumeChp.setFieldLabel("Résumé");
162
		resumeChp.setFieldLabel("Résumé");
163
		generalitesFieldset.add(resumeChp, new FormData(450, 0));
163
		generalitesFieldset.add(resumeChp, new FormData(450, 0));
164
		
164
		
165
		urlChp = new TextField<String>();
165
		urlChp = new TextField<String>();
166
		urlChp.setFieldLabel("URL du projet");
166
		urlChp.setFieldLabel("URL du projet");
167
		generalitesFieldset.add(urlChp, new FormData(450, 0));
167
		generalitesFieldset.add(urlChp, new FormData(450, 0));
168
	}
168
	}
169
	
169
	
170
	private void creerZoneComplement() {
170
	private void creerZoneComplement() {
171
		FormLayout layout = new FormLayout();
171
		FormLayout layout = new FormLayout();
172
		layout.setLabelWidth(100);
172
		layout.setLabelWidth(100);
173
		
173
		
174
		// Fieldset Edition
174
		// Fieldset Edition
175
		complementFieldset = new FieldSet();
175
		complementFieldset = new FieldSet();
176
		complementFieldset.setHeading("Informations complémentaires");
176
		complementFieldset.setHeading("Informations complémentaires");
177
		complementFieldset.setCollapsible(true);
177
		complementFieldset.setCollapsible(true);
178
		complementFieldset.setLayout(layout);
178
		complementFieldset.setLayout(layout);
179
		
179
		
180
		motsClesChp = new TextField<String>();
180
		motsClesChp = new TextField<String>();
181
		motsClesChp.setFieldLabel("Mots Clés");
181
		motsClesChp.setFieldLabel("Mots Clés");
182
		
182
		
183
		complementFieldset.add(motsClesChp);
183
		complementFieldset.add(motsClesChp);
184
		
184
		
185
		citationChp = new TextField<String>();
185
		citationChp = new TextField<String>();
186
		citationChp.setFieldLabel("Citation");
186
		citationChp.setFieldLabel("Citation");
187
		
187
		
188
		complementFieldset.add(citationChp);
188
		complementFieldset.add(citationChp);
189
		
189
		
190
		licenceChp = new TextField<String>();
190
		licenceChp = new TextField<String>();
191
		licenceChp.setFieldLabel("Licence");
191
		licenceChp.setFieldLabel("Licence");
192
		
192
		
193
		complementFieldset.add(licenceChp);
193
		complementFieldset.add(licenceChp);
194
		
194
		
195
		listeLangue = new ListStore<Valeur>();
195
		listeLangue = new ListStore<Valeur>();
196
		langueChp = new ComboBox<Valeur>();
196
		langueChp = new ComboBox<Valeur>();
197
		langueChp.setStore(listeLangue);
197
		langueChp.setStore(listeLangue);
198
		langueChp.setDisplayField("nom");
198
		langueChp.setDisplayField("nom");
199
		langueChp.setEditable(true);
199
		langueChp.setEditable(true);
200
		langueChp.setForceSelection(true);
200
		langueChp.setForceSelection(true);
201
		langueChp.setTypeAhead(true);
201
		langueChp.setTypeAhead(true);
202
		langueChp.setFieldLabel("Langue");
202
		langueChp.setFieldLabel("Langue");
203
		
203
		
204
		complementFieldset.add(langueChp);
204
		complementFieldset.add(langueChp);
205
		
205
		
206
		markPublicChp = new CheckBox();
206
		markPublicChp = new CheckBox();
207
		markPublicChp.setFieldLabel("Public");
207
		markPublicChp.setFieldLabel("Public");
208
		
208
		
209
		complementFieldset.add(markPublicChp);
209
		complementFieldset.add(markPublicChp);
210
	}
210
	}
211
	
211
	
212
	private void creerZoneIndexation() {
212
	private void creerZoneIndexation() {
213
		FormLayout layout = new FormLayout();
213
		FormLayout layout = new FormLayout();
214
		layout.setLabelWidth(100);
214
		layout.setLabelWidth(100);
215
		
215
		
216
		// Fieldset Edition
216
		// Fieldset Edition
217
		indexationFieldset = new FieldSet();
217
		indexationFieldset = new FieldSet();
218
		indexationFieldset.setHeading("Indexation");
218
		indexationFieldset.setHeading("Indexation");
219
		indexationFieldset.setCollapsible(true);
219
		indexationFieldset.setCollapsible(true);
220
		indexationFieldset.setLayout(layout);
220
		indexationFieldset.setLayout(layout);
221
		
221
		
222
		indexationHeureChp = new TextField<String>();
222
		indexationHeureChp = new TextField<String>();
223
		indexationHeureChp.setFieldLabel(i18nC.projetIndexationHeure());
223
		indexationHeureChp.setFieldLabel(i18nC.projetIndexationHeure());
224
		
224
		
225
		indexationFieldset.add(indexationHeureChp, new FormData(80, 0));
225
		indexationFieldset.add(indexationHeureChp, new FormData(80, 0));
226
		
226
		
227
		// liste 1073
227
		// liste 1073
228
		listeIndexationFrequence = new ListStore<Valeur>();
228
		listeIndexationFrequence = new ListStore<Valeur>();
229
		indexationFrequenceChp = new ComboBox<Valeur>();
229
		indexationFrequenceChp = new ComboBox<Valeur>();
230
		indexationFrequenceChp.setStore(listeIndexationFrequence);
230
		indexationFrequenceChp.setStore(listeIndexationFrequence);
231
		indexationFrequenceChp.setDisplayField("nom");
231
		indexationFrequenceChp.setDisplayField("nom");
232
		indexationFrequenceChp.setEditable(true);
232
		indexationFrequenceChp.setEditable(true);
233
		indexationFrequenceChp.setForceSelection(true);
233
		indexationFrequenceChp.setForceSelection(true);
234
		indexationFrequenceChp.setTypeAhead(true);
234
		indexationFrequenceChp.setTypeAhead(true);
235
		indexationFrequenceChp.setFieldLabel(i18nC.projetIndexationFrequence());
235
		indexationFrequenceChp.setFieldLabel(i18nC.projetIndexationFrequence());
236
		
236
		
237
		indexationFieldset.add(indexationFrequenceChp, new FormData(120, 0));
237
		indexationFieldset.add(indexationFrequenceChp, new FormData(120, 0));
238
		
238
		
239
		// liste 1072
239
		// liste 1072
240
		listeIndexationDuree = new ListStore<Valeur>();
240
		listeIndexationDuree = new ListStore<Valeur>();
241
		indexationDureeChp = new ComboBox<Valeur>();
241
		indexationDureeChp = new ComboBox<Valeur>();
242
		indexationDureeChp.setStore(listeIndexationDuree);
242
		indexationDureeChp.setStore(listeIndexationDuree);
243
		indexationDureeChp.setDisplayField("nom");
243
		indexationDureeChp.setDisplayField("nom");
244
		indexationDureeChp.setEditable(true);
244
		indexationDureeChp.setEditable(true);
245
		indexationDureeChp.setForceSelection(true);
245
		indexationDureeChp.setForceSelection(true);
246
		indexationDureeChp.setTypeAhead(true);
246
		indexationDureeChp.setTypeAhead(true);
247
		indexationDureeChp.setFieldLabel(i18nC.projetIndexationDuree());
247
		indexationDureeChp.setFieldLabel(i18nC.projetIndexationDuree());
248
		
248
		
249
		indexationFieldset.add(indexationDureeChp, new FormData(80, 0));
249
		indexationFieldset.add(indexationDureeChp, new FormData(80, 0));
250
				
250
				
251
	}
251
	}
252
	
252
	
253
	private void creerTabIndex() {
253
	private void creerTabIndex() {
254
		
254
		
255
		nomChp.setTabIndex(1);
255
		nomChp.setTabIndex(1);
256
		abreviationChp.setTabIndex(2);
256
		abreviationChp.setTabIndex(2);
257
		descriptionChp.setTabIndex(3);
257
		descriptionChp.setTabIndex(3);
258
		resumeChp.setTabIndex(4);
258
		resumeChp.setTabIndex(4);
259
		urlChp.setTabIndex(5);
259
		urlChp.setTabIndex(5);
260
				
260
				
261
		motsClesChp.setTabIndex(6);
261
		motsClesChp.setTabIndex(6);
262
		citationChp.setTabIndex(7);
262
		citationChp.setTabIndex(7);
263
		licenceChp.setTabIndex(8);
263
		licenceChp.setTabIndex(8);
264
		langueChp.setTabIndex(9);
264
		langueChp.setTabIndex(9);
265
		markPublicChp.setTabIndex(10);
265
		markPublicChp.setTabIndex(10);
266
		
266
		
267
		indexationHeureChp.setTabIndex(11);
267
		indexationHeureChp.setTabIndex(11);
268
		indexationFrequenceChp.setTabIndex(12);
268
		indexationFrequenceChp.setTabIndex(12);
269
		indexationDureeChp.setTabIndex(13);
269
		indexationDureeChp.setTabIndex(13);
270
		
270
		
271
		nomChp.focus();
271
		nomChp.focus();
272
	}
272
	}
273
 
273
 
274
	public void rafraichir(Object nouvellesDonnees) {
274
	public void rafraichir(Object nouvellesDonnees) {
275
		if (nouvellesDonnees instanceof Projet) {
275
		if (nouvellesDonnees instanceof Projet) {
276
			// Si on a reçu les details d'une projet
276
			// Si on a reçu les details d'une projet
277
			rafraichirProjet((Projet) nouvellesDonnees);
277
			rafraichirProjet((Projet) nouvellesDonnees);
278
			GWT.log("Un projet est arrivé : "+((Projet) nouvellesDonnees).getNom(), null);
278
			GWT.log("Un projet est arrivé : "+((Projet) nouvellesDonnees).getNom(), null);
279
		}
279
		}
280
		
280
		
281
		if(nouvellesDonnees instanceof ValeurListe) {
281
		if(nouvellesDonnees instanceof ValeurListe) {
282
			ValeurListe nValeurListe = (ValeurListe)nouvellesDonnees;
282
			ValeurListe nValeurListe = (ValeurListe)nouvellesDonnees;
283
			
283
			
284
			if(nValeurListe.getId() == listeValeurIndexationDureeInt) {
284
			if(nValeurListe.getId() == listeValeurIndexationDureeInt) {
285
				
285
				
286
				valeurListeIndexationDuree = nValeurListe;
286
				valeurListeIndexationDuree = nValeurListe;
287
				
287
				
288
				for(Iterator<String> it  = nValeurListe.keySet().iterator(); it.hasNext();) {
288
				for(Iterator<String> it  = nValeurListe.keySet().iterator(); it.hasNext();) {
289
					listeIndexationDuree.add(nValeurListe.get(it.next()));
289
					listeIndexationDuree.add(nValeurListe.get(it.next()));
290
					listeIndexationDuree.sort("id_valeur", SortDir.ASC);
290
					listeIndexationDuree.sort("id_valeur", SortDir.ASC);
291
				}
291
				}
292
				
292
				
293
				if(mode.equals(MODE_MODIFIER)) {
293
				if(mode.equals(MODE_MODIFIER)) {
294
					if(valeurListeIndexationDuree.get(projet.getIndexationDuree()) != null) {
294
					if(valeurListeIndexationDuree.get(projet.getIndexationDuree()) != null) {
295
						indexationDureeChp.setRawValue(valeurListeIndexationDuree.get(projet.getIndexationDuree()).getNom());
295
						indexationDureeChp.setRawValue(valeurListeIndexationDuree.get(projet.getIndexationDuree()).getNom());
296
					}
296
					}
297
				}
297
				}
298
				
298
				
299
				indexationDureeChp.expand();
299
				indexationDureeChp.expand();
300
 
300
 
301
			}
301
			}
302
			
302
			
303
			if(nValeurListe.getId() == listeValeurIndexationFrequenceInt) {
303
			if(nValeurListe.getId() == listeValeurIndexationFrequenceInt) {
304
				
304
				
305
				valeurListeIndexationFrequence = nValeurListe;
305
				valeurListeIndexationFrequence = nValeurListe;
306
				
306
				
307
				for(Iterator<String> it  = nValeurListe.keySet().iterator(); it.hasNext();) {
307
				for(Iterator<String> it  = nValeurListe.keySet().iterator(); it.hasNext();) {
308
					listeIndexationFrequence.add(nValeurListe.get(it.next()));
308
					listeIndexationFrequence.add(nValeurListe.get(it.next()));
309
					listeIndexationFrequence.sort("id_valeur", SortDir.ASC);
309
					listeIndexationFrequence.sort("id_valeur", SortDir.ASC);
310
				}
310
				}
311
				
311
				
312
				if(mode.equals(MODE_MODIFIER)) {
312
				if(mode.equals(MODE_MODIFIER)) {
313
					if(valeurListeIndexationFrequence.get(projet.getIndexationFreq()) != null) {
313
					if(valeurListeIndexationFrequence.get(projet.getIndexationFreq()) != null) {
314
						indexationFrequenceChp.setRawValue(valeurListeIndexationFrequence.get(projet.getIndexationFreq()).getNom());
314
						indexationFrequenceChp.setRawValue(valeurListeIndexationFrequence.get(projet.getIndexationFreq()).getNom());
315
					}
315
					}
316
				}
316
				}
317
				
317
				
318
				indexationFrequenceChp.expand();
318
				indexationFrequenceChp.expand();
319
			}
319
			}
320
			
320
			
321
			if(nValeurListe.getId() == listeLanguesInt) {
321
			if(nValeurListe.getId() == listeLanguesInt) {
322
				
322
				
323
				valeurListeLangue = nValeurListe;
323
				valeurListeLangue = nValeurListe;
324
				
324
				
325
				for(Iterator<String> it  = nValeurListe.keySet().iterator(); it.hasNext();) {
325
				for(Iterator<String> it  = nValeurListe.keySet().iterator(); it.hasNext();) {
326
					listeLangue.add(nValeurListe.get(it.next()));
326
					listeLangue.add(nValeurListe.get(it.next()));
327
					listeLangue.sort("id_valeur", SortDir.ASC);
327
					listeLangue.sort("id_valeur", SortDir.ASC);
328
				}
328
				}
329
				
329
				
330
				if(mode.equals(MODE_MODIFIER)) {
330
				if(mode.equals(MODE_MODIFIER)) {
331
					if(valeurListeLangue.get(projet.getLangue()) != null) {
331
					if(valeurListeLangue.get(projet.getLangue()) != null) {
332
						langueChp.setRawValue(valeurListeLangue.get(projet.getLangue()).getNom());
332
						langueChp.setRawValue(valeurListeLangue.get(projet.getLangue()).getNom());
333
					}
333
					}
334
				}
334
				}
335
			}
335
			}
336
			
336
			
337
			GWT.log("une liste de valeurs est arrivée "+nValeurListe.getId(), null);
337
			GWT.log("une liste de valeurs est arrivée "+nValeurListe.getId(), null);
338
		}
338
		}
339
		
339
		
340
		if (etreValide()) {
340
		if (etreValide()) {
341
			initialiserValidation();
341
			initialiserValidation();
342
			repandreRafraichissement();
342
			repandreRafraichissement();
343
			controlerFermetureApresRafraichissement();
343
			controlerFermetureApresRafraichissement();
344
		}
344
		}
345
	}
345
	}
346
 
346
 
347
	private void rafraichirProjet(Projet proj) {
347
	private void rafraichirProjet(Projet proj) {
348
		projet = proj;
348
		projet = proj;
349
		peuplerFormulaire();
349
		peuplerFormulaire();
350
	}
350
	}
351
	
351
	
352
	private Boolean etreValide() {
352
	private Boolean etreValide() {
353
		Boolean valide = false;
353
		Boolean valide = false;
354
		GWT.log("formulaire"+formulaireValideOk+" - Projet :"+projetValideOk, null);
354
		GWT.log("formulaire"+formulaireValideOk+" - Projet :"+projetValideOk, null);
355
		if (formulaireValideOk && projetValideOk) {
355
		if (formulaireValideOk && projetValideOk) {
356
			valide = true;
356
			valide = true;
357
		}
357
		}
358
		return valide;
358
		return valide;
359
	}
359
	}
360
	
360
	
361
	private void initialiserValidation() {
361
	private void initialiserValidation() {
362
		formulaireValideOk = false;
362
		formulaireValideOk = false;
363
		projetValideOk = false;
363
		projetValideOk = false;
364
	}
364
	}
365
	
365
	
366
	private void repandreRafraichissement() {
366
	private void repandreRafraichissement() {
367
		if (vueExterneARafraichirApresValidation != null) {
367
		if (vueExterneARafraichirApresValidation != null) {
368
			String type = "projet_modifie";
368
			String type = "projet_modifie";
369
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
369
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
370
				type = "projet_ajoute";
370
				type = "projet_ajoute";
371
			}
371
			}
372
			Information info = new Information(type);
372
			Information info = new Information(type);
373
			info.setDonnee(0, projet);
373
			info.setDonnee(0, projet);
374
			vueExterneARafraichirApresValidation.rafraichir(info);
374
			vueExterneARafraichirApresValidation.rafraichir(info);
375
		}
375
		}
376
	}
376
	}
377
	
377
	
378
	public boolean soumettreFormulaire() {
378
	public boolean soumettreFormulaire() {
379
		formulaireValideOk = verifierFormulaire();
379
		formulaireValideOk = verifierFormulaire();
380
		GWT.log("Form?"+formulaireValideOk, null);
380
		GWT.log("Form?"+formulaireValideOk, null);
381
		if (formulaireValideOk) {
381
		if (formulaireValideOk) {
382
			Projet projetCollecte = collecterProjet();
382
			Projet projetCollecte = collecterProjet();
383
			if (projetCollecte != null) {
383
			if (projetCollecte != null) {
384
				GWT.log("Info collectée ? ok", null);
384
				GWT.log("Info collectée ? ok", null);
385
				if (mode.equals(Formulaire.MODE_AJOUTER)) {
385
				if (mode.equals(Formulaire.MODE_AJOUTER)) {
386
					mediateur.ajouterProjet(this, projetCollecte);
386
					mediateur.ajouterProjet(this, projetCollecte);
387
				} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
387
				} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
388
					mediateur.modifierProjet(this, projetCollecte);
388
					mediateur.modifierProjet(this, projetCollecte);
389
				}
389
				}
390
			}
390
			}
391
		}
391
		}
392
		return formulaireValideOk;
392
		return formulaireValideOk;
393
	}
393
	}
394
	
394
	
395
	protected boolean verifierFormulaire() {
395
	protected boolean verifierFormulaire() {
396
		boolean valide = true;
396
		boolean valide = true;
397
		ArrayList<String> messages = new ArrayList<String>();
397
		ArrayList<String> messages = new ArrayList<String>();
398
		
398
		
399
		String titre = nomChp.getValue();
399
		String titre = nomChp.getValue();
400
		if (titre == null || titre.equals("")) {
400
		if (titre == null || titre.equals("")) {
401
			messages.add("Veuillez saisir le nom du projet !");
401
			messages.add("Veuillez saisir le nom du projet !");
402
		}
402
		}
403
		
403
		
404
		String abr = abreviationChp.getValue();
404
		String abr = abreviationChp.getValue();
405
		if (abr == null || abr.equals("")) {
405
		if (abr == null || abr.equals("")) {
406
			messages.add("Veuillez saisir l'abréviation du projet !");
406
			messages.add("Veuillez saisir l'abréviation du projet !");
407
		}
407
		}
408
		
408
		
409
		String desc = descriptionChp.getValue();
409
		String desc = descriptionChp.getValue();
410
		if (desc == null || desc.equals("")) {
410
		if (desc == null || desc.equals("")) {
411
			messages.add("Veuillez saisir la description du projet !");
411
			messages.add("Veuillez saisir la description du projet !");
412
		}
412
		}
413
		
413
		
414
		String resume = resumeChp.getValue();
414
		String resume = resumeChp.getValue();
415
		if (resume == null || resume.equals("")) {
415
		if (resume == null || resume.equals("")) {
416
			messages.add("Veuillez saisir le résumé du projet !");
416
			messages.add("Veuillez saisir le résumé du projet !");
417
		}
417
		}
418
		
418
		
419
		String uri = urlChp.getValue();
419
		String uri = urlChp.getValue();
420
		if (uri != null && ! uri.trim().isEmpty() && ! uri.matches(Pattern.url)) {
420
		if (uri != null && ! uri.trim().isEmpty() && ! uri.matches(Pattern.url)) {
421
			messages.add("L'URL saisie n'est pas valide !");
421
			messages.add("L'URL saisie n'est pas valide !");
422
		}
422
		}
423
		
423
		
424
		String heure = indexationHeureChp.getValue();
424
		String heure = indexationHeureChp.getValue();
425
		if (heure != null && ! heure.isEmpty() && !heure.matches(Pattern.heureMinute)) {
425
		if (heure != null && ! heure.isEmpty() && !heure.matches(Pattern.heureMinute)) {
426
			messages.add("L'heureMinute d'indexation saisie n'est pas valide !");
426
			messages.add("L'heureMinute d'indexation saisie n'est pas valide !");
427
		} else {
427
		} else {
428
			if(heure.matches(Pattern.heureMinute)) {
428
			if(heure.matches(Pattern.heureMinute)) {
429
				heure += ":00";
429
				heure += ":00";
430
			}
430
			}
431
		}
431
		}
432
		
432
		
433
		if (messages.size() != 0) {
433
		if (messages.size() != 0) {
434
			String[] tableauDeMessages = {};
434
			String[] tableauDeMessages = {};
435
			tableauDeMessages = messages.toArray(tableauDeMessages);
435
			tableauDeMessages = messages.toArray(tableauDeMessages);
436
			MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null);
436
			MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null);
437
			valide = false;
437
			valide = false;
438
		}
438
		}
439
		return valide;		
439
		return valide;		
440
	}
440
	}
441
	
441
	
442
	private void peuplerFormulaire() {
442
	private void peuplerFormulaire() {
443
		
443
		
444
		nomChp.setValue(projet.getNom());
444
		nomChp.setValue(projet.getNom());
445
		abreviationChp.setValue(projet.getAbreviation());
445
		abreviationChp.setValue(projet.getAbreviation());
446
		descriptionChp.setValue(projet.getDescription());
446
		descriptionChp.setValue(projet.getDescription());
447
		resumeChp.setValue(projet.getResume());
447
		resumeChp.setValue(projet.getResume());
448
		urlChp.setValue(projet.getUrl());
448
		urlChp.setValue(projet.getUrl());
449
		
449
		
450
		motsClesChp.setValue(projet.getMotsCles());
450
		motsClesChp.setValue(projet.getMotsCles());
451
		citationChp.setValue(projet.getCitation());
451
		citationChp.setValue(projet.getCitation());
452
		licenceChp.setValue(projet.getLicence());
452
		licenceChp.setValue(projet.getLicence());
453
				
453
				
454
		if(projet.getMarkPublic().equals("1")) {
454
		if(projet.getMarkPublic().equals("1")) {
455
			markPublicChp.setValue(true);
455
			markPublicChp.setValue(true);
456
		} else {
456
		} else {
457
			markPublicChp.setValue(false);
457
			markPublicChp.setValue(false);
458
		}
458
		}
459
		
459
		
460
		String[] heureTab = projet.getIndexationHeure().split(":");
460
		String[] heureTab = projet.getIndexationHeure().split(":");
461
		if(heureTab.length > 1) {
461
		if(heureTab.length > 1) {
462
			String heure = heureTab[0]+":"+heureTab[1];
462
			String heure = heureTab[0]+":"+heureTab[1];
463
			if(heure.matches(Pattern.heureMinute)) {
463
			if(heure.matches(Pattern.heureMinute)) {
464
				indexationHeureChp.setValue(heure);
464
				indexationHeureChp.setValue(heure);
465
			}
465
			}
466
		}
466
		}
467
		
467
		
468
		doLayout(true);
468
		doLayout(true);
469
		
469
		
470
	}
470
	}
471
	
471
	
472
	private Projet collecterProjet() {
472
	private Projet collecterProjet() {
473
		Projet projetARetourner = new Projet();
473
		Projet projetARetourner = new Projet();
474
		Projet projetCollecte = (Projet) projet.cloner(new Projet());
474
		Projet projetCollecte = (Projet) projet.cloner(new Projet());
475
		
475
		
476
		projetARetourner.setNom(nomChp.getValue());
476
		projetARetourner.setNom(nomChp.getValue());
477
		projetARetourner.setAbreviation(abreviationChp.getValue());
477
		projetARetourner.setAbreviation(abreviationChp.getValue());
478
		projetARetourner.setDescription(descriptionChp.getValue());
478
		projetARetourner.setDescription(descriptionChp.getValue());
479
		projetARetourner.setResume(resumeChp.getValue());
479
		projetARetourner.setResume(resumeChp.getValue());
480
		projetARetourner.setUrl(urlChp.getValue());
480
		projetARetourner.setUrl(urlChp.getValue());
481
		
481
		
482
		projetARetourner.setMotsCles(motsClesChp.getValue());
482
		projetARetourner.setMotsCles(motsClesChp.getValue());
483
		projetARetourner.setCitation(citationChp.getValue());
483
		projetARetourner.setCitation(citationChp.getValue());
484
		projetARetourner.setLicence(licenceChp.getValue());
484
		projetARetourner.setLicence(licenceChp.getValue());
485
		
485
		
486
		if(markPublicChp.getValue()) {
486
		if(markPublicChp.getValue()) {
487
			projetCollecte.setMarkPublic("1");
487
			projetCollecte.setMarkPublic("1");
488
		} else {
488
		} else {
489
			projetCollecte.setMarkPublic("0");
489
			projetCollecte.setMarkPublic("0");
490
		}
490
		}
491
		
491
		
492
		projetARetourner.setIndexationHeure(indexationHeureChp.getValue());
492
		projetARetourner.setIndexationHeure(indexationHeureChp.getValue());
493
		projetARetourner.setIndexationDuree(indexationDureeChp.getValue().getId());
493
		projetARetourner.setIndexationDuree(indexationDureeChp.getValue().getId());
494
		projetARetourner.setIndexationFreq(indexationFrequenceChp.getValue().getId());
494
		projetARetourner.setIndexationFreq(indexationFrequenceChp.getValue().getId());
495
		
495
		
496
		if (!projetCollecte.comparer(projet)) {
496
		if (!projetCollecte.comparer(projet)) {
497
			projetARetourner = projet = projetCollecte;
497
			projetARetourner = projet = projetCollecte;
498
		}
498
		}
499
		
499
		
500
		//GWT.log(projetARetourner.toString()+" "+projetARetourner., null)
500
		//GWT.log(projetARetourner.toString()+" "+projetARetourner., null)
501
		
501
		
502
		return projetARetourner;
502
		return projetARetourner;
503
	}
503
	}
504
	
504
	
505
	protected void reinitialiserFormulaire() {
505
	protected void reinitialiserFormulaire() {
506
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
506
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
507
			mediateur.afficherFormProjet(projet.getId());
507
			mediateur.afficherFormProjet(projet.getId());
508
		} else {
508
		} else {
509
			mediateur.afficherFormProjet(null);
509
			mediateur.afficherFormProjet(null);
510
		}
510
		}
511
	}
511
	}
512
	
512
	
513
	@Override
513
	@Override
514
	protected SelectionListener<ButtonEvent> creerEcouteurValidation() {
514
	protected SelectionListener<ButtonEvent> creerEcouteurValidation() {
515
		SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
515
		SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
516
			@Override
516
			@Override
517
			public void componentSelected(ButtonEvent ce) {
517
			public void componentSelected(ButtonEvent ce) {
518
				String code = ((Button) ce.getComponent()).getData("code");
518
				String code = ((Button) ce.getComponent()).getData("code");
519
				if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
519
				if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
520
					soumettreFormulaire();
520
					soumettreFormulaire();
521
					clicBoutonvalidation = true;
521
					clicBoutonvalidation = true;
522
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
522
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
523
					soumettreFormulaire();
523
					soumettreFormulaire();
524
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
524
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
525
					mediateur.clicMenu(menuIdCourant);
525
					mediateur.clicMenu(menuIdCourant);
526
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) {
526
				} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) {
527
					reinitialiserFormulaire();
527
					reinitialiserFormulaire();
528
				}
528
				}
529
			}
529
			}
530
		};
530
		};
531
		
531
		
532
		return ecouteur;
532
		return ecouteur;
533
	}
533
	}
534
}
534
}