Subversion Repositories eFlore/Applications.cel

Rev

Rev 268 | Go to most recent revision | Details | Compare with Previous | 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();
280 aurelien 37
		champRecherche.setWidth("90%");
268 aurelien 38
		boutonRechercher = new Button("Rechercher");
39
 
40
		boutonRechercher.addListener(new ButtonListenerAdapter() {
41
 
42
			public void onClick(Button button, EventObject e) {
43
				valider();
44
			}
45
		});
46
 
47
		champRecherche.addKeyPressListener(new EventCallback()	{
48
 
49
    	    public void execute(EventObject e) {
50
 
51
	    		switch(e.getKey()) {
52
	    			case KEY_ENTER:
53
	    				valider();
54
	    			break;
55
	    		}
56
    	    }
57
		});
58
 
59
		add(champRecherche);
60
		add(boutonRechercher);
61
 
62
		setCollapsible(true);
63
		setTitleCollapse(true);
64
		setPaddings(5);
65
	}
66
 
67
 
68
	public boolean renvoyerEtatFiltre() {
69
		return estModifie;
70
	}
71
 
72
 
73
	public String renvoyerNomFiltre() {
74
		return "Taxon";
75
	}
76
 
77
	public String[] renvoyerValeursAFiltrer() {
78
 
79
		if(champRecherche.getValueAsString() != null) {
80
			valeurRecherchee = champRecherche.getValueAsString();
81
		}
82
 
83
		String[] valeurs = {"nom_taxon",valeurRecherchee};
84
		return valeurs;
85
	}
86
 
87
 
88
	public void valider() {
89
		if(champRecherche.getValueAsString() != null && champRecherche.getValueAsString() != valeurRecherchee) {
90
			estModifie = true;
91
			oMediateur.obtenirNombreObservation();
92
		} else {
93
			estModifie = false;
94
		}
95
	}
96
 
97
	public void raz() {
98
		if(champRecherche.isCreated()) {
99
			champRecherche.reset();
100
			valeurRecherchee = "";
101
		}
102
	}
103
}