Subversion Repositories eFlore/Applications.coel

Rev

Rev 1337 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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