Subversion Repositories eFlore/Applications.del

Compare Revisions

Ignore whitespace Rev 1101 → Rev 1102

/trunk/src/org/tela_botanica/del/client/composants/votes/details/DetailListeVotesDeterminationVue.java
5,8 → 5,10
import java.util.Map;
 
import org.tela_botanica.del.client.i18n.I18n;
import org.tela_botanica.del.client.modeles.MoyenneVote;
import org.tela_botanica.del.client.modeles.PropositionDetermination;
import org.tela_botanica.del.client.modeles.VoteDetermination;
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;
 
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
17,6 → 19,8
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;
 
28,14 → 32,14
};
@UiField
HTMLPanel titre, auteur, aucuneDonnees;
HTMLPanel titre, auteur, aucuneDonnees, detailVotePour, detailVoteContre;
@UiField
Label scorePour, scoreContre;
@UiField
Panel panneauChargement;
 
@UiField
FlexTable htmlTableau;
public DetailListeVotesDeterminationVue() {
initWidget(uiBinder.createAndBindUi(this));
}
50,44 → 54,48
auteur.add(htmlAuteur);
Map<String, VoteDetermination> listeVotes = propositionDetermination.getVotesDeterminations();
htmlTableau.clear();
creerEntetes();
int votesAnonymesPour = 0;
int votesAnonymesContre = 0;
MoyenneVote moyenne = CalculVoteDeterminationService.calculerVoteDetermination(propositionDetermination);
scorePour.setText(String.valueOf(moyenne.getScore()) + '%');
scoreContre.setText(String.valueOf(100 - moyenne.getScore()) + '%');
for (Iterator<String> iterator = listeVotes.keySet().iterator(); iterator.hasNext();) {
VoteDetermination voteDetermination = listeVotes.get(iterator.next());
ajouterVote(voteDetermination);
VoteDetermination voteDetermination = listeVotes.get(iterator.next());
if (voteDetermination.getVote() == 1) {
//Votes pour
if (voteDetermination.getAuteur() != null) {
ajouterVote(voteDetermination, detailVotePour);
} else {
votesAnonymesPour++;
}
} else {
//Votes contre
if (voteDetermination.getAuteur() != null) {
ajouterVote(voteDetermination, detailVoteContre);
} else {
votesAnonymesContre++;
}
}
}
}
private void creerEntetes() {
htmlTableau.setHTML(1, 1, I18n.getVocabulary().contributeur());
htmlTableau.setHTML(1, 2, I18n.getVocabulary().valeurVote());
htmlTableau.setHTML(1, 3, I18n.getVocabulary().date());
}
@Override
public void ajouterVote(VoteDetermination vote) {
int index = htmlTableau.getRowCount() + 1;
String valeurVote = (vote.getVote() == 1) ? I18n.getVocabulary().oui() : I18n.getVocabulary().non();
String contributeur;
try {
contributeur = Integer.parseInt(vote.getContributeur())+"";
} catch (Exception e) {
contributeur = I18n.getVocabulary().anonyme();
if (votesAnonymesPour > 0) {
LigneVotePresenteur presenteurVote= new LigneVotePresenteur(new LigneVoteVue(), votesAnonymesPour);
presenteurVote.go(detailVotePour);
}
if(vote.getAuteur() != null) {
contributeur = vote.getAuteur().getNomComplet();
if (votesAnonymesContre > 0) {
LigneVotePresenteur presenteurVote= new LigneVotePresenteur(new LigneVoteVue(), votesAnonymesContre);
presenteurVote.go(detailVoteContre);
}
htmlTableau.setHTML(index, 1, contributeur);
htmlTableau.setHTML(index, 2, valeurVote+"");
htmlTableau.setHTML(index, 3, DateTimeFormat.getFormat("dd/MM/yyyy").format(vote.getDate()));
 
}
public void ajouterVote(VoteDetermination vote, HasWidgets panel) {
LigneVotePresenteur presenteurVote = new LigneVotePresenteur(new LigneVoteVue(), vote);
presenteurVote.go(panel);
}
@Override
public void startChargement() {
panneauChargement.setHeight((this.getOffsetHeight()/2)+"px");