Subversion Repositories eFlore/Applications.del

Compare Revisions

Ignore whitespace Rev 49 → Rev 50

/src/org/tela_botanica/del/client/vues/comparaisoneflore/ComparaisonEfloreVue.java
New file
0,0 → 1,89
package org.tela_botanica.del.client.vues.comparaisoneflore;
 
import java.util.List;
 
import org.tela_botanica.del.client.modeles.Observation;
 
import com.google.gwt.core.client.GWT;
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 nomEspece, nomAuteur, dateObservation, famille, localite;
 
@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) {
 
nomEspece.setText(observationPrincipale.getSpecies());
nomAuteur.setText(observationPrincipale.getAuteur());
imagePrincipale.setUrl(observationPrincipale.getUrl());
dateObservation.setText(observationPrincipale.getDate());
famille.setText(observationPrincipale.getFamille());
localite.setText(observationPrincipale.getLocalite());
 
}
 
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;
}
 
}
/src/org/tela_botanica/del/client/vues/comparaisoneflore/ComparaisonEfloreVue.ui.xml
New file
0,0 → 1,29
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<ui:with field='res' type='org.tela_botanica.del.client.Ressources' />
<g:HTMLPanel>
<g:VerticalPanel>
<g:HorizontalPanel>
<g:VerticalPanel>
<g:Image ui:field="imagePrincipale" />
<g:Label ui:field="nomEspece">Nom</g:Label>
<g:Label ui:field="nomAuteur">Auteur</g:Label>
<g:Label ui:field="dateObservation">Date</g:Label>
<g:Label ui:field="famille">Famille</g:Label>
<g:Label ui:field="localite">Localite</g:Label>
</g:VerticalPanel>
<g:VerticalPanel>
<g:HorizontalPanel>
<g:Image ui:field="scrollLeftImage" resource='{res.arrowLeft}'/>
<g:Image ui:field="imageEflore" />
<g:Image ui:field="scrollRightImage" resource='{res.arrowRight}' />
</g:HorizontalPanel>
<g:Label ui:field="nomEspeceEflore">Nom</g:Label>
<g:Label ui:field="nomAuteurEflore">Auteur</g:Label>
<g:Label ui:field="localiteEflore">Localite</g:Label>
<g:Label ui:field="dateObservationEflore">Date</g:Label>
</g:VerticalPanel>
</g:HorizontalPanel>
</g:VerticalPanel>
</g:HTMLPanel>
</ui:UiBinder>
/src/org/tela_botanica/del/client/vues/comparaisoneflore/ComparaisonEflorePresenteur.java
New file
0,0 → 1,59
package org.tela_botanica.del.client.vues.comparaisoneflore;
 
import java.util.List;
 
import org.tela_botanica.del.client.modeles.Observation;
import org.tela_botanica.del.client.utils.MockDatasource;
 
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HasWidgets;
 
public class ComparaisonEflorePresenteur {
 
private ComparaisonEfloreVue vue = new ComparaisonEfloreVue();
 
private final MockDatasource observationService = MockDatasource.getInstance();
 
private Observation observationPrincipale;
 
private String nomTaxonComparaison;
private List<Observation> observationsEflore ;
 
public ComparaisonEflorePresenteur(Observation observationPrincipale, String nomTaxonComparaison) {
this.observationPrincipale = observationPrincipale;
this.nomTaxonComparaison = nomTaxonComparaison;
}
 
public void go(HasWidgets composite) {
composite.add(vue);
vue.chargerImagePrincipale(observationPrincipale);
chargerObservationsEflore();
gererEvenements();
}
 
private void chargerObservationsEflore() {
observationsEflore = observationService.getObservationsEfloreParTaxon(nomTaxonComparaison);
vue.chargerImagesEflore(observationsEflore, 0);
}
 
private void gererEvenements() {
vue.getScrollLeftImage().addClickHandler(new ClickHandler() {
 
@Override
public void onClick(ClickEvent event) {
vue.chargerImagesEflore(observationsEflore, vue.getCurrentIndexImages()-1);
}
});
vue.getScrollRightImage().addClickHandler(new ClickHandler() {
 
@Override
public void onClick(ClickEvent event) {
vue.chargerImagesEflore(observationsEflore, vue.getCurrentIndexImages()+1);
}
});
}
 
}