Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1329 Rev 1367
1
package org.tela_botanica.client.vues.projet;
1
package org.tela_botanica.client.vues.projet;
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
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.ChampComboBoxListeValeurs;
7
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
8
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
8
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
9
import org.tela_botanica.client.composants.InfoLogger;
9
import org.tela_botanica.client.composants.InfoLogger;
10
import org.tela_botanica.client.composants.pagination.ProxyValeur;
10
import org.tela_botanica.client.composants.pagination.ProxyValeur;
11
import org.tela_botanica.client.interfaces.Rafraichissable;
11
import org.tela_botanica.client.interfaces.Rafraichissable;
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.Valeur;
14
import org.tela_botanica.client.modeles.Valeur;
15
import org.tela_botanica.client.modeles.projet.Projet;
15
import org.tela_botanica.client.modeles.projet.Projet;
-
 
16
import org.tela_botanica.client.synchronisation.Sequenceur;
16
import org.tela_botanica.client.util.Debug;
17
import org.tela_botanica.client.util.Debug;
17
import org.tela_botanica.client.util.Pattern;
18
import org.tela_botanica.client.util.Pattern;
18
import org.tela_botanica.client.util.UtilArray;
19
import org.tela_botanica.client.util.UtilArray;
19
import org.tela_botanica.client.util.UtilString;
20
import org.tela_botanica.client.util.UtilString;
20
import org.tela_botanica.client.vues.Formulaire;
21
import org.tela_botanica.client.vues.Formulaire;
21
 
22
 
22
import com.extjs.gxt.ui.client.Style.Scroll;
23
import com.extjs.gxt.ui.client.Style.Scroll;
23
import com.extjs.gxt.ui.client.data.ModelData;
24
import com.extjs.gxt.ui.client.data.ModelData;
24
import com.extjs.gxt.ui.client.data.ModelType;
25
import com.extjs.gxt.ui.client.data.ModelType;
25
import com.extjs.gxt.ui.client.event.BaseEvent;
26
import com.extjs.gxt.ui.client.event.BaseEvent;
26
import com.extjs.gxt.ui.client.event.Events;
27
import com.extjs.gxt.ui.client.event.Events;
27
import com.extjs.gxt.ui.client.event.Listener;
28
import com.extjs.gxt.ui.client.event.Listener;
28
import com.extjs.gxt.ui.client.widget.Info;
29
import com.extjs.gxt.ui.client.widget.Info;
29
import com.extjs.gxt.ui.client.widget.MessageBox;
30
import com.extjs.gxt.ui.client.widget.MessageBox;
30
import com.extjs.gxt.ui.client.widget.form.CheckBox;
31
import com.extjs.gxt.ui.client.widget.form.CheckBox;
31
import com.extjs.gxt.ui.client.widget.form.FieldSet;
32
import com.extjs.gxt.ui.client.widget.form.FieldSet;
32
import com.extjs.gxt.ui.client.widget.form.TextArea;
33
import com.extjs.gxt.ui.client.widget.form.TextArea;
33
import com.extjs.gxt.ui.client.widget.form.TextField;
34
import com.extjs.gxt.ui.client.widget.form.TextField;
34
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
35
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
35
import com.extjs.gxt.ui.client.widget.layout.FormData;
36
import com.extjs.gxt.ui.client.widget.layout.FormData;
36
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
37
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
37
 
38
 
