Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1322 Rev 1329
1
package org.tela_botanica.client.vues.commentaire;
1
package org.tela_botanica.client.vues.commentaire;
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.ChampComboBoxRechercheTempsReelPaginable;
7
import org.tela_botanica.client.composants.ChampSliderPourcentage;
8
import org.tela_botanica.client.composants.ChampSliderPourcentage;
8
import org.tela_botanica.client.composants.InfoLogger;
9
import org.tela_botanica.client.composants.InfoLogger;
-
 
10
import org.tela_botanica.client.composants.pagination.ProxyProjets;
9
import org.tela_botanica.client.interfaces.Rafraichissable;
11
import org.tela_botanica.client.interfaces.Rafraichissable;
10
import org.tela_botanica.client.modeles.Information;
12
import org.tela_botanica.client.modeles.Information;
11
import org.tela_botanica.client.modeles.MenuApplicationId;
13
import org.tela_botanica.client.modeles.MenuApplicationId;
12
import org.tela_botanica.client.modeles.commentaire.Commentaire;
14
import org.tela_botanica.client.modeles.commentaire.Commentaire;
13
import org.tela_botanica.client.modeles.projet.Projet;
15
import org.tela_botanica.client.modeles.projet.Projet;
14
import org.tela_botanica.client.modeles.projet.ProjetListe;
16
import org.tela_botanica.client.modeles.projet.ProjetListe;
15
import org.tela_botanica.client.util.Debug;
17
import org.tela_botanica.client.util.Debug;
16
import org.tela_botanica.client.util.UtilArray;
18
import org.tela_botanica.client.util.UtilArray;
17
import org.tela_botanica.client.util.UtilString;
19
import org.tela_botanica.client.util.UtilString;
18
import org.tela_botanica.client.vues.Formulaire;
20
import org.tela_botanica.client.vues.Formulaire;
-
 
21
 
-
 
22
import com.extjs.gxt.ui.client.data.ModelData;
19
 
23
import com.extjs.gxt.ui.client.data.ModelType;
20
import com.extjs.gxt.ui.client.event.Events;
24
import com.extjs.gxt.ui.client.event.Events;
21
import com.extjs.gxt.ui.client.store.ListStore;
25
import com.extjs.gxt.ui.client.store.ListStore;
22
import com.extjs.gxt.ui.client.widget.Info;
26
import com.extjs.gxt.ui.client.widget.Info;
23
import com.extjs.gxt.ui.client.widget.MessageBox;
27
import com.extjs.gxt.ui.client.widget.MessageBox;
24
import com.extjs.gxt.ui.client.widget.form.CheckBox;
28
import com.extjs.gxt.ui.client.widget.form.CheckBox;
25
import com.extjs.gxt.ui.client.widget.form.ComboBox;
29
import com.extjs.gxt.ui.client.widget.form.ComboBox;
26
import com.extjs.gxt.ui.client.widget.form.Field;
30
import com.extjs.gxt.ui.client.widget.form.Field;
27
import com.extjs.gxt.ui.client.widget.form.TextArea;
31
import com.extjs.gxt.ui.client.widget.form.TextArea;
28
import com.extjs.gxt.ui.client.widget.form.TextField;
32
import com.extjs.gxt.ui.client.widget.form.TextField;
29
import com.extjs.gxt.ui.client.widget.form.Validator;
33
import com.extjs.gxt.ui.client.widget.form.Validator;
30
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
34
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
31
import com.extjs.gxt.ui.client.widget.layout.FormData;
35
import com.extjs.gxt.ui.client.widget.layout.FormData;
32
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
36
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
33
 
37
 
34
 
38
 
