Subversion Repositories eFlore/Applications.del

Rev

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

Rev 408 Rev 419
1
package org.tela_botanica.del.client.composants.moteurrecherche;
1
package org.tela_botanica.del.client.composants.moteurrecherche;
2
 
2
 
3
import org.tela_botanica.del.client.i18n.I18n;
3
import org.tela_botanica.del.client.i18n.I18n;
4
import org.tela_botanica.del.client.modeles.InformationsRecherche;
4
import org.tela_botanica.del.client.modeles.InformationsRecherche;
5
 
5
 
6
import com.google.gwt.core.client.GWT;
6
import com.google.gwt.core.client.GWT;
7
import com.google.gwt.event.dom.client.HasClickHandlers;
7
import com.google.gwt.event.dom.client.HasClickHandlers;
8
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
8
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
9
import com.google.gwt.uibinder.client.UiBinder;
9
import com.google.gwt.uibinder.client.UiBinder;
10
import com.google.gwt.uibinder.client.UiField;
10
import com.google.gwt.uibinder.client.UiField;
11
import com.google.gwt.user.client.ui.Button;
11
import com.google.gwt.user.client.ui.Button;
12
import com.google.gwt.user.client.ui.Composite;
12
import com.google.gwt.user.client.ui.Composite;
13
import com.google.gwt.user.client.ui.HasText;
13
import com.google.gwt.user.client.ui.HasText;
14
import com.google.gwt.user.client.ui.HasWidgets;
14
import com.google.gwt.user.client.ui.HasWidgets;
15
import com.google.gwt.user.client.ui.Label;
15
import com.google.gwt.user.client.ui.Label;
16
import com.google.gwt.user.client.ui.Panel;
16
import com.google.gwt.user.client.ui.Panel;
17
import com.google.gwt.user.client.ui.TextBox;
17
import com.google.gwt.user.client.ui.TextBox;
18
import com.google.gwt.user.client.ui.Widget;
18
import com.google.gwt.user.client.ui.Widget;
19
 
19
 
