| Line 5... |
Line 5... |
| 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;
|
- |
|
| 11 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
10 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
| 12 |
import org.tela_botanica.client.modeles.Information;
|
11 |
import org.tela_botanica.client.modeles.Information;
|
| 13 |
import org.tela_botanica.client.modeles.MenuApplicationId;
|
12 |
import org.tela_botanica.client.modeles.MenuApplicationId;
|
| 14 |
import org.tela_botanica.client.modeles.commentaire.Commentaire;
|
13 |
import org.tela_botanica.client.modeles.commentaire.Commentaire;
|
| 15 |
import org.tela_botanica.client.modeles.projet.Projet;
|
- |
|
| 16 |
import org.tela_botanica.client.synchronisation.Sequenceur;
|
14 |
import org.tela_botanica.client.synchronisation.Sequenceur;
|
| 17 |
import org.tela_botanica.client.util.Debug;
|
15 |
import org.tela_botanica.client.util.Debug;
|
| 18 |
import org.tela_botanica.client.util.UtilArray;
|
16 |
import org.tela_botanica.client.util.UtilArray;
|
| 19 |
import org.tela_botanica.client.util.UtilString;
|
17 |
import org.tela_botanica.client.util.UtilString;
|
| 20 |
import org.tela_botanica.client.vues.Formulaire;
|
18 |
import org.tela_botanica.client.vues.Formulaire;
|
| Line 35... |
Line 33... |
| 35 |
|
33 |
|
| Line 36... |
Line 34... |
| 36 |
public class CommentaireForm extends Formulaire implements Rafraichissable {
|
34 |
public class CommentaireForm extends Formulaire implements Rafraichissable {
|
| Line 37... |
Line -... |
| 37 |
|
- |
|
| 38 |
private Commentaire commentaire;
|
35 |
|
| 39 |
|
36 |
private Commentaire commentaire;
|
| 40 |
private ChampComboBoxRechercheTempsReelPaginable projetsCombo = null;
|
37 |
|
| 41 |
private TextField<String> titreChp;
|
38 |
private TextField<String> titreChp;
|
| Line 85... |
Line 82... |
| 85 |
}
|
82 |
}
|
| 86 |
panneauFormulaire.setHeadingHtml(titre);
|
83 |
panneauFormulaire.setHeadingHtml(titre);
|
| 87 |
}
|
84 |
}
|
| Line 88... |
Line 85... |
| 88 |
|
85 |
|
| 89 |
private void creerChamps() {
|
- |
|
| 90 |
|
- |
|
| 91 |
ModelType modelTypeProjets = new ModelType();
|
- |
|
| 92 |
modelTypeProjets.setRoot("projets");
|
- |
|
| 93 |
modelTypeProjets.setTotalName("nbElements");
|
- |
|
| 94 |
modelTypeProjets.addField("cpr_nom");
|
- |
|
| 95 |
modelTypeProjets.addField("cpr_id_projet");
|
- |
|
| 96 |
|
- |
|
| 97 |
String displayNameProjets = "cpr_nom";
|
- |
|
| 98 |
ProxyProjets<ModelData> proxyProjets = new ProxyProjets<ModelData>(null);
|
- |
|
| 99 |
|
- |
|
| 100 |
projetsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyProjets, modelTypeProjets, displayNameProjets);
|
- |
|
| 101 |
projetsCombo.setWidth(100, 550);
|
- |
|
| 102 |
projetsCombo.getCombo().setTabIndex(tabIndex++);
|
- |
|
| 103 |
projetsCombo.getCombo().setFieldLabel(i18nC.projetChamp());
|
- |
|
| 104 |
projetsCombo.getCombo().setEmptyText(i18nC.txtListeProjetDefaut());
|
- |
|
| 105 |
projetsCombo.getCombo().setForceSelection(true);
|
- |
|
| 106 |
projetsCombo.getCombo().setEditable(false);
|
- |
|
| 107 |
projetsCombo.getCombo().setAllowBlank(false);
|
- |
|
| 108 |
projetsCombo.getCombo().setValidator(new Validator() {
|
- |
|
| 109 |
public String validate(Field<?> champ, String valeurAValider) {
|
- |
|
| 110 |
String retour = null;
|
- |
|
| 111 |
if (UtilString.isEmpty(valeurAValider)
|
- |
|
| 112 |
|| projetsCombo.getStore().findModel("cpr_nom", valeurAValider) == null) {
|
- |
|
| 113 |
champ.setValue(null);
|
- |
|
| 114 |
retour = i18nC.selectionnerValeur();
|
- |
|
| 115 |
}
|
- |
|
| 116 |
if(retour == null) {
|
- |
|
| 117 |
projetsCombo.getCombo().addStyleName(ComposantClass.OBLIGATOIRE_OK);
|
- |
|
| 118 |
projetsCombo.getCombo().removeStyleName(ComposantClass.OBLIGATOIRE);
|
- |
|
| 119 |
} else {
|
- |
|
| 120 |
projetsCombo.getCombo().removeStyleName(ComposantClass.OBLIGATOIRE_OK);
|
- |
|
| 121 |
projetsCombo.getCombo().addStyleName(ComposantClass.OBLIGATOIRE);
|
- |
|
| 122 |
}
|
- |
|
| 123 |
return retour;
|
- |
|
| 124 |
}
|
- |
|
| 125 |
});
|
- |
|
| 126 |
projetsCombo.getCombo().addStyleName(ComposantClass.OBLIGATOIRE);
|
- |
|
| 127 |
|
- |
|
| 128 |
panneauFormulaire.add(projetsCombo, new FormData(450, 0));
|
86 |
private void creerChamps() {
|
| 129 |
|
87 |
|
| 130 |
titreChp = new TextField<String>();
|
88 |
titreChp = new TextField<String>();
|
| 131 |
titreChp.setFieldLabel(i18nC.commentaireTitre());
|
89 |
titreChp.setFieldLabel(i18nC.commentaireTitre());
|
| 132 |
titreChp.setAllowBlank(false);
|
90 |
titreChp.setAllowBlank(false);
|
| 133 |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
91 |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
| Line 168... |
Line 126... |
| 168 |
commentaire = commentaireRecu;
|
126 |
commentaire = commentaireRecu;
|
| 169 |
peuplerFormulaire();
|
127 |
peuplerFormulaire();
|
| 170 |
genererTitreFormulaire();
|
128 |
genererTitreFormulaire();
|
| 171 |
}
|
129 |
}
|
| Line 172... |
Line -... |
| 172 |
|
- |
|
| 173 |
private String getValeurComboProjets() {
|
- |
|
| 174 |
String valeur = "";
|
- |
|
| 175 |
if (projetsCombo.getCombo().getValue() != null && projetsCombo.getCombo().isValid()) {
|
- |
|
| 176 |
Projet projet = new Projet (projetsCombo.getValeur());
|
- |
|
| 177 |
valeur = projet.getId();
|
- |
|
| 178 |
}
|
- |
|
| 179 |
return valeur;
|
- |
|
| 180 |
}
|
- |
|
| 181 |
|
- |
|
| 182 |
private void setValeurComboProjets() {
|
- |
|
| 183 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
- |
|
| 184 |
if (projetsCombo.getCombo().getStore() != null
|
- |
|
| 185 |
&& commentaire != null
|
- |
|
| 186 |
&& commentaire.getIdProjet() != null
|
- |
|
| 187 |
&& !UtilString.isEmpty(commentaire.getIdProjet())) {
|
- |
|
| 188 |
projetsCombo.chargerValeurInitiale(commentaire.getIdProjet(), "cpr_id_projet");
|
- |
|
| 189 |
} else {
|
- |
|
| 190 |
projetsCombo.getCombo().setValue(null);
|
- |
|
| 191 |
}
|
- |
|
| 192 |
} else if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
- |
|
| 193 |
if (projetsCombo.getCombo().getStore() != null) {
|
- |
|
| 194 |
projetsCombo.chargerValeurInitiale(mediateur.getProjetId(), "cpr_id_projet");
|
- |
|
| 195 |
} else {
|
- |
|
| 196 |
projetsCombo.getCombo().setValue(null);
|
- |
|
| 197 |
}
|
- |
|
| 198 |
}
|
- |
|
| 199 |
}
|
- |
|
| 200 |
|
130 |
|
| 201 |
private void rafraichirInformation(Information info) {
|
131 |
private void rafraichirInformation(Information info) {
|
| 202 |
// Gestion des messages d'erreur
|
132 |
// Gestion des messages d'erreur
|
| 203 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
133 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
| 204 |
Debug.log("MESSAGES:\n"+info.getMessages().toString());
|
134 |
Debug.log("MESSAGES:\n"+info.getMessages().toString());
|
| Line 283... |
Line 213... |
| 283 |
String titre = titreChp.getValue();
|
213 |
String titre = titreChp.getValue();
|
| 284 |
if (titre == null || titre.equals("")) {
|
214 |
if (titre == null || titre.equals("")) {
|
| 285 |
messages.add(i18nC.commentaireMessageTitre());
|
215 |
messages.add(i18nC.commentaireMessageTitre());
|
| 286 |
}
|
216 |
}
|
| Line 287... |
Line -... |
| 287 |
|
- |
|
| 288 |
if (UtilString.isEmpty(getValeurComboProjets())) {
|
- |
|
| 289 |
String selectionDe = i18nC.articleUn()+" "+i18nC.projetSingulier();
|
- |
|
| 290 |
String pour = i18nC.articleLa()+" "+i18nC.commentaireSingulier();
|
- |
|
| 291 |
messages.add(i18nM.selectionObligatoire(selectionDe, pour));
|
- |
|
| 292 |
}
|
- |
|
| 293 |
|
217 |
|
| 294 |
if (messages.size() != 0) {
|
218 |
if (messages.size() != 0) {
|
| 295 |
String[] tableauDeMessages = {};
|
219 |
String[] tableauDeMessages = {};
|
| 296 |
tableauDeMessages = messages.toArray(tableauDeMessages);
|
220 |
tableauDeMessages = messages.toArray(tableauDeMessages);
|
| 297 |
MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null);
|
221 |
MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null);
|
| 298 |
valide = false;
|
222 |
valide = false;
|
| 299 |
}
|
223 |
}
|
| 300 |
return valide;
|
224 |
return valide;
|
| Line 301... |
Line 225... |
| 301 |
}
|
225 |
}
|
| 302 |
|
- |
|
| 303 |
private void peuplerFormulaire() {
|
226 |
|
| 304 |
setValeurComboProjets();
|
227 |
private void peuplerFormulaire() {
|
| 305 |
titreChp.setValue(commentaire.getTitre());
|
228 |
titreChp.setValue(commentaire.getTitre());
|
| 306 |
texteChp.setValue(commentaire.getTexte());
|
229 |
texteChp.setValue(commentaire.getTexte());
|
| 307 |
ponderationChp.peupler(commentaire.getPonderation());
|
230 |
ponderationChp.peupler(commentaire.getPonderation());
|
| 308 |
boolean acces = (commentaire.etrePublic() ? true : false);
|
231 |
boolean acces = (commentaire.etrePublic() ? true : false);
|
| Line 309... |
Line 232... |
| 309 |
publicChp.setValue(acces);
|
232 |
publicChp.setValue(acces);
|
| 310 |
}
|
233 |
}
|
| Line 311... |
Line -... |
| 311 |
|
- |
|
| 312 |
private Commentaire collecterCommentaire() {
|
- |
|
| 313 |
Commentaire commentaireCollectee = (Commentaire) commentaire.cloner(new Commentaire());
|
234 |
|
| 314 |
|
235 |
private Commentaire collecterCommentaire() {
|
| Line 315... |
Line 236... |
| 315 |
commentaireCollectee.setIdProjet(getValeurComboProjets());
|
236 |
Commentaire commentaireCollectee = (Commentaire) commentaire.cloner(new Commentaire());
|
| 316 |
|
237 |
|