Subversion Repositories eFlore/Archives.cel-v1

Rev

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

Rev 14 Rev 24
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
import java.util.Iterator;
18
import java.util.Iterator;
19
import java.util.Vector;
19
import java.util.Vector;
20
 
20
 
21
import com.google.gwt.json.client.JSONArray;
21
import com.google.gwt.json.client.JSONArray;
22
import com.google.gwt.json.client.JSONNumber;
22
import com.google.gwt.json.client.JSONNumber;
23
import com.google.gwt.json.client.JSONParser;
23
import com.google.gwt.json.client.JSONParser;
24
import com.google.gwt.json.client.JSONString;
24
import com.google.gwt.json.client.JSONString;
25
import com.google.gwt.json.client.JSONValue;
25
import com.google.gwt.json.client.JSONValue;
26
import com.google.gwt.user.client.HTTPRequest;
26
import com.google.gwt.user.client.HTTPRequest;
27
import com.google.gwt.user.client.ResponseTextHandler;
27
import com.google.gwt.user.client.ResponseTextHandler;
28
import com.google.gwt.user.client.ui.Composite;
28
import com.google.gwt.user.client.ui.Composite;
29
import com.google.gwt.user.client.ui.FlexTable;
29
import com.google.gwt.user.client.ui.FlexTable;
30
import com.google.gwt.user.client.ui.Grid;
30
import com.google.gwt.user.client.ui.Grid;
31
import com.google.gwt.user.client.ui.HTML;
31
import com.google.gwt.user.client.ui.HTML;
32
import com.google.gwt.user.client.ui.HorizontalPanel;
32
import com.google.gwt.user.client.ui.HorizontalPanel;
33
import com.google.gwt.user.client.ui.Image;
33
import com.google.gwt.user.client.ui.Image;
34
import com.google.gwt.user.client.ui.SourcesTableEvents;
34
import com.google.gwt.user.client.ui.SourcesTableEvents;
35
import com.google.gwt.user.client.ui.TableListener;
35
import com.google.gwt.user.client.ui.TableListener;
36
import com.google.gwt.user.client.ui.VerticalPanel;
36
import com.google.gwt.user.client.ui.VerticalPanel;
37
import com.google.gwt.user.client.ui.DockPanel;
37
import com.google.gwt.user.client.ui.DockPanel;
38
import com.google.gwt.user.client.ui.Button;
38
import com.google.gwt.user.client.ui.Button;
39
import com.google.gwt.user.client.ui.CheckBox;
39
import com.google.gwt.user.client.ui.CheckBox;
40
import com.google.gwt.user.client.ui.Widget;
40
import com.google.gwt.user.client.ui.Widget;
41
import com.google.gwt.user.client.ui.ClickListener;
41
import com.google.gwt.user.client.ui.ClickListener;
42
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
42
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
43
import com.google.gwt.user.client.ui.HasVerticalAlignment;
43
import com.google.gwt.user.client.ui.HasVerticalAlignment;
44
 
44
 
45
/*
45
/*
46
 * Le retour de getUser appelle updateCount qui appelle update pour veiller à une
46
 * Le retour de getUser appelle updateCount qui appelle update pour veiller à une
47
 * initialisation correcte
47
 * initialisation correcte
48
 * 
48
 * 
49
 */
49
 */
50
 
50
 
51
public class InventoryItemList extends Composite implements
51
public class InventoryItemList extends Composite implements
52
		AutoCompleteAsyncTextBoxListener {
52
		AutoCompleteAsyncTextBoxListener {
53
 
53
 
54
	// Barre de navigation
54
	// Barre de navigation
55
 
55
 
56
	private class NavBar extends Composite implements ClickListener {
56
	private class NavBar extends Composite implements ClickListener {
57
 
57
 
58
		public final DockPanel bar = new DockPanel();
58
		public final DockPanel bar = new DockPanel();
59
 
59
 
60
		public final Button gotoFirst = new Button("<<", this);
60
		public final Button gotoFirst = new Button("<<", this);
61
 
61
 
62
		public final Button gotoNext = new Button(">", this);
62
		public final Button gotoNext = new Button(">", this);
63
 
63
 
64
		public final Button gotoPrev = new Button("<", this);
64
		public final Button gotoPrev = new Button("<", this);
65
 
65
 
66
		public final Button gotoEnd = new Button(">>", this);
66
		public final Button gotoEnd = new Button(">>", this);
67
		
67
		
68
		 
68
		 
69
		public final HTML status = new HTML();
69
		public final HTML status = new HTML();
70
		
70
		
71
 
71
 
72
		public NavBar() {
72
		public NavBar() {
73
			
73
			
74
			
74
			
75
			initWidget(bar);
75
			initWidget(bar);
76
			bar.setStyleName("navbar");
76
			bar.setStyleName("navbar");
77
			status.setStyleName("status");
77
			status.setStyleName("status");
78
			
78
			
79
			HorizontalPanel buttons = new HorizontalPanel();
79
			HorizontalPanel buttons = new HorizontalPanel();
80
			
80
			
81
			buttons.add(status);
81
			buttons.add(status);
82
			buttons.setCellHorizontalAlignment(status,
82
			buttons.setCellHorizontalAlignment(status,
83
					HasHorizontalAlignment.ALIGN_RIGHT);
83
					HasHorizontalAlignment.ALIGN_RIGHT);
84
			buttons.setCellVerticalAlignment(status,
84
			buttons.setCellVerticalAlignment(status,
85
					HasVerticalAlignment.ALIGN_MIDDLE);
85
					HasVerticalAlignment.ALIGN_MIDDLE);
86
			buttons.setCellWidth(status, "100%");
86
			buttons.setCellWidth(status, "100%");
87
 
87
 
88
 
88
 
89
			buttons.add(gotoFirst);
89
			buttons.add(gotoFirst);
90
			buttons.add(gotoPrev);
90
			buttons.add(gotoPrev);
91
			buttons.add(gotoNext);
91
			buttons.add(gotoNext);
92
			buttons.add(gotoEnd);
92
			buttons.add(gotoEnd);
93
			bar.add(buttons, DockPanel.EAST);
93
			bar.add(buttons, DockPanel.EAST);
94
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
94
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
95
			
95
			
96
			
96
			
97
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT);
97
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT);
98
 
98
 
99
			bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
99
			bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
100
			
100
			
101
			
101
			
102
		}
102
		}
103
		
103
		
104
		  
104
		  
105
 
105
 
106
		public void onClick(Widget sender) {
106
		public void onClick(Widget sender) {
107
			if (sender == gotoNext) {
107
			if (sender == gotoNext) {
108
				// Move forward a page.
108
				// Move forward a page.
109
				startIndex += VISIBLE_TAXON_COUNT;
109
				startIndex += VISIBLE_TAXON_COUNT;
110
				if (startIndex >= count)
110
				if (startIndex >= count)
111
					startIndex -= VISIBLE_TAXON_COUNT;
111
					startIndex -= VISIBLE_TAXON_COUNT;
112
			} else {
112
			} else {
113
				if (sender == gotoPrev) {
113
				if (sender == gotoPrev) {
114
					// Move back a page.
114
					// Move back a page.
115
					startIndex -= VISIBLE_TAXON_COUNT;
115
					startIndex -= VISIBLE_TAXON_COUNT;
116
					if (startIndex < 0)
116
					if (startIndex < 0)
117
						startIndex = 0;
117
						startIndex = 0;
118
				} else {
118
				} else {
119
					if (sender == gotoEnd) {
119
					if (sender == gotoEnd) {
120
						gotoEnd();
120
						gotoEnd();
121
					} else {
121
					} else {
122
						if (sender == gotoFirst) {
122
						if (sender == gotoFirst) {
123
							startIndex = 0;
123
							startIndex = 0;
124
						}
124
						}
125
					}
125
					}
126
				}
126
				}
127
			}
127
			}
128
			update();
128
			update();
129
		}
129
		}
130
 
130
 
131
	}
131
	}
