| Line 1... |
Line 1... |
| 1 |
package org.tela_botanica.client.vues.personne;
|
1 |
package org.tela_botanica.client.vues.personne;
|
| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| - |
|
3 |
import java.util.ArrayList;
|
| - |
|
4 |
import java.util.Iterator;
|
| 3 |
import java.util.ArrayList;
|
5 |
import java.util.LinkedList;
|
| Line 4... |
Line 6... |
| 4 |
import java.util.List;
|
6 |
import java.util.List;
|
| 5 |
|
7 |
|
| 6 |
import org.tela_botanica.client.ComposantClass;
|
8 |
import org.tela_botanica.client.ComposantClass;
|
| 7 |
import org.tela_botanica.client.Mediateur;
|
9 |
import org.tela_botanica.client.Mediateur;
|
| 8 |
import org.tela_botanica.client.images.Images;
|
10 |
import org.tela_botanica.client.images.Images;
|
| 9 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
11 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
| 10 |
import org.tela_botanica.client.modeles.Information;
|
12 |
import org.tela_botanica.client.modeles.Information;
|
| 11 |
import org.tela_botanica.client.modeles.Valeur;
|
13 |
import org.tela_botanica.client.modeles.Valeur;
|
| 12 |
import org.tela_botanica.client.modeles.ValeurListe;
|
- |
|
| 13 |
import org.tela_botanica.client.modeles.aDonnee;
|
14 |
import org.tela_botanica.client.modeles.ValeurListe;
|
| 14 |
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
|
15 |
import org.tela_botanica.client.modeles.aDonnee;
|
| 15 |
import org.tela_botanica.client.modeles.personne.Personne;
|
16 |
import org.tela_botanica.client.modeles.personne.Personne;
|
| 16 |
import org.tela_botanica.client.modeles.publication.Publication;
|
17 |
import org.tela_botanica.client.modeles.publication.Publication;
|
| 17 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
|
18 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
|
| 18 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
|
19 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
|
| - |
|
20 |
import org.tela_botanica.client.modeles.publication.PublicationListe;
|
| 19 |
import org.tela_botanica.client.modeles.publication.PublicationListe;
|
21 |
import org.tela_botanica.client.util.Debug;
|
| 20 |
import org.tela_botanica.client.util.Debug;
|
22 |
import org.tela_botanica.client.util.UtilString;
|
| 21 |
import org.tela_botanica.client.vues.FenetreForm;
|
23 |
import org.tela_botanica.client.vues.FenetreForm;
|
| 22 |
import org.tela_botanica.client.vues.Formulaire;
|
24 |
import org.tela_botanica.client.vues.Formulaire;
|
| 23 |
import org.tela_botanica.client.vues.FormulaireBarreValidation;
|
25 |
import org.tela_botanica.client.vues.FormulaireBarreValidation;
|
| Line 71... |
Line 73... |
| 71 |
private PublicationAPersonneListe publicationsSupprimees = null;
|
73 |
private PublicationAPersonneListe publicationsSupprimees = null;
|
| 72 |
private ComboBox<Publication> publicationsSaisiesComboBox = null;
|
74 |
private ComboBox<Publication> publicationsSaisiesComboBox = null;
|
| 73 |
private Button publicationsBoutonSupprimer = null;
|
75 |
private Button publicationsBoutonSupprimer = null;
|
| 74 |
private Button publicationsBoutonModifier = null;
|
76 |
private Button publicationsBoutonModifier = null;
|
| 75 |
private ComboBox<Valeur> typeRelationCombo = null;
|
77 |
private ComboBox<Valeur> typeRelationCombo = null;
|
| - |
|
78 |
private List<Valeur> roles = null;
|
| - |
|
79 |
private PublicationAPersonneListe listePublicationsLiees = new PublicationAPersonneListe();
|
| Line 76... |
Line 80... |
| 76 |
|
80 |
|
| Line 77... |
Line 81... |
| 77 |
private FenetreForm fenetreFormulaire = null;
|
81 |
private FenetreForm fenetreFormulaire = null;
|
| 78 |
|
82 |
|
| Line 85... |
Line 89... |
| 85 |
panneauPrincipal = creerPanneauContenantGrille();
|
89 |
panneauPrincipal = creerPanneauContenantGrille();
|
| 86 |
barreOutils = creerBarreOutilsGrille();
|
90 |
barreOutils = creerBarreOutilsGrille();
|
| 87 |
panneauPrincipal.setTopComponent(barreOutils);
|
91 |
panneauPrincipal.setTopComponent(barreOutils);
|
| 88 |
grille = creerGrille();
|
92 |
grille = creerGrille();
|
| 89 |
panneauPrincipal.add(grille);
|
93 |
panneauPrincipal.add(grille);
|
| 90 |
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication");
|
- |
|
| 91 |
add(panneauPrincipal);
|
94 |
add(panneauPrincipal);
|
| Line 92... |
Line 95... |
| 92 |
|
95 |
|
| 93 |
initialiser();
|
96 |
initialiser();
|
| Line 99... |
Line 102... |
| 99 |
publicationsAjoutees = new PublicationAPersonneListe();
|
102 |
publicationsAjoutees = new PublicationAPersonneListe();
|
| 100 |
publicationsSupprimees = new PublicationAPersonneListe();
|
103 |
publicationsSupprimees = new PublicationAPersonneListe();
|
| Line 101... |
Line 104... |
| 101 |
|
104 |
|
| 102 |
// Actualisation de l'état des boutons de la barre d'outils
|
105 |
// Actualisation de l'état des boutons de la barre d'outils
|
| 103 |
actualiserEtatBoutonsBarreOutils();
|
- |
|
| 104 |
mettreAJourPersonne();
|
106 |
actualiserEtatBoutonsBarreOutils();
|
| Line 105... |
Line 107... |
| 105 |
}
|
107 |
}
|
| 106 |
|
108 |
|
| - |
|
109 |
public void mettreAJourPersonne() {
|
| - |
|
110 |
personneSelectionnee = ((PersonneForm) formulaire).personneSelectionnee;
|
| - |
|
111 |
//Boucle sur les role pour trouver les publication à personne
|
| - |
|
112 |
if (roles != null) {
|
| 107 |
public void mettreAJourPersonne() {
|
113 |
mediateur.selectionnerPublicationAPersonne(this, null, personneSelectionnee.getId(), roles);
|
| Line 108... |
Line 114... |
| 108 |
personneSelectionnee = ((PersonneForm) formulaire).personneSelectionnee;
|
114 |
}
|
| 109 |
}
|
115 |
}
|
| Line 307... |
Line 313... |
| 307 |
ajouterDansGrille(publication, 0);
|
313 |
ajouterDansGrille(publication, 0);
|
| 308 |
}
|
314 |
}
|
| Line 309... |
Line 315... |
| 309 |
|
315 |
|
| 310 |
private void ajouterDansGrille(Publication publication, int index) {
|
316 |
private void ajouterDansGrille(Publication publication, int index) {
|
| 311 |
if (publication != null) {
|
- |
|
| 312 |
/*CollectionAPublication publicationLiee = new CollectionAPublication();
|
- |
|
| 313 |
publicationLiee.setPublication(publication);
|
- |
|
| 314 |
publicationLiee.setIdPublication(publication.getId());
|
- |
|
| 315 |
// Gestion de l'id de la collection
|
- |
|
| 316 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
- |
|
| 317 |
publicationLiee.setIdCollection(collection.getId());
|
- |
|
| 318 |
}
|
- |
|
| 319 |
|
- |
|
| 320 |
*/
|
- |
|
| 321 |
|
- |
|
| 322 |
PublicationAPersonne publicationLiee = new PublicationAPersonne();
|
- |
|
| 323 |
publicationLiee.setPersonne(personneSelectionnee);
|
- |
|
| 324 |
publicationLiee.setPublicationLiee(publication);
|
- |
|
| 325 |
publicationLiee.setIdPublication(publication.getId());
|
- |
|
| Line -... |
Line 317... |
| - |
|
317 |
if (publication != null) {
|
| - |
|
318 |
|
| - |
|
319 |
if (!listePublicationsLiees.containsKey(publication.getId())) {
|
| - |
|
320 |
PublicationAPersonne publicationLiee = new PublicationAPersonne();
|
| - |
|
321 |
publicationLiee.setPersonne(personneSelectionnee);
|
| - |
|
322 |
publicationLiee.setPublicationLiee(publication);
|
| - |
|
323 |
publicationLiee.setIdPublication(publication.getId());
|
| - |
|
324 |
publicationLiee.set("_etat_", aDonnee.ETAT_AJOUTE);
|
| 326 |
publicationLiee.set("_etat_", aDonnee.ETAT_AJOUTE);
|
325 |
listePublicationsLiees.put(publication.getId(), publicationLiee);
|
| 327 |
|
326 |
|
| 328 |
// Ajout à la grille
|
327 |
// Ajout à la grille
|
| 329 |
grille.stopEditing();
|
328 |
grille.stopEditing();
|
| 330 |
grille.getStore().insert(publicationLiee, 0);
|
329 |
grille.getStore().insert(publicationLiee, 0);
|
| - |
|
330 |
grille.startEditing(index, 0);
|
| - |
|
331 |
grille.getSelectionModel().select(index, false);
|
| - |
|
332 |
} else {
|
| 331 |
grille.startEditing(index, 0);
|
333 |
Info.display("Information", "La publication choisie existe déjà dans la liste.");
|
| 332 |
grille.getSelectionModel().select(index, false);
|
334 |
}
|
| Line -... |
Line 335... |
| - |
|
335 |
}
|
| - |
|
336 |
}
|
| - |
|
337 |
|
| - |
|
338 |
/**
|
| - |
|
339 |
* Met à jour la grille avec les informations contenus dans la variable listePublicationsLiees
|
| - |
|
340 |
*/
|
| - |
|
341 |
private void mettreAJourGrille() {
|
| - |
|
342 |
grille.getStore().removeAll();
|
| 333 |
}
|
343 |
grille.getStore().add(listePublicationsLiees.toList());
|
| 334 |
}
|
344 |
}
|
| 335 |
|
345 |
|
| 336 |
private void supprimerDansGrille(PublicationAPersonne publicationLiee) {
|
346 |
private void supprimerDansGrille(PublicationAPersonne publicationLiee) {
|
| 337 |
if (publicationLiee != null) {
|
347 |
if (publicationLiee != null) {
|
| Line 422... |
Line 432... |
| 422 |
GridCellRenderer<PublicationAPersonne> relationRendu = new GridCellRenderer<PublicationAPersonne>() {
|
432 |
GridCellRenderer<PublicationAPersonne> relationRendu = new GridCellRenderer<PublicationAPersonne>() {
|
| 423 |
@Override
|
433 |
@Override
|
| 424 |
public String render(PublicationAPersonne modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<PublicationAPersonne> store, Grid<PublicationAPersonne> grille) {
|
434 |
public String render(PublicationAPersonne modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<PublicationAPersonne> store, Grid<PublicationAPersonne> grille) {
|
| 425 |
// Gestion du texte afficher dans la cellule
|
435 |
// Gestion du texte afficher dans la cellule
|
| 426 |
String role = modele.get("_role_");
|
436 |
String role = modele.get("_role_");
|
| - |
|
437 |
String roleNom = "";
|
| 427 |
if (typeRelationCombo.getStore() != null && role.matches("[0-9]+")) {
|
438 |
if (typeRelationCombo.getStore() != null && role!=null && role.matches("[0-9]+")) {
|
| - |
|
439 |
roleNom = typeRelationCombo.getStore().findModel("id_valeur", role).getNom();
|
| 428 |
role = typeRelationCombo.getStore().findModel("id_valeur", role).getId();
|
440 |
role = typeRelationCombo.getStore().findModel("id_valeur", role).getId();
|
| 429 |
}
|
441 |
}
|
| 430 |
modele.set("_role_", role);
|
442 |
modele.set("_role_", role);
|
| 431 |
|
- |
|
| - |
|
443 |
modele.set("_etat_", aDonnee.ETAT_MODIFIE);
|
| 432 |
return role;
|
444 |
return roleNom;
|
| 433 |
}
|
445 |
}
|
| 434 |
};
|
446 |
};
|
| Line 435... |
Line 447... |
| 435 |
|
447 |
|
| 436 |
|
448 |
|
| 437 |
ColumnConfig typeRelationColonne = new ColumnConfig("_role_", i18nC.typeRelationPersonneCollection(), 75);
|
449 |
ColumnConfig typeRelationColonne = new ColumnConfig("_role_", i18nC.typeRelationPersonneCollection(), 75);
|
| - |
|
450 |
typeRelationColonne.setEditor(editeurRelation);
|
| 438 |
typeRelationColonne.setEditor(editeurRelation);
|
451 |
typeRelationColonne.setRenderer(relationRendu);
|
| Line 439... |
Line 452... |
| 439 |
typeRelationColonne.setRenderer(relationRendu);
|
452 |
|
| 440 |
colonnes.add(typeRelationColonne);
|
453 |
colonnes.add(typeRelationColonne);
|
| 441 |
|
454 |
|
| Line 511... |
Line 524... |
| 511 |
public void rafraichir(Object nouvellesDonnees) {
|
524 |
public void rafraichir(Object nouvellesDonnees) {
|
| 512 |
if (nouvellesDonnees instanceof Information) {
|
525 |
if (nouvellesDonnees instanceof Information) {
|
| 513 |
Information info = (Information) nouvellesDonnees;
|
526 |
Information info = (Information) nouvellesDonnees;
|
| 514 |
rafraichirInformation(info);
|
527 |
rafraichirInformation(info);
|
| 515 |
} else if (nouvellesDonnees instanceof ValeurListe) {
|
528 |
} else if (nouvellesDonnees instanceof ValeurListe) {
|
| 516 |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
|
529 |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
|
| 517 |
if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication"))) {
|
530 |
if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication"))) {
|
| 518 |
Formulaire.rafraichirComboBox(listeValeurs, typeRelationCombo);
|
531 |
Formulaire.rafraichirComboBox(listeValeurs, typeRelationCombo);
|
| - |
|
532 |
roles = listeValeurs.toList();
|
| - |
|
533 |
mettreAJourPersonne();
|
| 519 |
}
|
534 |
}
|
| 520 |
} else if (nouvellesDonnees instanceof PublicationListe) {
|
535 |
} else if (nouvellesDonnees instanceof PublicationListe) {
|
| 521 |
PublicationListe listePublications = (PublicationListe) nouvellesDonnees;
|
536 |
PublicationListe listePublications = (PublicationListe) nouvellesDonnees;
|
| 522 |
rafraichirPublicationListe(listePublications);
|
537 |
rafraichirPublicationListe(listePublications);
|
| - |
|
538 |
} else if (nouvellesDonnees instanceof PublicationAPersonneListe) {
|
| - |
|
539 |
PublicationAPersonneListe papl = (PublicationAPersonneListe) nouvellesDonnees;
|
| - |
|
540 |
List<PublicationAPersonne> paplListe = papl.toList();
|
| - |
|
541 |
if (paplListe.size()>0){
|
| - |
|
542 |
Iterator<PublicationAPersonne> it = paplListe.iterator();
|
| - |
|
543 |
while (it.hasNext()) {
|
| - |
|
544 |
PublicationAPersonne pap = it.next();
|
| - |
|
545 |
listePublicationsLiees.put(pap.getPublicationLiee().getId(), pap);
|
| - |
|
546 |
}
|
| - |
|
547 |
mettreAJourGrille();
|
| - |
|
548 |
|
| - |
|
549 |
}
|
| 523 |
} else {
|
550 |
} else {
|
| 524 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
551 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
| 525 |
}
|
552 |
}
|
| 526 |
}
|
553 |
}
|
| Line 579... |
Line 606... |
| 579 |
PublicationAPersonne publicationLiee = grille.getStore().getAt(i);
|
606 |
PublicationAPersonne publicationLiee = grille.getStore().getAt(i);
|
| 580 |
if (publicationLiee.get("_etat_") != null) {
|
607 |
if (publicationLiee.get("_etat_") != null) {
|
| 581 |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
|
608 |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
|
| 582 |
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role
|
609 |
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role
|
| 583 |
publicationsSupprimees.put("id"+idGenere++, publicationLiee);
|
610 |
publicationsSupprimees.put("id"+idGenere++, publicationLiee);
|
| 584 |
|
- |
|
| 585 |
PublicationAPersonne relationAAjouter = (PublicationAPersonne) publicationLiee.cloner(new PublicationAPersonne());
|
611 |
PublicationAPersonne relationAAjouter = (PublicationAPersonne) publicationLiee.cloner(new PublicationAPersonne());
|
| 586 |
publicationsAjoutees.put("id"+idGenere++, relationAAjouter);
|
612 |
publicationsAjoutees.put("id"+idGenere++, relationAAjouter);
|
| 587 |
Debug.log(publicationLiee.toString());
|
613 |
Debug.log(publicationLiee.toString());
|
| 588 |
}
|
614 |
}
|
| - |
|
615 |
|
| 589 |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
|
616 |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
|
| 590 |
publicationsAjoutees.put("id"+idGenere++, publicationLiee);
|
617 |
publicationsAjoutees.put("id"+idGenere++, publicationLiee);
|
| 591 |
Debug.log(publicationLiee.toString());
|
618 |
Debug.log(publicationLiee.toString());
|
| 592 |
}
|
619 |
}
|
| 593 |
// Initialisation de la grille
|
620 |
// Initialisation de la grille
|
| 594 |
publicationLiee.set("_etat_", "");
|
621 |
publicationLiee.set("_etat_", "");
|
| - |
|
622 |
|
| 595 |
}
|
623 |
}
|
| 596 |
}
|
624 |
}
|
| 597 |
grille.getStore().commitChanges();
|
625 |
grille.getStore().commitChanges();
|
| 598 |
}
|
626 |
}
|
| 599 |
}
|
627 |
}
|
| Line -... |
Line 628... |
| - |
|
628 |
|
| - |
|
629 |
public List verifier() {
|
| - |
|
630 |
|
| - |
|
631 |
List lstMessageErreur = new LinkedList<String>();
|
| - |
|
632 |
//Vérifier les roles
|
| - |
|
633 |
List<PublicationAPersonne> listePublis = grille.getStore().getModels();
|
| - |
|
634 |
Iterator<PublicationAPersonne> itPublis = listePublis.iterator();
|
| - |
|
635 |
while (itPublis.hasNext()) {
|
| - |
|
636 |
PublicationAPersonne publi = itPublis.next();
|
| - |
|
637 |
if (UtilString.isEmpty((String) publi.get("_role_"))) {
|
| - |
|
638 |
lstMessageErreur.add("Vous devez choisir le rôle de la relation " + grille.getStore().indexOf(publi));
|
| - |
|
639 |
}
|
| - |
|
640 |
}
|
| - |
|
641 |
return lstMessageErreur;
|
| - |
|
642 |
}
|
| 600 |
|
643 |
|
| 601 |
public void soumettre() {
|
644 |
public void soumettre() {
|
| 602 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
645 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
| 603 |
if (publicationsAjoutees.size() == 0 && publicationsSupprimees.size() == 0) {
|
646 |
if (publicationsAjoutees.size() == 0 && publicationsSupprimees.size() == 0) {
|
| 604 |
Info.display("Modification des publications liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
|
647 |
Info.display("Modification des publications liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
|