Subversion Repositories eFlore/Applications.del

Compare Revisions

Ignore whitespace Rev 209 → Rev 210

/trunk/src/org/tela_botanica/del/client/vues/comparaisoneflore/ComparaisonEfloreVue.ui.xml
New file
0,0 → 1,69
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
 
<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' />
<ui:with field="constants" type="org.tela_botanica.del.client.i18n.Vocabulary" />
<ui:style src="comparaisonEflore.css" />
<g:HorizontalPanel styleName="{style.zoneComparaison}">
<g:VerticalPanel styleName="{style.photoPrincipale}">
<g:Label text="{constants.taxon_a_determiner}" styleName="titre"/>
<g:Label text="{constants.taxon_a_determiner}" styleName="petit"/>
<g:Image ui:field="imagePrincipale" />
<g:HTMLPanel styleName="{style.meta}">
<g:Label text="{constants.metadonnees_photo}" styleName="titre"/>
<g:Label text="{constants.metadonnees_photo}" styleName="petit"/>
<br />
<g:Label text="{constants.observateur}" styleName="petit"/><g:Label ui:field="nomAuteur" />
<g:Label text="{constants.date_observation}" styleName="petit"/>
<g:Label ui:field="dateObservation" />
<g:Label text="{constants.commentaires}" styleName="petit"/>
<g:Label ui:field="famille"/>
<g:Label text="{constants.mots_clefs}" styleName="petit"/>
<g:Label ui:field="motsClefs"/>
 
<br />
<g:Label text="{constants.valide_par}" styleName="petit"/>
<g:Label ui:field="validateurs"/>
<g:Label text="{constants.date_validation}" styleName="petit"/>
<g:Label ui:field="dateValidation"/>
</g:HTMLPanel>
</g:VerticalPanel>
<g:VerticalPanel styleName="{style.photoComparee}">
<g:Label text="{constants.image_eflore}" styleName="titre"/>
<g:Label text="{constants.image_eflore}" styleName="petit"/>
<g:Image ui:field="imageEflore" />
<g:HorizontalPanel styleName="{style.fleches}">
<g:Image ui:field="scrollLeftImage" resource='{res.arrowLeft}' styleName="gauche"/>
<g:Image ui:field="scrollRightImage" resource='{res.arrowRight}' styleName="droite" />
</g:HorizontalPanel>
<g:HTMLPanel styleName="{style.meta}">
<g:Label text="{constants.metadonnees_photo}" styleName="titre"/>
<g:Label text="{constants.metadonnees_photo}" styleName="petit"/>
<g:Label text="{constants.taxon}" styleName="petit"/>
<g:Label ui:field="nomEspeceEflore" />
 
<g:Label text="{constants.localite}" styleName="petit"/>
<g:Label ui:field="localiteEflore"/>
 
<g:Label text="{constants.auteur}" styleName="petit"/>
<g:Label ui:field="nomAuteurEflore"/>
 
<g:Label text="{constants.transmis_le}" styleName="petit"/>
<g:Label ui:field="dateObservationEflore"/>
</g:HTMLPanel>
 
 
</g:VerticalPanel>
</g:HorizontalPanel>
</ui:UiBinder>
/trunk/src/org/tela_botanica/del/client/vues/comparaisoneflore/ComparaisonEflorePresenteur.java
New file
0,0 → 1,69
package org.tela_botanica.del.client.vues.comparaisoneflore;
 
import java.util.List;
 
import org.tela_botanica.del.client.cache.CacheClient;
import org.tela_botanica.del.client.modeles.Image;
import org.tela_botanica.del.client.modeles.VoteProtocole;
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 final MockDatasource validationService = MockDatasource.getInstance();
 
private Image imagePrincipale;
 
private String nomTaxonComparaison;
 
private List<org.tela_botanica.del.client.modeles.Image> imagesEflore;
 
public ComparaisonEflorePresenteur() {
this.imagePrincipale = CacheClient.getInstance().getImageCourante();
this.nomTaxonComparaison = CacheClient.getInstance().getTaxonPourRechercheEflore();
}
 
public void go(HasWidgets composite) {
composite.add(vue);
chargerValidationObservationPrincipale();
vue.chargerImagePrincipale(imagePrincipale);
chargerObservationsEflore();
gererEvenements();
}
 
private void chargerValidationObservationPrincipale() {
List<VoteProtocole> observationValidations = validationService.getVote(imagePrincipale.getIdImage());
imagePrincipale.setVoteProtocoles(observationValidations);
}
 
private void chargerObservationsEflore() {
imagesEflore = observationService.getImagesEfloreParTaxon(nomTaxonComparaison);
vue.chargerImagesEflore(imagesEflore, 0);
}
 
private void gererEvenements() {
vue.getScrollLeftImage().addClickHandler(new ClickHandler() {
 
@Override
public void onClick(ClickEvent event) {
vue.chargerImagesEflore(imagesEflore, vue.getCurrentIndexImages() - 1);
}
});
 
vue.getScrollRightImage().addClickHandler(new ClickHandler() {
 
@Override
public void onClick(ClickEvent event) {
vue.chargerImagesEflore(imagesEflore, vue.getCurrentIndexImages() + 1);
}
});
}
 
}
/trunk/src/org/tela_botanica/del/client/vues/comparaisoneflore/ComparaisonEfloreVue.java
New file
0,0 → 1,117
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;
}
 
}
/trunk/src/org/tela_botanica/del/client/vues/comparaisoneflore/comparaisonEflore.css
New file
0,0 → 1,7
.zoneComparaison {width:50%; margin:0 auto; height:100%}
.photoComparee {width:500px; margin-left:5px; padding:20px; border:#DDD solid 1px; -moz-border-radius:0 10px 10px 0;}
.photoPrincipale img, .photoComparee img {-moz-box-shadow:4px 4px 2px #AAA}
.photoPrincipale {width:500px; border:#DDD solid 1px; -moz-border-radius:10px 0 0 10px; padding:20px; height:100%}
.fleches {position:absolute; margin-left:-20px; padding:20px;margin-top:-50px; width:500px;}
.fleches img {cursor:pointer; -moz-box-shadow:0px 0px 0px #000}
.meta {color:white; background:#333; padding:10px; opacity:0.8em; margin-top:5px}