Subversion Repositories eFlore/Applications.cel

Rev

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

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