Subversion Repositories eFlore/Archives.cel-v1

Rev

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

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