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;
|
284 |
benjamin |
9 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
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;
|
361 |
benjamin |
17 |
import com.google.gwt.user.client.ui.Panel;
|
50 |
benjamin |
18 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
19 |
|
284 |
benjamin |
20 |
public class ComparaisonEfloreVue extends Composite implements ComparaisonEflorePresenteur.Vue {
|
50 |
benjamin |
21 |
|
|
|
22 |
interface MyUiBinder extends UiBinder<Widget, ComparaisonEfloreVue> {
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
|
237 |
gduche |
26 |
private int currentIndexImages;
|
50 |
benjamin |
27 |
|
|
|
28 |
@UiField
|
237 |
gduche |
29 |
Label nomAuteur, dateObservation, famille, motsClefs, validateurs, dateValidation, nomEspeceEflore, nomAuteurEflore, localiteEflore, dateObservationEflore;
|
50 |
benjamin |
30 |
|
|
|
31 |
@UiField
|
237 |
gduche |
32 |
Image imagePrincipale, imageEflore, scrollLeftImage, scrollRightImage;
|
50 |
benjamin |
33 |
|
361 |
benjamin |
34 |
@UiField
|
|
|
35 |
Panel panneauChargement;
|
|
|
36 |
|
50 |
benjamin |
37 |
public ComparaisonEfloreVue() {
|
|
|
38 |
initWidget(uiBinder.createAndBindUi(this));
|
|
|
39 |
}
|
|
|
40 |
|
284 |
benjamin |
41 |
public void chargerImagePrincipale(org.tela_botanica.del.client.modeles.Image image) {
|
50 |
benjamin |
42 |
|
62 |
benjamin |
43 |
// mots clefs
|
|
|
44 |
String motsClefsConcatenes = "";
|
360 |
benjamin |
45 |
try {
|
|
|
46 |
for (String motClef : image.getObservation().getMotsClefs()) {
|
|
|
47 |
motsClefsConcatenes += motClef + ",";
|
|
|
48 |
}
|
|
|
49 |
motsClefsConcatenes = motsClefsConcatenes.subSequence(0, motsClefsConcatenes.lastIndexOf(",")).toString();
|
|
|
50 |
} catch (Exception e) {
|
|
|
51 |
// TODO: handle exception
|
62 |
benjamin |
52 |
}
|
|
|
53 |
|
|
|
54 |
// validateurs
|
|
|
55 |
String validateursConcatenes = "";
|
284 |
benjamin |
56 |
try {
|
360 |
benjamin |
57 |
for (VoteProtocole observationValidation : image.getVoteProtocoles()) {
|
|
|
58 |
validateursConcatenes += observationValidation.getContributeur() + ", ";
|
|
|
59 |
}
|
284 |
benjamin |
60 |
validateursConcatenes = validateursConcatenes.subSequence(0, validateursConcatenes.lastIndexOf(",")).toString();
|
|
|
61 |
} catch (Exception e) {
|
62 |
benjamin |
62 |
|
284 |
benjamin |
63 |
}
|
|
|
64 |
|
62 |
benjamin |
65 |
// date derniere validation
|
|
|
66 |
Date dateDerniereValidation = null;
|
360 |
benjamin |
67 |
try {
|
|
|
68 |
for (VoteProtocole observationValidation : image.getVoteProtocoles()) {
|
|
|
69 |
if (dateDerniereValidation == null) {
|
|
|
70 |
dateDerniereValidation = observationValidation.getDate();
|
|
|
71 |
} else if (dateDerniereValidation.before(observationValidation.getDate())) {
|
|
|
72 |
dateDerniereValidation = observationValidation.getDate();
|
|
|
73 |
}
|
62 |
benjamin |
74 |
}
|
360 |
benjamin |
75 |
} catch (Exception e) {
|
62 |
benjamin |
76 |
}
|
|
|
77 |
|
|
|
78 |
motsClefs.setText(motsClefsConcatenes);
|
148 |
benjamin |
79 |
nomAuteur.setText(image.getObservation().getAuteur());
|
|
|
80 |
imagePrincipale.setUrl(image.getUrl());
|
|
|
81 |
dateObservation.setText(image.getObservation().getDate());
|
|
|
82 |
famille.setText(image.getObservation().getFamille());
|
62 |
benjamin |
83 |
validateurs.setText(validateursConcatenes);
|
50 |
benjamin |
84 |
|
284 |
benjamin |
85 |
if (dateDerniereValidation != null) {
|
|
|
86 |
dateValidation.setText(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(dateDerniereValidation));
|
|
|
87 |
}
|
|
|
88 |
|
50 |
benjamin |
89 |
}
|
|
|
90 |
|
284 |
benjamin |
91 |
public void chargerImagesEflore(List<org.tela_botanica.del.client.modeles.Image> observationsEflore, int indexImage) {
|
50 |
benjamin |
92 |
|
62 |
benjamin |
93 |
if (indexImage >= 0 && indexImage < observationsEflore.size()) {
|
50 |
benjamin |
94 |
currentIndexImages = indexImage;
|
|
|
95 |
}
|
|
|
96 |
|
148 |
benjamin |
97 |
org.tela_botanica.del.client.modeles.Image observationEflore = observationsEflore.get(currentIndexImages);
|
50 |
benjamin |
98 |
|
352 |
aurelien |
99 |
nomEspeceEflore.setText(observationEflore.getObservation().getNomRetenu());
|
148 |
benjamin |
100 |
nomAuteurEflore.setText(observationEflore.getObservation().getAuteur());
|
50 |
benjamin |
101 |
imageEflore.setUrl(observationEflore.getUrl());
|
148 |
benjamin |
102 |
dateObservationEflore.setText(observationEflore.getObservation().getDate());
|
|
|
103 |
localiteEflore.setText(observationEflore.getObservation().getLocalite());
|
50 |
benjamin |
104 |
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
public void setScrollLeftImage(Image scrollLeftImage) {
|
|
|
108 |
this.scrollLeftImage = scrollLeftImage;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
public int getCurrentIndexImages() {
|
|
|
112 |
return currentIndexImages;
|
|
|
113 |
}
|
|
|
114 |
|
284 |
benjamin |
115 |
@Override
|
|
|
116 |
public HasClickHandlers getScrollLeftImage() {
|
|
|
117 |
return scrollLeftImage;
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
@Override
|
|
|
121 |
public HasClickHandlers getScrollRightImage() {
|
|
|
122 |
return scrollRightImage;
|
|
|
123 |
}
|
|
|
124 |
|
361 |
benjamin |
125 |
public void startChargement() {
|
|
|
126 |
panneauChargement.setVisible(true);
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
public void stopChargement() {
|
|
|
130 |
panneauChargement.setVisible(false);
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
public Label getNomAuteur() {
|
|
|
134 |
return nomAuteur;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
public Image getImagePrincipale() {
|
|
|
138 |
return imagePrincipale;
|
|
|
139 |
}
|
|
|
140 |
|
50 |
benjamin |
141 |
}
|