132
 
132
 
133
	private void setStatusText(String text) {
133
	private void setStatusText(String text) {
134
		navBar.status.setText(text);
134
		navBar.status.setText(text);
135
	}
135
	}
136
 
136
 
137
	private static final int VISIBLE_TAXON_COUNT = 15;
137
	private static final int VISIBLE_TAXON_COUNT = 15;
138
 
138
 
139
	private Grid header = new Grid(1, 3);
139
	private Grid header = new Grid(1, 3);
140
 
140
 
141
	private FlexTable table = new FlexTable();
141
	private FlexTable table = new FlexTable();
142
 
142
 
143
	private VerticalPanel panel = new VerticalPanel();
143
	private VerticalPanel panel = new VerticalPanel();
144
 
144
 
145
	private int startIndex = 0;
145
	private int startIndex = 0;
146
 
146
 
147
	private String serviceBaseUrl = null;
147
	private String serviceBaseUrl = null;
148
 
148
 
149
	private int count = 65000;
149
	private int count = 65000;
150
 
150
 
151
	private String user;
151
	private String user;
152
 
152
 
153
	private NavBar navBar=null;
153
	private NavBar navBar=null;
154
	
154
	
155
	private Mediator mediator = null;
155
	private Mediator mediator = null;
156
 
156
 
157
	private int  selectedRow = -1;
157
	private int  selectedRow = -1;
158
	
158
	
159
	private String location = "all";
159
	private String location = "all";
160
	private String date = "all";
160
	private String date = "all";
161
	private String search = "all";
161
	private String search = "all";
162
	private String station = "all";
162
	private String station = "all";
163
 
-
 
164
	private boolean add=false;
-
 
165
	
163
 
166
	public InventoryItemList(Mediator med) {
164
	public InventoryItemList(Mediator med) {
167
 
165
 
168
		mediator=med;
166
		mediator=med;
169
		
167
		
170
	    mediator.registerInventoryItemList(this);
168
	    mediator.registerInventoryItemList(this);
171
		
169
		
172
		user=mediator.getUser();
170
		user=mediator.getUser();
173
	    serviceBaseUrl = mediator.getServiceBaseUrl();
171
	    serviceBaseUrl = mediator.getServiceBaseUrl();
174
	
172
	
175
		navBar = new NavBar();
173
		navBar = new NavBar();
176
		
174
		
177
 
175
 
178
		// Information complementaire : un tableau associe au retour de
176
		// Information complementaire : un tableau associe au retour de
179
		// l'assistant de saisie
177
		// l'assistant de saisie
180
 
178
 
181
		// Mise en forme du header
179
		// Mise en forme du header
182
 
180
 
183
		header.setCellSpacing(0);
181
		header.setCellSpacing(0);
184
		header.setCellPadding(2);
182
		header.setCellPadding(2);
185
		header.setWidth("100%");
183
		header.setWidth("100%");
186
 
184
 
187
		header.setStyleName("inventoryItem-ListHeader");
185
		header.setStyleName("inventoryItem-ListHeader");
188
 
186
 
189
		header.setWidget(0, 2, navBar);
187
		header.setWidget(0, 2, navBar);
190
 
188
 
191
		// Mise en forme de la table.
189
		// Mise en forme de la table.
192
 
190
 
193
		table.setCellSpacing(0);
191
		table.setCellSpacing(0);
194
		table.setBorderWidth(0);
192
		table.setBorderWidth(0);
195
		table.setCellPadding(2);
193
		table.setCellPadding(2);
196
		table.setWidth("100%");
194
		table.setWidth("100%");
197
		
195
		
198
 
196
 
199
		// Mise en forme barre navigation
197
		// Mise en forme barre navigation
200
 
198
 
201
		navBar.setWidth("100%");
199
		navBar.setWidth("100%");
202
 
200
 
203
		table.setStyleName("inventoryItem-List");
201
		table.setStyleName("inventoryItem-List");
204
 
202
 
205
		//panel.add(navBar);
203
		//panel.add(navBar);
206
		panel.add(header);
204
		panel.add(header);
207
		panel.add(table);
205
		panel.add(table);
208
 
206
 
209
		
207
		
210
		 // Hook up events.
208
		 // Hook up events.
211
	    table.addTableListener(new TableListener () {
209
	    table.addTableListener(new TableListener () {
212
	    	
210
	    	
213
			  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
211
			  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
214
				   
212
				   
215
				  if (table.getWidget(row, 0)!=null) {
213
				  if ((table.getWidget(row, 0)!=null) && (cell>0)){
216
				      selectRow(row);
214
				      selectRow(row);
217
				      // Numero d'ordre
215
				      // Numero d'ordre
218
				      mediator.onInventoryItemSelected(table.getText(row, 5));
216
				      mediator.onInventoryItemSelected(table.getText(row, 5));
219
				  }
217
				  }
220
			  }
218
			  }
221
 
219
 
222
	    });
220
	    });
223
	    
221
	    
224
		
222
		
225
		//updateCount();
223
		//updateCount();
226
		// update()
224
		// update()
227
 
225
 
228
		
226
		
229
		initWidget(panel);
227
		initWidget(panel);
230
 
228
 
231
 
229
 
232
	}
230
	}
233
	
231
	
234
	
232
	
235
	 
233
	 
236
	  private void selectRow(int row) {
234
	  private void selectRow(int row) {
237
		  
235
		  
238
		    styleRow(selectedRow, false);
236
		    styleRow(selectedRow, false);
239
		    styleRow(row, true);
237
		    styleRow(row, true);
240
 
238
 
241
		    selectedRow = row;
239
		    selectedRow = row;
242
		    
240
		    
243
		  }
241
		  }
244
		  
242
		  
245
		  
243
		  
246
		  private void styleRow(int row, boolean selected) {
244
		  private void styleRow(int row, boolean selected) {
247
			    if (row != -1) {
245
			    if (row != -1) {
248
			      if (selected)
246
			      if (selected)
249
			        table.getRowFormatter().addStyleName(row, "inventoryItem-SelectedRow");
247
			        table.getRowFormatter().addStyleName(row, "inventoryItem-SelectedRow");
250
			      else
248
			      else
251
			    	if (row < table.getRowCount()) { 
249
			    	if (row < table.getRowCount()) { 
252
			    		table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow");
250
			    		table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow");
253
			    	}
251
			    	}
254
			    }
252
			    }
255
			  }
253
			  }
256
 
254
 
257
 
255
 
258
	
256
	
259
 
257
 
260
	/**
258
	/**
261
	 * Action lancee par la selection d'un nom dans l'assistant de saisie. Lance
259
	 * Action lancee par la selection d'un nom dans l'assistant de saisie. Lance
262
	 * la recherche d'informations complémentaires (famille, numero
260
	 * la recherche d'informations complémentaires (famille, numero
263
	 * nomenclaturaux etc) et met a jour l'inventaire (addelement())
261
	 * nomenclaturaux etc) et met a jour l'inventaire (addelement())
264
	 * 
262
	 * 
265
	 * @return void
263
	 * @return void
266
	 */
