Subversion Repositories eFlore/Applications.del

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
50 benjamin 1
package org.tela_botanica.del.client.vues.comparaisoneflore;
2
 
3
import java.util.List;
4
 
73 benjamin 5
import org.tela_botanica.del.client.cache.CacheClient;
50 benjamin 6
import org.tela_botanica.del.client.modeles.Observation;
62 benjamin 7
import org.tela_botanica.del.client.modeles.ObservationValidation;
50 benjamin 8
import org.tela_botanica.del.client.utils.MockDatasource;
9
 
10
import com.google.gwt.event.dom.client.ClickEvent;
11
import com.google.gwt.event.dom.client.ClickHandler;
12
import com.google.gwt.user.client.ui.HasWidgets;
13
 
14
public class ComparaisonEflorePresenteur {
15
 
16
	private ComparaisonEfloreVue vue = new ComparaisonEfloreVue();
17
 
18
	private final MockDatasource observationService = MockDatasource.getInstance();
19
 
62 benjamin 20
	private final MockDatasource validationService = MockDatasource.getInstance();
21
 
50 benjamin 22
	private Observation observationPrincipale;
23
 
24
	private String nomTaxonComparaison;
25
 
62 benjamin 26
	private List<Observation> observationsEflore;
27
 
73 benjamin 28
	public ComparaisonEflorePresenteur() {
29
		this.observationPrincipale = CacheClient.getInstance().getCurrentObservation();
30
		this.nomTaxonComparaison = CacheClient.getInstance().getTaxonPourRechercheEflore();
50 benjamin 31
	}
32
 
33
	public void go(HasWidgets composite) {
34
		composite.add(vue);
62 benjamin 35
		chargerValidationObservationPrincipale();
50 benjamin 36
		vue.chargerImagePrincipale(observationPrincipale);
37
		chargerObservationsEflore();
38
		gererEvenements();
39
	}
40
 
62 benjamin 41
	private void chargerValidationObservationPrincipale() {
42
		List<ObservationValidation> observationValidations = validationService.getValidationData(observationPrincipale.getIdImage());
43
		observationPrincipale.setImageCelValidationDatas(observationValidations);
44
	}
45
 
50 benjamin 46
	private void chargerObservationsEflore() {
47
		observationsEflore = observationService.getObservationsEfloreParTaxon(nomTaxonComparaison);
48
		vue.chargerImagesEflore(observationsEflore, 0);
49
	}
50
 
51
	private void gererEvenements() {
52
		vue.getScrollLeftImage().addClickHandler(new ClickHandler() {
53
 
54
			@Override
55
			public void onClick(ClickEvent event) {
62 benjamin 56
				vue.chargerImagesEflore(observationsEflore, vue.getCurrentIndexImages() - 1);
50 benjamin 57
			}
58
		});
62 benjamin 59
 
50 benjamin 60
		vue.getScrollRightImage().addClickHandler(new ClickHandler() {
61
 
62
			@Override
63
			public void onClick(ClickEvent event) {
62 benjamin 64
				vue.chargerImagesEflore(observationsEflore, vue.getCurrentIndexImages() + 1);
50 benjamin 65
			}
66
		});
67
	}
68
 
69
}