38
public class ProjetForm extends Formulaire implements Rafraichissable {
39
public class ProjetForm extends Formulaire implements Rafraichissable {
39
	
40
	
40
	private Projet projet;
41
	private Projet projet;
41
	
42
	
42
	private String listeValeurIndexationDureeId = "dureesIndexation";
43
	private String listeValeurIndexationDureeId = "dureesIndexation";
43
	private String listeValeurIndexationFrequenceId = "frequencesIndexation";
44
	private String listeValeurIndexationFrequenceId = "frequencesIndexation";
44
	private String listeLanguesId = "langues";
45
	private String listeLanguesId = "langues";
45
	
46
	
46
	private FieldSet generalitesFieldset = null;
47
	private FieldSet generalitesFieldset = null;
47
	private TextField<String> nomChp = null;
48
	private TextField<String> nomChp = null;
48
	private TextField<String> abreviationChp = null;
49
	private TextField<String> abreviationChp = null;
49
	private TextArea descriptionChp = null;
50
	private TextArea descriptionChp = null;
50
	private TextArea resumeChp = null;
51
	private TextArea resumeChp = null;
51
	private TextField<String> urlChp = null;
52
	private TextField<String> urlChp = null;
52
			
53
			
53
	private FieldSet complementFieldset = null;
54
	private FieldSet complementFieldset = null;
54
	private TextField<String> motsClesChp = null;
55
	private TextField<String> motsClesChp = null;
55
	private TextField<String> citationChp = null;
56
	private TextField<String> citationChp = null;
56
	private TextField<String> licenceChp = null;
57
	private TextField<String> licenceChp = null;
57
	private ChampComboBoxRechercheTempsReelPaginable langueChp = null;
58
	private ChampComboBoxRechercheTempsReelPaginable langueChp = null;
58
	private CheckBox markPublicChp = null;
59
	private CheckBox markPublicChp = null;
59
	
60
	
60
	private FieldSet indexationFieldset = null;
61
	private FieldSet indexationFieldset = null;
61
	private TextField<String> indexationHeureChp = null;
62
	private TextField<String> indexationHeureChp = null;
62
	private ChampComboBoxListeValeurs indexationDureeChp = null;
63
	private ChampComboBoxListeValeurs indexationDureeChp = null;
63
	private ChampComboBoxListeValeurs indexationFrequenceChp = null;
64
	private ChampComboBoxListeValeurs indexationFrequenceChp = null;
64
 
65
 
65
	private boolean formulaireValideOk = false;
66
	private boolean formulaireValideOk = false;
66
	private boolean projetValideOk = false;
67
	private boolean projetValideOk = false;
-
 
68
	
-
 
69
	private Sequenceur sequenceur = new Sequenceur();
67
 
70
 
68
	private Rafraichissable vueExterneARafraichirApresValidation = null;
71
	private Rafraichissable vueExterneARafraichirApresValidation = null;
69
 
72
 
70
 
73
 
71
	public ProjetForm(Mediateur mediateurCourrant, String projetId) {
74
	public ProjetForm(Mediateur mediateurCourrant, String projetId) {
72
		initialiserProjetForm(mediateurCourrant, projetId);
75
		initialiserProjetForm(mediateurCourrant, projetId);
73
	}
76
	}
74
 
77
 
75
	public ProjetForm(Mediateur mediateurCourrant, String projetId, Rafraichissable vueARafraichirApresValidation) {
78
	public ProjetForm(Mediateur mediateurCourrant, String projetId, Rafraichissable vueARafraichirApresValidation) {
76
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
79
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
77
		initialiserProjetForm(mediateurCourrant, projetId);
80
		initialiserProjetForm(mediateurCourrant, projetId);
78
	}
81
	}
79
	
82
	
80
	private void initialiserProjetForm(Mediateur mediateurCourant, String projetId) {
83
	private void initialiserProjetForm(Mediateur mediateurCourant, String projetId) {
81
		projet = new Projet();
84
		projet = new Projet();
82
		projet.setId(projetId);
85
		projet.setId(projetId);
83
		
86
		
84
		String modeDeCreation = (projet.getId().isEmpty() ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
87
		String modeDeCreation = (projet.getId().isEmpty() ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
85
		initialiserFormulaire(mediateurCourant, modeDeCreation, MenuApplicationId.PROJET);
88
		initialiserFormulaire(mediateurCourant, modeDeCreation, MenuApplicationId.PROJET);
86
		
89
		
87
		panneauFormulaire.setLayout(new FlowLayout());
90
		panneauFormulaire.setLayout(new FlowLayout());
88
		panneauFormulaire.setScrollMode(Scroll.AUTO);
91
		panneauFormulaire.setScrollMode(Scroll.AUTO);
89
		genererTitreFormulaire();
92
		genererTitreFormulaire();
90
		
93
		
91
		creerZoneGeneralites();
94
		creerZoneGeneralites();
92
		panneauFormulaire.add(generalitesFieldset);
95
		panneauFormulaire.add(generalitesFieldset);
93
		
96
		
94
		creerZoneComplement();
97
		creerZoneComplement();
95
		panneauFormulaire.add(complementFieldset);
98
		panneauFormulaire.add(complementFieldset);
96
		
99
		
97
		creerZoneIndexation();
100
		creerZoneIndexation();
98
		panneauFormulaire.add(indexationFieldset);
101
		panneauFormulaire.add(indexationFieldset);
99
		
102
		
100
		creerTabIndex();
103
		creerTabIndex();
101
		
104
		
102
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
105
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
103
			mediateur.selectionnerProjet(this, projetId, null);
106
			mediateur.selectionnerProjet(this, projetId, null);
104
		}			
107
		}			
105
	}
108
	}
106
	
109
	
107
	private void genererTitreFormulaire() {
110
	private void genererTitreFormulaire() {
108
		String titre = i18nC.projetTitreFormAjout();
111
		String titre = i18nC.projetTitreFormAjout();
109
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
112
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
110
			 titre = i18nC.projetTitreFormModif();
113
			 titre = i18nC.projetTitreFormModif();
111
			 if (projet != null) {
114
			 if (projet != null) {
112
				 titre += " - "+i18nC.id()+": "+projet.getId();
115
				 titre += " - "+i18nC.id()+": "+projet.getId();
113
			 }
116
			 }
114
		}
117
		}
115
		panneauFormulaire.setHeading(titre);
118
		panneauFormulaire.setHeading(titre);
116
	}
119
	}
117
			
120
			
