Subversion Repositories eFlore/Applications.cel

Rev

Rev 669 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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