264
	 */
267
	public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,
265
	public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,
268
			  String str, String value) {
266
			  String str, String value) {
269
	
267
	
270
 
268
 
271
	mediator.onAddInventoryItem();
269
	mediator.onAddInventoryItem();
272
		
270
		
273
	}
271
	}
274
	
272
	
275
 
273
 
276
	// Action sur modification d'un element 
274
	// Action sur modification d'un element 
277
	
275
	
278
	
276
	
279
	public void updateElement() {
277
	public void updateElement() {
280
	
278
	
281
	
279
	
282
	if (mediator.inventoryItemIsValid()) {
280
	if (mediator.inventoryItemIsValid()) {
283
	
281
	
284
		final InventoryItem inventoryItem=mediator.getInventoryItem();
282
		final InventoryItem inventoryItem=mediator.getInventoryItem();
285
	
283
	
286
		setStatusDisabled();
284
		setStatusDisabled();
287
		
285
		
288
				if (inventoryItem.getNomenclaturalNumber() !=null) {
286
				if (inventoryItem.getNomenclaturalNumber() !=null) {
289
		
287
		
290
					HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(),
288
					HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(),
291
							new ResponseTextHandler() {
289
							new ResponseTextHandler() {
292
		
290
		
293
								public void onCompletion(String strcomplete) {
291
								public void onCompletion(String strcomplete) {
294
		
292
		
295
									JSONValue jsonValue = JSONParser.parse(strcomplete);
293
									JSONValue jsonValue = JSONParser.parse(strcomplete);
296
									JSONArray jsonArray;
294
									JSONArray jsonArray;
297
		
295
		
298
									if ((jsonArray = jsonValue.isArray()) != null) {
296
									if ((jsonArray = jsonValue.isArray()) != null) {
299
										// Nom retenu, Num Nomen nom retenu, Num Taxon,
297
										// Nom retenu, Num Nomen nom retenu, Num Taxon,
300
										// Famille
298
										// Famille
301
										updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(),
299
										updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(),
302
												((JSONString) jsonArray.get(0))
300
												((JSONString) jsonArray.get(0))
303
														.stringValue(),
301
														.stringValue(),
304
												((JSONString) jsonArray.get(1))
302
												((JSONString) jsonArray.get(1))
305
														.stringValue(),
303
														.stringValue(),
306
												((JSONString) jsonArray.get(2))
304
												((JSONString) jsonArray.get(2))
307
														.stringValue(),
305
														.stringValue(),
308
												((JSONString) jsonArray.get(3))
306
												((JSONString) jsonArray.get(3))
309
														.stringValue(),
307
														.stringValue(),
310
														inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
308
														inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
311
									}
309
									}
312
								}
310
								}
313
		
311
		
314
							});
312
							});
315
				}
313
				}
316
				// Saisie libre
314
				// Saisie libre
317
				else {
315
				else {
318
					updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
316
					updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
319
				}
317
				}
320
			
318
			
321
		}
319
		}
322
	else {
320
	else {
323
		return;
321
		return;
324
	}
322
	}
325
	}
323
	}
326
 
324
 
327
	
325
	
328
	
326
	
329
	// Action sur ajout d'un element 
327
	// Action sur ajout d'un element 
330
	
328
	
331
	
329
	
332
	public void addelement() {
330
	public void addelement() {
333
	
331
	
334
	
332
	
335
	if (mediator.inventoryItemIsValid()) {
333
	if (mediator.inventoryItemIsValid()) {
336
	
334
	
337
		final InventoryItem inventoryItem=mediator.getInventoryItem();
335
		final InventoryItem inventoryItem=mediator.getInventoryItem();
338
	
336
	
339
		setStatusDisabled();
337
		setStatusDisabled();
340
		
338
		
341
				// On met a jour rapidement l'affichage puis on lance la requete  ....
339
				// On met a jour rapidement l'affichage puis on lance la requete  ....
342
				
340
				
343
		/*		int row = table.insertRow(table.getRowCount());
341
		/*		int row = table.insertRow(table.getRowCount());
344
				// Case a cocher
342
				// Case a cocher
345
				table.setWidget(row, 0, new CheckBox());
343
				table.setWidget(row, 0, new CheckBox());
346
				// Nom saisi
344
				// Nom saisi
347
				table.setText(row, 1, nameText);
345
				table.setText(row, 1, nameText);
348
				
346
				
349
				table.getFlexCellFormatter().setWidth(row, 0, "2%");
347
				table.getFlexCellFormatter().setWidth(row, 0, "2%");
350
				table.getFlexCellFormatter()
348
				table.getFlexCellFormatter()
351
						.setWidth(row, 1, "31%");*/
349
						.setWidth(row, 1, "31%");*/
352
				
350
				
353
				// Recherche complement d'information
351
				// Recherche complement d'information
354
		
352
		
355
				if (inventoryItem.getNomenclaturalNumber() !=null) {
353
				if (inventoryItem.getNomenclaturalNumber() !=null) {
356
		
354
		
357
					HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(),
355
					HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(),
358
							new ResponseTextHandler() {
356
							new ResponseTextHandler() {
359
		
357
		
360
								public void onCompletion(String strcomplete) {
358
								public void onCompletion(String strcomplete) {
361
		
359
		
362
									JSONValue jsonValue = JSONParser.parse(strcomplete);
360
									JSONValue jsonValue = JSONParser.parse(strcomplete);
363
									JSONArray jsonArray;
361
									JSONArray jsonArray;
364
		
362
		
365
									if ((jsonArray = jsonValue.isArray()) != null) {
363
									if ((jsonArray = jsonValue.isArray()) != null) {
366
										// Nom retenu, Num Nomen nom retenu, Num Taxon,
364
										// Nom retenu, Num Nomen nom retenu, Num Taxon,
367
										// Famille
365
										// Famille
368
										addElement(inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(),
366
										addElement(inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(),
369
												((JSONString) jsonArray.get(0))
367
												((JSONString) jsonArray.get(0))
370
														.stringValue(),
368
														.stringValue(),
371
												((JSONString) jsonArray.get(1))
369
												((JSONString) jsonArray.get(1))
372
														.stringValue(),
370
														.stringValue(),
373
												((JSONString) jsonArray.get(2))
371
												((JSONString) jsonArray.get(2))
374
														.stringValue(),
372
														.stringValue(),
375
												((JSONString) jsonArray.get(3))
373
												((JSONString) jsonArray.get(3))
376
														.stringValue(),
374
														.stringValue(),
377
														inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
375
														inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
378
									}
376
									}
379
								}
377
								}
380
		
378
		
381
							});
379
							});
382
				}
380
				}
383
				// Saisie libre
381
				// Saisie libre
384
				else {
382
				else {
385
					addElement(inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
383
					addElement(inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
386
				}
384
				}
387
			
385
			
388
		}
386
		}
389
	else {
387
	else {
390
		return;
388
		return;
391
	}
389
	}
392
	}
390
	}
393
 
391
 
394
	/**
392
	/**
395
	 * Ajoute un element à l'inventaire
393
	 * Ajoute un element à l'inventaire
396
	 * 
394
	 * 
397
	 * @param nom_sel :
395
	 * @param nom_sel :
398
	 *            nom selectionne
396
	 *            nom selectionne
399
	 * @param num_nom_sel :
397
	 * @param num_nom_sel :
400
	 *            numero nomenclatural nom selectionne
398
	 *            numero nomenclatural nom selectionne
401
	 * @param nom_ret :
399
	 * @param nom_ret :
402
	 *            nom retenu
400
	 *            nom retenu
403
	 * @param num_nom_ret :
401
	 * @param num_nom_ret :
404
	 *            numero nomenclaturel nom retenu
402
	 *            numero nomenclaturel nom retenu
405
	 * @param num_taxon :
403
	 * @param num_taxon :
406
	 *            numero taxonomique
404
	 *            numero taxonomique
407
	 * @param famille :
405
	 * @param famille :
408
	 *            famille
406
	 *            famille
409
	 */
407
	 */
410
 
408
 
411
	private void addElement(String nom_sel, String num_nom_sel, String nom_ret,
409
	private void addElement(String nom_sel, String num_nom_sel, String nom_ret,
412
			String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String complementLocation, String comment) {
410
			String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String complementLocation, String comment) {
413
 
411
 
414
 
412
 
415
		count++;
413
		count++;
416
		HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant="
414
		HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant="
417
				+ user + "&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel
415
				+ user + "&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel
418
				+ "&nom_ret=" + nom_ret + "&num_nom_ret=" + num_nom_ret
416
				+ "&nom_ret=" + nom_ret + "&num_nom_ret=" + num_nom_ret
419
				+ "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat
417
				+ "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat
420
				+ "&station="+ complementLocation + "&commentaire="+ comment,
418
				+ "&station="+ complementLocation + "&commentaire="+ comment,
421
 
419
 
422
		new ResponseTextHandler() {
420
		new ResponseTextHandler() {
423
 
421
 
424
			public void onCompletion(String str) {
422
			public void onCompletion(String str) {
425
					location=loc;
423
					location=loc;
426
					if (location.compareTo("")==0) {
424
					if (location.compareTo("")==0) {
427
						location="000null";
425
						location="000null";
428
					}
426
					}
429
					add=true;
-
 
430
					mediator.onInventoryUpdated(location);
427
					mediator.onInventoryUpdated(location);
431
					updateCount();
428
					updateCount();
432
			}
429
			}
433
		});
430
		});
434
	}
431
	}