118
	private void creerZoneGeneralites() {
121
	private void creerZoneGeneralites() {
119
		FormLayout layout = new FormLayout();
122
		FormLayout layout = new FormLayout();
120
		layout.setLabelWidth(100);
123
		layout.setLabelWidth(100);
121
		
124
		
122
		// Fieldset Infos Générales
125
		// Fieldset Infos Générales
123
		generalitesFieldset = new FieldSet();
126
		generalitesFieldset = new FieldSet();
124
		generalitesFieldset.setHeading(i18nC.projetTitreInfoGenerale());
127
		generalitesFieldset.setHeading(i18nC.projetTitreInfoGenerale());
125
		generalitesFieldset.setCollapsible(true);
128
		generalitesFieldset.setCollapsible(true);
126
		generalitesFieldset.setLayout(layout);
129
		generalitesFieldset.setLayout(layout);
127
		
130
		
128
		nomChp = new TextField<String>();
131
		nomChp = new TextField<String>();
129
		nomChp.setName("cpu");
132
		nomChp.setName("cpu");
130
		nomChp.setFieldLabel(i18nC.projetNom());
133
		nomChp.setFieldLabel(i18nC.projetNom());
131
		nomChp.addStyleName(ComposantClass.OBLIGATOIRE);
134
		nomChp.addStyleName(ComposantClass.OBLIGATOIRE);
132
		nomChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
135
		nomChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
133
		generalitesFieldset.add(nomChp, new FormData(450, 0));
136
		generalitesFieldset.add(nomChp, new FormData(450, 0));
134
		
137
		
135
		abreviationChp = new TextField<String>();
138
		abreviationChp = new TextField<String>();
136
		abreviationChp.setFieldLabel(i18nC.projetAbreviation());
139
		abreviationChp.setFieldLabel(i18nC.projetAbreviation());
137
		abreviationChp.addStyleName(ComposantClass.OBLIGATOIRE);
140
		abreviationChp.addStyleName(ComposantClass.OBLIGATOIRE);
138
		abreviationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
141
		abreviationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
139
		generalitesFieldset.add(abreviationChp, new FormData(450, 0));
142
		generalitesFieldset.add(abreviationChp, new FormData(450, 0));
140
		
143
		
141
		descriptionChp = new TextArea();
144
		descriptionChp = new TextArea();
142
		descriptionChp.setFieldLabel(i18nC.projetDescription());
145
		descriptionChp.setFieldLabel(i18nC.projetDescription());
143
		descriptionChp.addStyleName(ComposantClass.OBLIGATOIRE);
146
		descriptionChp.addStyleName(ComposantClass.OBLIGATOIRE);
144
		descriptionChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
147
		descriptionChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
145
		generalitesFieldset.add(descriptionChp, new FormData(450, 0));
148
		generalitesFieldset.add(descriptionChp, new FormData(450, 0));
146
		
149
		
147
		resumeChp = new TextArea();
150
		resumeChp = new TextArea();
148
		resumeChp.setFieldLabel(i18nC.projetResume());
151
		resumeChp.setFieldLabel(i18nC.projetResume());
149
		resumeChp.addStyleName(ComposantClass.OBLIGATOIRE);
152
		resumeChp.addStyleName(ComposantClass.OBLIGATOIRE);
150
		resumeChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
153
		resumeChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
151
		generalitesFieldset.add(resumeChp, new FormData(450, 0));
154
		generalitesFieldset.add(resumeChp, new FormData(450, 0));
152
		
155
		
153
		urlChp = new TextField<String>();
156
		urlChp = new TextField<String>();
154
		urlChp.setFieldLabel(i18nC.projetUrl());
157
		urlChp.setFieldLabel(i18nC.projetUrl());
155
		generalitesFieldset.add(urlChp, new FormData(450, 0));
158
		generalitesFieldset.add(urlChp, new FormData(450, 0));
156
	}
159
	}
157
	
160
	