20
public class MoteurRechercheVue extends Composite implements MoteurRecherchePresenteur.Vue {
20
public class MoteurRechercheVue extends Composite implements MoteurRecherchePresenteur.Vue {
21
 
21
 
22
	interface Binder extends UiBinder<Widget, MoteurRechercheVue> {
22
	interface Binder extends UiBinder<Widget, MoteurRechercheVue> {
23
	}
23
	}
24
 
24
 
25
	private static Binder uiBinder = GWT.create(Binder.class);
25
	private static Binder uiBinder = GWT.create(Binder.class);
26
	private String labelRecherche = "";
26
	private String labelRecherche = "";
27
 
27
 
28
	@UiField
28
	@UiField
29
	Panel rechercheAvancee,taxon;
29
	Panel rechercheAvancee, taxon;
30
	@UiField
30
	@UiField
31
	Label lienRechercheAvancee, recherchePrecedente;
31
	Label lienRechercheAvancee, recherchePrecedente;
32
	@UiField
32
	@UiField
33
	Button boutonRecherche, boutonRechercheAvancee, boutonFermer;
33
	Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider;
34
	@UiField
34
	@UiField
35
	TextBox recherchePrincipale, departement, commune, famille, genre, tag, motCle, auteur, date;
35
	TextBox recherchePrincipale, departement, commune, famille, genre, tag, motCle, auteur, date;
36
 
36
 
37
	public MoteurRechercheVue(String labelRecherche) {
37
	public MoteurRechercheVue(String labelRecherche) {
38
		initWidget(uiBinder.createAndBindUi(this));
38
		initWidget(uiBinder.createAndBindUi(this));
39
		this.labelRecherche = labelRecherche;
39
		this.labelRecherche = labelRecherche;
40
		recherchePrincipale.setText(labelRecherche);
40
		recherchePrincipale.setText(labelRecherche);
41
		rechercheAvancee.setVisible(false);
41
		rechercheAvancee.setVisible(false);
42
	}
42
	}
43
 
43
 
44
	public String getLabelRecherche() {
44
	public String getLabelRecherche() {
45
		return labelRecherche;
45
		return labelRecherche;
46
	}
46
	}
47
 
47
 
48
	@Override
48
	@Override
49
	public HasClickHandlers getLienRechercheAvancee() {
49
	public HasClickHandlers getLienRechercheAvancee() {
50
		return lienRechercheAvancee;
50
		return lienRechercheAvancee;
51
	}
51
	}
52
 
52
 
53
	@Override
53
	@Override
54
	public void basculerAffichageZoneCache() {
54
	public void basculerAffichageZoneCache() {
55
		rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
55
		rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
-
 
56
		recherchePrincipale.setVisible(!recherchePrincipale.isVisible());
-
 
57
		boutonRecherche.setVisible(!boutonRecherche.isVisible());
56
	}
58
	}
57
 
59
 
58
	@Override
60
	@Override
59
	public HasClickHandlers getBoutonRechercheSimple() {
61
	public HasClickHandlers getBoutonRechercheSimple() {
60
		return boutonRecherche;
62
		return boutonRecherche;
61
	}
63
	}
62
	
64
	
63
	@Override
65
	@Override
64
	public HasClickHandlers getBoutonFermer() {
66
	public HasClickHandlers getBoutonFermer() {
65
		return boutonFermer;
67
		return boutonFermer;
66
	}
68
	}
-
 
69
	
-
 
70
	@Override
-
 
71
	public HasClickHandlers getBoutonVider() {
-
 
72
		return boutonVider;
-
 
73
	}
67
 
74
 
68
	@Override
75
	@Override
69
	public HasClickHandlers getBoutonRechercheAvancee() {
76
	public HasClickHandlers getBoutonRechercheAvancee() {
70
		return boutonRechercheAvancee;
77
		return boutonRechercheAvancee;
71
	}
78
	}
72
 
79
 
73
	@Override
80
	@Override
74
	public HasKeyPressHandlers getChampSaisie() {
81
	public HasKeyPressHandlers getChampSaisie() {
75
		return recherchePrincipale;
82
		return recherchePrincipale;
76
	}
83
	}
77
 
84
 
78
	@Override
85
	@Override
79
	public String getValeurRechercheSimple() {
86
	public String getValeurRechercheSimple() {
80
		return recherchePrincipale.getText();
87
		return recherchePrincipale.getText();
81
	}
88
	}
82
 
89
 
83
	@Override
90
	@Override
84
	public HasClickHandlers getChampSaisieCliquable() {
91
	public HasClickHandlers getChampSaisieCliquable() {
85
		return recherchePrincipale;
92
		return recherchePrincipale;
86
	}
93
	}
87
 
94
 
88
	@Override
95
	@Override
89
	public void setValeurRechercheSimple(String valeurRecherche) {
96
	public void setValeurRechercheSimple(String valeurRecherche) {
90
		recherchePrincipale.setText(valeurRecherche);
97
		recherchePrincipale.setText(valeurRecherche);
91
	}
98
	}
92
 
99
 
93
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
-
 
94
		getAuteur().setText(informationsRecherche.getAuteur());
-
 
95
		getCommune().setText(informationsRecherche.getCommune());
-
 
96
		getDate().setText(informationsRecherche.getDate());
-
 
97
		getDepartement().setText(informationsRecherche.getDepartement());
-
 
98
		getFamille().setText(informationsRecherche.getFamille());
-
 
99
		getMotCle().setText(informationsRecherche.getMotClef());
-
 
-
 
100
	public void chargerValeursRechercheSimplePrecedente(InformationsRecherche informationsRecherche) {
100
 
101
 
101
		
102
		this.nettoyer();
102
		if (informationsRecherche.getRechercheLibre() != null && !informationsRecherche.getRechercheLibre().equals("")) {
103
		if (informationsRecherche.getRechercheLibre() != null && !informationsRecherche.getRechercheLibre().equals("")) {
103
			getRecherchePrincipale().setText(informationsRecherche.getRechercheLibre());
104
			getRecherchePrincipale().setText(informationsRecherche.getRechercheLibre());
104
		}
105
		}
-
 
106
		afficherLigneInfoRecherche(informationsRecherche);
-
 
107
	}
-
 
108
 
-
 
109
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
-
 
110
		informationsRecherche.setRechercheLibre(null);
-
 
111
		getRecherchePrincipale().setText("");
-
 
112
		getDepartement().setText(informationsRecherche.getDepartement());
-
 
113
		getCommune().setText(informationsRecherche.getCommune());
-
 
114
		getFamille().setText(informationsRecherche.getFamille());
-
 
115
		getGenre().setText(informationsRecherche.getGenre());
-
 
116
		getTag().setText(informationsRecherche.getTag());
-
 
117
		getMotCle().setText(informationsRecherche.getMotClef());
-
 
118
		getAuteur().setText(informationsRecherche.getAuteur());
-
 
119
		getDate().setText(informationsRecherche.getDate());
105
 
120
		
106
		afficherLigneInfoRecherche(informationsRecherche);
121
		afficherLigneInfoRecherche(informationsRecherche);
107
	}
122
	}
108
 
123
 
109
	/**
124
	/**
110
	 * Affiche la ligne d'en tête montrant les elements de la requête à
125
	 * Affiche la ligne d'en tête montrant les elements de la requête à
111
	 * l'utilisateur
126
	 * l'utilisateur
112
	 * 
127
	 * 
113
	 * @param informationRecherche
128
	 * @param informationRecherche
114
	 */
