Subversion Repositories eFlore/Applications.del

Rev

Rev 436 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 436 Rev 445
Line 1... Line 1...
1
package org.tela_botanica.del.client.vues.rechercheobservations;
1
package org.tela_botanica.del.client.vues.rechercheobservations;
Line 2... Line -...
2
 
-
 
3
import org.tela_botanica.del.client.cache.CacheClient;
2
 
4
import org.tela_botanica.del.client.composants.moteurrecherche.MoteurRecherchePresenteur;
3
import org.tela_botanica.del.client.composants.moteurrecherche.MoteurRecherchePresenteur;
5
import org.tela_botanica.del.client.composants.moteurrecherche.MoteurRechercheVue;
-
 
6
import org.tela_botanica.del.client.composants.pagination.PaginationPresenteur;
-
 
7
import org.tela_botanica.del.client.composants.pagination.PaginationVue;
4
import org.tela_botanica.del.client.composants.moteurrecherche.MoteurRechercheVue;
8
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
-
 
9
import org.tela_botanica.del.client.modeles.Observation;
-
 
10
import org.tela_botanica.del.client.modeles.ObservationServiceResultat;
5
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
11
import org.tela_botanica.del.client.services.rest.ObservationService;
6
import org.tela_botanica.del.client.services.rest.ObservationService;
-
 
7
import org.tela_botanica.del.client.services.rest.ObservationServiceConcret;
-
 
8
import org.tela_botanica.del.client.vues.rechercheobservations.resultats.ResultatsRechercheObservationsPresenteur;
Line 12... Line 9...
12
import org.tela_botanica.del.client.services.rest.async.ObservationsCallback;
9
import org.tela_botanica.del.client.vues.rechercheobservations.resultats.ResultatsRechercheObservationsVue;
13
 
10
 
Line 14... Line 11...
14
import com.google.gwt.user.client.ui.HasWidgets;
11
import com.google.gwt.user.client.ui.HasWidgets;
Line 15... Line -...
15
import com.google.gwt.user.client.ui.IsWidget;
-
 
16
 
-
 