158
	private void creerZoneComplement() {
161
	private void creerZoneComplement() {
159
		FormLayout layout = new FormLayout();
162
		FormLayout layout = new FormLayout();
160
		layout.setLabelWidth(100);
163
		layout.setLabelWidth(100);
161
		
164
		
162
		// Fieldset Complément
165
		// Fieldset Complément
163
		complementFieldset = new FieldSet();
166
		complementFieldset = new FieldSet();
164
		complementFieldset.setHeading(i18nC.projetTitreComplement());
167
		complementFieldset.setHeading(i18nC.projetTitreComplement());
165
		complementFieldset.setCollapsible(true);
168
		complementFieldset.setCollapsible(true);
166
		complementFieldset.setLayout(layout);
169
		complementFieldset.setLayout(layout);
167
		
170
		
168
		motsClesChp = new TextField<String>();
171
		motsClesChp = new TextField<String>();
169
		motsClesChp.setFieldLabel(i18nC.projetMotsCles());
172
		motsClesChp.setFieldLabel(i18nC.projetMotsCles());
170
		complementFieldset.add(motsClesChp, new FormData(450, 0));
173
		complementFieldset.add(motsClesChp, new FormData(450, 0));
171
		
174
		
172
		citationChp = new TextField<String>();
175
		citationChp = new TextField<String>();
173
		citationChp.setFieldLabel(i18nC.projetCitation());
176
		citationChp.setFieldLabel(i18nC.projetCitation());
174
		complementFieldset.add(citationChp, new FormData(450, 0));
177
		complementFieldset.add(citationChp, new FormData(450, 0));
175
		
178
		
176
		licenceChp = new TextField<String>();
179
		licenceChp = new TextField<String>();
177
		licenceChp.setFieldLabel(i18nC.projetLicence());
180
		licenceChp.setFieldLabel(i18nC.projetLicence());
178
		complementFieldset.add(licenceChp, new FormData(450, 0));
181
		complementFieldset.add(licenceChp, new FormData(450, 0));
179
		
182
		
180
		ModelType modelTypesLangues = new ModelType();
183
		ModelType modelTypesLangues = new ModelType();
181
		modelTypesLangues.setRoot("valeurs");
184
		modelTypesLangues.setRoot("valeurs");
182
		modelTypesLangues.setTotalName("nbElements");
185
		modelTypesLangues.setTotalName("nbElements");
183
		modelTypesLangues.addField("cmlv_nom");
186
		modelTypesLangues.addField("cmlv_nom");
184
		modelTypesLangues.addField("cmlv_id_valeur");
187
		modelTypesLangues.addField("cmlv_id_valeur");
185
		modelTypesLangues.addField("cmlv_abreviation");
188
		modelTypesLangues.addField("cmlv_abreviation");
186
		modelTypesLangues.addField("cmlv_description");
189
		modelTypesLangues.addField("cmlv_description");
187
		
190
		
188
		String displayNameLangues = "cmlv_nom";
191
		String displayNameLangues = "cmlv_nom";
189
		String nomListeTypes = "langues";
192
		String nomListeTypes = "langues";
190
		ProxyValeur<ModelData> proxyLangues = new ProxyValeur<ModelData>(nomListeTypes);
193
		ProxyValeur<ModelData> proxyLangues = new ProxyValeur<ModelData>(nomListeTypes, sequenceur);
191
		
194
		
192
		langueChp = new ChampComboBoxRechercheTempsReelPaginable(proxyLangues, modelTypesLangues, displayNameLangues);
195
		langueChp = new ChampComboBoxRechercheTempsReelPaginable(proxyLangues, modelTypesLangues, displayNameLangues);
193
		langueChp.setWidth(100,300);
196
		langueChp.setWidth(100,300);
194
		langueChp.getCombo().setTabIndex(tabIndex++);
197
		langueChp.getCombo().setTabIndex(tabIndex++);
195
		langueChp.getCombo().setFieldLabel(i18nC.projetLangue());
198
		langueChp.getCombo().setFieldLabel(i18nC.projetLangue());
196
		langueChp.getCombo().setForceSelection(true);		
199
		langueChp.getCombo().setForceSelection(true);		
197
		
200
		
198
		complementFieldset.add(langueChp, new FormData(300, 0));
201
		complementFieldset.add(langueChp, new FormData(300, 0));
199
		
202
		
200
		markPublicChp = new CheckBox();
203
		markPublicChp = new CheckBox();
201
		markPublicChp.setFieldLabel(i18nC.projetMarkPublic());
204
		markPublicChp.setFieldLabel(i18nC.projetMarkPublic());
202
		markPublicChp.addListener(Events.Change, new Listener<BaseEvent>() {
205
		markPublicChp.addListener(Events.Change, new Listener<BaseEvent>() {
203
			public void handleEvent(BaseEvent be) {
206
			public void handleEvent(BaseEvent be) {
204
				if (markPublicChp.getValue()) {
207
				if (markPublicChp.getValue()) {
205
					indexationFieldset.show();
208
					indexationFieldset.show();
206
				} else {
209
				} else {
207
					indexationFieldset.hide();
210
					indexationFieldset.hide();
208
				}
211
				}
209
			}
212
			}
210
		});
213
		});
211
		complementFieldset.add(markPublicChp);
214
		complementFieldset.add(markPublicChp);
212
	}
215
	}
213
	
216
	
