Subversion Repositories eFlore/Applications.del

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
50 benjamin 1
package org.tela_botanica.del.client.vues.comparaisoneflore;
2
 
62 benjamin 3
import java.util.Date;
50 benjamin 4
import java.util.List;
5
 
148 benjamin 6
import org.tela_botanica.del.client.modeles.VoteProtocole;
50 benjamin 7
 
8
import com.google.gwt.core.client.GWT;
62 benjamin 9
import com.google.gwt.i18n.client.DateTimeFormat;
10
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
50 benjamin 11
import com.google.gwt.uibinder.client.UiBinder;
12
import com.google.gwt.uibinder.client.UiField;
13
import com.google.gwt.user.client.ui.Composite;
14
import com.google.gwt.user.client.ui.Image;
15
import com.google.gwt.user.client.ui.Label;
16
import com.google.gwt.user.client.ui.Widget;
17
 
18
public class ComparaisonEfloreVue extends Composite {
19
 
20
	interface MyUiBinder extends UiBinder<Widget, ComparaisonEfloreVue> {
21
	}
22
 
23
	private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
24
 
25
	@UiField
62 benjamin 26
	Label nomAuteur, dateObservation, famille, motsClefs, validateurs, dateValidation;
50 benjamin 27
 
28
	@UiField
29
	Label nomEspeceEflore, nomAuteurEflore, localiteEflore, dateObservationEflore;
30
 
31
	@UiField
32
	Image imagePrincipale;
33
 
34
	@UiField
35
	Image imageEflore;
36
 
37
	@UiField
38
	Image scrollLeftImage;
39
 
40
	@UiField
41
	Image scrollRightImage;
42
 
43
	private int currentIndexImages;
44
 
45
	public ComparaisonEfloreVue() {
46
		initWidget(uiBinder.createAndBindUi(this));
47
	}
48
 
148 benjamin 49
	protected void chargerImagePrincipale(org.tela_botanica.del.client.modeles.Image image) {
50 benjamin 50
 
62 benjamin 51
		// mots clefs
52
		String motsClefsConcatenes = "";
148 benjamin 53
		for (String motClef : image.getObservation().getMotsClefs()) {
62 benjamin 54
			motsClefsConcatenes += motClef + ",";
55
		}
56
		motsClefsConcatenes = motsClefsConcatenes.subSequence(0, motsClefsConcatenes.lastIndexOf(",")).toString();
57
 
58
		// validateurs
59
		String validateursConcatenes = "";
148 benjamin 60
		for (VoteProtocole observationValidation : image.getVoteProtocoles()) {
87 aurelien 61
			validateursConcatenes += observationValidation.getContributeur() + ", ";
62 benjamin 62
		}
63
		validateursConcatenes = validateursConcatenes.subSequence(0, validateursConcatenes.lastIndexOf(",")).toString();
64
 
65
		// date derniere validation
66
		Date dateDerniereValidation = null;
148 benjamin 67
		for (VoteProtocole observationValidation : image.getVoteProtocoles()) {
62 benjamin 68
			if (dateDerniereValidation == null) {
69
				dateDerniereValidation = observationValidation.getDate();
70
			} else if (dateDerniereValidation.before(observationValidation.getDate())) {
71
				dateDerniereValidation = observationValidation.getDate();
72
			}
73
		}
74
 
75
		motsClefs.setText(motsClefsConcatenes);
148 benjamin 76
		nomAuteur.setText(image.getObservation().getAuteur());
77
		imagePrincipale.setUrl(image.getUrl());
78
		dateObservation.setText(image.getObservation().getDate());
79
		famille.setText(image.getObservation().getFamille());
62 benjamin 80
		validateurs.setText(validateursConcatenes);
81
		dateValidation.setText(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(dateDerniereValidation));
50 benjamin 82
 
83
	}
84
 
148 benjamin 85
	protected void chargerImagesEflore(List<org.tela_botanica.del.client.modeles.Image> observationsEflore, int indexImage) {
50 benjamin 86
 
62 benjamin 87
		if (indexImage >= 0 && indexImage < observationsEflore.size()) {
50 benjamin 88
			currentIndexImages = indexImage;
89
		}
90
 
148 benjamin 91
		org.tela_botanica.del.client.modeles.Image observationEflore = observationsEflore.get(currentIndexImages);
50 benjamin 92
 
148 benjamin 93
		nomEspeceEflore.setText(observationEflore.getObservation().getSpecies());
94
		nomAuteurEflore.setText(observationEflore.getObservation().getAuteur());
50 benjamin 95
		imageEflore.setUrl(observationEflore.getUrl());
148 benjamin 96
		dateObservationEflore.setText(observationEflore.getObservation().getDate());
97
		localiteEflore.setText(observationEflore.getObservation().getLocalite());
50 benjamin 98
 
99
	}
100
 
101
	public Image getScrollLeftImage() {
102
		return scrollLeftImage;
103
	}
104
 
105
	public void setScrollLeftImage(Image scrollLeftImage) {
106
		this.scrollLeftImage = scrollLeftImage;
107
	}
108
 
109
	public int getCurrentIndexImages() {
110
		return currentIndexImages;
111
	}
112
 
113
	public Image getScrollRightImage() {
114
		return scrollRightImage;
115
	}
116
 
117
}