Subversion Repositories eFlore/Applications.coel

Rev

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

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