Subversion Repositories eFlore/Applications.cel

Rev

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

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