Subversion Repositories eFlore/Applications.del

Rev

Rev 309 | Rev 335 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
161 gduche 1
package org.tela_botanica.del.client.vues.rechercheobservations;
2
 
3
import java.util.HashMap;
4
import java.util.Iterator;
166 gduche 5
import java.util.List;
161 gduche 6
 
330 gduche 7
import org.tela_botanica.del.client.composants.moteurrecherche.MoteurRecherchePresenteur;
8
import org.tela_botanica.del.client.composants.moteurrecherche.MoteurRechercheVue;
161 gduche 9
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
166 gduche 10
import org.tela_botanica.del.client.modeles.Observation;
11
import org.tela_botanica.del.client.utils.MockDatasource;
161 gduche 12
 
13
import com.google.gwt.event.dom.client.ClickEvent;
14
import com.google.gwt.event.dom.client.ClickHandler;
309 aurelien 15
import com.google.gwt.event.dom.client.HasClickHandlers;
16
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
161 gduche 17
import com.google.gwt.event.dom.client.KeyCodes;
18
import com.google.gwt.event.dom.client.KeyPressEvent;
19
import com.google.gwt.event.dom.client.KeyPressHandler;
309 aurelien 20
import com.google.gwt.user.client.ui.Button;
21
import com.google.gwt.user.client.ui.HasText;
22
import com.google.gwt.user.client.ui.HasVisibility;
161 gduche 23
import com.google.gwt.user.client.ui.HasWidgets;
309 aurelien 24
import com.google.gwt.user.client.ui.IsWidget;
25
import com.google.gwt.user.client.ui.Label;
161 gduche 26
import com.google.gwt.user.client.ui.Panel;
27
import com.google.gwt.user.client.ui.RootPanel;
28
import com.google.gwt.user.client.ui.TextBox;
29
 
30
public class RechercheObservationsPresenteur extends Presenteur {
31
 
309 aurelien 32
	public abstract interface Vue extends IsWidget {
330 gduche 33
		public HasWidgets getZoneRecherche();
309 aurelien 34
		public HasWidgets getZoneObservations();
35
		public HasWidgets getZonePagination();
36
	}
37
	private Vue vue;
38
 
166 gduche 39
	private List<Observation> observations;
40
 
309 aurelien 41
	public RechercheObservationsPresenteur(Vue vue) {
42
		this.vue = vue;
161 gduche 43
	}
44
 
45
	public void go(HasWidgets composite) {
46
		if (composite == null) {
47
			composite = RootPanel.get();
48
		}
309 aurelien 49
		composite.add(vue.asWidget());
330 gduche 50
		ajouterMoteurRechercheAvancee();
220 gduche 51
		gererEvenements();
166 gduche 52
 
53
		// On commence par afficher la totalité des observations
54
		chercherObservations(null);
55
		afficherObservations();
161 gduche 56
	}
330 gduche 57
 
58
	protected void ajouterMoteurRechercheAvancee() {
59
		MoteurRecherchePresenteur presenteur = new MoteurRecherchePresenteur(new MoteurRechercheVue("Rechercher une observation"){}) {
60
 
61
			@Override
62
			public void lancerRecherche(String termeRecherche) {
63
				chercherObservations(null);
166 gduche 64
				afficherObservations();
161 gduche 65
			}
330 gduche 66
		};
67
		presenteur.go(vue.getZoneRecherche());
161 gduche 68
	}
69
 
330 gduche 70
	protected void gererEvenements() {}
161 gduche 71
 
166 gduche 72
	public void chercherObservations(HashMap<String, String> champsRecherche) {
73
		this.observations = MockDatasource.getInstance().getObservations(champsRecherche);
74
	}
161 gduche 75
 
166 gduche 76
	public void afficherObservations() {
309 aurelien 77
		vue.getZoneObservations().clear();
166 gduche 78
		for (Observation observation : observations) {
309 aurelien 79
			ObservationPresenteur presenteur = new ObservationPresenteur(new ObservationVue(), observation);
80
			presenteur.go(vue.getZoneObservations());
166 gduche 81
		}
161 gduche 82
	}
83
 
84
}