Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 3 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 4
1
/*
1
/*
2
 * Copyright 2006 Google Inc.
2
 * Copyright 2006 Google Inc.
3
 * 
3
 * 
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
 * use this file except in compliance with the License. You may obtain a copy of
5
 * use this file except in compliance with the License. You may obtain a copy of
6
 * the License at
6
 * the License at
7
 * 
7
 * 
8
 * http://www.apache.org/licenses/LICENSE-2.0
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 * 
9
 * 
10
 * Unless required by applicable law or agreed to in writing, software
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 * License for the specific language governing permissions and limitations under
13
 * License for the specific language governing permissions and limitations under
14
 * the License.
14
 * the License.
15
 */
15
 */
16
package org.tela_botanica.client;
16
package org.tela_botanica.client;
17
 
17
 
-
 
18
 
18
 
19
import com.google.gwt.i18n.client.Dictionary;
19
import com.google.gwt.json.client.JSONArray;
20
import com.google.gwt.json.client.JSONArray;
20
import com.google.gwt.json.client.JSONNumber;
21
import com.google.gwt.json.client.JSONNumber;
21
import com.google.gwt.json.client.JSONParser;
22
import com.google.gwt.json.client.JSONParser;
22
import com.google.gwt.json.client.JSONString;
23
import com.google.gwt.json.client.JSONString;
23
import com.google.gwt.json.client.JSONValue;
24
import com.google.gwt.json.client.JSONValue;
24
import com.google.gwt.user.client.HTTPRequest;
25
import com.google.gwt.user.client.HTTPRequest;
25
import com.google.gwt.user.client.ResponseTextHandler;
26
import com.google.gwt.user.client.ResponseTextHandler;
26
import com.google.gwt.user.client.ui.Composite;
27
import com.google.gwt.user.client.ui.Composite;
27
import com.google.gwt.user.client.ui.FlexTable;
28
import com.google.gwt.user.client.ui.FlexTable;
28
import com.google.gwt.user.client.ui.Grid;
29
import com.google.gwt.user.client.ui.Grid;
29
import com.google.gwt.user.client.ui.HTML;
30
import com.google.gwt.user.client.ui.HTML;
30
import com.google.gwt.user.client.ui.HorizontalPanel;
31
import com.google.gwt.user.client.ui.HorizontalPanel;
31
import com.google.gwt.user.client.ui.VerticalPanel;
32
import com.google.gwt.user.client.ui.VerticalPanel;
32
import com.google.gwt.user.client.ui.DockPanel;
33
import com.google.gwt.user.client.ui.DockPanel;
33
import com.google.gwt.user.client.ui.Button;
34
import com.google.gwt.user.client.ui.Button;
34
import com.google.gwt.user.client.ui.CheckBox;
35
import com.google.gwt.user.client.ui.CheckBox;
35
import com.google.gwt.user.client.ui.Widget;
36
import com.google.gwt.user.client.ui.Widget;
36
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
-
 
37
import com.google.gwt.user.client.ui.ClickListener;
37
import com.google.gwt.user.client.ui.ClickListener;
-
 
38
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
38
import com.google.gwt.user.client.ui.HasAlignment;
39
import com.google.gwt.user.client.ui.HasVerticalAlignment;
-
 
40
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
-
 
41
 
-
 
42
import java.util.Vector;
-
 
43
 
-
 
44
 
39
 
45
/* Le retour de getUser appelle getCount qui appelle update pour veiller à une initialisation correcte
40
 
46
 
41
/**
47
/**
42
 * A composite that displays a list of emails that can be selected.
48
 * A composite that displays a list of emails that can be selected.
43
 */
49
 */