214
	private void creerZoneIndexation() {
217
	private void creerZoneIndexation() {
215
		FormLayout layout = new FormLayout();
218
		FormLayout layout = new FormLayout();
216
		layout.setLabelWidth(100);
219
		layout.setLabelWidth(100);
217
		
220
		
218
		// Fieldset Indexation
221
		// Fieldset Indexation
219
		indexationFieldset = new FieldSet();
222
		indexationFieldset = new FieldSet();
220
		indexationFieldset.setHeading(i18nC.projetTitreIndexation());
223
		indexationFieldset.setHeading(i18nC.projetTitreIndexation());
221
		indexationFieldset.setCollapsible(true);
224
		indexationFieldset.setCollapsible(true);
222
		indexationFieldset.setLayout(layout);
225
		indexationFieldset.setLayout(layout);
223
		indexationFieldset.hide();
226
		indexationFieldset.hide();
224
		indexationFieldset.addListener(Events.Hide, new Listener<BaseEvent>() {
227
		indexationFieldset.addListener(Events.Hide, new Listener<BaseEvent>() {
225
			public void handleEvent(BaseEvent be) {
228
			public void handleEvent(BaseEvent be) {
226
				indexationHeureChp.clear();
229
				indexationHeureChp.clear();
227
				indexationFrequenceChp.clear();
230
				indexationFrequenceChp.clear();
228
				indexationDureeChp.clear();
231
				indexationDureeChp.clear();
229
			}
232
			}
230
		});
233
		});
231
		
234
		
232
		indexationHeureChp = new TextField<String>();
235
		indexationHeureChp = new TextField<String>();
233
		indexationHeureChp.setFieldLabel(i18nC.projetIndexationHeure());
236
		indexationHeureChp.setFieldLabel(i18nC.projetIndexationHeure());
234
		indexationHeureChp.setToolTip(i18nC.projetMessageHeureMinute());
237
		indexationHeureChp.setToolTip(i18nC.projetMessageHeureMinute());
235
		indexationFieldset.add(indexationHeureChp, new FormData(80, 0));
238
		indexationFieldset.add(indexationHeureChp, new FormData(80, 0));
236
		
239
		
237
		indexationFrequenceChp = new ChampComboBoxListeValeurs(i18nC.projetIndexationFrequence(), listeValeurIndexationFrequenceId);
240
		indexationFrequenceChp = new ChampComboBoxListeValeurs(i18nC.projetIndexationFrequence(), listeValeurIndexationFrequenceId);
238
		indexationFieldset.add(indexationFrequenceChp, new FormData(120, 0));
241
		indexationFieldset.add(indexationFrequenceChp, new FormData(120, 0));
239
		
242
		
240
		indexationDureeChp = new ChampComboBoxListeValeurs(i18nC.projetIndexationDuree(), listeValeurIndexationDureeId);
243
		indexationDureeChp = new ChampComboBoxListeValeurs(i18nC.projetIndexationDuree(), listeValeurIndexationDureeId);
241
		indexationFieldset.add(indexationDureeChp, new FormData(80, 0));
244
		indexationFieldset.add(indexationDureeChp, new FormData(80, 0));
242
				
245
				
243
	}
246
	}
244
	
247
	
245
	private void creerTabIndex() {
248
	private void creerTabIndex() {
246
		nomChp.setTabIndex(1);
249
		nomChp.setTabIndex(1);
247
		abreviationChp.setTabIndex(2);
250
		abreviationChp.setTabIndex(2);
248
		descriptionChp.setTabIndex(3);
251
		descriptionChp.setTabIndex(3);
249
		resumeChp.setTabIndex(4);
252
		resumeChp.setTabIndex(4);
250
		urlChp.setTabIndex(5);
253
		urlChp.setTabIndex(5);
251
				
254
				
252
		motsClesChp.setTabIndex(6);
255
		motsClesChp.setTabIndex(6);
253
		citationChp.setTabIndex(7);
256
		citationChp.setTabIndex(7);
254
		licenceChp.setTabIndex(8);
257
		licenceChp.setTabIndex(8);
255
		langueChp.setTabIndex(9);
258
		langueChp.setTabIndex(9);
256
		markPublicChp.setTabIndex(10);
259
		markPublicChp.setTabIndex(10);
257
		
260
		
258
		indexationHeureChp.setTabIndex(11);
261
		indexationHeureChp.setTabIndex(11);
259
		indexationFrequenceChp.setTabIndex(12);
262
		indexationFrequenceChp.setTabIndex(12);
260
		indexationDureeChp.setTabIndex(13);
263
		indexationDureeChp.setTabIndex(13);
261
		
264
		
262
		nomChp.focus();
265
		nomChp.focus();
263
	}
266
	}
264
 
267
 
265
	public void rafraichir(Object nouvellesDonnees) {
268
	public void rafraichir(Object nouvellesDonnees) {
266
		if (nouvellesDonnees instanceof Information) {
269
		if (nouvellesDonnees instanceof Information) {
267
			Information info = (Information) nouvellesDonnees;
270
			Information info = (Information) nouvellesDonnees;
268
			rafraichirInformation(info);
271
			rafraichirInformation(info);
269
		} else {
272
		} else {
270
			Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
273
			Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
271
		}
274
		}
272
		
275
		
273
		if (etreValide()) {
276
		if (etreValide()) {
274
			initialiserValidation();
277
			initialiserValidation();
275
			repandreRafraichissement();
278
			repandreRafraichissement();
276
			controlerFermeture();
279
			controlerFermeture();
277
		}
280
		}
278
	}
281
	}
279
 
282
 
280
	private void rafraichirInformation(Information info) {
283
	private void rafraichirInformation(Information info) {
281
		final String type = info.getType();
284
		final String type = info.getType();
282
		
285
		
283
		// Gestion des problèmes
286
		// Gestion des problèmes
284
		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
287
		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
285
			Debug.log("MESSAGES:\n"+info.getMessages().toString());
288
			Debug.log("MESSAGES:\n"+info.getMessages().toString());
286
		}
289
		}
287
		
290
		
288
		// Gestion des actions
291
		// Gestion des actions
