Subversion Repositories eFlore/Applications.coel

Rev

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

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