Subversion Repositories eFlore/Applications.del

Rev

Rev 322 | Rev 386 | Go to most recent revision | Show entire file | Ignore 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;
3
import org.tela_botanica.del.client.i18n.I18n;
Line 4... Line 4...
4
import java.util.Iterator;
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;
-
 
10
import com.google.gwt.uibinder.client.UiField;
9
import com.google.gwt.uibinder.client.UiBinder;
11
import com.google.gwt.user.client.Window;
10
import com.google.gwt.uibinder.client.UiField;
12
import com.google.gwt.user.client.ui.Button;
11
import com.google.gwt.user.client.ui.Button;
13
import com.google.gwt.user.client.ui.Composite;
12
import com.google.gwt.user.client.ui.Composite;
14
import com.google.gwt.user.client.ui.IsWidget;
13
import com.google.gwt.user.client.ui.HasText;
15
import com.google.gwt.user.client.ui.Label;
14
import com.google.gwt.user.client.ui.Label;
16
import com.google.gwt.user.client.ui.Panel;
15
import com.google.gwt.user.client.ui.Panel;
Line 17... Line 16...
17
import com.google.gwt.user.client.ui.TextBox;
16
import com.google.gwt.user.client.ui.TextBox;
Line 18... Line 17...
18
import com.google.gwt.user.client.ui.Widget;
17
import com.google.gwt.user.client.ui.Widget;
-
 
18
 
-
 
