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>(null);
|
102 |
ProxyProjets<ModelData> proxyProjets = new ProxyProjets<ModelData>(null);
|
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().setValidator(new Validator() {
|
112 |
projetsCombo.getCombo().setValidator(new Validator() {
|
113 |
public String validate(Field<?> champ, String valeurAValider) {
|
113 |
public String validate(Field<?> champ, String valeurAValider) {
|
114 |
String retour = null;
|
114 |
String retour = null;
|
115 |
if (UtilString.isEmpty(valeurAValider)
|
115 |
if (UtilString.isEmpty(valeurAValider)
|
116 |
|| projetsCombo.getStore().findModel("cpr_nom", valeurAValider) == null) {
|
116 |
|| projetsCombo.getStore().findModel("cpr_nom", valeurAValider) == null) {
|
117 |
champ.setValue(null);
|
117 |
champ.setValue(null);
|
118 |
retour = i18nC.selectionnerValeur();
|
118 |
retour = i18nC.selectionnerValeur();
|
119 |
}
|
119 |
}
|
120 |
return retour;
|
120 |
return retour;
|
121 |
}
|
121 |
}
|
122 |
});
|
122 |
});
|
123 |
|
123 |
|
124 |
panneauFormulaire.add(projetsCombo, new FormData(450, 0));
|
124 |
panneauFormulaire.add(projetsCombo, new FormData(450, 0));
|
125 |
|
125 |
|
126 |
titreChp = new TextField<String>();
|
126 |
titreChp = new TextField<String>();
|
127 |
titreChp.setFieldLabel(i18nC.commentaireTitre());
|
127 |
titreChp.setFieldLabel(i18nC.commentaireTitre());
|
128 |
titreChp.setAllowBlank(false);
|
128 |
titreChp.setAllowBlank(false);
|
129 |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
129 |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
130 |
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
130 |
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
131 |
titreChp.addListener(Events.Invalid, creerEcouteurChampObligatoire());
|
131 |
titreChp.addListener(Events.Invalid, creerEcouteurChampObligatoire());
|
132 |
panneauFormulaire.add(titreChp, new FormData(450, 0));
|
132 |
panneauFormulaire.add(titreChp, new FormData(450, 0));
|
133 |
|
133 |
|
134 |
texteChp = new TextArea();
|
134 |
texteChp = new TextArea();
|
135 |
texteChp.setFieldLabel(i18nC.commentaireTexte());
|
135 |
texteChp.setFieldLabel(i18nC.commentaireTexte());
|
136 |
panneauFormulaire.add(texteChp, new FormData(450, 250));
|
136 |
panneauFormulaire.add(texteChp, new FormData(450, 250));
|
137 |
|
137 |
|
138 |
ponderationChp = new ChampSliderPourcentage(i18nC.commentairePonderation());
|
138 |
ponderationChp = new ChampSliderPourcentage(i18nC.commentairePonderation());
|
139 |
panneauFormulaire.add(ponderationChp, new FormData(450, 0));
|
139 |
panneauFormulaire.add(ponderationChp, new FormData(450, 0));
|
140 |
|
140 |
|
141 |
publicChp = new CheckBox();
|
141 |
publicChp = new CheckBox();
|
142 |
publicChp.setFieldLabel(i18nC.donneePublic());
|
142 |
publicChp.setFieldLabel(i18nC.donneePublic());
|
143 |
panneauFormulaire.add(publicChp, new FormData(50, 0));
|
143 |
panneauFormulaire.add(publicChp, new FormData(50, 0));
|
144 |
}
|
144 |
}
|
145 |
|
145 |
|
146 |
public void rafraichir(Object nouvellesDonnees) {
|
146 |
public void rafraichir(Object nouvellesDonnees) {
|
147 |
if (nouvellesDonnees instanceof Commentaire) {
|
147 |
if (nouvellesDonnees instanceof Commentaire) {
|
148 |
// Si on a reçu les details d'une publication
|
148 |
// Si on a reçu les details d'une publication
|
149 |
rafraichirCommentaire((Commentaire) nouvellesDonnees);
|
149 |
rafraichirCommentaire((Commentaire) nouvellesDonnees);
|
150 |
} else if (nouvellesDonnees instanceof Information) {
|
150 |
} else if (nouvellesDonnees instanceof Information) {
|
151 |
rafraichirInformation((Information) nouvellesDonnees);
|
151 |
rafraichirInformation((Information) nouvellesDonnees);
|
152 |
} else {
|
152 |
} else {
|
153 |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
|
153 |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
|
154 |
}
|
154 |
}
|
155 |
|
155 |
|
156 |
if (etreValide()) {
|
156 |
if (etreValide()) {
|
157 |
initialiserValidation();
|
157 |
initialiserValidation();
|
158 |
repandreRafraichissement();
|
158 |
repandreRafraichissement();
|
159 |
controlerFermeture();
|
159 |
controlerFermeture();
|
160 |
}
|
160 |
}
|
161 |
}
|
161 |
}
|
162 |
|
162 |
|
163 |
private void rafraichirCommentaire(Commentaire commentaireRecu) {
|
163 |
private void rafraichirCommentaire(Commentaire commentaireRecu) {
|
164 |
commentaire = commentaireRecu;
|
164 |
commentaire = commentaireRecu;
|
165 |
peuplerFormulaire();
|
165 |
peuplerFormulaire();
|
166 |
genererTitreFormulaire();
|
166 |
genererTitreFormulaire();
|
167 |
}
|
167 |
}
|
168 |
|
168 |
|
169 |
private String getValeurComboProjets() {
|
169 |
private String getValeurComboProjets() {
|
170 |
String valeur = "";
|
170 |
String valeur = "";
|
171 |
if (projetsCombo.getCombo().getValue() != null && projetsCombo.getCombo().isValid()) {
|
171 |
if (projetsCombo.getCombo().getValue() != null && projetsCombo.getCombo().isValid()) {
|
172 |
Projet projet = new Projet (projetsCombo.getValeur());
|
172 |
Projet projet = new Projet (projetsCombo.getValeur());
|
173 |
valeur = projet.getId();
|
173 |
valeur = projet.getId();
|
174 |
}
|
174 |
}
|
175 |
return valeur;
|
175 |
return valeur;
|
176 |
}
|
176 |
}
|
- |
|
177 |
|
177 |
private void setValeurComboProjets() {
|
178 |
private void setValeurComboProjets() {
|
- |
|
179 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
178 |
if (projetsCombo.getStore() != null ) {
|
180 |
if (projetsCombo.getCombo().getStore() != null
|
- |
|
181 |
&& commentaire != null
|
- |
|
182 |
&& commentaire.getIdProjet() != null
|
179 |
if (mode.equals(Formulaire.MODE_MODIFIER) && commentaire != null) {
|
183 |
&& !UtilString.isEmpty(commentaire.getIdProjet())) {
|
180 |
projetsCombo.getCombo().setValue(projetsCombo.getStore().findModel("cpr_id_projet", commentaire.getIdProjet()));
|
184 |
projetsCombo.chargerValeurInitiale(commentaire.getIdProjet(), "cpr_id_projet");
|
- |
|
185 |
} else {
|
- |
|
186 |
projetsCombo.getCombo().setValue(null);
|
- |
|
187 |
}
|
181 |
} else if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
188 |
} else if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
- |
|
189 |
if (projetsCombo.getCombo().getStore() != null) {
|
182 |
projetsCombo.getCombo().setValue(projetsCombo.getStore().findModel("cpr_id_projet", mediateur.getProjetId()));
|
190 |
projetsCombo.chargerValeurInitiale(mediateur.getProjetId(), "cpr_id_projet");
|
- |
|
191 |
} else {
|
- |
|
192 |
projetsCombo.getCombo().setValue(null);
|
183 |
}
|
193 |
}
|
184 |
}
|
194 |
}
|
185 |
}
|
195 |
}
|
186 |
|
196 |
|
187 |
private void rafraichirInformation(Information info) {
|
197 |
private void rafraichirInformation(Information info) {
|
188 |
// Gestion des messages d'erreur
|
198 |
// Gestion des messages d'erreur
|
189 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
199 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
190 |
Debug.log("MESSAGES:\n"+info.getMessages().toString());
|
200 |
Debug.log("MESSAGES:\n"+info.getMessages().toString());
|
191 |
}
|
201 |
}
|
192 |
|
202 |
|
193 |
// Gestion des actions
|
203 |
// Gestion des actions
|
194 |
String type = info.getType();
|
204 |
String type = info.getType();
|
195 |
if (type.equals("ajout_commentaire") || type.equals("modif_commentaire")) {
|
205 |
if (type.equals("ajout_commentaire") || type.equals("modif_commentaire")) {
|
196 |
commentaireValideOk = true;
|
206 |
commentaireValideOk = true;
|
197 |
}
|
207 |
}
|
198 |
if (info.getType().equals("ajout_commentaire")) {
|
208 |
if (info.getType().equals("ajout_commentaire")) {
|
199 |
if (vueExterneARafraichirApresValidation != null) {
|
209 |
if (vueExterneARafraichirApresValidation != null) {
|
200 |
String noteId = (String) info.getDonnee(0);
|
210 |
String noteId = (String) info.getDonnee(0);
|
201 |
commentaire.setId(noteId);
|
211 |
commentaire.setId(noteId);
|
202 |
}
|
212 |
}
|
203 |
}
|
213 |
}
|
204 |
|
214 |
|
205 |
// Gestion des messages
|
215 |
// Gestion des messages
|
206 |
if (info.getType().equals("modif_commentaire")) {
|
216 |
if (info.getType().equals("modif_commentaire")) {
|
207 |
InfoLogger.display("Modification d'une note", info.toString());
|
217 |
InfoLogger.display("Modification d'une note", info.toString());
|
208 |
} else if (info.getType().equals("ajout_commentaire")) {
|
218 |
} else if (info.getType().equals("ajout_commentaire")) {
|
209 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
|
219 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
|
210 |
String noteId = (String) info.getDonnee(0);
|
220 |
String noteId = (String) info.getDonnee(0);
|
211 |
InfoLogger.display("Ajout d'une note", "La note '"+noteId+"' a bien été ajoutée");
|
221 |
InfoLogger.display("Ajout d'une note", "La note '"+noteId+"' a bien été ajoutée");
|
212 |
} else {
|
222 |
} else {
|
213 |
InfoLogger.display("Ajout d'une note", info.toString());
|
223 |
InfoLogger.display("Ajout d'une note", info.toString());
|
214 |
}
|
224 |
}
|
215 |
}
|
225 |
}
|
216 |
}
|
226 |
}
|
217 |
|
227 |
|
218 |
private Boolean etreValide() {
|
228 |
private Boolean etreValide() {
|
219 |
Boolean valide = false;
|
229 |
Boolean valide = false;
|
220 |
if (formulaireValideOk && commentaireValideOk) {
|
230 |
if (formulaireValideOk && commentaireValideOk) {
|
221 |
valide = true;
|
231 |
valide = true;
|
222 |
}
|
232 |
}
|
223 |
return valide;
|
233 |
return valide;
|
224 |
}
|
234 |
}
|
225 |
|
235 |
|
226 |
private void initialiserValidation() {
|
236 |
private void initialiserValidation() {
|
227 |
formulaireValideOk = false;
|
237 |
formulaireValideOk = false;
|
228 |
commentaireValideOk = false;
|
238 |
commentaireValideOk = false;
|
229 |
}
|
239 |
}
|
230 |
|
240 |
|
231 |
private void repandreRafraichissement() {
|
241 |
private void repandreRafraichissement() {
|
232 |
if (vueExterneARafraichirApresValidation != null) {
|
242 |
if (vueExterneARafraichirApresValidation != null) {
|
233 |
String type = "commentaire_modifiee";
|
243 |
String type = "commentaire_modifiee";
|
234 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
244 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
235 |
type = "commentaire_ajoutee";
|
245 |
type = "commentaire_ajoutee";
|
236 |
}
|
246 |
}
|
237 |
Information info = new Information(type);
|
247 |
Information info = new Information(type);
|
238 |
info.setDonnee(0, commentaire);
|
248 |
info.setDonnee(0, commentaire);
|
239 |
vueExterneARafraichirApresValidation.rafraichir(info);
|
249 |
vueExterneARafraichirApresValidation.rafraichir(info);
|
240 |
}
|
250 |
}
|
241 |
}
|
251 |
}
|
242 |
|
252 |
|
243 |
public boolean soumettreFormulaire() {
|
253 |
public boolean soumettreFormulaire() {
|
244 |
formulaireValideOk = verifierFormulaire();
|
254 |
formulaireValideOk = verifierFormulaire();
|
245 |
if (formulaireValideOk) {
|
255 |
if (formulaireValideOk) {
|
246 |
soumettreCommentaire();
|
256 |
soumettreCommentaire();
|
247 |
}
|
257 |
}
|
248 |
return formulaireValideOk;
|
258 |
return formulaireValideOk;
|
249 |
}
|
259 |
}
|
250 |
|
260 |
|
251 |
private void soumettreCommentaire() {
|
261 |
private void soumettreCommentaire() {
|
252 |
Commentaire commentaireCollectee = collecterCommentaire();
|
262 |
Commentaire commentaireCollectee = collecterCommentaire();
|
253 |
if (commentaireCollectee != null) {
|
263 |
if (commentaireCollectee != null) {
|
254 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
264 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
255 |
mediateur.ajouterCommentaire(this, commentaireCollectee);
|
265 |
mediateur.ajouterCommentaire(this, commentaireCollectee);
|
256 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
266 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
257 |
mediateur.modifierCommentaire(this, commentaireCollectee);
|
267 |
mediateur.modifierCommentaire(this, commentaireCollectee);
|
258 |
}
|
268 |
}
|
259 |
}
|
269 |
}
|
260 |
}
|
270 |
}
|
261 |
|
271 |
|
262 |
public boolean verifierFormulaire() {
|
272 |
public boolean verifierFormulaire() {
|
263 |
boolean valide = true;
|
273 |
boolean valide = true;
|
264 |
ArrayList<String> messages = new ArrayList<String>();
|
274 |
ArrayList<String> messages = new ArrayList<String>();
|
265 |
|
275 |
|
266 |
String titre = titreChp.getValue();
|
276 |
String titre = titreChp.getValue();
|
267 |
if (titre == null || titre.equals("")) {
|
277 |
if (titre == null || titre.equals("")) {
|
268 |
messages.add(i18nC.commentaireMessageTitre());
|
278 |
messages.add(i18nC.commentaireMessageTitre());
|
269 |
}
|
279 |
}
|
270 |
|
280 |
|
271 |
if (UtilString.isEmpty(getValeurComboProjets())) {
|
281 |
if (UtilString.isEmpty(getValeurComboProjets())) {
|
272 |
String selectionDe = i18nC.articleUn()+" "+i18nC.projetSingulier();
|
282 |
String selectionDe = i18nC.articleUn()+" "+i18nC.projetSingulier();
|
273 |
String pour = i18nC.articleLa()+" "+i18nC.commentaireSingulier();
|
283 |
String pour = i18nC.articleLa()+" "+i18nC.commentaireSingulier();
|
274 |
messages.add(i18nM.selectionObligatoire(selectionDe, pour));
|
284 |
messages.add(i18nM.selectionObligatoire(selectionDe, pour));
|
275 |
}
|
285 |
}
|
276 |
|
286 |
|
277 |
if (messages.size() != 0) {
|
287 |
if (messages.size() != 0) {
|
278 |
String[] tableauDeMessages = {};
|
288 |
String[] tableauDeMessages = {};
|
279 |
tableauDeMessages = messages.toArray(tableauDeMessages);
|
289 |
tableauDeMessages = messages.toArray(tableauDeMessages);
|
280 |
MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null);
|
290 |
MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null);
|
281 |
valide = false;
|
291 |
valide = false;
|
282 |
}
|
292 |
}
|
283 |
return valide;
|
293 |
return valide;
|
284 |
}
|
294 |
}
|
285 |
|
295 |
|
286 |
private void peuplerFormulaire() {
|
296 |
private void peuplerFormulaire() {
|
287 |
setValeurComboProjets();
|
297 |
setValeurComboProjets();
|
288 |
titreChp.setValue(commentaire.getTitre());
|
298 |
titreChp.setValue(commentaire.getTitre());
|
289 |
texteChp.setValue(commentaire.getTexte());
|
299 |
texteChp.setValue(commentaire.getTexte());
|
290 |
ponderationChp.peupler(commentaire.getPonderation());
|
300 |
ponderationChp.peupler(commentaire.getPonderation());
|
291 |
boolean acces = (commentaire.etrePublic() ? true : false);
|
301 |
boolean acces = (commentaire.etrePublic() ? true : false);
|
292 |
publicChp.setValue(acces);
|
302 |
publicChp.setValue(acces);
|
293 |
}
|
303 |
}
|
294 |
|
304 |
|
295 |
private Commentaire collecterCommentaire() {
|
305 |
private Commentaire collecterCommentaire() {
|
296 |
Commentaire commentaireCollectee = (Commentaire) commentaire.cloner(new Commentaire());
|
306 |
Commentaire commentaireCollectee = (Commentaire) commentaire.cloner(new Commentaire());
|
297 |
|
307 |
|
298 |
commentaireCollectee.setIdProjet(getValeurComboProjets());
|
308 |
commentaireCollectee.setIdProjet(getValeurComboProjets());
|
299 |
|
309 |
|
300 |
String titre = titreChp.getValue();
|
310 |
String titre = titreChp.getValue();
|
301 |
commentaireCollectee.setTitre(titre);
|
311 |
commentaireCollectee.setTitre(titre);
|
302 |
|
312 |
|
303 |
String texte = texteChp.getValue();
|
313 |
String texte = texteChp.getValue();
|
304 |
commentaireCollectee.setTexte(texte);
|
314 |
commentaireCollectee.setTexte(texte);
|
305 |
|
315 |
|
306 |
String ponderation = ponderationChp.getValeur();
|
316 |
String ponderation = ponderationChp.getValeur();
|
307 |
commentaireCollectee.setPonderation(ponderation);
|
317 |
commentaireCollectee.setPonderation(ponderation);
|
308 |
|
318 |
|
309 |
String acces = (publicChp.getValue() ? "1" : "0");
|
319 |
String acces = (publicChp.getValue() ? "1" : "0");
|
310 |
commentaireCollectee.setPublic(acces);
|
320 |
commentaireCollectee.setPublic(acces);
|
311 |
|
321 |
|
312 |
Commentaire commentaireARetourner = null;
|
322 |
Commentaire commentaireARetourner = null;
|
313 |
if (!commentaireCollectee.comparer(commentaire)) {
|
323 |
if (!commentaireCollectee.comparer(commentaire)) {
|
314 |
commentaireARetourner = commentaire = commentaireCollectee;
|
324 |
commentaireARetourner = commentaire = commentaireCollectee;
|
315 |
}
|
325 |
}
|
316 |
return commentaireARetourner;
|
326 |
return commentaireARetourner;
|
317 |
}
|
327 |
}
|
318 |
|
328 |
|
319 |
public void reinitialiserFormulaire() {
|
329 |
public void reinitialiserFormulaire() {
|
320 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
330 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
321 |
mediateur.afficherFormPublication(commentaire.getId());
|
331 |
mediateur.afficherFormPublication(commentaire.getId());
|
322 |
} else {
|
332 |
} else {
|
323 |
mediateur.afficherFormPublication(null);
|
333 |
mediateur.afficherFormPublication(null);
|
324 |
}
|
334 |
}
|
325 |
}
|
335 |
}
|
326 |
}
|
336 |
}
|