Subversion Repositories eFlore/Applications.del

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
602 aurelien 1
package org.tela_botanica.del.client.composants.formulaires.autocompletion;
261 aurelien 2
 
450 aurelien 3
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
457 aurelien 4
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
450 aurelien 5
import com.google.gwt.user.client.ui.HasWidgets;
261 aurelien 6
import com.google.gwt.user.client.ui.LayoutPanel;
7
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
8
import com.google.gwt.user.client.ui.SuggestBox;
9
import com.google.gwt.user.client.ui.SuggestOracle;
457 aurelien 10
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
261 aurelien 11
 
450 aurelien 12
public class AutoCompletionComboBoxVue extends LayoutPanel implements AutoCompletionComboBoxPresenteur.Vue {
261 aurelien 13
 
14
	MultiWordSuggestOracle msu = new MultiWordSuggestOracle();
15
	SuggestBox suggestions = new SuggestBox(msu);
16
 
17
	public AutoCompletionComboBoxVue() {
18
		add(suggestions);
386 aurelien 19
		//TODO: voir avec greg si la taille doit être définie ici
20
		setHeight("25px");
261 aurelien 21
		setWidth("100%");
22
	}
23
 
24
	public SuggestBox getSuggestBox() {
25
		return suggestions;
26
	}
27
 
28
	public void remplirListe(String[] listePropositions) {
29
 
30
		msu.clear();
31
		for (int i = 0; i < listePropositions.length; i++) {
32
			msu.add(listePropositions[i]);
33
		}
34
	}
35
 
450 aurelien 36
	@Override
261 aurelien 37
	public void afficherSuggestions(SuggestOracle.Request requeteOracle, SuggestOracle.Callback callBackOracle) {
38
		msu.requestSuggestions(requeteOracle, callBackOracle);
39
	}
416 gduche 40
 
450 aurelien 41
	@Override
42
	public void afficherListeDeroulante() {
43
		suggestions.showSuggestionList();
44
	}
45
 
416 gduche 46
	public void nettoyer() {
47
		suggestions.setText("");
48
	}
49
 
50
	public void setValeur(String taxon) {
457 aurelien 51
		suggestions.setValue(taxon);
416 gduche 52
	}
450 aurelien 53
 
54
	@Override
55
	public HasKeyPressHandlers getSuggestBoxHasKeyPressHandlers() {
56
		return suggestions;
57
	}
457 aurelien 58
 
59
	@Override
60
	public HasSelectionHandlers<Suggestion> getSuggestBoxHasSelectionChangeHandlers() {
61
		return suggestions;
62
	}
450 aurelien 63
 
64
	@Override
65
	public String getValeur() {
66
		return suggestions.getText();
67
	}
68
 
69
	@Override
70
	public void ajouterVue(HasWidgets composite) {
71
		composite.add(this.asWidget());
72
	}
261 aurelien 73
}