44
public class TaxonList extends Composite implements AutoCompleteAsyncTextBoxListener  {
50
public class TaxonList extends Composite implements AutoCompleteAsyncTextBoxListener  {
45
 
51
 
46
 
52
 
47
	  private class NavBar extends Composite implements ClickListener {
53
	  private class NavBar extends Composite implements ClickListener {
48
		  
54
		  
49
	    public final DockPanel bar = new DockPanel();
55
	    public final DockPanel bar = new DockPanel();
50
	    public final Button gotoFirst = new Button("<<", this);
56
	    public final Button gotoFirst = new Button("<<", this);
51
	    public final Button gotoNext = new Button(">", this);
57
	    public final Button gotoNext = new Button(">", this);
52
	    public final Button gotoPrev = new Button("<", this);
58
	    public final Button gotoPrev = new Button("<", this);
53
	    public final Button gotoEnd = new Button(">>", this);
59
	    public final Button gotoEnd = new Button(">>", this);
54
	    public final HTML status = new HTML();
60
	    public final HTML status = new HTML();
55
  
61
  
56
 
62
 
57
	    public NavBar() {
63
	    public NavBar() {
58
	      initWidget(bar);
64
	      initWidget(bar);
59
	      bar.setStyleName("navbar");
65
	      bar.setStyleName("navbar");
60
	      status.setStyleName("status");
66
	      status.setStyleName("status");
61
 
67
 
62
	      HorizontalPanel buttons = new HorizontalPanel();
68
	      HorizontalPanel buttons = new HorizontalPanel();
63
	      buttons.add(gotoFirst);
69
	      buttons.add(gotoFirst);
64
	      buttons.add(gotoPrev);
70
	      buttons.add(gotoPrev);
65
	      buttons.add(gotoNext);
71
	      buttons.add(gotoNext);
66
	      buttons.add(gotoEnd);
72
	      buttons.add(gotoEnd);
67
	      bar.add(buttons, DockPanel.EAST);
73
	      bar.add(buttons, DockPanel.EAST);
68
	      bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
74
	      bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
69
	      bar.add(status, DockPanel.CENTER);
75
	      bar.add(status, DockPanel.CENTER);
70
	      bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
76
	      bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
71
	      bar.setCellHorizontalAlignment(status, HasAlignment.ALIGN_RIGHT);
77
	      bar.setCellHorizontalAlignment(status, HasHorizontalAlignment.ALIGN_RIGHT);
72
	      bar.setCellVerticalAlignment(status, HasAlignment.ALIGN_MIDDLE);
78
	      bar.setCellVerticalAlignment(status, HasVerticalAlignment.ALIGN_MIDDLE);
73
	      bar.setCellWidth(status, "100%");
79
	      bar.setCellWidth(status, "100%");
74
 
80
 
75
	      // Initialize prev & first button to disabled.
81
	      // Initialize prev & first button to disabled.
76
	      //
82
	      //
77
	    }
83
	    }
78
 
84
 
79
	    
85
	    
80
	    public void onClick(Widget sender) {
86
	    public void onClick(Widget sender) {
81
	  	    if (sender == gotoNext) {
87
	  	    if (sender == gotoNext) {
82
	  	      // Move forward a page.
88
	  	      // Move forward a page.
83
	  	      startIndex += VISIBLE_TAXON_COUNT;
89
	  	      startIndex += VISIBLE_TAXON_COUNT;
84
	  	      if (startIndex >= count)
90
	  	      if (startIndex >= count)
85
	  	          startIndex -= VISIBLE_TAXON_COUNT;
91
	  	          startIndex -= VISIBLE_TAXON_COUNT;
86
	  	    } 
92
	  	    } 
87
	  	    else {
93
	  	    else {
88
	  	     if (sender == gotoPrev) {
94
	  	     if (sender == gotoPrev) {
89
	  	      // Move back a page.
95
	  	      // Move back a page.
90
	  	      startIndex -= VISIBLE_TAXON_COUNT;
96
	  	      startIndex -= VISIBLE_TAXON_COUNT;
91
	  	      if (startIndex < 0)
97
	  	      if (startIndex < 0)
92
	  	        startIndex = 0;
98
	  	        startIndex = 0;
93
	  	      }
99
	  	      }
94
	  	     else {
100
	  	     else {
95
	  	    	 if (sender==gotoEnd) {
101
	  	    	 if (sender==gotoEnd) {
96
	  	    	  	if ((count%VISIBLE_TAXON_COUNT)>0) {
102
	  	    	  	if ((count%VISIBLE_TAXON_COUNT)>0) {
97
    		    		startIndex=count-(count%VISIBLE_TAXON_COUNT); 
103
    		    		startIndex=count-(count%VISIBLE_TAXON_COUNT); 
98
    		    	}
104
    		    	}
99
    		    	else {
105
    		    	else {
100
    		    		startIndex=count-VISIBLE_TAXON_COUNT; 
106
    		    		startIndex=count-VISIBLE_TAXON_COUNT; 
101
    		    	}
107
    		    	}
102
	  	    	 }
108
	  	    	 }
103
	  	    	 else {
109
	  	    	 else {
104
	  	    		 if (sender== gotoFirst) {
110
	  	    		 if (sender== gotoFirst) {
105
	  	    			 startIndex = 0;
111
	  	    			 startIndex = 0;
106
	  	    		 }
112
	  	    		 }
107
	  	    	 }
113
	  	    	 }
108
	  	     }
114
	  	     }
109
	  	   }
115
	  	   }
110
	  	   update();
116
	  	   update();
111
	    }
117
	    }
112
 
118
 
113
	  }
119
	  }
114
 
120
 
115
  public void setStatusText(String text) {
121
  public void setStatusText(String text) {
116
	    navBar.status.setText(text);
122
	    navBar.status.setText(text);
117
  }
123
  }
118
 
124
 
119
  public void clearStatusText() {
125
  public void clearStatusText() {
120
	    navBar.status.setHTML("&nbsp;");
126
	    navBar.status.setHTML("&nbsp;");
121
  }
127
  }
122
 
128
 
123
	
129
	
124
 
130
 
125
  private static final int VISIBLE_TAXON_COUNT = 15;
131
  private static final int VISIBLE_TAXON_COUNT = 15;
126
	
132
	
127
  private Grid header = new Grid(1,3);
133
  private Grid header = new Grid(1,6);
128
  private FlexTable table = new FlexTable();
-
 
129
  private CellFormatter cellFormater = table.getCellFormatter();
134
  private FlexTable table = new FlexTable();
130
  private VerticalPanel panel = new VerticalPanel();
135
  private VerticalPanel panel = new VerticalPanel();
131
  
136
 
-
 
137
  private int startIndex=0;
132
  private int startIndex=0;
138
  private String serviceBaseUrl=getServiceBaseUrl();
-
 
139
  private int count=65000;
-
 
140
  
-
 
141
  private Vector complements=null;
-
 
142
  private String element=null;
-
 
143
  private String complement=null;
-
 
144
  
133
  private int count=65000;
145
  private String user;
134
  
146
  
135
  private NavBar navBar = new NavBar();
147
  private NavBar navBar = new NavBar();
-
 
148
  
-
 
149
  public TaxonList(Vector comps) {
-
 
150
 
-
 
151
	 
-
 
152
	getUser();
-
 
153
 
136
  
154
	
137
  public TaxonList() {
155
	// Information complementaire
138
 
156
	
139
	  
157
	complements=comps;
140
	  
158
	
141
    // Setup the header
159
    // Setup the header
142
	  
160
	  
143
    header.setCellSpacing(0);
161
    header.setCellSpacing(0);
144
    header.setCellPadding(2);
162
    header.setCellPadding(2);
145
    header.setWidth("100%");
163
    header.setWidth("100%");
146
 
164
 
147
    header.setStyleName("taxon-ListHeader");
165
    header.setStyleName("taxon-ListHeader");
148
    
166
    
149
    header.setText(0, 0, "Action");
167
    header.setText(0, 0, "");
150
    header.setText(0, 1, "Nom");
168
    header.setText(0, 1, "Nom saisi");
-
 
169
    header.setText(0, 2, "Nom retenu");
-
 
170
    header.setHTML(0, 3, "Code<br>Nomenclatural");
-
 
171
    header.setHTML(0, 4, "Code<br>Taxonomique");
-
 
172
    header.setText(0, 5, "");
-
 
173
  
-
 
174
	header.getCellFormatter().setWidth(0,0,"2%");
-
 
175
	header.getCellFormatter().setWidth(0,1,"31%");
-
 
176
	header.getCellFormatter().setWidth(0,2,"31%");
-
 
177
	header.getCellFormatter().setWidth(0,3,"9%");
-
 
178
	header.getCellFormatter().setWidth(0,4,"9%");
-
 
179
	header.getCellFormatter().setWidth(0,5,"18%");
151
    header.setText(0, 2, "Famille");
180
 
152
    
181
	
-
 
182
 
-
 
183
    header.setCellSpacing(0);
153
    
184
    header.setCellPadding(2);
154
   
185
 
155
    // Setup the table.
186
    // Setup the table.
156
	  
187
	  
157
    table.setCellSpacing(0);
188
    table.setCellSpacing(0);
-
 
189
    table.setBorderWidth(0);
158
    table.setCellPadding(2);
190
    table.setCellPadding(2);
159
    table.setWidth("100%");
191
    table.setWidth("100%");
160
 
192
 
161
 
193
 
162
    navBar.setWidth("100%");
194
    navBar.setWidth("100%");
163
 
195
 
164
    
196
    
165
   
197
   
166
    table.setStyleName("taxon-List");
198
    table.setStyleName("taxon-List");
167
 
199
 
168
    panel.add(navBar);
200
    panel.add(navBar);
169
    panel.add(header);
201
    panel.add(header);
170
    panel.add(table);
202
    panel.add(table);
171
    
203
    
172
    initWidget(panel);
204
    initWidget(panel);
173
    
-
 
174
    // Recherche derniere ligne ... (il y a une autre stratégie pour la calculer si le resultat n'arrive pas assez vite)
205
    
175
 
-
 
176
    
-
 
177
	 HTTPRequest.asyncGet("http://localhost/david/jrest/InventoryList/dd/", 
-
 
178
		    new ResponseTextHandler(){
-
 
179
 
-
 
180
		    	public void onCompletion(String str) {
-
 
181
 
-
 
182
// On se positionne sur la dernière page ...
-
 
183
		    		
-
 
184
		    		JSONValue jsonValue= JSONParser.parse(str);
-
 
185
		    		JSONNumber jsonNumber;
-
 
186
		    		    if ((jsonNumber = jsonValue.isNumber()) != null) {
-
 
187
		    		    	count=(int) jsonNumber.getValue();
-
 
188
		    		    	if ((count%VISIBLE_TAXON_COUNT)>0) {
-
 
189
		    		    		startIndex=count-(count%VISIBLE_TAXON_COUNT); 
-
 
190
		    		    	}
-
 
191
		    		    	else {
-
 
192
		    		    		startIndex=count-VISIBLE_TAXON_COUNT; 
-
 
193
		    		    	}
-
 
194
	 				
-
 
195
		    		    	update();
-
 
196
		    		    }
-
 
197
		    	}
-
 
198
	 	});
-
 
199
    
-
 
200
 
206
 
201
  }
207
  }
-
 
208
 
-
 
209
  public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,int pos, String str) {
202
 
210
		
-
 
211
	  
-
 
212
// Recherche informations complementaires :
-
 
213
// et Ajout ligne 
-
 
214
	 
-
 
215
	    if (pos>=0) {
-
 
216
	    complement=(String) complements.get(pos);
-
 
217
	    element=str;
-
 
218
	 
-
 
219
		 HTTPRequest.asyncGet(serviceBaseUrl+"/NameValid/"+complement, 
-
 
220
				    new ResponseTextHandler(){
-
 
221
 
203
  public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender, String str) {
222
				    	public void onCompletion(String str) {
204
		
223
		    
-
 
224
							JSONValue jsonValue= JSONParser.parse(str);
-
 
225
				  			JSONArray jsonArray;
205
// Ajout ligne 
226
				
-
 
227
				  			complements.clear();
-
 
228
				  			
-
 
229
				  			if ((jsonArray = jsonValue.isArray()) != null) {
-
 
230
				  					  // Nom retenu, Num Nomen nom retenu, Num Taxon, Famille
-
 
231
								      addElement(element,complement,((JSONString) jsonArray.get(0)).stringValue(),
-
 
232
								    		  ((JSONString) jsonArray.get(1)).stringValue(),((JSONString) jsonArray.get(2)).stringValue(),
-
 
233
								    		  ((JSONString) jsonArray.get(3)).stringValue());
-
 
234
				  			}
206
	 
235
				    	} 
-
 
236
 
-
 
237
				   	});
-
 
238
	    }
-
 
239
	    else {
-
 
240
 			complements.clear();
-
 
241
 
-
 
242
			addElement(str," "," "," "," "," ");
-
 
243
	    }
-
 
244
  }
-
 
245
  
-
 
246
 
-
 
247
  public void addElement(String nom_sel, String num_nom_sel, String nom_ret, String num_nom_ret, String num_taxon, String famille) {
-
 
248
	 
-
 
249
	  int lastOrdre=1;
-
 
250
	  if (table.getRowCount()>0) {
-
 
251
		  lastOrdre=new Integer(table.getText(table.getRowCount()-1,6)).intValue()+1;
-
 
252
	  }
207
 
253
		  
208
	    count++;
254
	  count++;
209
	  
255
	  HTTPRequest.asyncPost(serviceBaseUrl+"/Inventory/", "identifiant="+user+"&nom_sel="+nom_sel+"&num_nom_sel="+num_nom_sel
210
	    HTTPRequest.asyncPost("http://localhost/david/jrest/Inventory/", "identifiant=dd&nom="+str, 
256
			  +"&nom_ret="+nom_ret+"&num_nom_ret="+num_nom_ret+"&num_taxon="+num_taxon+"&famille="+famille+"&ordre="+lastOrdre,
211
	    new ResponseTextHandler(){
257
	  new ResponseTextHandler(){
212
 
258
	
213
	    	public void onCompletion(String str) {
259
	  	public void onCompletion(String str) {
214
		    	if ((count%VISIBLE_TAXON_COUNT)>0) {
260
		    	if ((count%VISIBLE_TAXON_COUNT)>0) {
215
		    		startIndex=count-(count%VISIBLE_TAXON_COUNT); 
261
		    		startIndex=count-(count%VISIBLE_TAXON_COUNT); 
216
		    	}
262
		    	}
217
		    	else {
263
		    	else {
218
		    		startIndex=count-VISIBLE_TAXON_COUNT; 
264
		    		startIndex=count-VISIBLE_TAXON_COUNT; 
219
		    	}
265
		    	}
-
 
266
		    	if (startIndex < 0) {
-
 
267
			  	    startIndex = 0;
-
 
268
			  	}
220
		    	update();
269
		    	update();
221
	    	}
270
	  	}
222
	    });
271
	  });
223
	    
-
 
224
 
-
 
225
  }
272
  }
