Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 5 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
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
 
-
 
18
 
17
 
19
import com.google.gwt.i18n.client.Dictionary;
18
import com.google.gwt.i18n.client.Dictionary;
20
import com.google.gwt.json.client.JSONArray;
19
import com.google.gwt.json.client.JSONArray;
21
import com.google.gwt.json.client.JSONNumber;
20
import com.google.gwt.json.client.JSONNumber;
22
import com.google.gwt.json.client.JSONParser;
21
import com.google.gwt.json.client.JSONParser;
23
import com.google.gwt.json.client.JSONString;
22
import com.google.gwt.json.client.JSONString;
24
import com.google.gwt.json.client.JSONValue;
23
import com.google.gwt.json.client.JSONValue;
25
import com.google.gwt.user.client.HTTPRequest;
24
import com.google.gwt.user.client.HTTPRequest;
26
import com.google.gwt.user.client.ResponseTextHandler;
25
import com.google.gwt.user.client.ResponseTextHandler;
27
import com.google.gwt.user.client.ui.Composite;
26
import com.google.gwt.user.client.ui.Composite;
28
import com.google.gwt.user.client.ui.FlexTable;
27
import com.google.gwt.user.client.ui.FlexTable;
29
import com.google.gwt.user.client.ui.Grid;
28
import com.google.gwt.user.client.ui.Grid;
30
import com.google.gwt.user.client.ui.HTML;
29
import com.google.gwt.user.client.ui.HTML;
31
import com.google.gwt.user.client.ui.HorizontalPanel;
30
import com.google.gwt.user.client.ui.HorizontalPanel;
32
import com.google.gwt.user.client.ui.VerticalPanel;
31
import com.google.gwt.user.client.ui.VerticalPanel;
33
import com.google.gwt.user.client.ui.DockPanel;
32
import com.google.gwt.user.client.ui.DockPanel;
34
import com.google.gwt.user.client.ui.Button;
33
import com.google.gwt.user.client.ui.Button;
35
import com.google.gwt.user.client.ui.CheckBox;
34
import com.google.gwt.user.client.ui.CheckBox;
36
import com.google.gwt.user.client.ui.Widget;
35
import com.google.gwt.user.client.ui.Widget;
37
import com.google.gwt.user.client.ui.ClickListener;
36
import com.google.gwt.user.client.ui.ClickListener;
38
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
37
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
39
import com.google.gwt.user.client.ui.HasVerticalAlignment;
38
import com.google.gwt.user.client.ui.HasVerticalAlignment;
40
 
-
 
41
import java.util.Vector;
-
 
42
 
39
 
43
 
40
/*
-
 
41
 * Le retour de getUser appelle getCount qui appelle update pour veiller à une
44
/* Le retour de getUser appelle getCount qui appelle update pour veiller à une initialisation correcte
42
 * initialisation correcte
45
 
43
 * 
46
 */
44
 */
47
 
-
 