35
public class CommentaireForm extends Formulaire implements Rafraichissable {
39
public class CommentaireForm extends Formulaire implements Rafraichissable {
36
	
40
	
37
	private Commentaire commentaire;
41
	private Commentaire commentaire;
38
 
42
 
39
	private ComboBox<Projet> projetsCombo = null;
43
	private ChampComboBoxRechercheTempsReelPaginable projetsCombo = null;
40
	private TextField<String> titreChp;
44
	private TextField<String> titreChp;
41
	private TextArea texteChp;
45
	private TextArea texteChp;
42
	private ChampSliderPourcentage ponderationChp;
46
	private ChampSliderPourcentage ponderationChp;
43
	private CheckBox publicChp;
47
	private CheckBox publicChp;
44
	
48
	
45
	private static boolean formulaireValideOk = false;
49
	private static boolean formulaireValideOk = false;
46
	private static boolean commentaireValideOk = false;
50
	private static boolean commentaireValideOk = false;
47
 
51
 
48
	public CommentaireForm(Mediateur mediateurCourrant, String commentaireId) {
52
	public CommentaireForm(Mediateur mediateurCourrant, String commentaireId) {
49
		initialiserCommentaireForm(mediateurCourrant, commentaireId);
53
		initialiserCommentaireForm(mediateurCourrant, commentaireId);
50
	}
54
	}
51
 
55
 
52
	public CommentaireForm(Mediateur mediateurCourrant, String commentaireId, Rafraichissable vueARafraichirApresValidation) {
56
	public CommentaireForm(Mediateur mediateurCourrant, String commentaireId, Rafraichissable vueARafraichirApresValidation) {
53
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
57
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
54
		initialiserCommentaireForm(mediateurCourrant, commentaireId);
58
		initialiserCommentaireForm(mediateurCourrant, commentaireId);
55
	}
59
	}
56
	
60
	
57
	private void initialiserCommentaireForm(Mediateur mediateurCourrant, String commentaireId) {
61
	private void initialiserCommentaireForm(Mediateur mediateurCourrant, String commentaireId) {
58
		initialiserValidation();
62
		initialiserValidation();
59
		
63
		
60
		commentaire = new Commentaire();
64
		commentaire = new Commentaire();
61
		commentaire.setId(commentaireId);
65
		commentaire.setId(commentaireId);
62
		
66
		
63
		String modeDeCreation = (UtilString.isEmpty(commentaire.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
67
		String modeDeCreation = (UtilString.isEmpty(commentaire.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
64
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.COMMENTAIRE);
68
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.COMMENTAIRE);
65
		
69
		
66
		panneauFormulaire.setLayout(new FormLayout());
70
		panneauFormulaire.setLayout(new FormLayout());
67
		genererTitreFormulaire();
71
		genererTitreFormulaire();
68
		creerChamps();
72
		creerChamps();
69
 
73
 
70
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
74
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
71
			mediateur.selectionnerCommentaire(this, commentaireId);
75
			mediateur.selectionnerCommentaire(this, commentaireId);
72
		}
76
		}
73
	}
77
	}
74
	
78
	
75
	private void genererTitreFormulaire() {
79
	private void genererTitreFormulaire() {
76
		String titre = i18nC.commentaireTitreFormAjout();
80
		String titre = i18nC.commentaireTitreFormAjout();
77
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
81
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
78
			 titre = i18nC.commentaireTitreFormModif();
82
			 titre = i18nC.commentaireTitreFormModif();
79
			 if (commentaire != null) {
83
			 if (commentaire != null) {
80
				 titre += " - "+i18nC.id()+": "+commentaire.getId();
84
				 titre += " - "+i18nC.id()+": "+commentaire.getId();
81
			 }
85
			 }
82
		}
86
		}
83
		panneauFormulaire.setHeading(titre);
87
		panneauFormulaire.setHeading(titre);
84
	}
88
	}
85
	
89
	