435
 
432
 
436
	
433
	
437
 
434
 
438
	/**
435
	/**
439
	 * Modifie un element de l'inventaire
436
	 * Modifie un element de l'inventaire
440
	 * 
437
	 * 
441
	 * @param ordre : numero d'ordre
438
	 * @param ordre : numero d'ordre
442
	 * @param nom_sel :
439
	 * @param nom_sel :
443
	 *            nom selectionne
440
	 *            nom selectionne
444
	 * @param num_nom_sel :
441
	 * @param num_nom_sel :
445
	 *            numero nomenclatural nom selectionne
442
	 *            numero nomenclatural nom selectionne
446
	 * @param nom_ret :
443
	 * @param nom_ret :
447
	 *            nom retenu
444
	 *            nom retenu
448
	 * @param num_nom_ret :
445
	 * @param num_nom_ret :
449
	 *            numero nomenclaturel nom retenu
446
	 *            numero nomenclaturel nom retenu
450
	 * @param num_taxon :
447
	 * @param num_taxon :
451
	 *            numero taxonomique
448
	 *            numero taxonomique
452
	 * @param famille :
449
	 * @param famille :
453
	 *            famille
450
	 *            famille
454
	 */
451
	 */
455
 
452
 
456
	private void updateElement(String ordre, String nom_sel, String num_nom_sel, String nom_ret,
453
	private void updateElement(String ordre, String nom_sel, String num_nom_sel, String nom_ret,
457
			String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String complementLocation, String comment) {
454
			String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String complementLocation, String comment) {
458
 
455
 
459
 
456
 
460
		HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user + "/" +ordre + "/",
457
		HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user + "/" +ordre + "/",
461
				 "&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel
458
				 "&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel
462
				+ "&nom_ret=" + nom_ret + "&num_nom_ret=" + num_nom_ret
459
				+ "&nom_ret=" + nom_ret + "&num_nom_ret=" + num_nom_ret
463
				+ "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat
460
				+ "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat
464
				+ "&station="+ complementLocation + "&commentaire="+ comment,
461
				+ "&station="+ complementLocation + "&commentaire="+ comment,
465
 
462
 
466
		new ResponseTextHandler() {
463
		new ResponseTextHandler() {
467
 
464
 
468
			public void onCompletion(String str) {
465
			public void onCompletion(String str) {
469
				add=false;
-
 
470
				mediator.onInventoryUpdated(location);
466
				mediator.onInventoryUpdated(location);
471
				update();
467
				update();
472
			}
468
			}
473
		});
469
		});
474
	}
470
	}
475
 
471
 
476
	/**
472
	/**
477
	 * Transmission de releve à Tela
473
	 * Transmission de releve à Tela
478
	 * 
474
	 * 
479
	 */
475
	 */
480
 
476
 
481
	
477
	
482
	
478
	
483
	public void transmitElement() {
479
	public void transmitElement() {
484
	
480
	
485
		setStatusDisabled();
481
		setStatusDisabled();
486
		Vector parseChecked = new Vector();
482
		Vector parseChecked = new Vector();
487
 
483
 
488
		// TODO : optimiser
484
		// TODO : optimiser
489
		// Lifo ...
485
		// Lifo ...
490
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
486
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
491
			 if (table.getWidget(i, 0)!=null) {
487
			 if (table.getWidget(i, 0)!=null) {
492
				 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
488
				 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
493
					 // Numero ordre
489
					 // Numero ordre
494
					 parseChecked.add(table.getText(i, 5));
490
					 parseChecked.add(table.getText(i, 5));
495
				 }
491
				 }
496
			 }
492
			 }
497
		}
493
		}
498
		StringBuffer ids=new StringBuffer();
494
		StringBuffer ids=new StringBuffer();
499
		for (Iterator it = parseChecked.iterator(); it.hasNext();) {
495
		for (Iterator it = parseChecked.iterator(); it.hasNext();) {
500
			ids.append((String)it.next());
496
			ids.append((String)it.next());
501
			if (it.hasNext()) ids.append(",");
497
			if (it.hasNext()) ids.append(",");
502
		}
498
		}
503
		
499
		
504
		if (ids.length()>0) {
500
		if (ids.length()>0) {
505
		
501
		
506
			HTTPRequest.asyncPost(serviceBaseUrl + "/InventoryTransmit/" + user
502
			HTTPRequest.asyncPost(serviceBaseUrl + "/InventoryTransmit/" + user
507
							+ "/" + ids.toString(), "transmission=1",
503
							+ "/" + ids.toString(), "transmission=1",
508
							
504
							
509
							new ResponseTextHandler() {
505
							new ResponseTextHandler() {
510
								public void onCompletion(String str) {
506
								public void onCompletion(String str) {
511
											update();
507
											update();
512
								}
508
								}
513
							});
509
							});
514
		}
510
		}
515
	
511
	
516
		setStatusEnabled();
512
		setStatusEnabled();
517
 
513
 
518
		
514
		
519
	}
515
	}
520
	
516
	
521
	
517
	
