Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 2 | Rev 6 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 4
Line 3... Line 3...
3
 
3
 
Line -... Line 4...
-
 
4
 
-
 
5
import java.util.EventListener;
-
 
6
 
-
 
7
 
-
 
8
import com.google.gwt.i18n.client.Dictionary;
-
 
9
import com.google.gwt.json.client.JSONArray;
4
 
10
import com.google.gwt.json.client.JSONParser;
5
import java.util.EventListener;
11
import com.google.gwt.json.client.JSONString;
Line -... Line 12...
-
 
12
import com.google.gwt.json.client.JSONValue;
-
 
13
import com.google.gwt.user.client.ResponseTextHandler;
Line 6... Line 14...
6
 
14
import com.google.gwt.user.client.ui.Composite;
Line 7... Line 15...
7
 
15
import com.google.gwt.user.client.ui.HorizontalPanel;
8
import com.google.gwt.user.client.ui.Composite;
16
 
9
import com.google.gwt.user.client.ui.HorizontalPanel;
17
import java.util.Vector;
Line 10... Line 18...
10
 
18
 
Line 11... Line 19...
11
 
19
 
12
import org.tela_botanica.client.AutoCompleteAsyncTextBox;
20
import org.tela_botanica.client.AutoCompleteAsyncTextBox;
13
 
-
 
-
 
21
 
Line 14... Line 22...
14
/**
22
/**
15
 * A composite that displays a list of names that can be selected.
23
 * A composite that displays a list of names that can be selected.
16
 */
24
 */
17
 
-
 
18
public class NameAssistant extends Composite implements EventListener  {
25
 
Line 19... Line 26...
19
 
26
public class NameAssistant extends Composite implements EventListener, ResponseTextHandler  {
Line 20... Line 27...
20
  private AutoCompleteAsyncTextBox autoCompletebox = new AutoCompleteAsyncTextBox();
27
 
21
  private HorizontalPanel panel = new HorizontalPanel();
28
  private AutoCompleteAsyncTextBox autoCompletebox = new AutoCompleteAsyncTextBox(this);
22
 
29
  private HorizontalPanel panel = new HorizontalPanel();
Line 23... Line 30...
23
  
30
  private Vector complements=null;
Line -... Line 31...
-
 
31
  
-
 
32
  public NameAssistant(AutoCompleteAsyncTextBoxListener listener,Vector comps) {
-
 
33
	
-
 
34
	complements=comps;
-
 
35
	autoCompletebox.setSearchUrl(getServiceBaseUrl()+"/NameSearch/");
-
 
36
	
-
 
37
	panel.add(autoCompletebox);
-
 
38
 
-
 
39
	autoCompletebox.setWidth("100%");
-
 
40
    initWidget(panel);
-
 
41
    autoCompletebox.addAutoCompleteAsyncTextBoxListener(listener);
-
 
42
 
-
 
43
  }
-
 
44
 
-
 
45
public void onCompletion(String str) {
-
 
46
	  
-
 
47
  			JSONValue jsonValue= JSONParser.parse(str);
-
 
48
  			JSONArray jsonArray;
-
 
49
  			JSONArray jsonArrayNested;
-
 
50
  			JSONString jsonString;
-
 
51
 
-
 
52
  			complements.clear();
-
 
53
  			
-
 
54
  			if ((jsonArray = jsonValue.isArray()) != null) {
-
 
55
  				for (int i = 0; i < jsonArray.size(); ++i) {
-
 
56
  				  if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
-
 
57
  					if ((jsonString = (jsonArrayNested.get(0)).isString()) != null) {
-
 
58
  						autoCompletebox.addItem(jsonString.stringValue());
-
 
59
  					}
-
 
60
  					if ((jsonString = (jsonArrayNested.get(1)).isString()) != null) {
-
 
61
  						complements.add(i,jsonString.stringValue());
-
 
62
  					}
-
 
63
  				  }
-
 
64
  				}
-
 
65
  			}
-
 
66
 
Line 24... Line 67...
24
  public NameAssistant(AutoCompleteAsyncTextBoxListener listener) {
67
  			autoCompletebox.displayList();
Line 25... Line 68...
25
	 
68