48
public class TaxonList extends Composite implements AutoCompleteAsyncTextBoxListener  {
-
 
-
 
45
 
49
 
46
public class TaxonList extends Composite implements
50
 
47
		AutoCompleteAsyncTextBoxListener {
51
	
48
 
52
// Barre de navigation 
49
	// Barre de navigation
53
	
50
 
54
	  private class NavBar extends Composite implements ClickListener {
51
	private class NavBar extends Composite implements ClickListener {
55
		  
52
 
56
	    public final DockPanel bar = new DockPanel();
53
		public final DockPanel bar = new DockPanel();
-
 
54
 
57
	    public final Button gotoFirst = new Button("<<", this);
55
		public final Button gotoFirst = new Button("<<", this);
-
 
56
 
58
	    public final Button gotoNext = new Button(">", this);
57
		public final Button gotoNext = new Button(">", this);
-
 
58
 
59
	    public final Button gotoPrev = new Button("<", this);
59
		public final Button gotoPrev = new Button("<", this);
-
 
60
 
60
	    public final Button gotoEnd = new Button(">>", this);
61
		public final Button gotoEnd = new Button(">>", this);
61
	    public final HTML status = new HTML();
-
 
-
 
62
 
62
  
63
		public final HTML status = new HTML();
63
 
64
 
64
	    public NavBar() {
65
		public NavBar() {
65
	      initWidget(bar);
66
			initWidget(bar);
66
	      bar.setStyleName("navbar");
67
			bar.setStyleName("navbar");
67
	      status.setStyleName("status");
68
			status.setStyleName("status");
68
 
69
 
69
	      HorizontalPanel buttons = new HorizontalPanel();
70
			HorizontalPanel buttons = new HorizontalPanel();
70
	      buttons.add(gotoFirst);
71
			buttons.add(gotoFirst);
71
	      buttons.add(gotoPrev);
72
			buttons.add(gotoPrev);
72
	      buttons.add(gotoNext);
73
			buttons.add(gotoNext);
73
	      buttons.add(gotoEnd);
74
			buttons.add(gotoEnd);
74
	      bar.add(buttons, DockPanel.EAST);
75
			bar.add(buttons, DockPanel.EAST);
75
	      bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
76
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
76
	      bar.add(status, DockPanel.CENTER);
77
			bar.add(status, DockPanel.CENTER);
77
	      bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
78
			bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
78
	      bar.setCellHorizontalAlignment(status, HasHorizontalAlignment.ALIGN_RIGHT);
79
			bar.setCellHorizontalAlignment(status,
-
 
80
					HasHorizontalAlignment.ALIGN_RIGHT);
79
	      bar.setCellVerticalAlignment(status, HasVerticalAlignment.ALIGN_MIDDLE);
81
			bar.setCellVerticalAlignment(status,
-
 
82
					HasVerticalAlignment.ALIGN_MIDDLE);
80
	      bar.setCellWidth(status, "100%");
83
			bar.setCellWidth(status, "100%");
81
 
84
 
82
	    }
85
		}
83
 
-
 
84
	    
86
 
85
	    public void onClick(Widget sender) {
87
		public void onClick(Widget sender) {
86
	  	    if (sender == gotoNext) {
88
			if (sender == gotoNext) {
87
	  	      // Move forward a page.
89
				// Move forward a page.
88
	  	      startIndex += VISIBLE_TAXON_COUNT;
90
				startIndex += VISIBLE_TAXON_COUNT;
89
	  	      if (startIndex >= count)
91
				if (startIndex >= count)
90
	  	          startIndex -= VISIBLE_TAXON_COUNT;
92
					startIndex -= VISIBLE_TAXON_COUNT;
91
	  	    } 
-
 
92
	  	    else {
93
			} else {
93
	  	     if (sender == gotoPrev) {
94
				if (sender == gotoPrev) {
94
	  	      // Move back a page.
95
					// Move back a page.
95
	  	      startIndex -= VISIBLE_TAXON_COUNT;
96
					startIndex -= VISIBLE_TAXON_COUNT;
96
	  	      if (startIndex < 0)
97
					if (startIndex < 0)
97
	  	        startIndex = 0;
98
						startIndex = 0;
98
	  	      }
-
 
99
	  	     else {
99
				} else {
100
	  	    	 if (sender==gotoEnd) {
100
					if (sender == gotoEnd) {
101
	  	    		gotoEnd();
101
						gotoEnd();
102
	  	    	 }
-
 
103
	  	    	 else {
102
					} else {
104
	  	    		 if (sender== gotoFirst) {
103
						if (sender == gotoFirst) {
105
	  	    			 startIndex = 0;
104
							startIndex = 0;
106
	  	    		 }
105
						}
107
	  	    	 }
106
					}
108
	  	     }
107
				}
109
	  	   }
108
			}
110
	  	   update();
109
			update();
111
	    }
110
		}
112
 
111
 
113
	  }
112
	}
114
 
113
 
115
  private void setStatusText(String text) {
114
	private void setStatusText(String text) {
116
	    navBar.status.setText(text);
115
		navBar.status.setText(text);
117
  }
116
	}
118
 
-
 
119
 
117
 
120
  private static final int VISIBLE_TAXON_COUNT = 15;
118
	private static final int VISIBLE_TAXON_COUNT = 15;
121
	
119
 
122
  private Grid header = new Grid(1,6);
120
	private Grid header = new Grid(1, 6);
-
 
121
 
123
  private FlexTable table = new FlexTable();
122
	private FlexTable table = new FlexTable();
-
 
123
 
124
  private VerticalPanel panel = new VerticalPanel();
124
	private VerticalPanel panel = new VerticalPanel();
125
 
125
 
126
  private int startIndex=0;
126
	private int startIndex = 0;
-
 
127
 
127
  private String serviceBaseUrl=getServiceBaseUrl();
128
	private String serviceBaseUrl = getServiceBaseUrl();
128
  private int count=65000;
-
 
129
  
-
 
130
  private Vector complements=null;
129
 
131
  private String element=null;
-
 
132
  private String complement=null;
130
	private int count = 65000;
133
  
131
 
134
  private String user;
132
	private String user;
135
  
133
 
136
  private NavBar navBar = new NavBar();
134
	private NavBar navBar = new NavBar();
137
  
135
 
138
  public TaxonList(Vector comps) {
-
 
139
 
136
	public TaxonList() {
140
	 
137
 
141
     initAsync();
138
		initAsync();
142
	
139
 
143
	// Information complementaire : un tableau associe au retour de l'assistant de saisie
-
 
144
	
140
		// Information complementaire : un tableau associe au retour de
145
	complements=comps;
141
		// l'assistant de saisie
146
	
142
 
147
    // Mise en forme du header 
143
		// Mise en forme du header
148
	  
144
 
149
    header.setCellSpacing(0);
145
		header.setCellSpacing(0);
150
    header.setCellPadding(2);
146
		header.setCellPadding(2);
151
    header.setWidth("100%");
147
		header.setWidth("100%");
152
 
148
 
153
    header.setStyleName("taxon-ListHeader");
149
		header.setStyleName("taxon-ListHeader");
154
    
150
 
155
    header.setText(0, 0, "");
151
		header.setText(0, 0, "");
156
    header.setText(0, 1, "Nom saisi");
152
		header.setText(0, 1, "Nom saisi");
157
    header.setText(0, 2, "Nom retenu");
153
		header.setText(0, 2, "Nom retenu");
158
    header.setHTML(0, 3, "Code<br>Nomenclatural");
154
		header.setHTML(0, 3, "Code<br>Nomenclatural");
159
    header.setHTML(0, 4, "Code<br>Taxonomique");
155
		header.setHTML(0, 4, "Code<br>Taxonomique");
160
    header.setText(0, 5, "Famille");
156
		header.setText(0, 5, "Famille");
161
  
157
 
162
	header.getCellFormatter().setWidth(0,0,"2%");
158
		header.getCellFormatter().setWidth(0, 0, "2%");
163
	header.getCellFormatter().setWidth(0,1,"31%");
159
		header.getCellFormatter().setWidth(0, 1, "31%");
164
	header.getCellFormatter().setWidth(0,2,"31%");
160
		header.getCellFormatter().setWidth(0, 2, "31%");
165
	header.getCellFormatter().setWidth(0,3,"9%");
161
		header.getCellFormatter().setWidth(0, 3, "9%");
166
	header.getCellFormatter().setWidth(0,4,"9%");
162
		header.getCellFormatter().setWidth(0, 4, "9%");
167
	header.getCellFormatter().setWidth(0,5,"18%");
163
		header.getCellFormatter().setWidth(0, 5, "18%");
168
 
164
 
169
    // Mise en forme de la table.
165
		// Mise en forme de la table.
170
	  
166
 
171
    table.setCellSpacing(0);
167
		table.setCellSpacing(0);
172
    table.setBorderWidth(0);
168
		table.setBorderWidth(0);
173
    table.setCellPadding(2);
169
		table.setCellPadding(2);
174
    table.setWidth("100%");
170
		table.setWidth("100%");
175
 
171
 
176
    // Mise en forme barre navigation
172
		// Mise en forme barre navigation
177
    
173
 
178
    navBar.setWidth("100%");
174
		navBar.setWidth("100%");
179
 
-
 
180
   
175
 
181
    table.setStyleName("taxon-List");
176
		table.setStyleName("taxon-List");
182
 
177
 
183
    panel.add(navBar);
178
		panel.add(navBar);
184
    panel.add(header);
179
		panel.add(header);
185
    panel.add(table);
180
		panel.add(table);
186
    
181
 
187
    initWidget(panel);
182
		initWidget(panel);
188
    
-
 
189
 
183
 
190
  }
184
	}
191
 
185
 
192
  /**
186
	/**
193
   * Action lancee par la selection d'un nom dans l'assistant de saisie. Lance la recherche d'informations
187
	 * Action lancee par la selection d'un nom dans l'assistant de saisie. Lance
-
 
188
	 * la recherche d'informations complémentaires (famille, numero
194
   * complémentaires (famille, numero nomenclaturaux etc) et met a jour l'inventaire (addelement())
189
	 * nomenclaturaux etc) et met a jour l'inventaire (addelement())
-
 
190
	 * 
195
   * @return void
191
	 * @return void
196
   */
192
	 */
197
  public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,int pos, String str) {
193
	public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,
-
 
194
			 final String str,final String value) {
198
	
195
 
199
	  	setStatusDisabled();
196
		setStatusDisabled();
200
	  	
-
 
201
	    // Il y a surement une meilleure facon de faire que de passer par une variable de classe 
-
 
202
	    // pour atteindre une inner classe
-
 
203
	  
-
 
204
	    element=str;
-
 
205
	
197
 
206
	    // Saisie assistée
198
		// Saisie assistée
207
	  
-
 
208
	    if (pos>=0) {
-
 
209
	 
-
 
210
	    // Le vecteur complements contient les informations complémentaires associées à un nom.
199
 
211
	    	
200
		if (value !=null) {
212
	    complement=(String) complements.get(pos);
201
 
213
	 
202
 
214
		 HTTPRequest.asyncGet(serviceBaseUrl+"/NameValid/"+complement, 
203
			HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + value,
215
				    new ResponseTextHandler(){
-
 
216
 
-
 
217
				    	public void onCompletion(String str) {
204
					new ResponseTextHandler() {
218
		    
205
 
-
 
206
						public void onCompletion(String strcomplete) {
-
 
207
 
219
							JSONValue jsonValue= JSONParser.parse(str);
208
							JSONValue jsonValue = JSONParser.parse(strcomplete);
-
 
209
							JSONArray jsonArray;
-
 
210
 
-
 
211
							if ((jsonArray = jsonValue.isArray()) != null) {
220
				  			JSONArray jsonArray;
212
								// Nom retenu, Num Nomen nom retenu, Num Taxon,
-
 
213
								// Famille
221
				
214
								addElement(str, value,
-
 
215
										((JSONString) jsonArray.get(0))
222
				  			complements.clear();
216
												.stringValue(),
223
				  			
217
										((JSONString) jsonArray.get(1))
224
				  			if ((jsonArray = jsonValue.isArray()) != null) {
218
												.stringValue(),
225
				  					  // Nom retenu, Num Nomen nom retenu, Num Taxon, Famille
219
										((JSONString) jsonArray.get(2))
226
								      addElement(element,complement,((JSONString) jsonArray.get(0)).stringValue(),
220
												.stringValue(),
227
								    		  ((JSONString) jsonArray.get(1)).stringValue(),((JSONString) jsonArray.get(2)).stringValue(),
221
										((JSONString) jsonArray.get(3))
228
								    		  ((JSONString) jsonArray.get(3)).stringValue());
222
												.stringValue());
229
				  			}
223
							}
230
				    	} 
224
						}
231
 
225
 
232
				   	});
226
					});
233
	    }
227
		}
234
	    // Saisie libre
228
		// Saisie libre
235
	    else {
229
		else {
236
 			complements.clear();
-
 
237
 
-
 
238
			addElement(element," "," "," "," "," ");
230
			addElement(str, " ", " ", " ", " ", " ");
239
	    }
231
		}
240
  }
