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();
32 gduche 20
	private ObservationVue vue = new ObservationVue();
9 benjamin 21
	private final Observation observation;
22
	private boolean detailsOpen = false;
23
 
14 benjamin 24
	public ObservationPresenteur(Observation observation) {
9 benjamin 25
		this.observation = observation;
26
	}
27
 
28
	public void go(HasWidgets composite) {
32 gduche 29
		composite.add(vue);
30
		vue.loadImage(observation);
31
		// loadValidationData();
32
		// handleEvents();
9 benjamin 33
 
34
	}
35
 
36
	private void loadValidationData() {
37
 
32 gduche 38
		List<ObservationValidation> observationValidationDatas = validationService.getValidationData(observation.getIdImage());
9 benjamin 39
 
40
		observation.setImageCelValidationDatas(observationValidationDatas);
32 gduche 41
		new MoyenneVotePresenteur(observationValidationDatas).go(vue.getRatePanel());
42
		vue.showValidationData(observationValidationDatas);
9 benjamin 43
 
44
	}
45
 
46
	private void handleEvents() {
32 gduche 47
		vue.getMoreDetailsHtml().addClickHandler(new ClickHandler() {
9 benjamin 48
 
49
			@Override
50
			public void onClick(ClickEvent event) {
51
 
52
				if (detailsOpen) {
32 gduche 53
					vue.clearDetails();
9 benjamin 54
				} else {
32 gduche 55
					new ObservationDetailPresenteur(observation).go(vue.getDetailsPanel());
56
					vue.getMoreDetailsHtml().setHTML("<img src='img/icon_minus.png' />");
9 benjamin 57
				}
58
				detailsOpen = !detailsOpen;
59
			}
60
		});
61
 
32 gduche 62
		vue.getProposeValidationDataHtml().addClickHandler(new ClickHandler() {
9 benjamin 63
 
64
			@Override
65
			public void onClick(ClickEvent event) {
32 gduche 66
				BusEvenementiel.getInstance().fireEvent(new EvenementValidation(observation));
9 benjamin 67
			}
68
		});
69
	}
70
}