289
		if (type.equals("selection_projet")) {
292
		if (type.equals("selection_projet")) {
290
			if (info.getDonnee(0) != null) {
293
			if (info.getDonnee(0) != null) {
291
				projet = (Projet) info.getDonnee(0);
294
				projet = (Projet) info.getDonnee(0);
292
			}
295
			}
293
			peuplerFormulaire();
296
			peuplerFormulaire();
294
			genererTitreFormulaire();
297
			genererTitreFormulaire();
295
		}
298
		}
296
		if (type.equals("ajout_projet") || type.equals("modif_projet")) {
299
		if (type.equals("ajout_projet") || type.equals("modif_projet")) {
297
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
300
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
298
				projetValideOk = true;
301
				projetValideOk = true;
299
				String projetId = (String) info.getDonnee(0);
302
				String projetId = (String) info.getDonnee(0);
300
				if (vueExterneARafraichirApresValidation != null) {
303
				if (vueExterneARafraichirApresValidation != null) {
301
					projet.setId(projetId);
304
					projet.setId(projetId);
302
				}
305
				}
303
			}
306
			}
304
		}
307
		}
305
		
308
		
306
		// Gestion des messages
309
		// Gestion des messages
307
		if (type.equals("selection_projet")) {
310
		if (type.equals("selection_projet")) {
308
			InfoLogger.display(i18nC.projetTitreFormModif(), info.toString());
311
			InfoLogger.display(i18nC.projetTitreFormModif(), info.toString());
309
		} else if (type.equals("modif_projet")) {
312
		} else if (type.equals("modif_projet")) {
310
			InfoLogger.display(i18nC.projetTitreFormModif(), info.toString());
313
			InfoLogger.display(i18nC.projetTitreFormModif(), info.toString());
311
		} else if (type.equals("ajout_projet")) {
314
		} else if (type.equals("ajout_projet")) {
312
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
315
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
313
				String projetId = (String) info.getDonnee(0);
316
				String projetId = (String) info.getDonnee(0);
314
				InfoLogger.display(i18nC.projetTitreFormAjout(), "Le projet '"+projetId+"' a bien été ajouté");
317
				InfoLogger.display(i18nC.projetTitreFormAjout(), "Le projet '"+projetId+"' a bien été ajouté");
315
			} else {
318
			} else {
316
				InfoLogger.display(i18nC.projetTitreFormAjout(), info.toString(), true);
319
				InfoLogger.display(i18nC.projetTitreFormAjout(), info.toString(), true);
317
			}
320
			}
318
		}
321
		}
319
	}
322
	}
320
		
323
		
321
	private Boolean etreValide() {
324
	private Boolean etreValide() {
322
		Boolean valide = false;
325
		Boolean valide = false;
323
		if (formulaireValideOk && projetValideOk) {
326
		if (formulaireValideOk && projetValideOk) {
324
			valide = true;
327
			valide = true;
325
		}
328
		}
326
		return valide;
329
		return valide;
327
	}
330
	}
328
	
331
	
329
	private void initialiserValidation() {
332
	private void initialiserValidation() {
330
		formulaireValideOk = false;
333
		formulaireValideOk = false;
331
		projetValideOk = false;
334
		projetValideOk = false;
332
	}
335
	}
333
	
336
	
334
	private void repandreRafraichissement() {
337
	private void repandreRafraichissement() {
335
		if (vueExterneARafraichirApresValidation != null) {
338
		if (vueExterneARafraichirApresValidation != null) {
336
			String type = "projet_modifie";
339
			String type = "projet_modifie";
337
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
340
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
338
				type = "projet_ajoute";
341
				type = "projet_ajoute";
339
			}
342
			}
340
			Information info = new Information(type);
343
			Information info = new Information(type);
341
			info.setDonnee(0, projet);
344
			info.setDonnee(0, projet);
342
			vueExterneARafraichirApresValidation.rafraichir(info);
345
			vueExterneARafraichirApresValidation.rafraichir(info);
343
		}
346
		}
344
	}
347
	}
345
	
348
	
346
	public boolean soumettreFormulaire() {
349
	public boolean soumettreFormulaire() {
347
		formulaireValideOk = verifierFormulaire();
350
		formulaireValideOk = verifierFormulaire();
348
		if (formulaireValideOk) {
351
		if (formulaireValideOk) {
349
			Projet projetCollecte = collecterProjet();
352
			Projet projetCollecte = collecterProjet();
350
			if (projetCollecte != null) {
353
			if (projetCollecte != null) {
351
				if (mode.equals(Formulaire.MODE_AJOUTER)) {
354
				if (mode.equals(Formulaire.MODE_AJOUTER)) {
352
					mediateur.ajouterProjet(this, projetCollecte);
355
					mediateur.ajouterProjet(this, projetCollecte);
353
				} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
356
				} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
354
					mediateur.modifierProjet(this, projetCollecte);
357
					mediateur.modifierProjet(this, projetCollecte);
355
				}
358
				}
356
			}
359
			}
357
		}
360
		}
358
		return formulaireValideOk;
361
		return formulaireValideOk;
359
	}
362
	}
360
	
363
	