522
	/**
518
	/**
523
	 * Suppression d'un element lde l'inventaire, a partir de son numero d'ordre
519
	 * Suppression d'un element lde l'inventaire, a partir de son numero d'ordre
524
	 * 
520
	 * 
525
	 */
521
	 */
526
 
522
 
527
	public void deleteElement() {
523
	public void deleteElement() {
528
 
524
 
529
		setStatusDisabled();
525
		setStatusDisabled();
530
		Vector parseChecked = new Vector();
526
		Vector parseChecked = new Vector();
531
 
527
 
532
		// TODO : optimiser
528
		// TODO : optimiser
533
		// Lifo ...
529
		// Lifo ...
534
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
530
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
535
			 if (table.getWidget(i, 0)!=null) {
531
			 if (table.getWidget(i, 0)!=null) {
536
				 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
532
				 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
537
					 // Numero ordre
533
					 // Numero ordre
538
					 parseChecked.add(table.getText(i, 5));
534
					 parseChecked.add(table.getText(i, 5));
539
					 count--;
535
					 count--;
540
				 }
536
				 }
541
			 }
537
			 }
542
		}
538
		}
543
		StringBuffer ids=new StringBuffer();
539
		StringBuffer ids=new StringBuffer();
544
		for (Iterator it = parseChecked.iterator(); it.hasNext();) {
540
		for (Iterator it = parseChecked.iterator(); it.hasNext();) {
545
			ids.append((String)it.next());
541
			ids.append((String)it.next());
546
			if (it.hasNext()) ids.append(",");
542
			if (it.hasNext()) ids.append(",");
547
		}
543
		}
548
		if (ids.length()>0) {
544
		if (ids.length()>0) {
549
			
545
			
550
			HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
546
			HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
551
							+ "/" + ids.toString(), "action=DELETE",
547
							+ "/" + ids.toString(), "action=DELETE",
552
							
548
							
553
							new ResponseTextHandler() {
549
							new ResponseTextHandler() {
554
								public void onCompletion(String str) {
550
								public void onCompletion(String str) {
555
											mediator.onInventoryUpdated("all");
551
											mediator.onInventoryUpdated("all");
556
											updateCount();
552
											updateCount();
557
								}
553
								}
558
							});
554
							});
559
		}
555
		}
560
	
556
	
561
		setStatusEnabled();
557
		setStatusEnabled();
562
	}
558
	}
563
	
559
	
564
	/**
560
	/**
565
	 * Selection de l'ensemble des elements affichés
561
	 * Selection de l'ensemble des elements affichés
566
	 * 
562
	 * 
567
	 */
563
	 */
568
 
564
 
569
	public void selectAll() {
565
	public void selectAll() {
570
 
566
 
571
		// TODO : optimiser ...
567
		// TODO : optimiser ...
572
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
568
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
573
			 if (table.getWidget(i, 0)!=null)
569
			 if (table.getWidget(i, 0)!=null)
574
			 ((CheckBox) table.getWidget(i, 0)).setChecked(true); 
570
			 ((CheckBox) table.getWidget(i, 0)).setChecked(true); 
575
		}
571
		}
576
	}
572
	}
577
 
573
 
578
	public void deselectAll() {
574
	public void deselectAll() {
579
	
575
	
580
		// TODO : optimiser ...
576
		// TODO : optimiser ...
581
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
577
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
582
			 if (table.getWidget(i, 0)!=null)
578
			 if (table.getWidget(i, 0)!=null)
583
			((CheckBox) table.getWidget(i, 0)).setChecked(false); 
579
			((CheckBox) table.getWidget(i, 0)).setChecked(false); 
584
		}
580
		}
585
	}
581
	}
586
 
582
 
587
 
583
 
588
 
584
 
589
	/**
585
	/**
590
	 * Recherche nombre d'enregistrement pour l'utilisateur et la localite en cours
586
	 * Recherche nombre d'enregistrement pour l'utilisateur et la localite en cours
591
	 * 
587
	 * 
592
	 */
588
	 */
593
	public void updateCount	() {
589
	public void updateCount	() {
594
		
590
		
595
		setStatusDisabled();
591
		setStatusDisabled();
596
		
592
		
597
		String adate="all";
593
		String adate="all";
598
		if (date.compareTo("all")!=0) {
594
		if (date.compareTo("all")!=0) {
599
			adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
595
			adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
600
		}
596
		}
601
 
597
 
602
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location + "/" + adate  + "/" + search +  "/" + station, 
598
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location + "/" + adate  + "/" + search +  "/" + station, 
603
				new ResponseTextHandler() {
599
				new ResponseTextHandler() {
604
 
600
 
605
					public void onCompletion(String str) {
601
					public void onCompletion(String str) {
606
 
602
 
607
						JSONValue jsonValue = JSONParser.parse(str);
603
						JSONValue jsonValue = JSONParser.parse(str);
608
						JSONNumber jsonNumber;
604
						JSONNumber jsonNumber;
609
						if ((jsonNumber = jsonValue.isNumber()) != null) {
605
						if ((jsonNumber = jsonValue.isNumber()) != null) {
610
							count = (int) jsonNumber.getValue();
606
							count = (int) jsonNumber.getValue();
611
							/*
607
							/*
612
							if (count==0) {
608
							if (count==0) {
613
								location="all";
609
								location="all";
614
							}
610
							}
615
							*/
611
							*/
616
							if (location.compareTo("")==0)
612
							if (location.compareTo("")==0)
617
								location="000null";
613
								location="000null";
618
						//	mediator.onInventoryItemUpdate(location);
614
						//	mediator.onInventoryItemUpdate(location);
619
							gotoEnd(); // Derniere page
615
							gotoEnd(); // Derniere page
620
							update();
616
							update();
621
						}
617
						}
622
					}
618
					}
623
				});
619
				});
624
 
620
 
625
	}
621
	}
626
	
622
	
627
	
623
	
628
	private String subLeft(String text, int length) {
624
	private String subLeft(String text, int length) {
629
		return (text.length() < length) ? text : text.substring(0, length)+ " ...";
625
		return (text.length() < length) ? text : text.substring(0, length)+ " ...";
630
	} 
626
	} 
631
 
627
 
632
	/**
628
	/**
633
	 * Mise a jour de l'affichage, à partir des données d'inventaire deja
629
	 * Mise a jour de l'affichage, à partir des données d'inventaire deja
634
	 * saisies. La valeur de this.startIndex permet de determiner quelles
630
	 * saisies. La valeur de this.startIndex permet de determiner quelles
635
	 * données seront affichées
631
	 * données seront affichées
636
	 * 
632
	 * 
637
	 *  @param deep : force une mise a jour totale
633
	 *  @param deep : force une mise a jour totale
638
	 */
634
	 */
639
 
635
 
