Subversion Repositories eFlore/Applications.del

Rev

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

Rev 457 Rev 533
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, commune;
29
	Panel rechercheAvancee, taxon, commune;
30
	@UiField
30
	@UiField
31
	Label lienRechercheAvancee, recherchePrecedente;
31
	Label lienRechercheAvancee, recherchePrecedente;
32
	@UiField
32
	@UiField
33
	Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider;
33
	Button boutonRecherche, boutonRechercheAvancee, boutonFermer, boutonVider;
34
	@UiField
34
	@UiField
35
	TextBox recherchePrincipale, departement, famille, genre, tag, motCle, auteur, date;
35
	TextBox recherchePrincipale, contientMots, departement, 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
 
-
 
48
	@Override
47
 
49
	public HasClickHandlers getLienRechercheAvancee() {
48
	public HasClickHandlers getLienRechercheAvancee() {
50
		return lienRechercheAvancee;
49
		return lienRechercheAvancee;
51
	}
50
	}
52
 
-
 
53
	@Override
51
 
54
	public void basculerAffichageZoneCache() {
52
	public void basculerAffichageZoneCache() {
55
		rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
53
		rechercheAvancee.setVisible(!rechercheAvancee.isVisible());
56
		recherchePrincipale.setVisible(!recherchePrincipale.isVisible());
54
		recherchePrincipale.setVisible(!recherchePrincipale.isVisible());
57
		boutonRecherche.setVisible(!boutonRecherche.isVisible());
55
		boutonRecherche.setVisible(!boutonRecherche.isVisible());
58
	}
56
	}
59
 
-
 
60
	@Override
57
 
61
	public HasClickHandlers getBoutonRechercheSimple() {
58
	public HasClickHandlers getBoutonRechercheSimple() {
62
		return boutonRecherche;
59
		return boutonRecherche;
63
	}
60
	}
64
 
-
 
65
	@Override
61
 
66
	public HasClickHandlers getBoutonFermer() {
62
	public HasClickHandlers getBoutonFermer() {
67
		return boutonFermer;
63
		return boutonFermer;
68
	}
64
	}
69
 
-
 
70
	@Override
65
 
71
	public HasClickHandlers getBoutonVider() {
66
	public HasClickHandlers getBoutonVider() {
72
		return boutonVider;
67
		return boutonVider;
73
	}
68
	}
74
 
-
 
75
	@Override
69
 
76
	public HasClickHandlers getBoutonRechercheAvancee() {
70
	public HasClickHandlers getBoutonRechercheAvancee() {
77
		return boutonRechercheAvancee;
71
		return boutonRechercheAvancee;
78
	}
72
	}
79
 
-
 
80
	@Override
73
 
81
	public HasKeyPressHandlers getChampSaisie() {
74
	public HasKeyPressHandlers getChampSaisie() {
82
		return recherchePrincipale;
75
		return recherchePrincipale;
83
	}
76
	}
84
 
-
 
85
	@Override
77
 
86
	public String getValeurRechercheSimple() {
78
	public String getValeurRechercheSimple() {
87
		return recherchePrincipale.getText();
79
		return recherchePrincipale.getText();
88
	}
80
	}
-
 
81
	
-
 
82
	public String getContientMots() {
-
 
83
		return contientMots.getText();
-
 
84
	}
89
 
-
 
90
	@Override
85
 
91
	public HasClickHandlers getChampSaisieCliquable() {
86
	public HasClickHandlers getChampSaisieCliquable() {
92
		return recherchePrincipale;
87
		return recherchePrincipale;
93
	}
88
	}
94
 
-
 
95
	@Override
89
 
96
	public void setValeurRechercheSimple(String valeurRecherche) {
90
	public void setValeurRechercheSimple(String valeurRecherche) {
97
		recherchePrincipale.setText(valeurRecherche);
91
		recherchePrincipale.setText(valeurRecherche);
98
	}
92
	}
-
 
93
	
-
 
94
	public void setContientMots(String mots) {
99
	
95
		contientMots.setText(mots);
-
 
96
	}
100
	@Override
97
	
101
	public void setValeurDepartement(String dpt) {
98
	public void setValeurDepartement(String dpt) {
102
		departement.setValue(dpt);
99
		departement.setValue(dpt);
103
	}
100
	}
-
 
101
	
104
 
102
 
105
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
103
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
106
		recherchePrincipale.setText(informationsRecherche.getRechercheLibre());
104
		recherchePrincipale.setText(informationsRecherche.getRechercheLibre());
-
 
105
		contientMots.setText(informationsRecherche.getRechercheLibre());
107
		departement.setText(informationsRecherche.getDepartement());
106
		departement.setText(informationsRecherche.getDepartement());
108
		famille.setText(informationsRecherche.getFamille());
107
		famille.setText(informationsRecherche.getFamille());
109
		genre.setText(informationsRecherche.getGenre());
108
		genre.setText(informationsRecherche.getGenre());
110
		tag.setText(informationsRecherche.getTag());
109
		tag.setText(informationsRecherche.getTag());
111
		motCle.setText(informationsRecherche.getMotClef());
110
		motCle.setText(informationsRecherche.getMotClef());
112
		auteur.setText(informationsRecherche.getAuteur());
111
		auteur.setText(informationsRecherche.getAuteur());
113
		date.setText(informationsRecherche.getDate());
112
		date.setText(informationsRecherche.getDate());
114
 
113
 
115
		afficherLigneInfoRecherche(informationsRecherche);
114
		afficherLigneInfoRecherche(informationsRecherche);
116
	}
115
	}
117
 
116
 
118
	/**
117
	/**
119
	 * Affiche la ligne d'en tête montrant les elements de la requête à
118
	 * Affiche la ligne d'en tête montrant les elements de la requête à
120
	 * l'utilisateur
119
	 * l'utilisateur
121
	 * 
120
	 * 
122
	 * @param informationRecherche
121
	 * @param informationRecherche
123
	 */
