Subversion Repositories eFlore/Applications.coel

Rev

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

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