232
	}
241
 
233
 
242
  /**
234
	/**
243
   * Ajoute un element à l'inventaire 
235
	 * Ajoute un element à l'inventaire
-
 
236
	 * 
-
 
237
	 * @param nom_sel :
244
   * @param nom_sel : nom selectionne
238
	 *            nom selectionne
-
 
239
	 * @param num_nom_sel :
245
   * @param num_nom_sel : numero nomenclatural nom selectionne
240
	 *            numero nomenclatural nom selectionne
-
 
241
	 * @param nom_ret :
-
 
242
	 *            nom retenu
246
   * @param nom_ret : nom retenu
243
	 * @param num_nom_ret :
247
   * @param num_nom_ret : numero nomenclaturel nom retenu
244
	 *            numero nomenclaturel nom retenu
-
 
245
	 * @param num_taxon :
248
   * @param num_taxon : numero taxonomique
246
	 *            numero taxonomique
249
   * @param famille : famille
247
	 * @param famille :
-
 
248
	 *            famille
250
   */
249
	 */
251
 
250
 
-
 
251
	public void addElement(String nom_sel, String num_nom_sel, String nom_ret,
252
  public void addElement(String nom_sel, String num_nom_sel, String nom_ret, String num_nom_ret, String num_taxon, String famille) {
252
			String num_nom_ret, String num_taxon, String famille) {
253
	 
253
 
254
	  // Calcul du nouveau numéro d'ordre 
254
		// Calcul du nouveau numéro d'ordre
255
	  
255
 
256
	 /* int order=1;
256
		/*
257
	  if (table.getRowCount()>0) {
257
		 * int order=1; if (table.getRowCount()>0) { order=new
258
		  order=new Integer(table.getText(table.getRowCount()-1,6)).intValue()+1;
258
		 * Integer(table.getText(table.getRowCount()-1,6)).intValue()+1; }
259
	  }*/
259
		 */
260
		  
260
 
-
 
261
		count++;
261
	  count++;
262
		HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant="
-
 
263
				+ user + "&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel
262
	  HTTPRequest.asyncPost(serviceBaseUrl+"/Inventory/", "identifiant="+user+"&nom_sel="+nom_sel+"&num_nom_sel="+num_nom_sel
264
				+ "&nom_ret=" + nom_ret + "&num_nom_ret=" + num_nom_ret
263
			  +"&nom_ret="+nom_ret+"&num_nom_ret="+num_nom_ret+"&num_taxon="+num_taxon+"&famille="+famille,
265
				+ "&num_taxon=" + num_taxon + "&famille=" + famille,
264
			  
266
 
265
	  new ResponseTextHandler(){
267
		new ResponseTextHandler() {
266
	
268
 
267
	  	public void onCompletion(String str) {
269
			public void onCompletion(String str) {
268
	  			gotoEnd();
270
				gotoEnd();
269
		    	update();
271
				update();
270
	  	}
272
			}
271
	  });
273
		});
272
  }
