Subversion Repositories eFlore/Applications.cel

Rev

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

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