361
	public boolean verifierFormulaire() {
364
	public boolean verifierFormulaire() {
362
		boolean valide = true;
365
		boolean valide = true;
363
		ArrayList<String> messages = new ArrayList<String>();
366
		ArrayList<String> messages = new ArrayList<String>();
364
		
367
		
365
		String titre = nomChp.getValue();
368
		String titre = nomChp.getValue();
366
		if (titre == null || titre.equals("")) {
369
		if (titre == null || titre.equals("")) {
367
			messages.add(i18nC.projetMessageNom());
370
			messages.add(i18nC.projetMessageNom());
368
		}
371
		}
369
		
372
		
370
		String abr = abreviationChp.getValue();
373
		String abr = abreviationChp.getValue();
371
		if (abr == null || abr.equals(i18nC.projetMessageAbreviation())) {
374
		if (abr == null || abr.equals(i18nC.projetMessageAbreviation())) {
372
			messages.add(i18nC.projetMessageAbreviation());
375
			messages.add(i18nC.projetMessageAbreviation());
373
		}
376
		}
374
		
377
		
375
		String desc = descriptionChp.getValue();
378
		String desc = descriptionChp.getValue();
376
		if (desc == null || desc.equals(i18nC.projetMessageDescription())) {
379
		if (desc == null || desc.equals(i18nC.projetMessageDescription())) {
377
			messages.add(i18nC.projetDescription());
380
			messages.add(i18nC.projetDescription());
378
		}
381
		}
379
		
382
		
380
		String resume = resumeChp.getValue();
383
		String resume = resumeChp.getValue();
381
		if (resume == null || resume.equals(i18nC.projetMessageResume())) {
384
		if (resume == null || resume.equals(i18nC.projetMessageResume())) {
382
			messages.add(i18nC.projetMessageResume());
385
			messages.add(i18nC.projetMessageResume());
383
		}
386
		}
384
		
387
		
385
		String uri = urlChp.getValue();
388
		String uri = urlChp.getValue();
386
		if (uri != null && ! uri.trim().isEmpty() && ! uri.matches(Pattern.url)) {
389
		if (uri != null && ! uri.trim().isEmpty() && ! uri.matches(Pattern.url)) {
387
			messages.add(i18nC.messageUrlNonValide());
390
			messages.add(i18nC.messageUrlNonValide());
388
		}
391
		}
389
		
392
		
390
		if (markPublicChp.getValue()) {
393
		if (markPublicChp.getValue()) {
391
			String heure = indexationHeureChp.getValue();
394
			String heure = indexationHeureChp.getValue();
392
			if (!UtilString.isEmpty(heure) && !heure.matches(Pattern.heureMinute)) {
395
			if (!UtilString.isEmpty(heure) && !heure.matches(Pattern.heureMinute)) {
393
				messages.add(i18nC.projetMessageHeureMinute());
396
				messages.add(i18nC.projetMessageHeureMinute());
394
			}
397
			}
395
		}
398
		}
396
		
399
		
397
		if (messages.size() != 0) {
400
		if (messages.size() != 0) {
398
			String[] tableauDeMessages = {};
401
			String[] tableauDeMessages = {};
399
			tableauDeMessages = messages.toArray(tableauDeMessages);
402
			tableauDeMessages = messages.toArray(tableauDeMessages);
400
			MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null);
403
			MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null);
401
			valide = false;
404
			valide = false;
402
		}
405
		}
403
		return valide;		
406
		return valide;		
404
	}
407
	}
405
	
408
	
406
	private void peuplerFormulaire() {
409
	private void peuplerFormulaire() {
407
		nomChp.setValue(projet.getNom());
410
		nomChp.setValue(projet.getNom());
408
		abreviationChp.setValue(projet.getAbreviation());
411
		abreviationChp.setValue(projet.getAbreviation());
409
		descriptionChp.setValue(projet.getDescription());
412
		descriptionChp.setValue(projet.getDescription());
410
		resumeChp.setValue(projet.getResume());
413
		resumeChp.setValue(projet.getResume());
411
		urlChp.setValue(projet.getUrl());
414
		urlChp.setValue(projet.getUrl());
412
		
415
		
413
		motsClesChp.setValue(projet.getMotsCles());
416
		motsClesChp.setValue(projet.getMotsCles());
414
		citationChp.setValue(projet.getCitation());
417
		citationChp.setValue(projet.getCitation());
415
		licenceChp.setValue(projet.getLicence());
418
		licenceChp.setValue(projet.getLicence());
416
		if (projet.getLangue().matches("[0-9]+")) {
419
		if (projet.getLangue().matches("[0-9]+")) {
417
			langueChp.getCombo().setValue(langueChp.getStore().findModel("cmlv_id_valeur", projet.getLangue()));
420
			langueChp.getCombo().setValue(langueChp.getStore().findModel("cmlv_id_valeur", projet.getLangue()));
418
		} else {
421
		} else {
419
			langueChp.getCombo().setRawValue(projet.getLangue());
422
			langueChp.getCombo().setRawValue(projet.getLangue());
420
		}
423
		}
421
		if (projet.getMarkPublic().equals("1")) {
424
		if (projet.getMarkPublic().equals("1")) {
422
			markPublicChp.setValue(true);
425
			markPublicChp.setValue(true);
423
			String[] heureTab = projet.getIndexationHeure().split(":");
426
			String[] heureTab = projet.getIndexationHeure().split(":");
424
			if (heureTab.length > 1) {
427
			if (heureTab.length > 1) {
425
				String heure = heureTab[0]+":"+heureTab[1];
428
				String heure = heureTab[0]+":"+heureTab[1];
426
				if (heure.matches(Pattern.heureMinute)) {
429
				if (heure.matches(Pattern.heureMinute)) {
427
					indexationHeureChp.setValue(heure);
430
					indexationHeureChp.setValue(heure);
428
				}
431
				}
429
			}
432
			}
430
			indexationFrequenceChp.peupler(projet.getIndexationFreq());
433
			indexationFrequenceChp.peupler(projet.getIndexationFreq());
431
			indexationDureeChp.peupler(projet.getIndexationDuree());
434
			indexationDureeChp.peupler(projet.getIndexationDuree());
432
		} else {
435
		} else {
433
			markPublicChp.setValue(false);
436
			markPublicChp.setValue(false);
434
		}
437
		}
435
		
438
		
436
		doLayout(true);
439
		doLayout(true);
437
	}
440
	}