640
	public void update() {
636
	public void update() {
641
 
637
 
642
	
638
	
643
//		table.setBorderWidth(1);
639
//		table.setBorderWidth(1);
644
		setStatusDisabled();
640
		setStatusDisabled();
645
 
641
 
646
		String adate="all";
642
		String adate="all";
647
		if (date.compareTo("all")!=0) {
643
		if (date.compareTo("all")!=0) {
648
			adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
644
			adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
649
		}
645
		}
650
		
646
		
651
		
647
		
652
		String com;
648
		String com;
653
		if (location.compareTo("all")==0) {
649
		if (location.compareTo("all")==0) {
654
			com="Toutes communes";
650
			com="Toutes communes";
655
		}
651
		}
656
		else {
652
		else {
657
			if (location.compareTo("000null")==0) {
653
			if (location.compareTo("000null")==0) {
658
				com="Communes non renseign&eacute;es";
654
				com="Communes non renseign&eacute;es";
659
			}
655
			}
660
			else {
656
			else {
661
			com="Commune de "+location;
657
			com="Commune de "+location;
662
			}
658
			}
663
		}
659
		}
664
 
660
 
665
		
661
		
666
		String dat;
662
		String dat;
667
		
663
		
668
		if (date.compareTo("all")==0) {
664
		if (date.compareTo("all")==0) {
669
			dat=", toutes p&eacute;riodes";
665
			dat=", toutes p&eacute;riodes";
670
		}
666
		}
671
		else {
667
		else {
672
			if (date.compareTo("00/00/0000")==0) {
668
			if (date.compareTo("00/00/0000")==0) {
673
				dat=", p&eacute;riodes non renseign&eacute;es";
669
				dat=", p&eacute;riodes non renseign&eacute;es";
674
			}
670
			}
675
			else {
671
			else {
676
				dat=", le "+ date;
672
				dat=", le "+ date;
677
			}
673
			}
678
		}
674
		}
679
	
675
	
680
		
676
		
681
		String stat;
677
		String stat;
682
		
678
		
683
		if (station.compareTo("all")==0) {
679
		if (station.compareTo("all")==0) {
684
			stat=", toutes stations";
680
			stat=", toutes stations";
685
		}
681
		}
686
		else {
682
		else {
687
			if (station.compareTo("000null")==0) {
683
			if (station.compareTo("000null")==0) {
688
				stat=", stations non renseign&eacute;es";
684
				stat=", stations non renseign&eacute;es";
689
			}
685
			}
690
			else {
686
			else {
691
				stat=", station "+ station;
687
				stat=", station "+ station;
692
			}
688
			}
693
		}
689
		}
694
	
690
	
695
		
691
		
696
		header.setHTML(0, 0, com +  dat + stat );
692
		header.setHTML(0, 0, com +  dat + stat );
697
		
693
		
698
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/" + search + "/" + station + "/"
694
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/" + search + "/" + station + "/"
699
				+ startIndex + "/" + VISIBLE_TAXON_COUNT,
695
				+ startIndex + "/" + VISIBLE_TAXON_COUNT,
700
 
696
 
701
		new ResponseTextHandler() {
697
		new ResponseTextHandler() {
702
 
698
 
703
			public void onCompletion(String str) {
699
			public void onCompletion(String str) {
704
 
700
 
705
				JSONValue jsonValue = JSONParser.parse(str);
701
				JSONValue jsonValue = JSONParser.parse(str);
706
				JSONArray jsonArray;
702
				JSONArray jsonArray;
707
				JSONArray jsonArrayNested;
703
				JSONArray jsonArrayNested;
708
				
704
				
709
				StringBuffer left=new StringBuffer();
705
				StringBuffer left=new StringBuffer();
710
				StringBuffer center=new StringBuffer();
706
				StringBuffer center=new StringBuffer();
711
				StringBuffer right=new StringBuffer();
707
				StringBuffer right=new StringBuffer();
712
				
708
				
713
				
709
				
714
 
710
 
715
				
711
				
716
				int row=0;
712
				int row=0;
717
				int i=0;
713
				int i=0;
718
				if ((jsonArray = jsonValue.isArray()) != null) {
714
				if ((jsonArray = jsonValue.isArray()) != null) {
719
					int arraySize = jsonArray.size();
715
					int arraySize = jsonArray.size();
720
					for (i = 0; i < arraySize; ++i) {
716
					for (i = 0; i < arraySize; ++i) {
721
						if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
717
						if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
722
							if (i>=table.getRowCount()) {
718
							if (i>=table.getRowCount()) {
723
								 row = table.insertRow(table.getRowCount());
719
								 row = table.insertRow(table.getRowCount());
724
							}
720
							}
725
							else {
721
							else {
726
								row = i;
722
								row = i;
727
							}
723
							}
728
 
724
 
729
							left=new StringBuffer();
725
							left=new StringBuffer();
730
							center=new StringBuffer();
726
							center=new StringBuffer();
731
							right=new StringBuffer();
727
							right=new StringBuffer();
732
							
728
							
733
							// Case a cocher
729
							// Case a cocher
734
							table.setWidget(row, 0, new CheckBox());
730
							table.setWidget(row, 0, new CheckBox());
735
							
731
							
736
							
732
							
737
							// Observation transmise
733
							// Observation transmise
738
							
734
							
739
							
735
							
740
							String atransmit=((JSONString) jsonArrayNested .get(11)).stringValue();
736
							String atransmit=((JSONString) jsonArrayNested .get(11)).stringValue();
741
							
737
							
742
							if (atransmit.compareTo("1")==0) {
738
							if (atransmit.compareTo("1")==0) {
743
								table.setWidget(row,1,new Image("tela.gif"));
739
								table.setWidget(row,1,new Image("tela.gif"));
744
							}
740
							}
745
							else {
741
							else {
746
								table.setWidget(row,1,new HTML("&nbsp;"));
742
								table.setWidget(row,1,new HTML("&nbsp;"));
747
							}
743
							}
748
							
744
							
749
							left.append("<b>"+((JSONString) jsonArrayNested .get(0)).stringValue()+"</b>");
745
							left.append("<b>"+((JSONString) jsonArrayNested .get(0)).stringValue()+"</b>");
750
							
746
							
751
							// Nom retenu
747
							// Nom retenu
752
							String aname=((JSONString) jsonArrayNested .get(2)).stringValue();
748
							String aname=((JSONString) jsonArrayNested .get(2)).stringValue();
753
							
749
							
754
							if (aname.compareTo("null")==0) {
750
							if (aname.compareTo("null")==0) {
755
							}
751
							}
756
							else {
752
							else {
757
								center.append(aname+", ");
753
								center.append(aname+", ");
758
							}
754
							}
759
							
755
							
760
							// Num nomenclatural
756
							// Num nomenclatural
761
							String ann=((JSONString) jsonArrayNested .get(3)).stringValue();
757
							String ann=((JSONString) jsonArrayNested .get(3)).stringValue();
762
							
758
							
763
							if (ann.compareTo("0")!=0) {
759
							if (ann.compareTo("0")!=0) {
764
								center.append(""+ann+"-");
760
								center.append(""+ann+"-");
765
							}
761
							}
766
							else {
762
							else {
767
								center.append("0-");
763
								center.append("0-");
768
							}
764
							}
769
 
765
 
770
							
766
							
771
							// Num Taxonomique
767
							// Num Taxonomique
772
							
768
							
773
							String ant=((JSONString) jsonArrayNested .get(4)).stringValue();
769
							String ant=((JSONString) jsonArrayNested .get(4)).stringValue();
774
							
770
							
775
							if (ant.compareTo("0")!=0) {
771
							if (ant.compareTo("0")!=0) {
776
								center.append(ant+", ");
772
								center.append(ant+", ");
777
							}
773
							}
778
							else {
774
							else {
779
								center.append("0, ");
775
								center.append("0, ");
780
							}
776
							}
781
 
777
 
782
							// Famille
778
							// Famille
783
							String afamily=((JSONString) jsonArrayNested .get(5)).stringValue();
779
							String afamily=((JSONString) jsonArrayNested .get(5)).stringValue();
784
							
780
							
785
							if (afamily.compareTo("null")==0) {
781
							if (afamily.compareTo("null")==0) {
786
								//
782
								//
787
							}
783
							}
788
							else {
784
							else {
789
								center.append(afamily+", ");
785
								center.append(afamily+", ");
790
							}
786
							}
791
 
787
 
792
							
788
							
793
							String aloc=((JSONString) jsonArrayNested .get(6)).stringValue();
789
							String aloc=((JSONString) jsonArrayNested .get(6)).stringValue();
794
//								Localisation - Lieu
790
//								Localisation - Lieu
795
								
791
								
796
								if (aloc.compareTo("000null")==0) {
792
								if (aloc.compareTo("000null")==0) {
797
									if (center.length()==0) {
793
									if (center.length()==0) {
798
										center.append("Commune absente");
794
										center.append("Commune absente");
799
									}
795
									}
800
									else {
796
									else {
801
										center.append("commune absente");
797
										center.append("commune absente");
802
									}
798
									}
803
								}
799
								}
804
								else {
800
								else {
805
									if (center.length()==0) {
801
									if (center.length()==0) {
806
										center.append("Commune de "+aloc);
802
										center.append("Commune de "+aloc);
807
									}
803
									}
808
									else {
804
									else {
809
										center.append("commune de "+aloc);
805
										center.append("commune de "+aloc);
810
									}
806
									}
811
										
807
										
812
								}
808
								}
813
							
809
							
814
								
810
								
815
								String alieudit=((JSONString) jsonArrayNested .get(9)).stringValue();
811
								String alieudit=((JSONString) jsonArrayNested .get(9)).stringValue();
816
							
812
							
817
//								Localisation - Lieu dit
813
//								Localisation - Lieu dit
818
								
814
								
819
								if (alieudit.compareTo("000null")!=0) {
815
								if (alieudit.compareTo("000null")!=0) {
820
									center.append(", "+alieudit);
816
									center.append(", "+alieudit);
821
								}
817
								}
822
							
818
							
823
								String acomment=((JSONString) jsonArrayNested .get(10)).stringValue();
819
								String acomment=((JSONString) jsonArrayNested .get(10)).stringValue();
824
//								Commentaire
820
//								Commentaire
825
								
821
								
826
								if (acomment.compareTo("null")!=0) {
822
								if (acomment.compareTo("null")!=0) {
827
									center.append(", "+acomment);
823
									center.append(", "+acomment);
828
								}
824
								}
829
 
825
 
830
								
826
								
831
								String adate=((JSONString) jsonArrayNested .get(8)).stringValue();
827
								String adate=((JSONString) jsonArrayNested .get(8)).stringValue();
832
								
828
								
833
//								Date 
829
//								Date 
834
								if (adate.compareTo("0000-00-00 00:00:00")!=0) {
830
								if (adate.compareTo("0000-00-00 00:00:00")!=0) {
835
									right.append("<b>"+adate+"</b>"); 
831
									right.append("<b>"+adate+"</b>"); 
836
								}
832
								}
837
								else {
833
								else {
838
//									right.append("<b>00/00/0000</b>"); 
834
//									right.append("<b>00/00/0000</b>"); 
839
								}
835
								}
840
								
836
								
841
							
837
							
842
							table.setHTML(row, 2, subLeft("&nbsp;"+left,40));
838
							table.setHTML(row, 2, subLeft("&nbsp;"+left,40));
843
							table.setHTML(row, 3, subLeft("&nbsp;"+center,120));
839
							table.setHTML(row, 3, subLeft("&nbsp;"+center,120));
844
							table.setHTML(row, 4, subLeft("&nbsp;"+right,25));
840
							table.setHTML(row, 4, subLeft("&nbsp;"+right,25));
845
							
841
							
846
							table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow");
842
							table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow");
847
							
843
							
848
						
844
						
849
							table.getCellFormatter().setWidth(row,0,"2%");
845
							table.getCellFormatter().setWidth(row,0,"2%");
850
							table.getCellFormatter().setWidth(row,1,"2%");
846
							table.getCellFormatter().setWidth(row,1,"2%");
851
							table.getCellFormatter().setWordWrap(row,2,false);
847
							table.getCellFormatter().setWordWrap(row,2,false);
852
							table.getCellFormatter().setWidth(row,2,"10%");
848
							table.getCellFormatter().setWidth(row,2,"10%");
853
							table.getCellFormatter().setWordWrap(row,3,false);
849
							table.getCellFormatter().setWordWrap(row,3,false);
854
							table.getCellFormatter().setWordWrap(row,4,false);
850
							table.getCellFormatter().setWordWrap(row,4,false);
855
							table.getCellFormatter().setWidth(row,4,"7%");
851
							table.getCellFormatter().setWidth(row,4,"7%");
856
							
852
							
857
							
853
							
858
							String aordre=((JSONString) jsonArrayNested.get(7)).stringValue();
854
							String aordre=((JSONString) jsonArrayNested.get(7)).stringValue();
859
						
855
						
860
							// Numero d'ordre (caché)
856
							// Numero d'ordre (caché)
861
		
857
		
862
							
858
							
863
							table.setText(row, 5, aordre);
859
							table.setText(row, 5, aordre);
-
 
860
 
864
 
861
							/*
865
							if (add){
862
							if (add){
866
								if (i ==(arraySize -1)) {
863
								if (i ==(arraySize -1)) {
867
									selectRow(row);
864
									selectRow(row);
868
									mediator.getEntryPanel().setOrdre(aordre);
865
									mediator.getEntryPanel().setOrdre(aordre);
869
								}
866
								}
870
								
867
								
871
							}
868
							}
872
							else {
869
							else {
873
								if ((mediator.getEntryPanel().getOrdre()!=null) && (mediator.getEntryPanel().getOrdre().compareTo(aordre)==0)) {
870
								if ((mediator.getEntryPanel().getOrdre()!=null) && (mediator.getEntryPanel().getOrdre().compareTo(aordre)==0)) {
874
									selectRow(row);
871
									selectRow(row);
875
								}
872
								}
876
							}
873
							}
-
 
874
							*/
877
 
875
 
878
							table.getCellFormatter().setVisible(row, 5, false);
876
							table.getCellFormatter().setVisible(row, 5, false);
879
 
877
 
880
							
878
							
881
						}
879
						}
882
 
880
 
883
					}
881
					}
884
				}
882
				}
885
 
883
 
886
				
884
				
887
				// Suppression fin ancien affichage
885
				// Suppression fin ancien affichage
888
				for (int j=i;j<VISIBLE_TAXON_COUNT;j++) {
886
				for (int j=i;j<VISIBLE_TAXON_COUNT;j++) {
889
						 table.setHTML(j,0,"&nbsp;");
887
						 table.setHTML(j,0,"&nbsp;");
890
						 table.setHTML(j,1,"&nbsp;");
888
						 table.setHTML(j,1,"&nbsp;");
891
						 table.setHTML(j,2,"&nbsp;");
889
						 table.setHTML(j,2,"&nbsp;");
892
						 table.setHTML(j,3,"&nbsp;");
890
						 table.setHTML(j,3,"&nbsp;");
893
						 table.setHTML(j,4,"&nbsp;");
891
						 table.setHTML(j,4,"&nbsp;");
894
						 table.setHTML(j,5,"&nbsp;");
892
						 table.setHTML(j,5,"&nbsp;");
895
						table.getCellFormatter().setVisible(j, 5, false);
893
						table.getCellFormatter().setVisible(j, 5, false);
896
						table.getRowFormatter().removeStyleName(j, "inventoryItem-SelectedRow");
894
						table.getRowFormatter().removeStyleName(j, "inventoryItem-SelectedRow");
897
				}
895
				}
898
				
-
 
899
				add=false;
-
 
900
 
896
 
901
				setStatusEnabled();
897
				setStatusEnabled();
902
				
898
				
903
				
899
				
904
			}
900
			}
905
		});
