Subversion Repositories eFlore/Applications.del

Rev

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

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