226
  
-
 
-
 
273
 
227
 
274
  
228
  public void deleteElement() {
275
  public void deleteElement() {
229
 
276
 
230
	    // Lifo ...
277
	    // Lifo ...
231
      for (int i=table.getRowCount()-1; i>=0;i--){
278
      for (int i=table.getRowCount()-1; i>=0;i--){
232
		 if (((CheckBox) table.getWidget(i,0)).isChecked())  {
279
		 if (((CheckBox) table.getWidget(i,0)).isChecked())  {
233
			String str=table.getText(i,2);
280
			String str=table.getText(i,6);
234
			count--;
281
			count--;
235
			 HTTPRequest.asyncPost("http://localhost/david/jrest/Inventory/dd/"+str, "action=DELETE", 
282
			 HTTPRequest.asyncPost(serviceBaseUrl+"/Inventory/"+user+"/"+str, "action=DELETE", 
236
			   new ResponseTextHandler(){
283
			   new ResponseTextHandler(){
237
 
284
 
238
			   	public void onCompletion(String str) {
285
			   	public void onCompletion(String str) {
239
			   		if ((count%VISIBLE_TAXON_COUNT)>0) {
286
			    	if ((count%VISIBLE_TAXON_COUNT)==0) {
240
			    		startIndex=count-(count%VISIBLE_TAXON_COUNT); 
-
 
241
			    	}
-
 
242
			    	else {
-
 
243
			    		startIndex=count-VISIBLE_TAXON_COUNT; 
287
			    		startIndex=count-VISIBLE_TAXON_COUNT; 
244
			    	}
288
			    	}
-
 
289
			    	if (startIndex < 0) {
-
 
290
				  	    startIndex = 0;
-
 
291
				  	}
245
			    	update();
292
			    	update();
246
			   	}
293
			   	}
247
			  });
294
			  });
248
 
295
 
249
	  	 }
296
	  	 }
250
	  }
297
	  }
251
  }
298
  }
