Subversion Repositories eFlore/Applications.cel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
268 aurelien 1
package org.tela_botanica.client.vues.observation.filtres;
2
 
3
import org.tela_botanica.client.interfaces.Filtrable;
4
import org.tela_botanica.client.observation.ObservationMediateur;
5
 
6
import com.google.gwt.user.client.ui.ClickListener;
7
import com.gwtext.client.core.EventCallback;
8
import com.gwtext.client.core.EventObject;
9
import com.google.gwt.user.client.ui.Widget;
10
import com.gwtext.client.widgets.Button;
11
import com.gwtext.client.widgets.Panel;
12
import com.gwtext.client.widgets.event.ButtonListener;
13
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
14
import com.gwtext.client.widgets.form.TextField;
15
 
16
public class RechercheLibreVue extends Panel implements Filtrable {
17
 
18
	private ObservationMediateur oMediateur = null;
19
 
20
	private TextField champRecherche = null;
21
 
22
	private static String titrePanneau = "Recherche libre";
23
 
24
	private String valeurRecherchee= "";
25
 
26
	private Button boutonRechercher = null;
27
 
28
	private boolean estModifie = true;
29
 
30
	private final int KEY_ENTER = 13;
31
 
32
 
33
	public RechercheLibreVue(ObservationMediateur om) {
34
		super(titrePanneau);
35
		oMediateur = om;
36
		champRecherche = new TextField();
37
		boutonRechercher = new Button("Rechercher");
38
 
39
		boutonRechercher.addListener(new ButtonListenerAdapter() {
40
 
41
			public void onClick(Button button, EventObject e) {
42
				valider();
43
			}
44
		});
45
 
46
		champRecherche.addKeyPressListener(new EventCallback()	{
47
 
48
    	    public void execute(EventObject e) {
49
 
50
	    		switch(e.getKey()) {
51
	    			case KEY_ENTER:
52
	    				valider();
53
	    			break;
54
	    		}
55
    	    }
56
		});
57
 
58
		add(champRecherche);
59
		add(boutonRechercher);
60
 
61
		setCollapsible(true);
62
		setTitleCollapse(true);
63
		setPaddings(5);
64
	}
65
 
66
 
67
	public boolean renvoyerEtatFiltre() {
68
		return estModifie;
69
	}
70
 
71
 
72
	public String renvoyerNomFiltre() {
73
		return "Taxon";
74
	}
75
 
76
	public String[] renvoyerValeursAFiltrer() {
77
 
78
		if(champRecherche.getValueAsString() != null) {
79
			valeurRecherchee = champRecherche.getValueAsString();
80
		}
81
 
82
		String[] valeurs = {"nom_taxon",valeurRecherchee};
83
		return valeurs;
84
	}
85
 
86
 
87
	public void valider() {
88
		if(champRecherche.getValueAsString() != null && champRecherche.getValueAsString() != valeurRecherchee) {
89
			estModifie = true;
90
			oMediateur.obtenirNombreObservation();
91
		} else {
92
			estModifie = false;
93
		}
94
	}
95
 
96
	public void raz() {
97
		if(champRecherche.isCreated()) {
98
			champRecherche.reset();
99
			valeurRecherchee = "";
100
		}
101
	}
102
}