Subversion Repositories eFlore/Applications.coel

Rev

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