Subversion Repositories eFlore/Applications.del

Rev

Rev 210 | Rev 352 | Go to most recent revision | Details | Compare with Previous | 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
	private final MockDatasource observationService = MockDatasource.getInstance();
62 benjamin 18
	private final MockDatasource validationService = MockDatasource.getInstance();
148 benjamin 19
	private Image imagePrincipale;
50 benjamin 20
	private String nomTaxonComparaison;
148 benjamin 21
	private List<org.tela_botanica.del.client.modeles.Image> imagesEflore;
62 benjamin 22
 
73 benjamin 23
	public ComparaisonEflorePresenteur() {
148 benjamin 24
		this.imagePrincipale = CacheClient.getInstance().getImageCourante();
73 benjamin 25
		this.nomTaxonComparaison = CacheClient.getInstance().getTaxonPourRechercheEflore();
50 benjamin 26
	}
27
 
28
	public void go(HasWidgets composite) {
29
		composite.add(vue);
62 benjamin 30
		chargerValidationObservationPrincipale();
148 benjamin 31
		vue.chargerImagePrincipale(imagePrincipale);
50 benjamin 32
		chargerObservationsEflore();
33
		gererEvenements();
34
	}
35
 
62 benjamin 36
	private void chargerValidationObservationPrincipale() {
178 benjamin 37
		List<VoteProtocole> observationValidations = validationService.getVote(imagePrincipale.getIdImage());
148 benjamin 38
		imagePrincipale.setVoteProtocoles(observationValidations);
62 benjamin 39
	}
40
 
50 benjamin 41
	private void chargerObservationsEflore() {
148 benjamin 42
		imagesEflore = observationService.getImagesEfloreParTaxon(nomTaxonComparaison);
43
		vue.chargerImagesEflore(imagesEflore, 0);
50 benjamin 44
	}
45
 
46
	private void gererEvenements() {
237 gduche 47
		vue.scrollLeftImage.addClickHandler(new ClickHandler() {
50 benjamin 48
 
49
			@Override
50
			public void onClick(ClickEvent event) {
148 benjamin 51
				vue.chargerImagesEflore(imagesEflore, vue.getCurrentIndexImages() - 1);
50 benjamin 52
			}
53
		});
62 benjamin 54
 
237 gduche 55
		vue.scrollRightImage.addClickHandler(new ClickHandler() {
50 benjamin 56
 
57
			@Override
58
			public void onClick(ClickEvent event) {
148 benjamin 59
				vue.chargerImagesEflore(imagesEflore, vue.getCurrentIndexImages() + 1);
50 benjamin 60
			}
61
		});
62
	}
63
 
64
}