86
	private void creerChamps() {
90
	private void creerChamps() {
-
 
91
		
-
 
92
		ModelType modelTypeProjets = new ModelType();
87
		projetsCombo = new ComboBox<Projet>();
93
		modelTypeProjets.setRoot("projets");
88
		projetsCombo.setTabIndex(tabIndex++);
94
		modelTypeProjets.setTotalName("nbElements");
-
 
95
		modelTypeProjets.addField("cpr_nom");
89
		projetsCombo.setFieldLabel(i18nC.projetChamp());
96
		modelTypeProjets.addField("cpr_id_projet");
-
 
97
		
-
 
98
		String displayNameProjets = "cpr_nom";
-
 
99
		ProxyProjets<ModelData> proxyProjets = new ProxyProjets<ModelData>();
-
 
100
		
-
 
101
		projetsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyProjets, modelTypeProjets, displayNameProjets);
90
		projetsCombo.setDisplayField("nom");
102
		projetsCombo.setWidth(100, 550);
91
		projetsCombo.setTriggerAction(TriggerAction.ALL);
103
		projetsCombo.getCombo().setTabIndex(tabIndex++);
92
		projetsCombo.setStore(new ListStore<Projet>());
104
		projetsCombo.getCombo().setFieldLabel(i18nC.projetChamp());
93
		projetsCombo.setEmptyText(i18nC.txtListeProjetDefaut());
105
		projetsCombo.getCombo().setEmptyText(i18nC.txtListeProjetDefaut());
94
		projetsCombo.setEditable(false);
106
		projetsCombo.getCombo().setForceSelection(true);
95
		projetsCombo.setForceSelection(true);
107
		projetsCombo.getCombo().setEditable(false);
96
		projetsCombo.setAllowBlank(false);
108
		projetsCombo.getCombo().setAllowBlank(false);
-
 
109
		projetsCombo.getCombo().addStyleName(ComposantClass.OBLIGATOIRE);
97
		projetsCombo.setValidator(new Validator() {
110
		projetsCombo.getCombo().setValidator(new Validator() {
98
			public String validate(Field<?> champ, String valeurAValider) {
111
			public String validate(Field<?> champ, String valeurAValider) {
99
				String retour = null;
112
				String retour = null;
100
				if (UtilString.isEmpty(valeurAValider) 
113
				if (UtilString.isEmpty(valeurAValider) 
101
						|| projetsCombo.getStore().findModel("nom", valeurAValider) == null) {
114
						|| projetsCombo.getStore().findModel("cpr_nom", valeurAValider) == null) {
102
					champ.setValue(null);
115
					champ.setValue(null);
103
					retour = i18nC.selectionnerValeur();
116
					retour = i18nC.selectionnerValeur();
104
				}
117
				}
105
				return retour;
118
				return retour;
106
			}
119
			}
107
		});
120
		});
108
		projetsCombo.addStyleName(ComposantClass.OBLIGATOIRE);
-
 
109
		projetsCombo.addListener(Events.Valid, creerEcouteurChampObligatoire());
121
		projetsCombo.getCombo().addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
-
 
122
		
110
		panneauFormulaire.add(projetsCombo, new FormData(450, 0));
123
		panneauFormulaire.add(projetsCombo, new FormData(450, 0));
111
		mediateur.selectionnerProjet(this, null, null);
-
 
112
		
124
		
113
		titreChp = new TextField<String>();
125
		titreChp = new TextField<String>();
114
		titreChp.setFieldLabel(i18nC.commentaireTitre());
126
		titreChp.setFieldLabel(i18nC.commentaireTitre());
115
		titreChp.setAllowBlank(false);
127
		titreChp.setAllowBlank(false);
116
		titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
128
		titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
117
		titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
129
		titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
118
		titreChp.addListener(Events.Invalid, creerEcouteurChampObligatoire());
130
		titreChp.addListener(Events.Invalid, creerEcouteurChampObligatoire());
119
		panneauFormulaire.add(titreChp, new FormData(450, 0));
131
		panneauFormulaire.add(titreChp, new FormData(450, 0));
120
		
132
		
121
		texteChp = new TextArea();
133
		texteChp = new TextArea();
122
		texteChp.setFieldLabel(i18nC.commentaireTexte());
134
		texteChp.setFieldLabel(i18nC.commentaireTexte());
123
		panneauFormulaire.add(texteChp, new FormData(450, 250));
135
		panneauFormulaire.add(texteChp, new FormData(450, 250));
124
		
136
		
125
		ponderationChp = new ChampSliderPourcentage(i18nC.commentairePonderation());
137
		ponderationChp = new ChampSliderPourcentage(i18nC.commentairePonderation());
126
		panneauFormulaire.add(ponderationChp, new FormData(450, 0));
138
		panneauFormulaire.add(ponderationChp, new FormData(450, 0));
127
		
139
		
128
		publicChp = new CheckBox();
140
		publicChp = new CheckBox();
129
		publicChp.setFieldLabel(i18nC.donneePublic());
141
		publicChp.setFieldLabel(i18nC.donneePublic());
130
		panneauFormulaire.add(publicChp, new FormData(50, 0));
142
		panneauFormulaire.add(publicChp, new FormData(50, 0));
131
	}
143
	}
132
	
144
	