901
		});
906
		
902
		
907
 
903
 
908
	}
904
	}
909
 
905
 
910
 
906
 
911
	/**
907
	/**
912
	 * Affichage message d'attente et désactivation navigation
908
	 * Affichage message d'attente et désactivation navigation
913
	 * 
909
	 * 
914
	 * @param
910
	 * @param
915
	 * @return void
911
	 * @return void
916
	 */
912
	 */
917
 
913
 
918
	private void setStatusDisabled() {
914
	private void setStatusDisabled() {
919
 
915
 
920
		navBar.gotoFirst.setEnabled(false);
916
		navBar.gotoFirst.setEnabled(false);
921
		navBar.gotoPrev.setEnabled(false);
917
		navBar.gotoPrev.setEnabled(false);
922
		navBar.gotoNext.setEnabled(false);
918
		navBar.gotoNext.setEnabled(false);
923
		navBar.gotoEnd.setEnabled(false);
919
		navBar.gotoEnd.setEnabled(false);
924
 
920
 
925
		setStatusText("Patientez ...");
921
		setStatusText("Patientez ...");
926
	}
922
	}
927
 
923
 
928
	/**
924
	/**
929
	 * Affichage numero de page et gestion de la navigation
925
	 * Affichage numero de page et gestion de la navigation
930
	 * 
926
	 * 
931
	 */
