166 |
gduche |
1 |
package org.tela_botanica.del.client.vues.rechercheobservations;
|
|
|
2 |
|
|
|
3 |
import java.util.List;
|
|
|
4 |
|
332 |
gduche |
5 |
import org.tela_botanica.del.client.cache.CacheClient;
|
166 |
gduche |
6 |
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
|
332 |
gduche |
7 |
import org.tela_botanica.del.client.modeles.Image;
|
166 |
gduche |
8 |
import org.tela_botanica.del.client.modeles.Observation;
|
332 |
gduche |
9 |
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
|
|
|
10 |
import org.tela_botanica.del.client.navigation.evenement.validationobservation.EvenementValidation;
|
436 |
benjamin |
11 |
import org.tela_botanica.del.client.vues.rechercheobservations.observationdeterminations.ObservationDeterminationPresenteur;
|
|
|
12 |
import org.tela_botanica.del.client.vues.rechercheobservations.observationdeterminations.ObservationDeterminationVue;
|
|
|
13 |
import org.tela_botanica.del.client.vues.rechercheobservations.observationimages.ObservationImagesPresenteur;
|
|
|
14 |
import org.tela_botanica.del.client.vues.rechercheobservations.observationimages.ObservationImagesVue;
|
166 |
gduche |
15 |
|
200 |
gduche |
16 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
17 |
import com.google.gwt.event.dom.client.ClickHandler;
|
309 |
aurelien |
18 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
166 |
gduche |
19 |
import com.google.gwt.user.client.ui.HasWidgets;
|
309 |
aurelien |
20 |
import com.google.gwt.user.client.ui.IsWidget;
|
166 |
gduche |
21 |
|
|
|
22 |
public class ObservationPresenteur extends Presenteur {
|
436 |
benjamin |
23 |
|
309 |
aurelien |
24 |
public abstract interface Vue extends IsWidget {
|
436 |
benjamin |
25 |
|
332 |
gduche |
26 |
public HasClickHandlers getLienDeterminer();
|
436 |
benjamin |
27 |
|
|
|
28 |
public HasWidgets getDeterminationsPanel();
|
|
|
29 |
|
|
|
30 |
public HasWidgets getImagesPanel();
|
309 |
aurelien |
31 |
}
|
436 |
benjamin |
32 |
|
309 |
aurelien |
33 |
private Vue vue;
|
166 |
gduche |
34 |
|
|
|
35 |
private Observation observation;
|
|
|
36 |
|
309 |
aurelien |
37 |
public ObservationPresenteur(Vue vue, Observation observation) {
|
166 |
gduche |
38 |
this.observation = observation;
|
314 |
gduche |
39 |
this.vue = vue;
|
166 |
gduche |
40 |
chargerObservation();
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
public void chargerObservation() {
|
|
|
44 |
|
436 |
benjamin |
45 |
new ObservationImagesPresenteur(new ObservationImagesVue(), observation).go(vue.getImagesPanel());
|
|
|
46 |
new ObservationDeterminationPresenteur(new ObservationDeterminationVue(), observation.getPropositionsDetermination()).go(vue.getDeterminationsPanel());
|
166 |
gduche |
47 |
|
436 |
benjamin |
48 |
gererEvenements();
|
183 |
gduche |
49 |
|
166 |
gduche |
50 |
}
|
|
|
51 |
|
|
|
52 |
public void go(HasWidgets composite) {
|
309 |
aurelien |
53 |
composite.add(vue.asWidget());
|
166 |
gduche |
54 |
}
|
|
|
55 |
|
220 |
gduche |
56 |
protected void gererEvenements() {
|
436 |
benjamin |
57 |
|
332 |
gduche |
58 |
vue.getLienDeterminer().addClickHandler(new ClickHandler() {
|
436 |
benjamin |
59 |
|
332 |
gduche |
60 |
public void onClick(ClickEvent event) {
|
|
|
61 |
List<Image> images = observation.getImages();
|
|
|
62 |
if (images.size() > 0) {
|
|
|
63 |
CacheClient.getInstance().setImageCourante(images.get(0));
|
|
|
64 |
} else {
|
|
|
65 |
CacheClient.getInstance().setImageCourante(null);
|
|
|
66 |
}
|
|
|
67 |
BusEvenementiel.getInstance().fireEvent(new EvenementValidation(observation));
|
|
|
68 |
}
|
|
|
69 |
});
|
166 |
gduche |
70 |
}
|
|
|
71 |
}
|