274
	}
273
 
275
 
274
  /**
276
	/**
275
   * Suppression d'un element lde l'inventaire, a partir de son numero d'ordre
277
	 * Suppression d'un element lde l'inventaire, a partir de son numero d'ordre
276
   *
278
	 * 
277
   */
279
	 */
278
 
-
 
279
  
280
 
280
  public void deleteElement() {
-
 
281
 
281
	public void deleteElement() {
282
	  
282
 
283
	  setStatusDisabled();
283
		setStatusDisabled();
284
	  boolean checked=false;
284
		boolean checked = false;
285
 
285
 
286
	    // Lifo ...
286
		// Lifo ...
287
      for (int i=table.getRowCount()-1; i>=0;i--){
287
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
288
		 if (((CheckBox) table.getWidget(i,0)).isChecked())  {
288
			if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
289
			checked=true;
289
				checked = true;
290
			String str=table.getText(i,6);
290
				String str = table.getText(i, 6);
291
			count--;
291
				count--;
292
			 HTTPRequest.asyncPost(serviceBaseUrl+"/Inventory/"+user+"/"+str, "action=DELETE", 
292
				HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
-
 
293
						+ "/" + str, "action=DELETE",
293
			   new ResponseTextHandler(){
294
						new ResponseTextHandler() {
294
 
295
 
295
			   	public void onCompletion(String str) {
296
							public void onCompletion(String str) {
296
			   		gotoEnd();
297
								gotoEnd();
297
			    	update();
298
								update();
298
			   	}
299
							}
299
			  });
300
						});
300
 
301
 
301
	  	 }
302
			}
302
	  }
