Subversion Repositories eFlore/Applications.del

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 benjamin 1
package org.tela_botanica.del.client.vues.rechercheobservations;
9 benjamin 2
 
3
import java.util.List;
4
 
5
import org.tela_botanica.del.client.modeles.Observation;
14 benjamin 6
import org.tela_botanica.del.client.modeles.ObservationValidation;
16 benjamin 7
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
8
import org.tela_botanica.del.client.navigation.evenement.validationobservation.EvenementValidation;
9 benjamin 9
import org.tela_botanica.del.client.utils.MockDatasource;
14 benjamin 10
import org.tela_botanica.del.client.vues.rechercheobservations.detail.ObservationDetailPresenteur;
11
import org.tela_botanica.del.client.vues.rechercheobservations.vote.MoyenneVotePresenteur;
9 benjamin 12
 
13
import com.google.gwt.event.dom.client.ClickEvent;
14
import com.google.gwt.event.dom.client.ClickHandler;
15
import com.google.gwt.user.client.ui.HasWidgets;
16
 
14 benjamin 17
public class ObservationPresenteur {
9 benjamin 18
 
19
	private final MockDatasource validationService = MockDatasource.getInstance();
20
 
14 benjamin 21
	private ObservationVue view = new ObservationVue();
9 benjamin 22
 
23
	private final Observation observation;
24
 
25
	private boolean detailsOpen = false;
26
 
14 benjamin 27
	public ObservationPresenteur(Observation observation) {
9 benjamin 28
		this.observation = observation;
29
	}
30
 
31
	public void go(HasWidgets composite) {
32
		composite.add(view);
33
		view.loadImage(observation);
34
		loadValidationData();
35
		handleEvents();
36
 
37
	}
38
 
39
	private void loadValidationData() {
40
 
14 benjamin 41
		List<ObservationValidation> observationValidationDatas = validationService
9 benjamin 42
				.getValidationData(observation.getIdImage());
43
 
44
		observation.setImageCelValidationDatas(observationValidationDatas);
14 benjamin 45
		new MoyenneVotePresenteur(observationValidationDatas).go(view
9 benjamin 46
				.getRatePanel());
47
		view.showValidationData(observationValidationDatas);
48
 
49
	}
50
 
51
	private void handleEvents() {
52
		view.getMoreDetailsHtml().addClickHandler(new ClickHandler() {
53
 
54
			@Override
55
			public void onClick(ClickEvent event) {
56
 
57
				if (detailsOpen) {
58
					view.clearDetails();
59
				} else {
14 benjamin 60
					new ObservationDetailPresenteur(observation).go(view
9 benjamin 61
							.getDetailsPanel());
62
					view.getMoreDetailsHtml().setHTML(
63
							"<img src='img/icon_minus.png' />");
64
				}
65
				detailsOpen = !detailsOpen;
66
			}
67
		});
68
 
69
		view.getProposeValidationDataHtml().addClickHandler(new ClickHandler() {
70
 
71
			@Override
72
			public void onClick(ClickEvent event) {
14 benjamin 73
				BusEvenementiel.getInstance().fireEvent(
74
						new EvenementValidation(observation));
9 benjamin 75
			}
76
		});
77
	}
78
}