Subversion Repositories eFlore/Applications.del

Rev

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

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