303
		}
303
      if (!checked) {
304
		if (!checked) {
304
    	  setStatusEnabled(); 
305
			setStatusEnabled();
305
      }
306
		}
306
  }
307
	}
307
 
308
 
308
  /** 
309
	/**
309
   * 
310
	 * 
310
   * Lancement des initialisations dependantes de réponses asynchrones : le retour d'une demande d'initialisation declanche 
311
	 * Lancement des initialisations dependantes de réponses asynchrones : le
311
   * la demande d'initialisation suivantes
312
	 * retour d'une demande d'initialisation declanche la demande
312
   * user : resultat recherche nom d'utilisateur
313
	 * d'initialisation suivantes user : resultat recherche nom d'utilisateur
313
   * count : resultat nombre d'enregistrements d'inventaires
314
	 * count : resultat nombre d'enregistrements d'inventaires affichage
314
   * affichage enregistrements trouvés 
315
	 * enregistrements trouvés
315
   *
316
	 * 
316
   */
317
	 */
317
  private void initAsync() {
318
	private void initAsync() {
318
	 
319
 
319
	  getUser();
320
		getUser();
320
	  // getCount()
321
		// getCount()
321
	  // update()
322
		// update()
322
	  
323
 
323
  }
324
	}
324
  
325
 
325
  /**
326
	/**
326
   * Recherche utilisateur en cours 
327
	 * Recherche utilisateur en cours
327
   *
328
	 * 
328
   */
329
	 */
329
  private void getUser() {
330
	private void getUser() {
330
	  
-
 
331
	  
331
 
332
    	 setStatusDisabled();
332
		setStatusDisabled();
333
 
333
 
334
		 HTTPRequest.asyncGet(serviceBaseUrl+"/User/", 
334
		HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
335
				    new ResponseTextHandler(){
335
				new ResponseTextHandler() {
336
 
336
 
337
				    	public void onCompletion(String str) {
337
					public void onCompletion(String str) {
338
				    		JSONValue jsonValue= JSONParser.parse(str);
338
						JSONValue jsonValue = JSONParser.parse(str);
339
				    		JSONString jsonString;
339
						JSONString jsonString;
340
				    		    if ((jsonString = jsonValue.isString()) != null) {
340
						if ((jsonString = jsonValue.isString()) != null) {
341
				    		    	user = jsonString.stringValue();
341
							user = jsonString.stringValue();
342
				    		    }
342
						}
343
				    		    getCount();
343
						getCount();
344
				    	}
344
					}
345
			 	});
345
				});
346
		    
-
 
347
		  
-
 
348
 
346
 
349
		}  
