Subversion Repositories eFlore/Applications.del

Rev

Rev 261 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 261 Rev 268
Line 13... Line 13...
13
import com.google.gwt.json.client.JSONValue;
13
import com.google.gwt.json.client.JSONValue;
14
import com.google.gwt.user.client.Timer;
14
import com.google.gwt.user.client.Timer;
15
import com.google.gwt.user.client.ui.HasWidgets;
15
import com.google.gwt.user.client.ui.HasWidgets;
16
import com.google.gwt.user.client.ui.SuggestOracle;
16
import com.google.gwt.user.client.ui.SuggestOracle;
Line 17... Line 17...
17
 
17
 
-
 
18
public abstract class AutoCompletionComboBoxPresenteur {
-
 
19
	
-
 
20
	// Complétion de taxons :
Line 18... Line 21...
18
public class AutoCompletionComboBoxPresenteur {
21
	// http://www.tela-botanica.org/eflore/cel2/jrest/NameSearch/
Line 19... Line 22...
19
		
22
		
20
	private AutoCompletionComboBoxVue autoCompletionComboBoxVue = new AutoCompletionComboBoxVue();
23
	private AutoCompletionComboBoxVue autoCompletionComboBoxVue = new AutoCompletionComboBoxVue();
Line 21... Line 24...
21
	
24
	
22
	SuggestOracle.Request requeteOracle;
25
	SuggestOracle.Request requeteOracle;
-
 
26
    SuggestOracle.Callback callBackOracle;
-
 
27
    
Line 23... Line 28...
23
    SuggestOracle.Callback callBackOracle;
28
	Timer suggestionTimer = null;
24
    
-
 
-
 
29
    int tempsAvantRequete = 500;
25
	Timer suggestionTimer = null;
30
    
Line 26... Line 31...
26
    int tempsAvantRequete = 500;
31
    String urlRequete = "";
27
	
32
	
28
	public AutoCompletionComboBoxPresenteur() {
33
	public AutoCompletionComboBoxPresenteur(String urlRequete) {
Line 89... Line 94...
89
			}
94
			}
Line 90... Line 95...
90
			
95
			
91
			requeteAjax = parties[0]+"/"+parties[1];
96
			requeteAjax = parties[0]+"/"+parties[1];
Line 92... Line -...
92
		}
-
 
93
		
97
		}
Line 94... Line 98...
94
		String altUrl = "http://www.tela-botanica.org/eflore/cel2/jrest/NameSearch/";		
98
		
Line 95... Line 99...
95
		String urlProxy = "proxy.php?url="+URL.encode(altUrl+requeteAjax);
99
		String urlProxy = "proxy.php?url="+URL.encode(urlRequete+requeteAjax);
Line 106... Line 110...
106
				}
110
				}
Line 107... Line 111...
107
 
111
 
108
				public void onResponseReceived(final Request request,
112
				public void onResponseReceived(final Request request,
Line 109... Line -...
109
						final Response response) {
-
 
110
					
-
 
111
					final JSONValue responseValue = JSONParser.parseStrict(response.getText());
-
 
112
					JSONArray noms;
-
 
113
				
-
 
114
					if ((noms=responseValue.isArray()) != null) {
-
 
115
							
113
						final Response response) {
116
						final int taillemax = noms.size();	
-
 
117
						String[] valeurs = new String[taillemax];
-
 
118
						for (int i = 0; i < taillemax; i++) {
-
 
Line 119... Line 114...
119
							valeurs[i] = (noms.get(i).isArray().get(0).isString().stringValue());
114
					
120
						}
115
					String[] valeurs = parserResultatRequete(response);
121
					    
116
					    
122
						autoCompletionComboBoxVue.remplirListe(valeurs);
-
 
123
						requeteOracle.setQuery(requete);
117
					autoCompletionComboBoxVue.remplirListe(valeurs);
124
						autoCompletionComboBoxVue.afficherSuggestions(requeteOracle, callBackOracle);	
118
					requeteOracle.setQuery(requete);
Line 125... Line 119...
125
					}
119
					autoCompletionComboBoxVue.afficherSuggestions(requeteOracle, callBackOracle);	
126
				}
120
				}
127
			}) ;
121
			}) ;
128
 
122
 
129
		} catch (RequestException e) {
123
		} catch (RequestException e) {
-
 
124
			// TODO Auto-generated catch block
-
 
125
			e.printStackTrace();
130
			// TODO Auto-generated catch block
126
		}
131
			e.printStackTrace();
127
	}