133
	public void rafraichir(Object nouvellesDonnees) {
145
	public void rafraichir(Object nouvellesDonnees) {
134
		if (nouvellesDonnees instanceof Commentaire) {
146
		if (nouvellesDonnees instanceof Commentaire) {
135
			// Si on a reçu les details d'une publication
147
			// Si on a reçu les details d'une publication
136
			rafraichirCommentaire((Commentaire) nouvellesDonnees);
148
			rafraichirCommentaire((Commentaire) nouvellesDonnees);
137
		} else if (nouvellesDonnees instanceof ProjetListe) {
-
 
138
			ProjetListe projets = (ProjetListe) nouvellesDonnees;
-
 
139
			Formulaire.rafraichirComboBox(projets, projetsCombo);
-
 
140
			setValeurComboProjets();
-
 
141
		} else if (nouvellesDonnees instanceof Information) {
149
		} else if (nouvellesDonnees instanceof Information) {
142
			rafraichirInformation((Information) nouvellesDonnees);	
150
			rafraichirInformation((Information) nouvellesDonnees);	
143
		} else {
151
		} else {
144
			Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
152
			Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
145
		}
153
		}
146
		
154
		
147
		if (etreValide()) {
155
		if (etreValide()) {
148
			initialiserValidation();
156
			initialiserValidation();
149
			repandreRafraichissement();
157
			repandreRafraichissement();
150
			controlerFermeture();
158
			controlerFermeture();
151
		}
159
		}
152
	}
160
	}
153
	
161
	
154
	private void rafraichirCommentaire(Commentaire commentaireRecu) {
162
	private void rafraichirCommentaire(Commentaire commentaireRecu) {
155
		commentaire = commentaireRecu;
163
		commentaire = commentaireRecu;
156
		peuplerFormulaire();
164
		peuplerFormulaire();
157
		genererTitreFormulaire();
165
		genererTitreFormulaire();
158
	}
166
	}
159
	
167
	
160
	private String getValeurComboProjets() {
168
	private String getValeurComboProjets() {
161
		String valeur = "";
169
		String valeur = "";
162
		if (projetsCombo.getValue() != null && projetsCombo.isValid()) {
170
		if (projetsCombo.getCombo().getValue() != null && projetsCombo.getCombo().isValid()) {
-
 
171
			Projet projet = new Projet (projetsCombo.getValeur());
163
			valeur = projetsCombo.getValue().getId();
172
			valeur = projet.getId();
164
		}
173
		}
165
		return valeur;
174
		return valeur;
166
	}
175
	}
167
	private void setValeurComboProjets() {
176
	private void setValeurComboProjets() {
168
		if (projetsCombo.getStore() != null ) {
177
		if (projetsCombo.getStore() != null ) {
169
			if (mode.equals(Formulaire.MODE_MODIFIER) && commentaire != null) {
178
			if (mode.equals(Formulaire.MODE_MODIFIER) && commentaire != null) {
170
				projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", commentaire.getIdProjet()));
179
				projetsCombo.getCombo().setValue(projetsCombo.getStore().findModel("cpr_id_projet", commentaire.getIdProjet()));
171
			} else if (mode.equals(Formulaire.MODE_AJOUTER)) {
180
			} else if (mode.equals(Formulaire.MODE_AJOUTER)) {
172
				projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", mediateur.getProjetId()));
181
				projetsCombo.getCombo().setValue(projetsCombo.getStore().findModel("cpr_id_projet", mediateur.getProjetId()));
173
			}
182
			}
174
		}
183
		}
175
	}
184
	}
176
	
185
	
177
	private void rafraichirInformation(Information info) {
186
	private void rafraichirInformation(Information info) {
178
		// Gestion des messages d'erreur
187
		// Gestion des messages d'erreur
179
		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
188
		if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
180
			Debug.log("MESSAGES:\n"+info.getMessages().toString());
189
			Debug.log("MESSAGES:\n"+info.getMessages().toString());
181
		}
190
		}
182
		
191
		
183
		// Gestion des actions
192
		// Gestion des actions
184
		String type = info.getType();
193
		String type = info.getType();
185
		if (type.equals("ajout_commentaire") || type.equals("modif_commentaire")) {
194
		if (type.equals("ajout_commentaire") || type.equals("modif_commentaire")) {
186
			commentaireValideOk = true;
195
			commentaireValideOk = true;
187
		}
196
		}
188
		if (info.getType().equals("ajout_commentaire")) {
197
		if (info.getType().equals("ajout_commentaire")) {
189
			if (vueExterneARafraichirApresValidation != null) {
198
			if (vueExterneARafraichirApresValidation != null) {
190
				String noteId = (String) info.getDonnee(0);
199
				String noteId = (String) info.getDonnee(0);
191
				commentaire.setId(noteId);
200
				commentaire.setId(noteId);
192
			}
201
			}
193
		}
202
		}
194
		
203
		
195
		// Gestion des messages
204
		// Gestion des messages