19
public class MoteurRechercheVue extends Composite implements MoteurRecherchePresenteur.Vue {
19
 
20
 
20
public class MoteurRechercheVue extends Composite implements MoteurRecherchePresenteur.Vue {
21
	interface Binder extends UiBinder<Widget, MoteurRechercheVue> {
21
 
22
	}
-
 
23
 
22
	interface Binder extends UiBinder<Widget, MoteurRechercheVue> {}
24
	private static Binder uiBinder = GWT.create(Binder.class);
-
 
25
	private String labelRecherche = "";
23
	private static Binder uiBinder = GWT.create(Binder.class);
26
 
-
 
27
	@UiField
24
	private String labelRecherche = "";
28
	Panel rechercheAvancee;
-
 
29
	@UiField
25
	
30
	Label lienRechercheAvancee, recherchePrecedente;
26
	@UiField Panel rechercheAvancee;
31
	@UiField
27
	@UiField Label lienRechercheAvancee, recherchePrecedente;
32
	Button boutonRecherche, boutonRechercheAvancee;
28
	@UiField Button boutonRecherche, boutonRechercheAvancee;
33
	@UiField
29
	@UiField TextBox recherchePrincipale, departement, commune, taxon, famille, genre, tag, motCle, auteur, date;
34
	TextBox recherchePrincipale, departement, commune, taxon, famille, genre, tag, motCle, auteur, date;
30
	
35
 
31
	public MoteurRechercheVue(String labelRecherche) {
36
	public MoteurRechercheVue(String labelRecherche) {
32
		initWidget(uiBinder.createAndBindUi(this));
37
		initWidget(uiBinder.createAndBindUi(this));
Line 33... Line 38...
33
		this.labelRecherche = labelRecherche;
38
		this.labelRecherche = labelRecherche;
34
		recherchePrincipale.setText(labelRecherche);
39
		recherchePrincipale.setText(labelRecherche);
35
		rechercheAvancee.setVisible(false);
40
		rechercheAvancee.setVisible(false);
36
	}
41
	}
37
 
42
 
38
	public String getLabelRecherche() {
43
	public String getLabelRecherche() {
39
		return labelRecherche;
44
		return labelRecherche;
40
	}
45
	}
Line 51... Line 56...
51
 
56
 
52
	@Override
57
	@Override
53
	public HasClickHandlers getBoutonRechercheSimple() {
58
	public HasClickHandlers getBoutonRechercheSimple() {
54
		return boutonRecherche;
59
		return boutonRecherche;
55
	}
60
	}
56
	
61
 
57
	@Override
62
	@Override
58
	public HasClickHandlers getBoutonRechercheAvancee() {
63
	public HasClickHandlers getBoutonRechercheAvancee() {
59
		return boutonRechercheAvancee;
64
		return boutonRechercheAvancee;
Line 71... Line 76...
71
 
76
 
72
	@Override
77
	@Override
73
	public HasClickHandlers getChampSaisieCliquable() {
78
	public HasClickHandlers getChampSaisieCliquable() {
74
		return recherchePrincipale;
79
		return recherchePrincipale;
75
	}
80
	}
76
	
81
 
77
	@Override
82
	@Override
78
	public void setValeurRechercheSimple(String valeurRecherche) {
83
	public void setValeurRechercheSimple(String valeurRecherche) {
79
		recherchePrincipale.setText(valeurRecherche);
84
		recherchePrincipale.setText(valeurRecherche);
Line -... Line 85...
-
 
85
	}
-
 
86
 
-
 
87
	public void chargerValeursRecherchePrecedente(InformationsRecherche informationsRecherche) {
80
	}
88
		getAuteur().setText(informationsRecherche.getAuteur());
-
 
89
		getCommune().setText(informationsRecherche.getCommune());
81
 
90
		getDate().setText(informationsRecherche.getDate());
-
 
91
		getDepartement().setText(informationsRecherche.getDepartement());
Line 82... Line -...
82
	@Override
-
 
83
	public HashMap<String, String> collecterFormulaire() {
-
 
84
 
-
 
85
		HashMap<String, String> champsRecherche = new HashMap<String, String>();
-
 
Line 86... Line 92...
86
		if (!recherchePrincipale.getText().equals("")) {
92
		getFamille().setText(informationsRecherche.getFamille());
87
			champsRecherche.put("search", recherchePrincipale.getText());
93
		getMotCle().setText(informationsRecherche.getMotClef());
88
		}
94
 
-
 
95
		
89
		
96
		if (informationsRecherche.getRechercheLibre() != null && !informationsRecherche.getRechercheLibre().equals("")) {
-
 
97
			getRecherchePrincipale().setText(informationsRecherche.getRechercheLibre());
-
 
98
		}
-
 
99
 
-
 
100
		afficherLigneInfoRecherche(informationsRecherche);
-
 
101
	}
-
 
102
 
-
 
103
	/**
-
 
104
	 * Affiche la ligne d'en tête montrant les elements de la requête à
-
 
105
	 * l'utilisateur
-
 
106
	 * 
90
		if (!departement.getText().equals("")) {
107
	 * @param informationRecherche
-
 
108
	 */
-
 
109
	private void afficherLigneInfoRecherche(InformationsRecherche informationRecherche) {
91
			champsRecherche.put("dept", departement.getText());
110
 
92
		}
111
		StringBuffer texteRecherchePrecedente = new StringBuffer();
93
		if (!commune.getText().equals("")) {
112
		if (informationRecherche.getRechercheLibre()!=null&&!informationRecherche.getRechercheLibre().equals("")) {
94
			champsRecherche.put("com", commune.getText());
113
			texteRecherchePrecedente.append(I18n.getVocabulary().rechercheLibre() + ":" + informationRecherche.getRechercheLibre() + " ");
95
		}
114
		}
96
		if (!taxon.getText().equals("")) {
115
		if (!informationRecherche.getAuteur().equals("")) {
97
			champsRecherche.put("taxon", taxon.getText());
116
			texteRecherchePrecedente.append(I18n.getVocabulary().auteur() + ":" + informationRecherche.getAuteur() + " ");
98
		}
117
		}
99
		if (!famille.getText().equals("")) {
118
		if (!informationRecherche.getCommune().equals("")) {
100
			champsRecherche.put("fam", famille.getText());
119
			texteRecherchePrecedente.append(I18n.getVocabulary().commune() + ":" + informationRecherche.getCommune() + " ");
101
		}
120
		}
102
		if (!genre.getText().equals("")) {
121
		if (!informationRecherche.getDate().equals("")) {
103
			champsRecherche.put("gen", genre.getText());
122
			texteRecherchePrecedente.append(I18n.getVocabulary().date() + ":" + informationRecherche.getDate() + " ");
104
		}
123
		}
105
		if (!tag.getText().equals("")) {
124
		if (!informationRecherche.getDepartement().equals("")) {
106
			champsRecherche.put("tag", tag.getText());
125
			texteRecherchePrecedente.append(I18n.getVocabulary().departement() + ":" + informationRecherche.getDepartement() + " ");
107
		}
126
		}
108
		if (!motCle.getText().equals("")) {
127
		if (!informationRecherche.getFamille().equals("")) {
109
			champsRecherche.put("motCle", motCle.getText());
128
			texteRecherchePrecedente.append(I18n.getVocabulary().famille() + ":" + informationRecherche.getFamille() + " ");
110
		}
129
		}
111
		if (!auteur.getText().equals("")) {
130
		if (!informationRecherche.getGenre().equals("")) {
112
			champsRecherche.put("auteur", auteur.getText());
131
			texteRecherchePrecedente.append(I18n.getVocabulary().genre() + ":" + informationRecherche.getGenre() + " ");
113
		}
-
 
114
		if (!date.getText().equals("")) {
132
		}
115
			champsRecherche.put("date", date.getText());
133
		if (!informationRecherche.getMotClef().equals("")) {
116
		}
134
			texteRecherchePrecedente.append(I18n.getVocabulary().mot_clef() + ":" + informationRecherche.getMotClef() + " ");
117
		
-
 
118
		return champsRecherche;
135
		}
119
	}
-
 
120
	
-
 
121
	@Override
-
 
122
	public String getChaineRecherche() {
-
 
123
		HashMap<String, String> valeursRecherche = collecterFormulaire();
-
 
124
		String chaineRecherche = "";
-
 
125
		if (valeursRecherche != null) {
-
 
126
			Iterator<String> itCles = valeursRecherche.keySet().iterator();
-
 
127
			while (itCles.hasNext()) {
-
 
128
				String cle = itCles.next();
-
 
129
				String valeur = valeursRecherche.get(cle);
-
 
130
				if (valeur != "") {
-
 
131
					chaineRecherche += cle + ":=" + valeur + " ";
136
		recherchePrecedente.setText(texteRecherchePrecedente.toString());
132
				}
137
	}
Line -... Line 138...
-
 
138
 
-
 
139
	public HasText getRecherchePrincipale() {
-
 
140
		return recherchePrincipale;
-
 
141
	}
-
 
142
 
-
 
143
	public HasText getDepartement() {
-
 
144
		return departement;
-
 
145
	}
-
 
146
 
133
			}
147
	public HasText getCommune() {
-
 
148
		return commune;
-
 
149
	}
134
		}
150
 
-
 
151
	public HasText getTaxon() {
-
 
152
		return taxon;
-
 
153
	}
135
		return chaineRecherche;
154
 
-
 
155
	public HasText getFamille() {
136
	}
156
		return famille;
-
 
157
	}
-
 
158
 
-
 
159
	public HasText getGenre() {
-
 
160
		return genre;
-
 
161
	}
-
 
162
 
-
 
163
	public HasText getTag() {
-
 
164
		return tag;
-
 
165
	}
-
 
166
 
-
 
167
	public HasText getMotCle() {
-
 
168
		return motCle;
-
 
169
	}
-
 
170
 
-
 
171
	public HasText getAuteur() {
-
 
172
		return auteur;
-
 
173
	}
137
 
174