14,19 → 14,31 |
|
import com.google.gwt.event.dom.client.ClickEvent; |
import com.google.gwt.event.dom.client.ClickHandler; |
import com.google.gwt.http.client.Response; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONValue; |
import com.google.gwt.user.client.ui.HasWidgets; |
|
public class FormulairePropositionPresenteur extends Presenteur { |
|
private AutoCompletionComboBoxPresenteur autoCompletionComboBoxPresenteur = new AutoCompletionComboBoxPresenteur(); |
private AutoCompletionComboBoxPresenteur autoCompletionNomTaxonsPresenteur; |
private String urlServiceCompletionNom = "http://www.tela-botanica.org/eflore/cel2/jrest/NameSearch/"; |
|
public FormulairePropositionPresenteur() { |
super(new FormulairePropositionVue()); |
|
autoCompletionNomTaxonsPresenteur = new AutoCompletionComboBoxPresenteur(urlServiceCompletionNom) { |
@Override |
protected String[] parserResultatRequete(Response response) { |
return convertirReponseVersListeNom(response); |
} |
}; |
} |
|
public void go(HasWidgets composite) { |
|
autoCompletionComboBoxPresenteur.go(((FormulairePropositionVue)getVue()).getPropositionTaxon()); |
autoCompletionNomTaxonsPresenteur.go(((FormulairePropositionVue)getVue()).getPropositionTaxon()); |
composite.add((FormulairePropositionVue)getVue()); |
gererEvenements(); |
} |
72,8 → 84,25 |
propositionAjoutee.setContributeur(auteur); |
propositionAjoutee.setDate(new Date()); |
|
propositionAjoutee.setEspece(autoCompletionComboBoxPresenteur.getValeur()); |
propositionAjoutee.setEspece(autoCompletionNomTaxonsPresenteur.getValeur()); |
|
return propositionAjoutee; |
} |
|
private String[] convertirReponseVersListeNom(Response response) { |
final JSONValue responseValue = JSONParser.parseStrict(response.getText()); |
JSONArray noms; |
String[] valeurs = new String[0]; |
|
if ((noms=responseValue.isArray()) != null) { |
|
final int taillemax = noms.size(); |
valeurs = new String[taillemax]; |
for (int i = 0; i < taillemax; i++) { |
valeurs[i] = (noms.get(i).isArray().get(0).isString().stringValue()); |
} |
} |
|
return valeurs; |
} |
} |