Subversion Repositories eFlore/Applications.del

Rev

Rev 330 | Rev 359 | 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
 
166 gduche 3
import java.util.List;
161 gduche 4
 
335 benjamin 5
import org.tela_botanica.del.client.cache.CacheClient;
330 gduche 6
import org.tela_botanica.del.client.composants.moteurrecherche.MoteurRecherchePresenteur;
7
import org.tela_botanica.del.client.composants.moteurrecherche.MoteurRechercheVue;
161 gduche 8
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
335 benjamin 9
import org.tela_botanica.del.client.i18n.I18n;
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.user.client.ui.HasWidgets;
309 aurelien 14
import com.google.gwt.user.client.ui.IsWidget;
161 gduche 15
import com.google.gwt.user.client.ui.RootPanel;
16
 
17
public class RechercheObservationsPresenteur extends Presenteur {
18
 
309 aurelien 19
	public abstract interface Vue extends IsWidget {
330 gduche 20
		public HasWidgets getZoneRecherche();
335 benjamin 21
 
309 aurelien 22
		public HasWidgets getZoneObservations();
335 benjamin 23
 
309 aurelien 24
		public HasWidgets getZonePagination();
25
	}
335 benjamin 26
 
309 aurelien 27
	private Vue vue;
335 benjamin 28
 
166 gduche 29
	private List<Observation> observations;
30
 
309 aurelien 31
	public RechercheObservationsPresenteur(Vue vue) {
32
		this.vue = vue;
161 gduche 33
	}
34
 
35
	public void go(HasWidgets composite) {
36
		if (composite == null) {
37
			composite = RootPanel.get();
38
		}
309 aurelien 39
		composite.add(vue.asWidget());
330 gduche 40
		ajouterMoteurRechercheAvancee();
220 gduche 41
		gererEvenements();
166 gduche 42
 
161 gduche 43
	}
335 benjamin 44
 
330 gduche 45
	protected void ajouterMoteurRechercheAvancee() {
335 benjamin 46
		MoteurRecherchePresenteur presenteur = new MoteurRecherchePresenteur(new MoteurRechercheVue(I18n.getVocabulary().rechercherObservation()) {
47
		}, false, true) {
48
 
330 gduche 49
			@Override
335 benjamin 50
			public void lancerRecherche() {
51
				chercherObservations();
161 gduche 52
			}
330 gduche 53
		};
54
		presenteur.go(vue.getZoneRecherche());
161 gduche 55
	}
56
 
335 benjamin 57
	protected void gererEvenements() {
166 gduche 58
	}
161 gduche 59
 
335 benjamin 60
	public void chercherObservations() {
61
 
62
		this.observations = MockDatasource.getInstance().getObservations(CacheClient.getInstance().getInformationsRechercheObservation());
309 aurelien 63
		vue.getZoneObservations().clear();
166 gduche 64
		for (Observation observation : observations) {
309 aurelien 65
			ObservationPresenteur presenteur = new ObservationPresenteur(new ObservationVue(), observation);
66
			presenteur.go(vue.getZoneObservations());
166 gduche 67
		}
161 gduche 68
	}
69
 
70
}