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