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