Rev 69 | Blame | Last modification | View Log | RSS feed
package org.tela_botanica.del.client.vues.comparaisoneflore;
import java.util.Date;
import java.util.List;
import org.tela_botanica.del.client.modeles.Observation;
import org.tela_botanica.del.client.modeles.ObservationValidation;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
public class ComparaisonEfloreVue extends Composite {
interface MyUiBinder extends UiBinder<Widget, ComparaisonEfloreVue> {
}
private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
@UiField
Label nomAuteur, dateObservation, famille, motsClefs, validateurs, dateValidation;
@UiField
Label nomEspeceEflore, nomAuteurEflore, localiteEflore, dateObservationEflore;
@UiField
Image imagePrincipale;
@UiField
Image imageEflore;
@UiField
Image scrollLeftImage;
@UiField
Image scrollRightImage;
private int currentIndexImages;
public ComparaisonEfloreVue() {
initWidget(uiBinder.createAndBindUi(this));
}
protected void chargerImagePrincipale(Observation observationPrincipale) {
// mots clefs
String motsClefsConcatenes = "";
for (String motClef : observationPrincipale.getMotsClefs()) {
motsClefsConcatenes += motClef + ",";
}
motsClefsConcatenes = motsClefsConcatenes.subSequence(0, motsClefsConcatenes.lastIndexOf(",")).toString();
// validateurs
String validateursConcatenes = "";
for (ObservationValidation observationValidation : observationPrincipale.getImageCelValidationDatas()) {
validateursConcatenes += observationValidation.getContributeur() + ", ";
}
validateursConcatenes = validateursConcatenes.subSequence(0, validateursConcatenes.lastIndexOf(",")).toString();
// date derniere validation
Date dateDerniereValidation = null;
for (ObservationValidation observationValidation : observationPrincipale.getImageCelValidationDatas()) {
if (dateDerniereValidation == null) {
dateDerniereValidation = observationValidation.getDate();
} else if (dateDerniereValidation.before(observationValidation.getDate())) {
dateDerniereValidation = observationValidation.getDate();
}
}
motsClefs.setText(motsClefsConcatenes);
nomAuteur.setText(observationPrincipale.getAuteur());
imagePrincipale.setUrl(observationPrincipale.getUrl());
dateObservation.setText(observationPrincipale.getDate());
famille.setText(observationPrincipale.getFamille());
validateurs.setText(validateursConcatenes);
dateValidation.setText(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(dateDerniereValidation));
}
protected void chargerImagesEflore(List<Observation> observationsEflore, int indexImage) {
if (indexImage >= 0 && indexImage < observationsEflore.size()) {
currentIndexImages = indexImage;
}
Observation observationEflore = observationsEflore.get(currentIndexImages);
nomEspeceEflore.setText(observationEflore.getSpecies());
nomAuteurEflore.setText(observationEflore.getAuteur());
imageEflore.setUrl(observationEflore.getUrl());
dateObservationEflore.setText(observationEflore.getDate());
localiteEflore.setText(observationEflore.getLocalite());
}
public Image getScrollLeftImage() {
return scrollLeftImage;
}
public void setScrollLeftImage(Image scrollLeftImage) {
this.scrollLeftImage = scrollLeftImage;
}
public int getCurrentIndexImages() {
return currentIndexImages;
}
public Image getScrollRightImage() {
return scrollRightImage;
}
}