Subversion Repositories eFlore/Applications.coel

Rev

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

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