-
 
299
 
-
 
300
  private void getUser() {
-
 
301
		 HTTPRequest.asyncGet(serviceBaseUrl+"/User/", 
-
 
302
				    new ResponseTextHandler(){
-
 
303
 
-
 
304
				    	public void onCompletion(String str) {
-
 
305
				    		JSONValue jsonValue= JSONParser.parse(str);
-
 
306
				    		JSONString jsonString;
-
 
307
				    		    if ((jsonString = jsonValue.isString()) != null) {
-
 
308
				    		    	user = jsonString.stringValue();
-
 
309
				    		    }
-
 
310
				    		    getCount();
-
 
311
				    	}
-
 
312
			 	});
-
 
313
		    
-
 
314
		  
-
 
315
 
-
 
316
		}  
-
 
317
 
-
 
318
  
-
 
319
  private void getCount() {
-
 
320
  // Recherche derniere ligne ... (il y a une autre stratégie pour la calculer si le resultat n'arrive pas assez vite)
-
 
321
 
-
 
322
  
-
 
323
	 HTTPRequest.asyncGet(serviceBaseUrl+"/InventoryList/"+user+"/", 
-
 
324
		    new ResponseTextHandler(){
-
 
325
 
-
 
326
		    	public void onCompletion(String str) {
-
 
327
 
-
 
328
//On se positionne sur la dernière page ...
-
 
329
		    		
-
 
330
		    		JSONValue jsonValue= JSONParser.parse(str);
-
 
331
		    		JSONNumber jsonNumber;
-
 
332
		    		    if ((jsonNumber = jsonValue.isNumber()) != null) {
-
 
333
		    		    	count=(int) jsonNumber.getValue();
-
 
334
		    		    	if ((count%VISIBLE_TAXON_COUNT)>0) {
-
 
335
		    		    		startIndex=count-(count%VISIBLE_TAXON_COUNT); 
-
 
336
		    		    	}
-
 
337
		    		    	else {
-
 
338
		    		    		startIndex=count-VISIBLE_TAXON_COUNT; 
-
 
339
		    		    	}
-
 
340
		    		    	if (startIndex < 0) {
-
 
341
		    			  	    startIndex = 0;
-
 
342
		    			  	}
-
 
343
	 				
-
 
344
		    		    	update();
-
 
345
		    		    }
-
 
346
		    	}
-
 
347
	 	});
-
 
348
 
-
 
349
  }