347
	}
350
 
348
 
351
 /**
349
	/**
352
  * Recherche nombre d'enregistrement pour l'utilisateur en cours
350
	 * Recherche nombre d'enregistrement pour l'utilisateur en cours
353
  *
351
	 * 
354
  */ 
352
	 */
355
  private void getCount() {
353
	private void getCount() {
356
 
354
 
357
	 HTTPRequest.asyncGet(serviceBaseUrl+"/InventoryList/"+user+"/", 
355
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryList/" + user + "/",
358
		    new ResponseTextHandler(){
356
				new ResponseTextHandler() {
359
 
357
 
360
		    	public void onCompletion(String str) {
358
					public void onCompletion(String str) {
361
 
359
 
362
		    		JSONValue jsonValue= JSONParser.parse(str);
360
						JSONValue jsonValue = JSONParser.parse(str);
363
		    		JSONNumber jsonNumber;
361
						JSONNumber jsonNumber;
364
		    		    if ((jsonNumber = jsonValue.isNumber()) != null) {
362
						if ((jsonNumber = jsonValue.isNumber()) != null) {
365
		    		    	count=(int) jsonNumber.getValue();
363
							count = (int) jsonNumber.getValue();
366
		    		    	gotoEnd(); // Derniere page
364
							gotoEnd(); // Derniere page
367
		    		    	update();
365
							update();
368
		    		    }
366
						}
369
		    	}
367
					}
370
	 	});
368
				});
371
 
369
 
372
  }
370
	}
373
 
371
 
374
  /**
372
	/**
375
   * Mise a jour de l'affichage, à partir des données d'inventaire deja saisies.
373
	 * Mise a jour de l'affichage, à partir des données d'inventaire deja
376
   * La valeur de this.startIndex permet de determiner quelles données seront affichées 
374
	 * saisies. La valeur de this.startIndex permet de determiner quelles
-
 
375
	 * données seront affichées
377
   *
376
	 * 
378
   */
377
	 */
379
  
378
 
