Subversion Repositories eFlore/Applications.cel

Rev

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

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