17
public class RechercheObservationsPresenteur extends Presenteur {
12
import com.google.gwt.user.client.ui.IsWidget;
18
 
13
 
Line 19... Line 14...
19
	private ObservationService serviceObs;
14
public class RechercheObservationsPresenteur extends Presenteur {
20
 
-
 
21
	public abstract interface Vue extends IsWidget {
-
 
22
		public HasWidgets getZoneRecherche();
-
 
23
 
-
 
24
		public HasWidgets getZoneObservations();
-
 
25
 
-
 
26
		public HasWidgets getZonePaginationHaut();
-
 
27
 
-
 
28
		public HasWidgets getZonePaginationBas();
-
 
29
 
-
 
30
		public void startChargement();
15
 
Line 31... Line 16...
31
 
16
	public abstract interface Vue extends IsWidget {
Line 32... Line 17...
32
		public void stopChargement();
17
		public HasWidgets getZoneRecherche();
Line 33... Line 18...
33
 
18
 
34
		public void nettoyer();
-
 
35
	}
19
		public HasWidgets getZoneResultats();
Line 36... Line 20...
36
 
20
	}
Line 37... Line 21...
37
	private Vue vue;
21
 
38
 
22
	private Vue vue;
Line 39... Line -...
39
	public RechercheObservationsPresenteur(ObservationService serviceObs, Vue vue) {
-
 
40
 
-
 
41
		this.vue = vue;
-
 
42
		this.serviceObs = serviceObs;
-
 
43
	}
-
 
44
 
-
 
45
	public void go(HasWidgets composite) {
-
 
46
 
-
 
47
		composite.add(vue.asWidget());
-
 
48
		ajouterMoteurRechercheAvancee();
23
 
Line 49... Line 24...
49
 
24
	public RechercheObservationsPresenteur(ObservationService serviceObs, Vue vue) {
50
		ObservationsCallback callback = new ObservationsCallback() {
25
 
51
			@Override
26
		this.vue = vue;
Line 52... Line 27...
52
			public void surObservationsRecues(ObservationServiceResultat observationsRecues) {
27
	}
53
				creerWidgetPagination(observationsRecues.getNbTotalObservationsPourLaRecherche());
28
 
54
				afficherObservations(observationsRecues);
29
	public void go(HasWidgets composite) {
55
			}
30
 
56
		};
31
		composite.add(vue.asWidget());
57
 
32
		ajouterMoteurRechercheAvancee();
58
		serviceObs.getObservations(CacheClient.getInstance().getInformationsRechercheObservation(), 0, CacheClient.getInstance().getPasPagination(), callback);
33
 
Line 59... Line -...
59
	}
-
 
60
 
-
 
61
	protected void ajouterMoteurRechercheAvancee() {
-
 
62
		MoteurRecherchePresenteur presenteur = new MoteurRecherchePresenteur(new MoteurRechercheVue("") {
34
	}
63
		}, false, true) {
-
 
64
 
35
 
65
			@Override
-
 
66
			public void lancerRecherche() {
-
 
67
				chargerEtAfficherObservations(0, CacheClient.getInstance().getPasPagination());
-
 
68
			}
-
 
69
		};
-
 
70
		presenteur.go(vue.getZoneRecherche());
-
 
71
	}
-
 
72
 
-
 
73
	protected void gererEvenements() {
-
 
74
	}
-
 
75
 
36
	protected void ajouterMoteurRechercheAvancee() {
76
	public void chargerEtAfficherObservations(int debut, int fin) {
-
 
77
		vue.startChargement();
-
 
78
		vue.nettoyer();
-
 
79
		ObservationsCallback callback = new ObservationsCallback() {
-
 
80
 
-
 
81
			@Override
-
 
82
			public void surObservationsRecues(ObservationServiceResultat observationsRecues) {
37
		MoteurRecherchePresenteur presenteur = new MoteurRecherchePresenteur(new MoteurRechercheVue("") {
Line 83... Line -...
83
				afficherObservations(observationsRecues);
-
 
84
			}
-
 
85
		};
-
 
86
		serviceObs.getObservations(CacheClient.getInstance().getInformationsRechercheObservation(), debut, fin, callback);
-
 
87
	}
-
 
88
 
-
 
89
	private void afficherObservations(ObservationServiceResultat observationServiceResultat) {
-
 
90
		vue.nettoyer();
-
 
91
		for (Observation observation : observationServiceResultat.getObservations()) {
-
 
92
			ObservationPresenteur presenteur = new ObservationPresenteur(new ObservationVue(), observation);
-
 
93
			presenteur.go(vue.getZoneObservations());
38
		}, false, true) {
94
		}
-
 
95
		vue.stopChargement();
-
 
96
	}
-
 
97
 
-
 
98
	private void creerWidgetPagination(int nbObservations) {
-
 
99
		PaginationPresenteur paginationPresenteurHaut = new PaginationPresenteur(new PaginationVue(), nbObservations, CacheClient.getInstance().getPasPagination()) {
-
 
100
 
-
 
101
			@Override
-
 
102
			public void changerPage(int debut, int fin) {
-
 
103
				chargerEtAfficherObservations(debut, fin);
-
 
104
				CacheClient.getInstance().setPageCouranteRechercheObservations(getPageCourante());
-
 
105
			}
-
 
106
 
-
 
107
			@Override
-
 
108
			public void actualiserPasCache(int pas) {
-
 
109
				CacheClient.getInstance().setPasPagination(pas);
-
 
110
			}
-
 
111
 
-
 
112
		};
-
 
113
 
-
 
114
		PaginationPresenteur paginationPresenteurBas = new PaginationPresenteur(new PaginationVue(), nbObservations, CacheClient.getInstance().getPasPagination()) {
-
 
115
 
39
 
Line 116... Line 40...
116
			@Override
40
			@Override