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;
148 benjamin 6
import org.tela_botanica.del.client.modeles.Image;
7
import org.tela_botanica.del.client.modeles.VoteProtocole;
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
 
148 benjamin 22
	private Image imagePrincipale;
50 benjamin 23
 
24
	private String nomTaxonComparaison;
25
 
148 benjamin 26
	private List<org.tela_botanica.del.client.modeles.Image> imagesEflore;
62 benjamin 27
 
73 benjamin 28
	public ComparaisonEflorePresenteur() {
148 benjamin 29
		this.imagePrincipale = CacheClient.getInstance().getImageCourante();
73 benjamin 30
		this.nomTaxonComparaison = CacheClient.getInstance().getTaxonPourRechercheEflore();
50 benjamin 31
	}
32
 
33
	public void go(HasWidgets composite) {
34
		composite.add(vue);
62 benjamin 35
		chargerValidationObservationPrincipale();
148 benjamin 36
		vue.chargerImagePrincipale(imagePrincipale);
50 benjamin 37
		chargerObservationsEflore();
38
		gererEvenements();
39
	}
40
 
62 benjamin 41
	private void chargerValidationObservationPrincipale() {
148 benjamin 42
		List<VoteProtocole> observationValidations = validationService.getValidationData(imagePrincipale.getIdImage());
43
		imagePrincipale.setVoteProtocoles(observationValidations);
62 benjamin 44
	}
45
 
50 benjamin 46
	private void chargerObservationsEflore() {
148 benjamin 47
		imagesEflore = observationService.getImagesEfloreParTaxon(nomTaxonComparaison);
48
		vue.chargerImagesEflore(imagesEflore, 0);
50 benjamin 49
	}
50
 
51
	private void gererEvenements() {
52
		vue.getScrollLeftImage().addClickHandler(new ClickHandler() {
53
 
54
			@Override
55
			public void onClick(ClickEvent event) {
148 benjamin 56
				vue.chargerImagesEflore(imagesEflore, 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) {
148 benjamin 64
				vue.chargerImagesEflore(imagesEflore, vue.getCurrentIndexImages() + 1);
50 benjamin 65
			}
66
		});
67
	}
68
 
69
}