Rev 449 | Rev 1062 | Go to most recent revision | Blame | Compare with Previous | 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.event.dom.client.HasClickHandlers;
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.Panel;
import com.google.gwt.user.client.ui.Widget;
public class ComparaisonEfloreVue extends Composite implements ComparaisonEflorePresenteur.Vue {
interface MyUiBinder extends UiBinder<Widget, ComparaisonEfloreVue> {
}
private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
private int currentIndexImages;
@UiField
Label nomAuteur, dateObservation, famille, motsClefs, validateurs, dateValidation, nomEspeceEflore, nomAuteurEflore, localiteEflore, dateObservationEflore;
@UiField
Image imagePrincipale, imageEflore, scrollLeftImage, scrollRightImage;
@UiField
Panel panneauChargement;
public ComparaisonEfloreVue() {
initWidget(uiBinder.createAndBindUi(this));
}
public void chargerImagePrincipale(org.tela_botanica.del.client.modeles.Image image) {
// mots clefs
String motsClefsConcatenes = "";
try {
for (String motClef : image.getObservation().getMotsClefs()) {
motsClefsConcatenes += motClef + ",";
}
motsClefsConcatenes = motsClefsConcatenes.subSequence(0, motsClefsConcatenes.lastIndexOf(",")).toString();
} catch (Exception e) {
// TODO: handle exception
}
// validateurs
String validateursConcatenes = "";
try {
/*for (VoteProtocole observationValidation : image.getVoteProtocoles()) {
validateursConcatenes += observationValidation.getContributeur() + ", ";
}*/
validateursConcatenes = validateursConcatenes.subSequence(0, validateursConcatenes.lastIndexOf(",")).toString();
} catch (Exception e) {
}
// date derniere validation
Date dateDerniereValidation = null;
try {
/*for (VoteProtocole observationValidation : image.getVoteProtocoles()) {
if (dateDerniereValidation == null) {
dateDerniereValidation = observationValidation.getDate();
} else if (dateDerniereValidation.before(observationValidation.getDate())) {
dateDerniereValidation = observationValidation.getDate();
}
}*/
} catch (Exception e) {
}
motsClefs.setText(motsClefsConcatenes);
nomAuteur.setText(image.getObservation().getAuteur());
imagePrincipale.setUrl(image.getUrl());
dateObservation.setText(image.getObservation().getDateReleve());
famille.setText(image.getObservation().getFamille());
validateurs.setText(validateursConcatenes);
if (dateDerniereValidation != null) {
dateValidation.setText(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(dateDerniereValidation));
}
}
public 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().getNomRetenu());
nomAuteurEflore.setText(observationEflore.getObservation().getAuteur());
imageEflore.setUrl(observationEflore.getUrl());
dateObservationEflore.setText(observationEflore.getObservation().getDateReleve());
localiteEflore.setText(observationEflore.getObservation().getLocalite());
}
public void setScrollLeftImage(Image scrollLeftImage) {
this.scrollLeftImage = scrollLeftImage;
}
public int getCurrentIndexImages() {
return currentIndexImages;
}
@Override
public HasClickHandlers getScrollLeftImage() {
return scrollLeftImage;
}
@Override
public HasClickHandlers getScrollRightImage() {
return scrollRightImage;
}
public void startChargement() {
panneauChargement.setVisible(true);
}
public void stopChargement() {
panneauChargement.setVisible(false);
}
public Label getNomAuteur() {
return nomAuteur;
}
public Image getImagePrincipale() {
return imagePrincipale;
}
}