380
  private void update() {
379
	private void update() {
381
	  
-
 
382
 
380
 
383
	 setStatusDisabled();
381
		setStatusDisabled();
-
 
382
 
384
	 
383
		// TODO : optimisation : ne supprimer que les lignes qui ne seront pas
-
 
384
		// alimentes .
385
	 // TODO : optimisation : ne supprimer que les lignes qui ne seront pas alimentes .
385
 
386
 
386
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryList/" + user + "/"
387
	 HTTPRequest.asyncGet(serviceBaseUrl+"/InventoryList/"+user+"/"+startIndex+"/"+VISIBLE_TAXON_COUNT, 
387
				+ startIndex + "/" + VISIBLE_TAXON_COUNT,
388
			 
388
 
389
		    new ResponseTextHandler(){
389
		new ResponseTextHandler() {
390
 
390
 
391
		    	public void onCompletion(String str) {
391
			public void onCompletion(String str) {
392
 
392
 
393
		    		    JSONValue jsonValue= JSONParser.parse(str);
393
				JSONValue jsonValue = JSONParser.parse(str);
394
		    		    JSONArray jsonArray;
394
				JSONArray jsonArray;
395
		    		    JSONArray jsonArrayNested;
395
				JSONArray jsonArrayNested;
396
		    		 
396
 
397
		    		    // Lifo ...
397
				// Lifo ...
398
		    	        for (int i=table.getRowCount()-1; i>=0;i--){
398
				for (int i = table.getRowCount() - 1; i >= 0; i--) {
399
		                        table.removeRow(i);
399
					table.removeRow(i);
400
		                }
400
				}
401
 
-
 
402
 
401
 
403
		    		    int j=0;
402
				int j = 0;
404
		    		    if ((jsonArray = jsonValue.isArray()) != null) {
403
				if ((jsonArray = jsonValue.isArray()) != null) {
405
		    		      for (int i = 0; i < jsonArray.size(); ++i) {
404
					for (int i = 0; i < jsonArray.size(); ++i) {
406
		    		    	  if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
405
						if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
407
		    		    		  int row=table.insertRow(table.getRowCount());
406
							int row = table.insertRow(table.getRowCount());
408
		    		    		  // Case a cocher
407
							// Case a cocher
409
		    		    		  table.setWidget(row,0,new CheckBox());
408
							table.setWidget(row, 0, new CheckBox());
410
		    		    		  // Nom saisi
409
							// Nom saisi
411
		    		    		  table.setText(row,1,((JSONString) jsonArrayNested.get(0)).stringValue());
410
							table.setText(row, 1, ((JSONString) jsonArrayNested
-
 
411
									.get(0)).stringValue());
412
		    		    		  // Nom retenu
412
							// Nom retenu
413
		    		    		  table.setText(row,2,((JSONString) jsonArrayNested.get(2)).stringValue());
413
							table.setText(row, 2, ((JSONString) jsonArrayNested
-
 
414
									.get(2)).stringValue());
414
		    		    		  // Num nomenclatural
415
							// Num nomenclatural
415
		    		    		  table.setText(row,3,((JSONString) jsonArrayNested.get(1)).stringValue());
416
							table.setText(row, 3, ((JSONString) jsonArrayNested
-
 
417
									.get(1)).stringValue());
416
		    		    		  // Num Taxonomique
418
							// Num Taxonomique
417
		    		    		  table.setText(row,4,((JSONString) jsonArrayNested.get(4)).stringValue());
419
							table.setText(row, 4, ((JSONString) jsonArrayNested
-
 
420
									.get(4)).stringValue());
418
		    		    		  // Famille
421
							// Famille
419
		    		    		  table.setText(row,5,((JSONString) jsonArrayNested.get(5)).stringValue());
422
							table.setText(row, 5, ((JSONString) jsonArrayNested
-
 
423
									.get(5)).stringValue());
420
		    		    		  // Numero d'ordre
424
							// Numero d'ordre
421
		    		    		  table.setText(row,6,((JSONString) jsonArrayNested.get(6)).stringValue());
425
							table.setText(row, 6, ((JSONString) jsonArrayNested
-
 
426
									.get(6)).stringValue());
422
		    		    		  
427
 
423
		    		    		  table.getCellFormatter().setVisible(row,6,false);
428
							table.getCellFormatter().setVisible(row, 6, false);
424
		    		     		  
429
 
425
		    		    		  table.getFlexCellFormatter().setWidth(row,0,"2%");
430
							table.getFlexCellFormatter().setWidth(row, 0, "2%");
426
		    		    		  table.getFlexCellFormatter().setWidth(row,1,"31%");
431
							table.getFlexCellFormatter()
-
 
432
									.setWidth(row, 1, "31%");
427
		    		    		  table.getFlexCellFormatter().setWidth(row,2,"31%");
433
							table.getFlexCellFormatter()
-
 
434
									.setWidth(row, 2, "31%");
428
		    		    		  table.getFlexCellFormatter().setWidth(row,3,"9%");
435
							table.getFlexCellFormatter().setWidth(row, 3, "9%");
429
		    		    		  table.getFlexCellFormatter().setWidth(row,4,"9%");
436
							table.getFlexCellFormatter().setWidth(row, 4, "9%");
430
		    		    		  table.getFlexCellFormatter().setWidth(row,5,"18%");
437
							table.getFlexCellFormatter()
-
 
438
									.setWidth(row, 5, "18%");
431
		    		    		  j++;
439
							j++;
432
		    		    	  }
440
						}
433
		    		    	  
441
 
434
		    		      }
442
					}
435
		    		    } 
443
				}
436
		    		    setStatusEnabled();
444
				setStatusEnabled();
437
		    		    
445
 
438
		    	}
446
			}
439
		    });
447
		});
440
 
448
 
441
  }
449
	}
442
 
450
 
443
  /**
451
	/**
444
   * Recuperation du prefixe d'appel des services  
452
	 * Recuperation du prefixe d'appel des services
445
   */
453
	 */
446
  
454
 
447
	private String getServiceBaseUrl() {
455
	private String getServiceBaseUrl() {
448
		  
456
 
449
		  Dictionary theme = Dictionary.getDictionary("Parameters");
457
		Dictionary theme = Dictionary.getDictionary("Parameters");
450
		  return theme.get("serviceBaseUrl");
458
		return theme.get("serviceBaseUrl");
451
		  
-
 
452
	
459
 
453
		}  
-
 
454
	
460
	}
455
	
461
 
-
 
462
	/**
456
	/**
463
	 * Affichage message d'attente et désactivation navigation
457
	 * Affichage message d'attente et désactivation navigation
464
	 * 
458
	 * @param 
465
	 * @param
459
	 * @return void  
466
	 * @return void
460
	 */
467
	 */
461
	
468
 
462
	private void setStatusDisabled() {
469
	private void setStatusDisabled() {
463
		
470
 
464
		navBar.gotoFirst.setEnabled(false);
471
		navBar.gotoFirst.setEnabled(false);
465
		navBar.gotoPrev.setEnabled(false);
472
		navBar.gotoPrev.setEnabled(false);
466
		navBar.gotoNext.setEnabled(false);
473
		navBar.gotoNext.setEnabled(false);
467
		navBar.gotoEnd.setEnabled(false);
474
		navBar.gotoEnd.setEnabled(false);
468
	
475
 
469
		setStatusText("Patientez ...");
476
		setStatusText("Patientez ...");
470
	}
477
	}