122
	 */
124
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
123
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
125
 
124
 
126
		// tax dep com fam gen ta mo au date
125
		// tax dep com fam gen ta mo au date
127
		StringBuffer texteRecherchePrecedente = new StringBuffer();
126
		StringBuffer texteRecherchePrecedente = new StringBuffer();
128
 
127
 
129
		if (informationRecherche.getRechercheLibre() != null && !informationRecherche.getRechercheLibre().equals("")) {
128
		if (informationRecherche.getRechercheLibre() != null && !informationRecherche.getRechercheLibre().equals("")) {
130
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
129
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
131
		}
130
		}
132
		if (informationRecherche.getTaxon() != null && !informationRecherche.getTaxon().equals("")) {
131
		if (informationRecherche.getTaxon() != null && !informationRecherche.getTaxon().equals("")) {
133
			texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
132
			texteRecherchePrecedente.append(I18n.getVocabulary().taxon() + ":" + informationRecherche.getTaxon() + " ");
134
		}
133
		}
135
		if (informationRecherche.getDepartement() != null && !informationRecherche.getDepartement().equals("")) {
134
		if (informationRecherche.getDepartement() != null && !informationRecherche.getDepartement().equals("")) {
136
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
135
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
137
		}
136
		}
138
		if (informationRecherche.getCommune() != null && !informationRecherche.getCommune().equals("")) {
137
		if (informationRecherche.getCommune() != null && !informationRecherche.getCommune().equals("")) {
139
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
138
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
140
		}
139
		}
141
		if (informationRecherche.getFamille() != null && !informationRecherche.getFamille().equals("")) {
140
		if (informationRecherche.getFamille() != null && !informationRecherche.getFamille().equals("")) {
142
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
141
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
143
		}
142
		}
144
		if (informationRecherche.getGenre() != null && !informationRecherche.getGenre().equals("")) {
143
		if (informationRecherche.getGenre() != null && !informationRecherche.getGenre().equals("")) {
145
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
144
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
146
		}
145
		}
147
		if (informationRecherche.getTag() != null && !informationRecherche.getTag().equals("")) {
146
		if (informationRecherche.getTag() != null && !informationRecherche.getTag().equals("")) {
148
			texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
147
			texteRecherchePrecedente.append(I18n.getVocabulary().tag() + ":" + informationRecherche.getTag() + " ");
149
		}
148
		}
150
		if (informationRecherche.getMotClef() != null && !informationRecherche.getMotClef().equals("")) {
149
		if (informationRecherche.getMotClef() != null && !informationRecherche.getMotClef().equals("")) {
151
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
150
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
152
		}
151
		}
153
		if (informationRecherche.getAuteur() != null && !informationRecherche.getAuteur().equals("")) {
152
		if (informationRecherche.getAuteur() != null && !informationRecherche.getAuteur().equals("")) {
154
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
153
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
155
		}
154
		}
156
		if (informationRecherche.getDate() != null && !informationRecherche.getDate().equals("")) {
155
		if (informationRecherche.getDate() != null && !informationRecherche.getDate().equals("")) {
157
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
156
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
158
		}
157
		}
159
 
158
 
160
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
159
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
161
	}
160
	}
162
 
161
 
163
	public void nettoyer() {
162
	public void nettoyer() {
164
		chargerValeursRecherchePrecedente(new InformationsRecherche());
163
		chargerValeursRecherchePrecedente(new InformationsRecherche());
165
	}
164
	}
166
 
-
 
167
	public String getRecherchePrincipale() {
-
 
168
		return recherchePrincipale.getText();
-
 
169
	}
-
 
170
 
165
 
171
	public String getDepartement() {
166
	public String getDepartement() {
172
		return departement.getText();
167
		return departement.getText();
173
	}
168
	}
174
 
169
 
175
	public HasWidgets getCommune() {
170
	public HasWidgets getCommune() {
176
		return commune;
171
		return commune;
177
	}
172
	}
178
 
173
 
179
	public HasWidgets getTaxon() {
174
	public HasWidgets getTaxon() {
180
		return taxon;
175
		return taxon;
181
	}
176
	}
182
 
177
 
183
	public String getFamille() {
178
	public String getFamille() {
184
		return famille.getText();
179
		return famille.getText();
185
	}
180
	}
186
 
181
 
187
	public String getGenre() {
182
	public String getGenre() {
188
		return genre.getText();
183
		return genre.getText();
189
	}
184
	}
190
 
185
 
191
	public String getTag() {
186
	public String getTag() {
192
		return tag.getText();
187
		return tag.getText();
193
	}
188
	}
194
 
189
 
195
	public String getMotCle() {
190
	public String getMotCle() {
196
		return motCle.getText();
191
		return motCle.getText();
197
	}
192
	}
198
 
193
 
199
	public String getAuteur() {
194
	public String getAuteur() {
200
		return auteur.getText();
195
		return auteur.getText();
201
	}
196
	}
202
 
197
 
203
	public String getDate() {
198
	public String getDate() {
204
		return date.getText();
199
		return date.getText();
205
	}
200
	}
206
 
201
 
207
	public void focusSaisie() {
202
	public void focusSaisie() {
208
		this.recherchePrincipale.setFocus(true);
203
		this.recherchePrincipale.setFocus(true);
209
	}
204
	}
210
 
205
 
211
	@Override
206
	@Override
212
	public void ajouterVue(HasWidgets composite) {
207
	public void ajouterVue(HasWidgets composite) {
213
		composite.add(this.asWidget());
208
		composite.add(this.asWidget());
214
	}
209
	}
215
}
210
}