41 |
aurelien |
1 |
package org.tela_botanica.del.client.vues.plateformedetermination.forum;
|
|
|
2 |
|
978 |
gduche |
3 |
import java.util.ArrayList;
|
893 |
gduche |
4 |
import java.util.List;
|
1001 |
aurelien |
5 |
|
159 |
benjamin |
6 |
import org.tela_botanica.del.client.cache.CacheClient;
|
658 |
benjamin |
7 |
import org.tela_botanica.del.client.modeles.InterventionForum;
|
159 |
benjamin |
8 |
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
|
303 |
aurelien |
9 |
import org.tela_botanica.del.client.navigation.evenement.ajoutcommentaire.EvenementAjoutCommentaire;
|
|
|
10 |
import org.tela_botanica.del.client.navigation.evenement.ajoutcommentaire.GestionnaireEvenementAjoutCommentaire;
|
159 |
benjamin |
11 |
import org.tela_botanica.del.client.navigation.evenement.ajoutdetermination.EvenementAjoutDetermination;
|
|
|
12 |
import org.tela_botanica.del.client.navigation.evenement.ajoutdetermination.GestionnaireEvenementAjoutDetermination;
|
1001 |
aurelien |
13 |
import org.tela_botanica.del.client.navigation.evenement.suppressioncommentaire.EvenementSuppressionCommentaire;
|
|
|
14 |
import org.tela_botanica.del.client.navigation.evenement.suppressioncommentaire.GestionnaireEvenementSuppressionCommentaire;
|
|
|
15 |
import org.tela_botanica.del.client.navigation.evenement.suppressiondetermination.EvenementSuppressionDetermination;
|
|
|
16 |
import org.tela_botanica.del.client.navigation.evenement.suppressiondetermination.GestionnaireEvenementSuppressionDetermination;
|
|
|
17 |
import org.tela_botanica.del.client.services.rest.CommentaireServiceConcret;
|
|
|
18 |
import org.tela_botanica.del.client.services.rest.PropositionDeterminationServiceConcret;
|
663 |
benjamin |
19 |
import org.tela_botanica.del.client.vues.plateformedetermination.forum.interventions.ForumInterventionPresenteur;
|
|
|
20 |
import org.tela_botanica.del.client.vues.plateformedetermination.forum.interventions.ForumInterventionVue;
|
41 |
aurelien |
21 |
|
|
|
22 |
import com.google.gwt.user.client.ui.HasWidgets;
|
303 |
aurelien |
23 |
import com.google.gwt.user.client.ui.IsWidget;
|
41 |
aurelien |
24 |
|
159 |
benjamin |
25 |
public class ForumPresenteur {
|
658 |
benjamin |
26 |
|
303 |
aurelien |
27 |
public interface Vue extends IsWidget {
|
658 |
benjamin |
28 |
|
663 |
benjamin |
29 |
public abstract HasWidgets getPanneauInterventions();
|
1001 |
aurelien |
30 |
|
|
|
31 |
public abstract void vider();
|
303 |
aurelien |
32 |
}
|
84 |
benjamin |
33 |
|
303 |
aurelien |
34 |
private Vue vue;
|
84 |
benjamin |
35 |
|
303 |
aurelien |
36 |
public ForumPresenteur(Vue vue) {
|
|
|
37 |
this.vue = vue;
|
|
|
38 |
}
|
658 |
benjamin |
39 |
|
41 |
aurelien |
40 |
public void go(HasWidgets composite) {
|
84 |
benjamin |
41 |
|
159 |
benjamin |
42 |
chargerDeterminations();
|
303 |
aurelien |
43 |
composite.add(vue.asWidget());
|
159 |
benjamin |
44 |
|
|
|
45 |
gererEvenements();
|
41 |
aurelien |
46 |
}
|
84 |
benjamin |
47 |
|
159 |
benjamin |
48 |
private void chargerDeterminations() {
|
978 |
gduche |
49 |
|
1001 |
aurelien |
50 |
vue.vider();
|
|
|
51 |
List<InterventionForum> interventions = new ArrayList<InterventionForum>(CacheClient.getInstance().getObservationCourante().getInterventionsForum());
|
|
|
52 |
|
978 |
gduche |
53 |
int i = 0;
|
|
|
54 |
while (interventions.size() > 0 && i < 10) {
|
|
|
55 |
i++;
|
|
|
56 |
InterventionForum interventionCourante = interventions.get(0);
|
1001 |
aurelien |
57 |
ForumInterventionPresenteur presenteur = new ForumInterventionPresenteur(new ForumInterventionVue(), interventionCourante, new CommentaireServiceConcret(), new PropositionDeterminationServiceConcret());
|
|
|
58 |
String id = interventionCourante.getId() != null ? interventionCourante.getId() : "0";
|
978 |
gduche |
59 |
List<InterventionForum> fils = trouverFils(interventions, interventionCourante);
|
|
|
60 |
if (fils.size() > 0) {
|
|
|
61 |
for (InterventionForum interventionFille : fils) {
|
1001 |
aurelien |
62 |
ForumInterventionPresenteur presenteurFille = new ForumInterventionPresenteur(new ForumInterventionVue(), interventionFille, new CommentaireServiceConcret(), new PropositionDeterminationServiceConcret());
|
|
|
63 |
presenteur.addEnfant(presenteurFille);
|
978 |
gduche |
64 |
interventions.remove(interventions.indexOf(interventionFille));
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
presenteur.go(vue.getPanneauInterventions());
|
|
|
69 |
interventions.remove(interventions.indexOf(interventionCourante));
|
893 |
gduche |
70 |
}
|
|
|
71 |
}
|
978 |
gduche |
72 |
|
|
|
73 |
private List<InterventionForum> trouverFils(List<InterventionForum> interventions, InterventionForum parent) {
|
|
|
74 |
List<InterventionForum> fils = new ArrayList<InterventionForum>();
|
|
|
75 |
for (InterventionForum interventionCourante : interventions) {
|
|
|
76 |
InterventionForum parentCourant = interventionCourante.getParent();
|
|
|
77 |
if (parentCourant != null && interventionCourante.getIdParent().equals(parent.getId())) {
|
|
|
78 |
fils.add(interventionCourante);
|
|
|
79 |
}
|
171 |
aurelien |
80 |
}
|
978 |
gduche |
81 |
return fils;
|
41 |
aurelien |
82 |
}
|
978 |
gduche |
83 |
|
159 |
benjamin |
84 |
private void gererEvenements() {
|
|
|
85 |
BusEvenementiel.getInstance().addHandler(EvenementAjoutDetermination.TYPE, new GestionnaireEvenementAjoutDetermination() {
|
|
|
86 |
|
|
|
87 |
@Override
|
|
|
88 |
public void onAjoutDetermination(EvenementAjoutDetermination event) {
|
1001 |
aurelien |
89 |
new ForumInterventionPresenteur(new ForumInterventionVue(), event.getPropositionDetermination(), new CommentaireServiceConcret(), new PropositionDeterminationServiceConcret()).go(vue.getPanneauInterventions());
|
159 |
benjamin |
90 |
}
|
|
|
91 |
});
|
658 |
benjamin |
92 |
|
303 |
aurelien |
93 |
BusEvenementiel.getInstance().addHandler(EvenementAjoutCommentaire.TYPE, new GestionnaireEvenementAjoutCommentaire() {
|
658 |
benjamin |
94 |
|
303 |
aurelien |
95 |
@Override
|
|
|
96 |
public void onAjoutCommentaire(EvenementAjoutCommentaire event) {
|
1001 |
aurelien |
97 |
new ForumInterventionPresenteur(new ForumInterventionVue(), event.getCommentaire(), new CommentaireServiceConcret(), new PropositionDeterminationServiceConcret()).go(vue.getPanneauInterventions());
|
303 |
aurelien |
98 |
}
|
|
|
99 |
});
|
1001 |
aurelien |
100 |
|
|
|
101 |
BusEvenementiel.getInstance().addHandler(EvenementSuppressionDetermination.TYPE, new GestionnaireEvenementSuppressionDetermination() {
|
|
|
102 |
|
|
|
103 |
@Override
|
|
|
104 |
public void onSuppressionDetermination(
|
|
|
105 |
EvenementSuppressionDetermination event) {
|
|
|
106 |
chargerDeterminations();
|
|
|
107 |
}
|
|
|
108 |
});
|
|
|
109 |
|
|
|
110 |
BusEvenementiel.getInstance().addHandler(EvenementSuppressionCommentaire.TYPE, new GestionnaireEvenementSuppressionCommentaire() {
|
|
|
111 |
|
|
|
112 |
@Override
|
|
|
113 |
public void onSuppressionCommentaire(
|
|
|
114 |
EvenementSuppressionCommentaire event) {
|
|
|
115 |
chargerDeterminations();
|
|
|
116 |
}
|
|
|
117 |
});
|
94 |
aurelien |
118 |
}
|
41 |
aurelien |
119 |
}
|