196
		if (info.getType().equals("modif_commentaire")) {
205
		if (info.getType().equals("modif_commentaire")) {
197
			InfoLogger.display("Modification d'une note", info.toString());
206
			InfoLogger.display("Modification d'une note", info.toString());
198
		} else if (info.getType().equals("ajout_commentaire")) {
207
		} else if (info.getType().equals("ajout_commentaire")) {
199
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
208
			if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
200
				String noteId = (String) info.getDonnee(0);
209
				String noteId = (String) info.getDonnee(0);
201
				InfoLogger.display("Ajout d'une note", "La note '"+noteId+"' a bien été ajoutée");
210
				InfoLogger.display("Ajout d'une note", "La note '"+noteId+"' a bien été ajoutée");
202
			} else {
211
			} else {
203
				InfoLogger.display("Ajout d'une note", info.toString());
212
				InfoLogger.display("Ajout d'une note", info.toString());
204
			}
213
			}
205
		}
214
		}
206
	}
215
	}
207
 
216
 
208
	private Boolean etreValide() {
217
	private Boolean etreValide() {
209
		Boolean valide = false;
218
		Boolean valide = false;
210
		Debug.log("formulaire"+formulaireValideOk+" - Commentaire :"+commentaireValideOk);
-
 
211
		if (formulaireValideOk && commentaireValideOk) {
219
		if (formulaireValideOk && commentaireValideOk) {
212
			valide = true;
220
			valide = true;
213
		}
221
		}
214
		return valide;
222
		return valide;
215
	}
223
	}
216
	
224
	
217
	private void initialiserValidation() {
225
	private void initialiserValidation() {
218
		formulaireValideOk = false;
226
		formulaireValideOk = false;
219
		commentaireValideOk = false;
227
		commentaireValideOk = false;
220
	}
228
	}
221
	
229
	
222
	private void repandreRafraichissement() {
230
	private void repandreRafraichissement() {
223
		if (vueExterneARafraichirApresValidation != null) {
231
		if (vueExterneARafraichirApresValidation != null) {
224
			String type = "commentaire_modifiee";
232
			String type = "commentaire_modifiee";
225
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
233
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
226
				type = "commentaire_ajoutee";
234
				type = "commentaire_ajoutee";
227
			}
235
			}
228
			Information info = new Information(type);
236
			Information info = new Information(type);
229
			info.setDonnee(0, commentaire);
237
			info.setDonnee(0, commentaire);
230
			vueExterneARafraichirApresValidation.rafraichir(info);
238
			vueExterneARafraichirApresValidation.rafraichir(info);
231
		}
239
		}
232
	}
240
	}
233
	
241
	
234
	public boolean soumettreFormulaire() {
242
	public boolean soumettreFormulaire() {
235
		formulaireValideOk = verifierFormulaire();
243
		formulaireValideOk = verifierFormulaire();
236
		if (formulaireValideOk) {
244
		if (formulaireValideOk) {
237
			soumettreCommentaire();
245
			soumettreCommentaire();
238
		}
246
		}
239
		return formulaireValideOk;
247
		return formulaireValideOk;
240
	}
248
	}
241
	
249
	
242
	private void soumettreCommentaire() {
250
	private void soumettreCommentaire() {
243
		Commentaire commentaireCollectee = collecterCommentaire();
251
		Commentaire commentaireCollectee = collecterCommentaire();
244
		if (commentaireCollectee != null) {
252
		if (commentaireCollectee != null) {
245
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
253
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
246
				mediateur.ajouterCommentaire(this, commentaireCollectee);
254
				mediateur.ajouterCommentaire(this, commentaireCollectee);
247
			} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
255
			} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
248
				mediateur.modifierCommentaire(this, commentaireCollectee);
256
				mediateur.modifierCommentaire(this, commentaireCollectee);
249
			}
257
			}
250
		}
258
		}
251
	}
259
	}
252
	
260
	
