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