471
	
-
 
472
 
478
 
473
	/**
479
	/**
474
	 * Affichage numero de page et gestion de la navigation
480
	 * Affichage numero de page et gestion de la navigation
475
	 *
481
	 * 
476
	 */
482
	 */
477
	
483
 
478
	private void setStatusEnabled() {
484
	private void setStatusEnabled() {
479
	
485
 
480
		// Il y a forcemment un disabled avant d'arriver ici
486
		// Il y a forcemment un disabled avant d'arriver ici
481
		
487
 
482
		if (count > 0 ) {	
488
		if (count > 0) {
483
				
489
 
-
 
490
			if (startIndex >= VISIBLE_TAXON_COUNT) { // Au dela de la
484
			if (startIndex >= VISIBLE_TAXON_COUNT) { // Au dela de la premiere page
491
														// premiere page
485
				navBar.gotoPrev.setEnabled(true);
492
				navBar.gotoPrev.setEnabled(true);
486
				navBar.gotoFirst.setEnabled(true);
493
				navBar.gotoFirst.setEnabled(true);
-
 
494
				if (startIndex < (count - VISIBLE_TAXON_COUNT)) { // Pas la
-
 
495
																	// derniere
487
				if (startIndex<(count-VISIBLE_TAXON_COUNT)) {  // Pas la derniere page
496
																	// page
488
					navBar.gotoNext.setEnabled(true);
497
					navBar.gotoNext.setEnabled(true);
489
					navBar.gotoEnd.setEnabled(true);
498
					navBar.gotoEnd.setEnabled(true);
490
					setStatusText((startIndex + 1) + " - " + (startIndex + VISIBLE_TAXON_COUNT));
499
					setStatusText((startIndex + 1) + " - "
491
				}
500
							+ (startIndex + VISIBLE_TAXON_COUNT));
492
				else { // Derniere page
501
				} else { // Derniere page
493
					setStatusText((startIndex + 1) + " - " + count);
502
					setStatusText((startIndex + 1) + " - " + count);
494
				}
-
 
495
			}
503
				}
496
			else {  // Premiere page
504
			} else { // Premiere page
497
				if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres
505
				if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres
498
					navBar.gotoNext.setEnabled(true);
506
					navBar.gotoNext.setEnabled(true);
499
					navBar.gotoEnd.setEnabled(true);
507
					navBar.gotoEnd.setEnabled(true);
500
					setStatusText((startIndex + 1) + " - " + (startIndex + VISIBLE_TAXON_COUNT));
508
					setStatusText((startIndex + 1) + " - "
501
				}
509
							+ (startIndex + VISIBLE_TAXON_COUNT));
502
				else {
510
				} else {
503
					setStatusText((startIndex + 1) + " - " + count);
511
					setStatusText((startIndex + 1) + " - " + count);
504
				}
512
				}
505
			}
513
			}
506
		}
514
		}
507
		
-
 
508
		
515
 
509
		else { // Pas d'inventaire, pas de navigation
516
		else { // Pas d'inventaire, pas de navigation
510
			 setStatusText(0 + " - " + 0);
517
			setStatusText(0 + " - " + 0);
511
		}
518
		}
512
	}
519
	}
513
	
-
 
514
	
520
 
515
	/**
521
	/**
-
 
522
	 * Positionnement index de parcours (this.startIndex) pour affichage de la
-
 
523
	 * dernière page
516
	 * Positionnement index de parcours (this.startIndex) pour affichage de la dernière page
524
	 * 
517
	 * @param 
525
	 * @param
518
	 * @return void  
526
	 * @return void
519
	 */
527
	 */
520
	
528
 
521
	private void gotoEnd() {
529
	private void gotoEnd() {
522
		
530
 
523
		  	if ( (count==0) || (count%VISIBLE_TAXON_COUNT)>0) {
531
		if ((count == 0) || (count % VISIBLE_TAXON_COUNT) > 0) {
524
	    		startIndex=count-(count%VISIBLE_TAXON_COUNT); 
532
			startIndex = count - (count % VISIBLE_TAXON_COUNT);
525
	    	}
-
 
526
	    	else {
533
		} else {
527
	    		startIndex=count-VISIBLE_TAXON_COUNT; 
534
			startIndex = count - VISIBLE_TAXON_COUNT;
528
	    	}
535
		}
529
		  	
536
 
530
	}
537
	}
531
	
538
 
532
}
539
}