252
  
350
 
-
 
351
  
-
 
352
  private void update() {
-
 
353
	  
253
  
354
	  
254
  private void update() {
355
	 // TODO : optimisation : ne supprimer que les lignes qui ne seront pas alimentes .
255
 
356
 
256
	 navBar.gotoFirst.setEnabled(false);
357
	 navBar.gotoFirst.setEnabled(false);
257
	 navBar.gotoPrev.setEnabled(false);
358
	 navBar.gotoPrev.setEnabled(false);
258
     navBar.gotoNext.setEnabled(false);
359
     navBar.gotoNext.setEnabled(false);
259
     navBar.gotoEnd.setEnabled(false);
360
     navBar.gotoEnd.setEnabled(false);
260
 
361
 
261
     setStatusText("Patientez ...");
362
     setStatusText("Patientez ...");
262
 
363
 
263
	 HTTPRequest.asyncGet("http://localhost/david/jrest/InventoryList/dd/"+startIndex+"/"+VISIBLE_TAXON_COUNT, 
364
	 HTTPRequest.asyncGet(serviceBaseUrl+"/InventoryList/"+user+"/"+startIndex+"/"+VISIBLE_TAXON_COUNT, 
264
		    new ResponseTextHandler(){
365
		    new ResponseTextHandler(){
265
 
366
 
266
		    	public void onCompletion(String str) {
367
		    	public void onCompletion(String str) {
267
 
368
 
268
		    		    JSONValue jsonValue= JSONParser.parse(str);
369
		    		    JSONValue jsonValue= JSONParser.parse(str);
269
		    		    JSONArray jsonArray;
370
		    		    JSONArray jsonArray;
270
		    		    JSONArray jsonArrayNested;
371
		    		    JSONArray jsonArrayNested;
271
		    		 
372
		    		 
272
		    		    // Lifo ...
373
		    		    // Lifo ...
273
		    	        for (int i=table.getRowCount()-1; i>=0;i--){
374
		    	        for (int i=table.getRowCount()-1; i>=0;i--){
274
		                        table.removeRow(i);
375
		                        table.removeRow(i);
275
		                }
376
		                }
276
 
377
 
-
 
378
 
277
 
379
		    		    int j=0;
278
		    		    if ((jsonArray = jsonValue.isArray()) != null) {
380
		    		    if ((jsonArray = jsonValue.isArray()) != null) {
279
		    		      int i; 	
381
		    		      int i; 	
280
		    		      for (i = 0; i < jsonArray.size(); ++i) {
382
		    		      for (i = 0; i < jsonArray.size(); ++i) {
281
		    		    	  if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
383
		    		    	  if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
282
		    		    		  int row=table.insertRow(table.getRowCount());
384
		    		    		  int row=table.insertRow(table.getRowCount());
-
 
385
		    		    		  // Case a cocher
283
		    		    		  table.setWidget(row,0,new CheckBox());
386
		    		    		  table.setWidget(row,0,new CheckBox());
-
 
387
		    		    		  // Nom saisi
284
		    		    		  table.setText(row,1,((JSONString) jsonArrayNested.get(0)).stringValue());
388
		    		    		  table.setText(row,1,((JSONString) jsonArrayNested.get(0)).stringValue());
-
 
389
		    		    		  // Nom retenu
285
		    		    		  table.setText(row,2,((JSONString) jsonArrayNested.get(1)).stringValue());
390
		    		    		  table.setText(row,2,((JSONString) jsonArrayNested.get(2)).stringValue());
-
 
391
		    		    		  // Num nomenclatural
-
 
392
		    		    		  table.setText(row,3,((JSONString) jsonArrayNested.get(1)).stringValue());
-
 
393
		    		    		  // Num Taxonomique
-
 
394
		    		    		  table.setText(row,4,((JSONString) jsonArrayNested.get(4)).stringValue());
-
 
395
		    		    		  // Famille
-
 
396
		    		    		  table.setText(row,5,((JSONString) jsonArrayNested.get(5)).stringValue());
-
 
397
		    		    		  // Numero d'ordre
-
 
398
		    		    		  table.setText(row,6,((JSONString) jsonArrayNested.get(6)).stringValue());
-
 
399
		    		    		  
286
		    		    		  cellFormater.setVisible(row,2,false);
400
		    		    		  table.getCellFormatter().setVisible(row,6,true);
-
 
401
		    		    		  
-
 
402
		    		    		  table.getFlexCellFormatter().setWidth(row,0,"2%");
-
 
403
		    		    		  table.getFlexCellFormatter().setWidth(row,1,"31%");
-
 
404
		    		    		  table.getFlexCellFormatter().setWidth(row,2,"31%");
-
 
405
		    		    		  table.getFlexCellFormatter().setWidth(row,3,"9%");
-
 
406
		    		    		  table.getFlexCellFormatter().setWidth(row,4,"9%");
-
 
407
		    		    		  table.getFlexCellFormatter().setWidth(row,5,"18%");
-
 
408
		    		    		  j++;
287
		    		    	  }
409
		    		    	  }
-
 
410
		    		    	  
288
		    		      }
411
		    		      }
289
		    		      // Calcul nombre d'enregistrement total
412
		    		      // Calcul nombre d'enregistrement total (c'est un doublon, c'est normal ...)
290
		    		      if (i<VISIBLE_TAXON_COUNT) {
413
		    		      if (i<VISIBLE_TAXON_COUNT) {
291
		    		    	  count = startIndex+i;
414
		    		    	  count = startIndex+i;
292
		    		      }
415
		    		      }
293
		    		      
416
		    		      
294
		    		      // Navigation 
417
		    		      // Navigation 
295
		    		      
-
 
296
		    		      setStatusText((startIndex + 1) + " - " + (startIndex + VISIBLE_TAXON_COUNT));
418
		    		      
297
 
419
 
298
		    		      // Premiere page 
420
		    		      // Premiere page 
299
		    		      if (startIndex<VISIBLE_TAXON_COUNT) {
421
		    		      if (startIndex<VISIBLE_TAXON_COUNT ) {
300
		    		    		navBar.gotoPrev.setEnabled(false);
422
		    		    		navBar.gotoPrev.setEnabled(false);
301
		    		    		navBar.gotoFirst.setEnabled(false);
423
		    		    		navBar.gotoFirst.setEnabled(false);
302
		    		    		navBar.gotoNext.setEnabled(true);
424
		    		    		navBar.gotoNext.setEnabled(true);
303
		    		    		navBar.gotoEnd.setEnabled(true);
425
		    		    		navBar.gotoEnd.setEnabled(true);
-
 
426
		    		    		if (count < VISIBLE_TAXON_COUNT) {
-
 
427
		    		    			setStatusText((startIndex + 1) + " - " + count );
-
 
428
		    		    		}
-
 
429
		    		    		else {
-
 
430
				    		      setStatusText((startIndex + 1) + " - " + (startIndex + VISIBLE_TAXON_COUNT));
-
 
431
		    		    		}
304
		    		    		
432
		    		    		
305
		    		      }
433
		    		      }
306
		    		      // Derniere page
434
		    		      // Derniere page
307
		    		      else {
435
		    		      else {
308
		    		    	  if (startIndex>=(count-VISIBLE_TAXON_COUNT)) {
436
		    		    	  if (startIndex>=(count-VISIBLE_TAXON_COUNT)) {
309
		    		    		navBar.gotoPrev.setEnabled(true);
437
		    		    		navBar.gotoPrev.setEnabled(true);
310
		    		    		navBar.gotoFirst.setEnabled(true);
438
		    		    		navBar.gotoFirst.setEnabled(true);
311
		    		    		navBar.gotoNext.setEnabled(false);
439
		    		    		navBar.gotoNext.setEnabled(false);
312
		    		    		navBar.gotoEnd.setEnabled(false);
440
		    		    		navBar.gotoEnd.setEnabled(false);
313
		    		    		setStatusText((startIndex + 1) + " - " + count);
441
		    		    		setStatusText((startIndex + 1) + " - " + count);
314
		    		    	  }
442
		    		    	  }
-
 
443
		    		    	  // Page normale 
315
		    		    	  else {
444
		    		    	  else {
316
				    		      navBar.gotoPrev.setEnabled(true);
445
				    		      navBar.gotoPrev.setEnabled(true);
317
				    		      navBar.gotoFirst.setEnabled(true);
446
				    		      navBar.gotoFirst.setEnabled(true);
318
				    		      navBar.gotoNext.setEnabled(true);
447
				    		      navBar.gotoNext.setEnabled(true);
319
				    		      navBar.gotoEnd.setEnabled(true);
448
				    		      navBar.gotoEnd.setEnabled(true);
-
 
449
				    		      setStatusText((startIndex + 1) + " - " + (startIndex + VISIBLE_TAXON_COUNT));
320
		    		    	  }
450
		    		    	  }
321
		    		      }
451
		    		      }
322
		    		    }
452
		    		    }
-
 
453
		    		    // Tableau vide (TODO : despaguettiser)
-
 
454
		    		    if (j==0) {
-
 
455
		    		    	   navBar.gotoPrev.setEnabled(false);
-
 
456
				    		   navBar.gotoFirst.setEnabled(false);
-
 
457
				    		   navBar.gotoNext.setEnabled(false);
-
 
458
				    		   navBar.gotoEnd.setEnabled(false);
-
 
459
				    		   setStatusText(0 + " - " + 0);
-
 
460
		    		    }
323
		    	}
461
		    	}
324
		    });
462
		    });
325
 
463
 
326
  }
464
  }
-
 
465
 
327
 
466
private String getServiceBaseUrl() {
-
 
467
	  
-
 
468
	  Dictionary theme = Dictionary.getDictionary("Parameters");
-
 
469
	  return theme.get("serviceBaseUrl");
-
 
470
	  
-
 
471
 
328
  
472
	}  
329
  
473
 
330
  
474
 
331
 
475
 
332
}
476
}