129
	 */
115
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
130
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
-
 
131
 
116
 
132
		//tax dep com fam gen ta mo au date
-
 
133
		StringBuffer texteRecherchePrecedente = new StringBuffer();
117
		StringBuffer texteRecherchePrecedente = new StringBuffer();
134
		
118
		if (informationRecherche.getRechercheLibre()!=null&&!informationRecherche.getRechercheLibre().equals("")) {
135
		if (informationRecherche.getRechercheLibre()!=null&&!informationRecherche.getRechercheLibre().equals("")) {
119
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
136
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
120
		}
137
		}
121
		if (!informationRecherche.getAuteur().equals("")) {
-
 
122
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
-
 
123
		}
-
 
124
		if (!informationRecherche.getCommune().equals("")) {
138
		if (informationRecherche.getTaxon() != null&&!informationRecherche.getTaxon().equals("")) {
125
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
-
 
126
		}
-
 
127
		if (!informationRecherche.getDate().equals("")) {
-
 
128
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
139
			texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
129
		}
140
		}
130
		if (!informationRecherche.getDepartement().equals("")) {
141
		if (informationRecherche.getDepartement()!=null && !informationRecherche.getDepartement().equals("")) {
131
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
142
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
132
		}
143
		}
-
 
144
		if (informationRecherche.getCommune()!=null && !informationRecherche.getCommune().equals("")) {
-
 
145
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
-
 
146
		}
133
		if (!informationRecherche.getFamille().equals("")) {
147
		if (informationRecherche.getFamille()!=null && !informationRecherche.getFamille().equals("")) {
134
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
148
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
135
		}
149
		}
136
		if (!informationRecherche.getGenre().equals("")) {
150
		if (informationRecherche.getGenre()!=null && !informationRecherche.getGenre().equals("")) {
137
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
151
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
138
		}
152
		}
-
 
153
		if (informationRecherche.getTag()!=null && !informationRecherche.getTag().equals("")) {
-
 
154
			texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
-
 
155
		}
139
		if (!informationRecherche.getMotClef().equals("")) {
156
		if (informationRecherche.getMotClef()!=null && !informationRecherche.getMotClef().equals("")) {
140
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
157
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
141
		}
158
		}
-
 
159
		if (informationRecherche.getAuteur()!=null && !informationRecherche.getAuteur().equals("")) {
-
 
160
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
-
 
161
		}
-
 
162
		if (informationRecherche.getDate()!=null && !informationRecherche.getDate().equals("")) {
-
 
163
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
-
 
164
		}
-
 
165
		
-
 
166
		
-
 
167
		
142
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
168
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
143
	}
169
	}
-
 
170
 
-
 
171
	public void nettoyer() {
-
 
172
		chargerValeursRecherchePrecedente(new InformationsRecherche());
-
 
173
	}
144
 
174
	
145
	public HasText getRecherchePrincipale() {
175
	public HasText getRecherchePrincipale() {
146
		return recherchePrincipale;
176
		return recherchePrincipale;
147
	}
177
	}
148
 
178
 
149
	public HasText getDepartement() {
179
	public HasText getDepartement() {
150
		return departement;
180
		return departement;
151
	}
181
	}
152
 
182
 
153
	public HasText getCommune() {
183
	public HasText getCommune() {
154
		return commune;
184
		return commune;
155
	}
185
	}
156
 
186
 
157
	public HasWidgets getTaxon() {
187
	public HasWidgets getTaxon() {
158
		return taxon;
188
		return taxon;
159
	}
189
	}
160
 
190
 
161
	public HasText getFamille() {
191
	public HasText getFamille() {
162
		return famille;
192
		return famille;
163
	}
193
	}
164
 
194
 
165
	public HasText getGenre() {
195
	public HasText getGenre() {
166
		return genre;
196
		return genre;
167
	}
197
	}
168
 
198
 
169
	public HasText getTag() {
199
	public HasText getTag() {
170
		return tag;
200
		return tag;
171
	}
201
	}
172
 
202
 
173
	public HasText getMotCle() {
203
	public HasText getMotCle() {
174
		return motCle;
204
		return motCle;
175
	}
205
	}
176
 
206
 
177
	public HasText getAuteur() {
207
	public HasText getAuteur() {
178
		return auteur;
208
		return auteur;
179
	}
209
	}
180
 
210
 
181
	public HasText getDate() {
211
	public HasText getDate() {
182
		return date;
212
		return date;
183
	}
213
	}
184
 
214
 
185
	public void focusSaisie() {
215
	public void focusSaisie() {
186
		this.recherchePrincipale.setFocus(true);
216
		this.recherchePrincipale.setFocus(true);
187
	}
217
	}
188
}
218
}