Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 184 Rev 195
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues.observation;
2
 
2
 
3
import org.tela_botanica.client.interfaces.Filtrable;
3
import org.tela_botanica.client.interfaces.Filtrable;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
5
import org.tela_botanica.client.observation.ObservationMediateur;
5
import org.tela_botanica.client.observation.ObservationMediateur;
6
 
6
 
7
import com.google.gwt.user.client.ui.Label;
7
import com.google.gwt.user.client.ui.Label;
8
import com.gwtext.client.core.EventObject;
8
import com.gwtext.client.core.EventObject;
9
import com.gwtext.client.widgets.Button;
9
import com.gwtext.client.widgets.Button;
10
import com.gwtext.client.widgets.Panel;
10
import com.gwtext.client.widgets.Panel;
11
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
11
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
12
import com.gwtext.client.widgets.event.KeyListener;
12
import com.gwtext.client.widgets.event.KeyListener;
13
import com.gwtext.client.widgets.form.TextField;
13
import com.gwtext.client.widgets.form.TextField;
14
 
14
 
15
public class MotsClesObsVue extends Panel implements Filtrable, Rafraichissable {
15
public class MotsClesObsVue extends Panel implements Filtrable, Rafraichissable {
16
	
16
	
17
	private ObservationMediateur oMediateur = null ; 
17
	private ObservationMediateur oMediateur = null ; 
18
	
18
	
19
	/**
19
	/**
20
	 * Barre de recherche
20
	 * Barre de recherche
21
	 * 
21
	 * 
22
	 */
22
	 */
23
	private TextField champRecherche = null;
23
	private TextField champRecherche = null;
24
 
24
 
25
	/**
25
	/**
26
	 * Booleen d'etat du filtre
26
	 * Booleen d'etat du filtre
27
	 */
27
	 */
28
	private boolean filtreModifie = false;
28
	private boolean filtreModifie = false;
29
 
29
 
30
	/**
30
	/**
31
	 * mot(s) à chercher
31
	 * mot(s) à chercher
32
	 */
32
	 */
33
	private String motsAChercher = "";
33
	private String motsAChercher = "";
34
	
34
	
35
	/**
35
	/**
36
	 * bouton de validation
36
	 * bouton de validation
37
	 */
37
	 */
38
	private Button ok = null ;
38
	private Button ok = null ;
39
	
39
	
40
	private Button afficherNuage = null;
40
	private Button afficherNuage = null;
41
	
41
	
42
	/**
42
	/**
43
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
43
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
44
	 */
44
	 */
45
	@SuppressWarnings("unused")
45
	@SuppressWarnings("unused")
46
	private MotsClesObsVue() {
46
	private MotsClesObsVue() {
47
		super();
47
		super();
48
	}
48
	}
49
 
49
 
50
	/**
50
	/**
51
	 * Constructeur avec médiateur
51
	 * Constructeur avec médiateur
52
	 * 
52
	 * 
53
	 * @param im
53
	 * @param im
54
	 */
54
	 */
55
	public MotsClesObsVue(ObservationMediateur om) {
55
	public MotsClesObsVue(ObservationMediateur om) {
56
		super();
56
		super();
57
		oMediateur = om;
57
		oMediateur = om;
58
 
58
 
59
		Label labelRecherche = new Label("Mots clés :");
59
		Label labelRecherche = new Label("Mots clés :");
60
		champRecherche = new TextField();
60
		champRecherche = new TextField();
61
		ok = new Button("Rechercher");
61
		ok = new Button("Rechercher");
62
		afficherNuage = new Button("Voir les mots clés");
62
		afficherNuage = new Button("Voir les mots clés");
63
 
63
 
64
		add(labelRecherche);
64
		add(labelRecherche);
65
		add(champRecherche);
65
		add(champRecherche);
66
		add(ok);
66
		add(ok);
67
		add(afficherNuage);
67
		add(afficherNuage);
68
 
68
 
69
		setPaddings(5);
69
		setPaddings(5);
70
		setBorder(false);
70
		setBorder(false);
71
		setAutoWidth(true);
71
		setAutoWidth(true);
72
		setCollapsible(true);
72
		setCollapsible(true);
73
 
73
 
74
		ajouterListeners();
74
		ajouterListeners();
75
	}
75
	}
76
 
76
 
77
	/**
77
	/**
78
	 * ajoute des listeners
78
	 * ajoute des listeners
79
	 */
79
	 */
80
	private void ajouterListeners() {
80
	private void ajouterListeners() {
81
 
81
 
82
		// gestion de la touche entrée
82
		// gestion de la touche entrée
83
		champRecherche.addKeyListener(EventObject.ENTER, new KeyListener() {
83
		champRecherche.addKeyListener(EventObject.ENTER, new KeyListener() {
84
 
84
 
85
			public void onKey(int key, EventObject e) {
85
			public void onKey(int key, EventObject e) {
86
 
86
 
87
				valider();
87
				valider();
88
			}
88
			}
89
 
89
 
90
		});
90
		});
91
		
91
		
92
		ok.addListener(new ButtonListenerAdapter() {
92
		ok.addListener(new ButtonListenerAdapter() {
93
 
93
 
94
			public void onClick(Button button, EventObject e) {
94
			public void onClick(Button button, EventObject e) {
95
				valider();
95
				valider();
96
			}
96
			}
97
		});
97
		});
98
		
98
		
99
		afficherNuage.addListener(new ButtonListenerAdapter() {
99
		afficherNuage.addListener(new ButtonListenerAdapter() {
100
 
100
 
101
			public void onClick(Button button, EventObject e) {
101
			public void onClick(Button button, EventObject e) {
102
		//		oMediateur.afficherNuageMotsCles();
102
		//		oMediateur.afficherNuageMotsCles();
103
			}
103
			}
104
		});
104
		});
105
	}
105
	}
106
 
106
 
107
	/**
107
	/**
108
	 * Fonction héritée de l'interface rafraichissable
108
	 * Fonction héritée de l'interface rafraichissable
109
	 */
109
	 */
110
	public void rafraichir(Object nouvelleDonnees,
110
	public void rafraichir(Object nouvelleDonnees,
111
			boolean repandreRaffraichissement) {
111
			boolean repandreRaffraichissement) {
112
 
112
 
113
		if(nouvelleDonnees instanceof String) {
113
		if(nouvelleDonnees instanceof String) {
114
			
114
			
115
			champRecherche.setValue(champRecherche.getValueAsString()+" "+(String)nouvelleDonnees);
115
			champRecherche.setValue(champRecherche.getValueAsString()+" "+(String)nouvelleDonnees);
116
		}
116
		}
117
		filtreModifie = false;
117
		filtreModifie = false;
118
 
118
 
119
	}
119
	}
120
 
120
 
121
	/**
121
	/**
122
	 * renvoie l'état du filtre (modifié ou non)
122
	 * renvoie l'état du filtre (modifié ou non)
123
	 * 
123
	 * 
124
	 * @return l'état du filtre
124
	 * @return l'état du filtre
125
	 */
125
	 */
126
	public boolean renvoyerEtatFiltre() {
126
	public boolean renvoyerEtatFiltre() {
127
 
127
 
128
		return filtreModifie;
128
		return filtreModifie;
129
	}
129
	}
130
 
130
 
131
	/**
131
	/**
132
	 * Renvoie le nom du filtre
132
	 * Renvoie le nom du filtre
133
	 * 
133
	 * 
134
	 * @return le nom du filtre
134
	 * @return le nom du filtre
135
	 */
135
	 */
136
	public String renvoyerNomFiltre() {
136
	public String renvoyerNomFiltre() {
137
 
137
 
138
		return "Recherche Mots clés";
138
		return "Recherche Mots clés";
139
	}
139
	}
140
 
140
 
141
	/**
141
	/**
142
	 * Renvoie un tableau contenant le nom du champ à filtrer et la valeur
142
	 * Renvoie un tableau contenant le nom du champ à filtrer et la valeur
143
	 * 
143
	 * 
144
	 * @return un tableau contenant le nom du champ à filtrer et sa valeur
144
	 * @return un tableau contenant le nom du champ à filtrer et sa valeur
145
	 */
145
	 */
146
	public String[] renvoyerValeursAFiltrer() {
146
	public String[] renvoyerValeursAFiltrer() {
147
 
147
 
148
		String[] valeurFiltre = new String[0];
148
		String[] valeurFiltre = new String[0];
149
		if(!motsAChercher.equals("")) {
149
		if(!motsAChercher.equals("")) {
150
			valeurFiltre = new String[2];
150
			valeurFiltre = new String[2];
151
			valeurFiltre[0] = "mots_cles";
151
			valeurFiltre[0] = "mots_cles";
152
			valeurFiltre[1] = motsAChercher;
152
			valeurFiltre[1] = motsAChercher;
153
		}
153
		}
154
		return valeurFiltre;
154
		return valeurFiltre;
155
	}
155
	}
156
 
156
 
157
	/**
157
	/**
158
	 * Accesseur pour le médiateur
158
	 * Accesseur pour le médiateur
159
	 * 
159
	 * 
160
	 * @return le médiateur associé
160
	 * @return le médiateur associé
161
	 */
161
	 */
162
	public ObservationMediateur getIMediateur() {
162
	public ObservationMediateur getIMediateur() {
163
		return oMediateur;
163
		return oMediateur;
164
	}
164
	}
165
 
165
 
166
	/**
166
	/**
167
	 * Effectue quelque opérations dans la classe et envoie une requête de
167
	 * Effectue quelque opérations dans la classe et envoie une requête de
168
	 * données au médiateur
168
	 * données au médiateur
169
	 */
169
	 */
170
	public void valider() {
170
	public void valider() {
171
		filtreModifie = true;
171
		filtreModifie = true;
172
		motsAChercher = champRecherche.getText();
172
		motsAChercher = champRecherche.getText();
173
		oMediateur.obtenirNombreObservation();
173
		oMediateur.obtenirNombreObservation();
174
	}
174
	}
175
 
175
 
176
	/**
176
	/**
177
	 * Affiche la fenetre
177
	 * Affiche la fenetre
178
	 */
178
	 */
179
	public void afficherFiltre() {
179
	public void afficherFiltre() {
180
 
180
 
181
		champRecherche.setValue(motsAChercher);
181
		champRecherche.setValue(motsAChercher);
182
	}
182
	}
183
}
183
}