Subversion Repositories eFlore/Applications.del

Rev

Rev 322 | Rev 386 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 322 Rev 335
Line 1... Line 1...
1
package org.tela_botanica.del.client.composants.moteurrecherche;
1
package org.tela_botanica.del.client.composants.moteurrecherche;
Line 2... Line 2...
2
 
2
 
3
import java.util.HashMap;
-
 
4
 
3
import org.tela_botanica.del.client.cache.CacheClient;
5
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
4
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
Line 6... Line 5...
6
import org.tela_botanica.del.client.i18n.I18n;
5
import org.tela_botanica.del.client.modeles.InformationsRecherche;
7
 
6
 
8
import com.google.gwt.event.dom.client.ClickEvent;
7
import com.google.gwt.event.dom.client.ClickEvent;
9
import com.google.gwt.event.dom.client.ClickHandler;
8
import com.google.gwt.event.dom.client.ClickHandler;
10
import com.google.gwt.event.dom.client.HasClickHandlers;
9
import com.google.gwt.event.dom.client.HasClickHandlers;
11
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
10
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
12
import com.google.gwt.event.dom.client.KeyCodes;
11
import com.google.gwt.event.dom.client.KeyCodes;
13
import com.google.gwt.event.dom.client.KeyPressEvent;
12
import com.google.gwt.event.dom.client.KeyPressEvent;
14
import com.google.gwt.event.dom.client.KeyPressHandler;
13
import com.google.gwt.event.dom.client.KeyPressHandler;
15
import com.google.gwt.user.client.Window;
14
import com.google.gwt.user.client.ui.HasText;
Line 16... Line 15...
16
import com.google.gwt.user.client.ui.HasWidgets;
15
import com.google.gwt.user.client.ui.HasWidgets;
Line 17... Line 16...
17
import com.google.gwt.user.client.ui.IsWidget;
16
import com.google.gwt.user.client.ui.IsWidget;
-
 
17
 
18
 
18
public abstract class MoteurRecherchePresenteur extends Presenteur {
-
 
19
 
19
public abstract class MoteurRecherchePresenteur extends Presenteur {
20
	public abstract interface Vue extends IsWidget {
-
 
21
 
20
	
22
		public abstract HasClickHandlers getLienRechercheAvancee();
-
 
23
 
21
	public abstract interface Vue extends IsWidget {
24
		public abstract void basculerAffichageZoneCache();
-
 
25
 
22
		public abstract HasClickHandlers getLienRechercheAvancee();
26
		public abstract HasClickHandlers getBoutonRechercheSimple();
-
 
27
 
23
		public abstract void basculerAffichageZoneCache();
28
		public abstract HasClickHandlers getBoutonRechercheAvancee();
-
 
29
 
24
		public abstract HasClickHandlers getBoutonRechercheSimple();
30
		public abstract HasKeyPressHandlers getChampSaisie();
-
 
31
 
25
		public abstract HasClickHandlers getBoutonRechercheAvancee();
32
		public abstract HasClickHandlers getChampSaisieCliquable();
-
 
33
 
26
		public abstract HasKeyPressHandlers getChampSaisie();
34
		public abstract String getValeurRechercheSimple();
-
 
35
 
27
		public abstract HasClickHandlers getChampSaisieCliquable();
36
		public void setValeurRechercheSimple(String valeurRecherche);
-
 
37
 
28
		public abstract String getValeurRechercheSimple();
38
		public String getLabelRecherche();
-
 
39
 
-
 
40
		public HasText getRecherchePrincipale();
-
 
41
 
-
 
42
		public HasText getDepartement();
-
 
43
 
-
 
44
		public HasText getCommune();
-
 
45
 
29
		public void setValeurRechercheSimple(String valeurRecherche);
46
		public HasText getTaxon();
-
 
47
 
-
 
48
		public HasText getFamille();
-
 
49
 
-
 
50
		public HasText getGenre();
-
 
51
 
-
 
52
		public HasText getTag();
-
 
53
 
-
 
54
		public HasText getMotCle();
-
 
55
 
-
 
56
		public HasText getAuteur();
30
		public String getLabelRecherche();
57
 
Line 31... Line 58...
31
		public abstract HashMap<String, String> collecterFormulaire(); 
58
		public HasText getDate();
-
 
59
 
Line 32... Line 60...
32
		public String getChaineRecherche();
60
		public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche);
33
		public abstract void setRecherchePrecedente();
61
	}
-
 
62
 
-
 
63
	private final Vue vue;
34
	}
64
	private final boolean pourRechercheImages, pourRechercheObservations;
35
 
65
 
Line 36... Line 66...
36
	private Vue vue;
66
	public MoteurRecherchePresenteur(Vue vue, boolean pourRechercheImages, boolean pourRechercheObservations) {
37
	
67
		this.vue = vue;
-
 
68
		this.pourRechercheImages = pourRechercheImages;
38
	public MoteurRecherchePresenteur(Vue vue) {
69
		this.pourRechercheObservations = pourRechercheObservations;
39
		this.vue = vue;
70
		gererEvenements();
Line 40... Line 71...
40
		gererEvenements();
71
	}
41
	}
72
 
Line 53... Line 84...
53
			}
