Subversion Repositories eFlore/Applications.cel

Rev

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

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