253
	public boolean verifierFormulaire() {
261
	public boolean verifierFormulaire() {
254
		boolean valide = true;
262
		boolean valide = true;
255
		ArrayList<String> messages = new ArrayList<String>();
263
		ArrayList<String> messages = new ArrayList<String>();
256
		
264
		
257
		String titre = titreChp.getValue();
265
		String titre = titreChp.getValue();
258
		if (titre == null || titre.equals("")) {
266
		if (titre == null || titre.equals("")) {
259
			messages.add(i18nC.commentaireMessageTitre());
267
			messages.add(i18nC.commentaireMessageTitre());
260
		}
268
		}
261
		
269
		
262
		if (UtilString.isEmpty(getValeurComboProjets())) {
270
		if (UtilString.isEmpty(getValeurComboProjets())) {
263
			String selectionDe = i18nC.articleUn()+" "+i18nC.projetSingulier();
271
			String selectionDe = i18nC.articleUn()+" "+i18nC.projetSingulier();
264
			String pour = i18nC.articleLa()+" "+i18nC.commentaireSingulier();
272
			String pour = i18nC.articleLa()+" "+i18nC.commentaireSingulier();
265
			messages.add(i18nM.selectionObligatoire(selectionDe, pour));
273
			messages.add(i18nM.selectionObligatoire(selectionDe, pour));
266
		}
274
		}
267
		
275
		
268
		if (messages.size() != 0) {
276
		if (messages.size() != 0) {
269
			String[] tableauDeMessages = {};
277
			String[] tableauDeMessages = {};
270
			tableauDeMessages = messages.toArray(tableauDeMessages);
278
			tableauDeMessages = messages.toArray(tableauDeMessages);
271
			MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null);
279
			MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null);
272
			valide = false;
280
			valide = false;
273
		}
281
		}
274
		return valide;		
282
		return valide;		
275
	}
283
	}
276
	
284
	
277
	private void peuplerFormulaire() {
285
	private void peuplerFormulaire() {
278
		setValeurComboProjets();
286
		setValeurComboProjets();
279
		titreChp.setValue(commentaire.getTitre());
287
		titreChp.setValue(commentaire.getTitre());
280
		texteChp.setValue(commentaire.getTexte());
288
		texteChp.setValue(commentaire.getTexte());
281
		ponderationChp.peupler(commentaire.getPonderation());
289
		ponderationChp.peupler(commentaire.getPonderation());
282
		boolean acces = (commentaire.etrePublic() ? true : false);
290
		boolean acces = (commentaire.etrePublic() ? true : false);
283
		publicChp.setValue(acces);
291
		publicChp.setValue(acces);
284
	}
292
	}
285
	
293
	
286
	private Commentaire collecterCommentaire() {
294
	private Commentaire collecterCommentaire() {
287
		Commentaire commentaireCollectee = (Commentaire) commentaire.cloner(new Commentaire());
295
		Commentaire commentaireCollectee = (Commentaire) commentaire.cloner(new Commentaire());
288
		
296
		
289
		commentaireCollectee.setIdProjet(getValeurComboProjets());
297
		commentaireCollectee.setIdProjet(getValeurComboProjets());
290
		
298
		
291
		String titre = titreChp.getValue();
299
		String titre = titreChp.getValue();
292
		commentaireCollectee.setTitre(titre);
300
		commentaireCollectee.setTitre(titre);
293
		
301
		
294
		String texte = texteChp.getValue();
302
		String texte = texteChp.getValue();
295
		commentaireCollectee.setTexte(texte);
303
		commentaireCollectee.setTexte(texte);
296
		
304
		
297
		String ponderation = ponderationChp.getValeur();
305
		String ponderation = ponderationChp.getValeur();
298
		commentaireCollectee.setPonderation(ponderation);
306
		commentaireCollectee.setPonderation(ponderation);
299
		
307
		
300
		String acces = (publicChp.getValue() ? "1" : "0");
308
		String acces = (publicChp.getValue() ? "1" : "0");
301
		commentaireCollectee.setPublic(acces);
309
		commentaireCollectee.setPublic(acces);
302
		
310
		
303
		Commentaire commentaireARetourner = null;
311
		Commentaire commentaireARetourner = null;
304
		if (!commentaireCollectee.comparer(commentaire)) {
312
		if (!commentaireCollectee.comparer(commentaire)) {
305
			commentaireARetourner = commentaire = commentaireCollectee;
313
			commentaireARetourner = commentaire = commentaireCollectee;
306
		}
314
		}
307
		return commentaireARetourner;
315
		return commentaireARetourner;
308
	}
316
	}
309
	
317
	
310
	public void reinitialiserFormulaire() {
318
	public void reinitialiserFormulaire() {
311
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
319
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
312
			mediateur.afficherFormPublication(commentaire.getId());
320
			mediateur.afficherFormPublication(commentaire.getId());
313
		} else {
321
		} else {
314
			mediateur.afficherFormPublication(null);
322
			mediateur.afficherFormPublication(null);
315
		}
323
		}
316
	}
324
	}
317
}
325
}