438
	
441
	
439
	private Projet collecterProjet() {
442
	private Projet collecterProjet() {
440
		Projet projetCollecte = (Projet) projet.cloner(new Projet());
443
		Projet projetCollecte = (Projet) projet.cloner(new Projet());
441
		
444
		
442
		projetCollecte.setNom(nomChp.getValue());
445
		projetCollecte.setNom(nomChp.getValue());
443
		projetCollecte.setAbreviation(abreviationChp.getValue());
446
		projetCollecte.setAbreviation(abreviationChp.getValue());
444
		projetCollecte.setDescription(descriptionChp.getValue());
447
		projetCollecte.setDescription(descriptionChp.getValue());
445
		projetCollecte.setResume(resumeChp.getValue());
448
		projetCollecte.setResume(resumeChp.getValue());
446
		projetCollecte.setUrl(urlChp.getValue());
449
		projetCollecte.setUrl(urlChp.getValue());
447
		
450
		
448
		projetCollecte.setMotsCles(motsClesChp.getValue());
451
		projetCollecte.setMotsCles(motsClesChp.getValue());
449
		projetCollecte.setCitation(citationChp.getValue());
452
		projetCollecte.setCitation(citationChp.getValue());
450
		projetCollecte.setLicence(licenceChp.getValue());
453
		projetCollecte.setLicence(licenceChp.getValue());
451
		if (langueChp.getValeur() != null) {
454
		if (langueChp.getValeur() != null) {
452
			Debug.log("langueChp.getValeur()="+langueChp.getValeur());
455
			Debug.log("langueChp.getValeur()="+langueChp.getValeur());
453
			Valeur valeur = new Valeur(langueChp.getValeur());
456
			Valeur valeur = new Valeur(langueChp.getValeur());
454
			projetCollecte.setLangue(valeur.getId());
457
			projetCollecte.setLangue(valeur.getId());
455
		} else {
458
		} else {
456
			projetCollecte.setLangue("");
459
			projetCollecte.setLangue("");
457
		}
460
		}
458
		String markPublic = (markPublicChp.getValue()) ? "1" : "0";
461
		String markPublic = (markPublicChp.getValue()) ? "1" : "0";
459
		projetCollecte.setMarkPublic(markPublic);
462
		projetCollecte.setMarkPublic(markPublic);
460
		
463
		
461
		projetCollecte.setIndexationHeure(indexationHeureChp.getValue());
464
		projetCollecte.setIndexationHeure(indexationHeureChp.getValue());
462
		projetCollecte.setIndexationFreq(indexationFrequenceChp.getValeur());
465
		projetCollecte.setIndexationFreq(indexationFrequenceChp.getValeur());
463
		projetCollecte.setIndexationDuree(indexationDureeChp.getValeur());
466
		projetCollecte.setIndexationDuree(indexationDureeChp.getValeur());
464
 
467
 
465
		Projet projetARetourner = null;
468
		Projet projetARetourner = null;
466
		if (!projetCollecte.comparer(projet)) {
469
		if (!projetCollecte.comparer(projet)) {
467
			projetARetourner = projet = projetCollecte;
470
			projetARetourner = projet = projetCollecte;
468
			Debug.log(projetARetourner.toString());
471
			Debug.log(projetARetourner.toString());
469
		}
472
		}
470
		return projetARetourner;
473
		return projetARetourner;
471
	}
474
	}
472
	
475
	
473
	public void reinitialiserFormulaire() {
476
	public void reinitialiserFormulaire() {
474
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
477
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
475
			mediateur.afficherFormProjet(projet.getId());
478
			mediateur.afficherFormProjet(projet.getId());
476
		} else {
479
		} else {
477
			mediateur.afficherFormProjet(null);
480
			mediateur.afficherFormProjet(null);
478
		}
481
		}
479
	}
482
	}
480
 
483
 
481
}
484
}