Rev 87 | 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.VoteProtocole;
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(org.tela_botanica.del.client.modeles.Image image) {
// mots clefs
String motsClefsConcatenes = "";
for (String motClef : image.getObservation().getMotsClefs()) {
motsClefsConcatenes += motClef + ",";
}
motsClefsConcatenes = motsClefsConcatenes.subSequence(0, motsClefsConcatenes.lastIndexOf(",")).toString();
// validateurs
String validateursConcatenes = "";
for (VoteProtocole observationValidation : image.getVoteProtocoles()) {
validateursConcatenes += observationValidation.getContributeur() + ", ";
}
validateursConcatenes = validateursConcatenes.subSequence(0, validateursConcatenes.lastIndexOf(",")).toString();
// date derniere validation
Date dateDerniereValidation = null;
for (VoteProtocole observationValidation : image.getVoteProtocoles()) {
if (dateDerniereValidation == null) {
dateDerniereValidation = observationValidation.getDate();
} else if (dateDerniereValidation.before(observationValidation.getDate())) {
dateDerniereValidation = observationValidation.getDate();
}
}
motsClefs.setText(motsClefsConcatenes);
nomAuteur.setText(image.getObservation().getAuteur());
imagePrincipale.setUrl(image.getUrl());
dateObservation.setText(image.getObservation().getDate());
famille.setText(image.getObservation().getFamille());
validateurs.setText(validateursConcatenes);
dateValidation.setText(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(dateDerniereValidation));
}
protected void chargerImagesEflore(List<org.tela_botanica.del.client.modeles.Image> observationsEflore, int indexImage) {
if (indexImage >= 0 && indexImage < observationsEflore.size()) {
currentIndexImages = indexImage;
}
org.tela_botanica.del.client.modeles.Image observationEflore = observationsEflore.get(currentIndexImages);
nomEspeceEflore.setText(observationEflore.getObservation().getSpecies());
nomAuteurEflore.setText(observationEflore.getObservation().getAuteur());
imageEflore.setUrl(observationEflore.getUrl());
dateObservationEflore.setText(observationEflore.getObservation().getDate());
localiteEflore.setText(observationEflore.getObservation().getLocalite());
}
public Image getScrollLeftImage() {
return scrollLeftImage;
}
public void setScrollLeftImage(Image scrollLeftImage) {
this.scrollLeftImage = scrollLeftImage;
}
public int getCurrentIndexImages() {
return currentIndexImages;
}
public Image getScrollRightImage() {
return scrollRightImage;
}
}