Subversion Repositories eFlore/Applications.del

Rev

Rev 330 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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