Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 1313 Rev 2627
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.i18n.Msg;
3
import org.tela_botanica.client.interfaces.Filtrable;
4
import org.tela_botanica.client.interfaces.Filtrable;
4
import org.tela_botanica.client.observation.ObservationMediateur;
5
import org.tela_botanica.client.observation.ObservationMediateur;
5
 
6
 
6
import com.gwtext.client.core.EventCallback;
7
import com.gwtext.client.core.EventCallback;
7
import com.gwtext.client.core.EventObject;
8
import com.gwtext.client.core.EventObject;
8
import com.gwtext.client.widgets.Button;
9
import com.gwtext.client.widgets.Button;
9
import com.gwtext.client.widgets.Panel;
10
import com.gwtext.client.widgets.Panel;
10
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
11
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
11
import com.gwtext.client.widgets.form.TextField;
12
import com.gwtext.client.widgets.form.TextField;
12
 
13
 
13
public class RechercheLibreVue extends Panel implements Filtrable {
14
public class RechercheLibreVue extends Panel implements Filtrable {
14
 
15
 
15
	private ObservationMediateur oMediateur = null;
16
	private ObservationMediateur oMediateur = null;
16
	
17
	
17
	private TextField champRecherche = null;
18
	private TextField champRecherche = null;
18
	
19
	
19
	private static String titrePanneau = "Recherche libre";
20
	private static String titrePanneau = Msg.get("recherche-libre");
20
	
21
	
21
	private String valeurRecherchee= "";
22
	private String valeurRecherchee= "";
22
	
23
	
23
	private Button boutonRechercher = null;
24
	private Button boutonRechercher = null;
24
	
25
	
25
	private boolean estModifie = true;
26
	private boolean estModifie = true;
26
	
27
	
27
	private final int KEY_ENTER = 13;
28
	private final int KEY_ENTER = 13;
28
	
29
	
29
	
30
	
30
	public RechercheLibreVue(ObservationMediateur om) {
31
	public RechercheLibreVue(ObservationMediateur om) {
31
		super(titrePanneau);
32
		super(titrePanneau);
32
		oMediateur = om;
33
		oMediateur = om;
33
		champRecherche = new TextField();
34
		champRecherche = new TextField();
34
		champRecherche.setWidth("90%");
35
		champRecherche.setWidth("90%");
35
		boutonRechercher = new Button("Rechercher");
36
		boutonRechercher = new Button(Msg.get("rechercher"));
36
		
37
		
37
		boutonRechercher.addListener(new ButtonListenerAdapter() {
38
		boutonRechercher.addListener(new ButtonListenerAdapter() {
38
 
39
 
39
			@Override
40
			@Override
40
			public void onClick(Button button, EventObject e) {
41
			public void onClick(Button button, EventObject e) {
41
				valider();
42
				valider();
42
			}
43
			}
43
		});
44
		});
44
		
45
		
45
		champRecherche.addKeyPressListener(new EventCallback()	{
46
		champRecherche.addKeyPressListener(new EventCallback()	{
46
	    	
47
	    	
47
    	    @Override
48
    	    @Override
48
			public void execute(EventObject e) {
49
			public void execute(EventObject e) {
49
    	    	   		  
50
    	    	   		  
50
	    		switch(e.getKey()) {
51
	    		switch(e.getKey()) {
51
	    			case KEY_ENTER:
52
	    			case KEY_ENTER:
52
	    				valider();
53
	    				valider();
53
	    			break;
54
	    			break;
54
	    		}
55
	    		}
55
    	    }
56
    	    }
56
		});
57
		});
57
		
58
		
58
		add(champRecherche);
59
		add(champRecherche);
59
		add(boutonRechercher);
60
		add(boutonRechercher);
60
		
61
		
61
		setCollapsible(true);
62
		setCollapsible(true);
62
		setTitleCollapse(true);
63
		setTitleCollapse(true);
63
		setPaddings(5);
64
		setPaddings(5);
64
	}
65
	}
65
 
66
 
66
 
67
 
67
	@Override
68
	@Override
68
	public boolean renvoyerEtatFiltre() {
69
	public boolean renvoyerEtatFiltre() {
69
		return estModifie;
70
		return estModifie;
70
	}
71
	}
71
 
72
 
72
 
73
 
73
	@Override
74
	@Override
74
	public String renvoyerNomFiltre() {
75
	public String renvoyerNomFiltre() {
75
		return "Recherche libre";
76
		return Msg.get("recherche-libre");
76
	}
77
	}
77
 
78
 
78
	@Override
79
	@Override
79
	public String[] renvoyerValeursAFiltrer() {
80
	public String[] renvoyerValeursAFiltrer() {
80
		
81
		
81
		String nom = "recherche";
82
		String nom = "recherche";
82
		
83
		
83
		if(champRecherche.getValueAsString() != null && !champRecherche.getValueAsString().trim().equals("")) {
84
		if(champRecherche.getValueAsString() != null && !champRecherche.getValueAsString().trim().equals("")) {
84
			valeurRecherchee = champRecherche.getValueAsString();
85
			valeurRecherchee = champRecherche.getValueAsString();
85
		} else {
86
		} else {
86
			valeurRecherchee = "";
87
			valeurRecherchee = "";
87
		}
88
		}
88
		
89
		
89
		String[] valeurs = {nom,valeurRecherchee};
90
		String[] valeurs = {nom,valeurRecherchee};
90
		return valeurs;
91
		return valeurs;
91
	}
92
	}
92
 
93
 
93
 
94
 
94
	@Override
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
			oMediateur.obtenirNombreObservation();
99
			oMediateur.obtenirNombreObservation();
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
	}
110
 
111
 
111
	@Override
112
	@Override
112
	public void viderFiltre() {
113
	public void viderFiltre() {
113
		champRecherche.setValue("");
114
		champRecherche.setValue("");
114
		valeurRecherchee = "";
115
		valeurRecherchee = "";
115
	}
116
	}
116
}
117
}