927
	 */
932
 
928
 
933
	private void setStatusEnabled() {
929
	private void setStatusEnabled() {
934
 
930
 
935
		// Il y a forcemment un disabled avant d'arriver ici
931
		// Il y a forcemment un disabled avant d'arriver ici
936
 
932
 
937
		if (count > 0) {
933
		if (count > 0) {
938
 
934
 
939
			if (startIndex >= VISIBLE_TAXON_COUNT) { // Au dela de la
935
			if (startIndex >= VISIBLE_TAXON_COUNT) { // Au dela de la
940
														// premiere page
936
														// premiere page
941
				navBar.gotoPrev.setEnabled(true);
937
				navBar.gotoPrev.setEnabled(true);
942
				navBar.gotoFirst.setEnabled(true);
938
				navBar.gotoFirst.setEnabled(true);
943
				if (startIndex < (count - VISIBLE_TAXON_COUNT)) { // Pas la
939
				if (startIndex < (count - VISIBLE_TAXON_COUNT)) { // Pas la
944
																	// derniere
940
																	// derniere
945
																	// page
941
																	// page
946
					navBar.gotoNext.setEnabled(true);
942
					navBar.gotoNext.setEnabled(true);
947
					navBar.gotoEnd.setEnabled(true);
943
					navBar.gotoEnd.setEnabled(true);
948
					setStatusText((startIndex + 1) + " - "
944
					setStatusText((startIndex + 1) + " - "
949
							+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count );
945
							+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count );
950
				} else { // Derniere page
946
				} else { // Derniere page
951
					setStatusText((startIndex + 1) + " - " + count + " sur " + count );
947
					setStatusText((startIndex + 1) + " - " + count + " sur " + count );
952
				}
948
				}
953
			} else { // Premiere page
949
			} else { // Premiere page
954
				if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres
950
				if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres
955
					navBar.gotoNext.setEnabled(true);
951
					navBar.gotoNext.setEnabled(true);
956
					navBar.gotoEnd.setEnabled(true);
952
					navBar.gotoEnd.setEnabled(true);
957
					setStatusText((startIndex + 1) + " - "
953
					setStatusText((startIndex + 1) + " - "
958
							+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count);
954
							+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count);
959
				} else {
955
				} else {
960
					setStatusText((startIndex + 1) + " - " + count + " sur " + count);
956
					setStatusText((startIndex + 1) + " - " + count + " sur " + count);
961
				}
957
				}
962
			}
958
			}
963
		}
959
		}
964
 
960
 
965
		else { // Pas d'inventaire, pas de navigation
961
		else { // Pas d'inventaire, pas de navigation
966
			setStatusText("0 - 0 sur 0");
962
			setStatusText("0 - 0 sur 0");
967
		}
963
		}
968
	}
964
	}
969
 
965
 
970
	/*
966
	/*
971
	 * Positionnement index de parcours (this.startIndex) pour affichage de la
967
	 * Positionnement index de parcours (this.startIndex) pour affichage de la
972
	 * dernière page
968
	 * dernière page
973
	 * 
969
	 * 
974
	 * @param
970
	 * @param
975
	 * @return void
971
	 * @return void
976
	 */
972
	 */
977
 
973
 
978
	private void gotoEnd() {
974
	private void gotoEnd() {
979
 
975
 
980
		if ((count == 0) || (count % VISIBLE_TAXON_COUNT) > 0) {
976
		if ((count == 0) || (count % VISIBLE_TAXON_COUNT) > 0) {
981
			startIndex = count - (count % VISIBLE_TAXON_COUNT);
977
			startIndex = count - (count % VISIBLE_TAXON_COUNT);
982
		} else {
978
		} else {
983
			startIndex = count - VISIBLE_TAXON_COUNT;
979
			startIndex = count - VISIBLE_TAXON_COUNT;
984
		}
980
		}
985
 
981
 
986
	}
982
	}
987
 
983
 
988
	/*
984
	/*
989
	 * Recherche en cours
985
	 * Recherche en cours
990
	 * 
986
	 * 
991
	 */
987
	 */
992
	
988
	
993
	public void setSearch(String search) {
989
	public void setSearch(String search) {
994
		this.search = search;
990
		this.search = search;
995
	}
991
	}
996
 
992
 
997
 
993
 
998
	
994
	
999
	/*
995
	/*
1000
	 * Localite en cours 
996
	 * Localite en cours 
1001
	 * 
997
	 * 
1002
	 */
998
	 */
1003
	
999
	
1004
	public void setLocation(String location) {
1000
	public void setLocation(String location) {
1005
		this.location = location;
1001
		this.location = location;
1006
	}
1002
	}
1007
 
1003
 
1008
 
1004
 
1009
 
1005
 
1010
	public void setDate(String date) {
1006
	public void setDate(String date) {
1011
		this.date = date;
1007
		this.date = date;
1012
	}
1008
	}
1013
 
1009
 
1014
 
1010
 
1015
	public void setUser(String user) {
1011
	public void setUser(String user) {
1016
		this.user = user;
1012
		this.user = user;
1017
	}
1013
	}
1018
	
1014
	
1019
 
1015
 
1020
	public void setStation(String station) {
1016
	public void setStation(String station) {
1021
		this.station = station;
1017
		this.station = station;
1022
	}
1018
	}
1023
 
1019
 
1024
 
1020
 
1025
	
1021
	
1026
	
1022
	
1027
	
1023
	
1028
 
1024
 
1029
 
1025
 
1030
}
1026
}