84
			}
54
		});
85
		});
Line 55... Line 86...
55
		
86
 
56
		vue.getBoutonRechercheSimple().addClickHandler(new ClickHandler() {
87
		vue.getBoutonRechercheSimple().addClickHandler(new ClickHandler() {
57
			public void onClick(ClickEvent event) {
88
			public void onClick(ClickEvent event) {
58
				afficherInfoRecherche();
89
				collecterInfosRecherche();
59
				lancerRecherche(vue.getChaineRecherche());
90
				afficherRequeteEtLancerRecherche();
60
			}
91
			}
Line 61... Line 92...
61
		});
92
		});
62
		
93
 
63
		vue.getBoutonRechercheAvancee().addClickHandler(new ClickHandler() {
94
		vue.getBoutonRechercheAvancee().addClickHandler(new ClickHandler() {
-
 
95
			public void onClick(ClickEvent event) {
64
			public void onClick(ClickEvent event) {
96
				collecterInfosRecherche();
65
				afficherInfoRecherche();
97
				vue.basculerAffichageZoneCache();
66
				lancerRecherche(vue.getChaineRecherche());
98
				afficherRequeteEtLancerRecherche();
Line 67... Line 99...
67
			}
99
			}
Line 68... Line 100...
68
		});
100
		});
69
		
101
 
70
		vue.getChampSaisie().addKeyPressHandler(new KeyPressHandler() {
102
		vue.getChampSaisie().addKeyPressHandler(new KeyPressHandler() {
71
			
103
 
72
			public void onKeyPress(KeyPressEvent event) {
104
			public void onKeyPress(KeyPressEvent event) {
73
				if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
105
				if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
74
					afficherInfoRecherche();
106
					collecterInfosRecherche();
Line 75... Line 107...
75
					lancerRecherche(vue.getChaineRecherche());
107
					afficherRequeteEtLancerRecherche();
Line 84... Line 116...
84
				if (vue.getValeurRechercheSimple().equals(vue.getLabelRecherche())) {
116
				if (vue.getValeurRechercheSimple().equals(vue.getLabelRecherche())) {
85
					vue.setValeurRechercheSimple("");
117
					vue.setValeurRechercheSimple("");
86
				}
118
				}
87
			}
119
			}
88
		});
120
		});
-
 
121
	}
-
 
122
 
-
 
123
	private void collecterInfosRecherche() {
-
 
124
		InformationsRecherche informationRecherche = new InformationsRecherche();
-
 
125
		informationRecherche.setAuteur(vue.getAuteur().getText());
-
 
126
		informationRecherche.setCommune(vue.getCommune().getText());
-
 
127
		informationRecherche.setDate(vue.getDate().getText());
-
 
128
		informationRecherche.setDepartement(vue.getDepartement().getText());
-
 
129
		informationRecherche.setFamille(vue.getFamille().getText());
-
 
130
		informationRecherche.setGenre(vue.getGenre().getText());
-
 
131
		informationRecherche.setMotClef(vue.getMotCle().getText());
Line -... Line 132...
-
 
132
 
-
 
133
		if (!vue.getRecherchePrincipale().getText().equals(vue.getLabelRecherche())) {
-
 
134
			informationRecherche.setRechercheLibre(vue.getRecherchePrincipale().getText());
-
 
135
		}
-
 
136
		if (isPourRechercheImages()) {
-
 
137
			CacheClient.getInstance().setInformationsRechercheImage(informationRecherche);
-
 
138
		} else if (isPourRechercheObservations()) {
-
 
139
			CacheClient.getInstance().setInformationsRechercheObservation(informationRecherche);
89
			
140
		}
Line -... Line 141...
-
 
141
	}
-
 
142
 
-
 
143
	private InformationsRecherche getInformationsRechercheEnCache() {
-
 
144
		if (isPourRechercheImages()) {
-
 
145
			return CacheClient.getInstance().getInformationsRechercheImage();
-
 
146
		} else if (isPourRechercheObservations()) {
-
 
147
			return CacheClient.getInstance().getInformationsRechercheObservation();
-
 
148
		}
-
 
149
		return null;
90
	}
150
	}
-
 
151
 
-
 
152
	public void afficherRequeteEtLancerRecherche() {
-
 
153
		InformationsRecherche informationsRecherche = getInformationsRechercheEnCache();
-
 
154
		if (informationsRecherche != null) {
91
	
155
			vue.chargerValeursRecherchePrecedente(informationsRecherche);
92
	private void afficherInfoRecherche() {
156
		}
Line 93... Line 157...
93
		vue.setRecherchePrecedente();
157
		lancerRecherche();
-
 
158
	}
-
 
159
 
-
 
160
	public abstract void lancerRecherche();
-
 
161
 
-
 
162
	public boolean isPourRechercheImages() {
-
 
163
		return pourRechercheImages;
-
 
164
	}
-
 
165
 
94
	}
166
	public boolean isPourRechercheObservations() {