Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 11 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 ddelon 1
/*
2
 * Copyright 2006 Google Inc.
3
 *
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
6
 * the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
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
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 * License for the specific language governing permissions and limitations under
14
 * the License.
15
 */
16
package org.tela_botanica.client;
17
 
18
import java.util.Iterator;
19
import java.util.Vector;
20
 
21
import com.google.gwt.json.client.JSONArray;
22
import com.google.gwt.json.client.JSONNumber;
23
import com.google.gwt.json.client.JSONParser;
24
import com.google.gwt.json.client.JSONString;
25
import com.google.gwt.json.client.JSONValue;
26
import com.google.gwt.user.client.HTTPRequest;
27
import com.google.gwt.user.client.ResponseTextHandler;
28
import com.google.gwt.user.client.ui.Composite;
29
import com.google.gwt.user.client.ui.FlexTable;
30
import com.google.gwt.user.client.ui.Grid;
31
import com.google.gwt.user.client.ui.HTML;
32
import com.google.gwt.user.client.ui.HorizontalPanel;
33
import com.google.gwt.user.client.ui.VerticalPanel;
34
import com.google.gwt.user.client.ui.DockPanel;
35
import com.google.gwt.user.client.ui.Button;
36
import com.google.gwt.user.client.ui.CheckBox;
37
import com.google.gwt.user.client.ui.Widget;
38
import com.google.gwt.user.client.ui.ClickListener;
39
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
40
import com.google.gwt.user.client.ui.HasVerticalAlignment;
41
import com.google.gwt.user.client.ui.Label;
42
 
43
/*
44
 * Le retour de getUser appelle updateCount qui appelle update pour veiller à une
45
 * initialisation correcte
46
 *
47
 */
48
 
49
public class InventoryItemList extends Composite implements
50
		AutoCompleteAsyncTextBoxListener {
51
 
52
	// Barre de navigation
53
 
54
	private class NavBar extends Composite implements ClickListener {
55
 
56
		public final DockPanel bar = new DockPanel();
57
 
58
		public final Button gotoFirst = new Button("<<", this);
59
 
60
		public final Button gotoNext = new Button(">", this);
61
 
62
		public final Button gotoPrev = new Button("<", this);
63
 
64
		public final Button gotoEnd = new Button(">>", this);
12 ddelon 65
 
66
 
11 ddelon 67
		public final HTML status = new HTML();
68
 
69
 
70
		public NavBar() {
12 ddelon 71
 
72
 
11 ddelon 73
			initWidget(bar);
74
			bar.setStyleName("navbar");
75
			status.setStyleName("status");
76
 
77
			HorizontalPanel buttons = new HorizontalPanel();
78
 
79
			buttons.add(status);
80
			buttons.setCellHorizontalAlignment(status,
81
					HasHorizontalAlignment.ALIGN_RIGHT);
82
			buttons.setCellVerticalAlignment(status,
83
					HasVerticalAlignment.ALIGN_MIDDLE);
84
			buttons.setCellWidth(status, "100%");
85
 
86
 
87
			buttons.add(gotoFirst);
88
			buttons.add(gotoPrev);
89
			buttons.add(gotoNext);
90
			buttons.add(gotoEnd);
91
			bar.add(buttons, DockPanel.EAST);
92
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
93
 
94
 
95
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT);
96
 
97
			bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
98
 
99
 
100
 
101
			VerticalPanel actions = new VerticalPanel();
102
 
12 ddelon 103
 
11 ddelon 104
			HorizontalPanel actionButton = new HorizontalPanel();
105
 
12 ddelon 106
			HTML addButton = new HTML("Nouvelle observation");
107
			addButton.setStyleName("html_button");
108
		    addButton.addClickListener(
109
 
110
		    		new ClickListener() {
111
 
112
		    			public void onClick(Widget w) {
113
		    				 openEntryPanel();
114
		    			}
115
 
116
		    		}
117
 
118
 
119
		    );
120
 
121
 
122
		    actionButton.add(addButton);
123
 
11 ddelon 124
			HTML delButton=new HTML("Suppression");
125
			delButton.setStyleName("html_button");
126
			delButton.addClickListener(
127
			    	new ClickListener() {
128
			    		public void onClick(Widget sender) {
129
			    			mediator.getInventoryItemList().deleteElement();
130
			    		}
131
			     	}
132
			);
133
 
134
			actionButton.add(delButton);
135
 
136
			HTML exportButton=new HTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" +mediator.getUser()+"\">"+"Tout exporter</a>");
137
			actionButton.add(exportButton);
138
			exportButton.setStyleName("html_button");
139
 
140
			actionButton.setSpacing(5);
141
 
142
			actions.add(actionButton);
143
 
12 ddelon 144
 
145
			HorizontalPanel selections = new HorizontalPanel();
146
 
147
			selections.setSpacing(3);
148
 
11 ddelon 149
 
12 ddelon 150
			selections.add(new HTML("S&eacute;lection : "));
151
 
152
			Label allLabel = new Label("Tous");
153
			Label separatorLabel = new Label(",");
154
			Label noneLabel = new Label("Aucun");
155
 
156
			allLabel.setStyleName("selection_label");
157
			noneLabel.setStyleName("selection_label");
158
 
159
			selections.add(allLabel);
160
			allLabel.addClickListener(
161
				    	new ClickListener() {
162
				    		public void onClick(Widget sender) {
163
				    			selectAll();
164
				    		}
165
				     	}
166
			);
167
 
168
			selections.add(separatorLabel);
169
 
170
			selections.add(noneLabel);
171
			noneLabel.addClickListener(
172
				    	new ClickListener() {
173
				    		public void onClick(Widget sender) {
174
				    			deselectAll();
175
				    		}
176
				     	}
177
			);
178
 
179
 
180
			actionButton.add(selections);
181
 
182
 
183
 
184
 
11 ddelon 185
			bar.add(actions, DockPanel.WEST);
186
 
187
 
12 ddelon 188
 
11 ddelon 189
 
190
 
191
		}
12 ddelon 192
 
193
 
194
		private void openEntryPanel() {
11 ddelon 195
 
12 ddelon 196
		             mediator.onEntryClick();
197
 
198
		}
199
 
200
 
201
 
11 ddelon 202
		public void onClick(Widget sender) {
203
			if (sender == gotoNext) {
204
				// Move forward a page.
205
				startIndex += VISIBLE_TAXON_COUNT;
206
				if (startIndex >= count)
207
					startIndex -= VISIBLE_TAXON_COUNT;
208
			} else {
209
				if (sender == gotoPrev) {
210
					// Move back a page.
211
					startIndex -= VISIBLE_TAXON_COUNT;
212
					if (startIndex < 0)
213
						startIndex = 0;
214
				} else {
215
					if (sender == gotoEnd) {
216
						gotoEnd();
217
					} else {
218
						if (sender == gotoFirst) {
219
							startIndex = 0;
220
						}
221
					}
222
				}
223
			}
224
			update();
225
		}
226
 
227
	}
228
 
229
	private void setStatusText(String text) {
230
		navBar.status.setText(text);
231
	}
232
 
233
	private static final int VISIBLE_TAXON_COUNT = 15;
234
 
235
	private Grid header = new Grid(1, 7);
236
 
237
	private FlexTable table = new FlexTable();
238
 
239
	private VerticalPanel panel = new VerticalPanel();
240
 
241
	private int startIndex = 0;
242
 
243
	private String serviceBaseUrl = null;
244
 
245
	private int count = 65000;
246
 
247
	private String user;
248
 
249
	private NavBar navBar=null;
250
 
251
	private Mediator mediator = null;
252
 
253
	private String location = "all";
12 ddelon 254
	private String date = "all";
11 ddelon 255
 
256
	public InventoryItemList(Mediator med) {
257
 
258
		mediator=med;
259
 
260
	    mediator.registerInventoryItemList(this);
261
 
262
		user=mediator.getUser();
263
	    serviceBaseUrl = mediator.getServiceBaseUrl();
264
 
265
		navBar = new NavBar();
266
 
267
 
268
		// Information complementaire : un tableau associe au retour de
269
		// l'assistant de saisie
270
 
271
		// Mise en forme du header
272
 
273
		header.setCellSpacing(0);
274
		header.setCellPadding(2);
275
		header.setWidth("100%");
276
 
12 ddelon 277
		header.setStyleName("inventoryItem-ListHeader");
11 ddelon 278
 
279
		header.setText(0, 0, "");
12 ddelon 280
		header.setHTML(0, 1, "Plante observ&eacute;e");
281
		header.setHTML(0, 2, "R&eacute;f&eacute;rence retenue");
282
		header.setHTML(0, 3, "R&eacute;f&eacute;rence<br>Nomenclaturale");
283
		header.setHTML(0, 4, "R&eacute;f&eacute;rence<br>Taxonomique");
11 ddelon 284
		header.setText(0, 5, "Famille");
12 ddelon 285
		header.setText(0, 6, "Commune");
11 ddelon 286
 
287
		header.getCellFormatter().setWidth(0, 0, "2%");
288
		header.getCellFormatter().setWidth(0, 1, "31%");
289
		header.getCellFormatter().setWidth(0, 2, "31%");
290
		header.getCellFormatter().setWidth(0, 3, "9%");
291
		header.getCellFormatter().setWidth(0, 4, "9%");
292
		header.getCellFormatter().setWidth(0, 5, "9%");
293
		header.getCellFormatter().setWidth(0, 6, "9%");
294
 
295
		// Mise en forme de la table.
296
 
297
		table.setCellSpacing(0);
298
		table.setBorderWidth(0);
299
		table.setCellPadding(2);
300
		table.setWidth("100%");
301
 
302
		// Mise en forme barre navigation
303
 
304
		navBar.setWidth("100%");
305
 
12 ddelon 306
		table.setStyleName("inventoryItem-List");
11 ddelon 307
 
308
		panel.add(navBar);
309
		panel.add(header);
310
		panel.add(table);
311
 
12 ddelon 312
 
313
		//updateCount();
11 ddelon 314
		// update()
315
 
316
 
317
		initWidget(panel);
318
 
319
 
320
	}
12 ddelon 321
 
322
 
323
 
11 ddelon 324
 
12 ddelon 325
 
326
 
11 ddelon 327
	/**
328
	 * Action lancee par la selection d'un nom dans l'assistant de saisie. Lance
329
	 * la recherche d'informations complémentaires (famille, numero
330
	 * nomenclaturaux etc) et met a jour l'inventaire (addelement())
331
	 *
332
	 * @return void
333
	 */
334
	public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,
335
			  String str, String value) {
336
 
12 ddelon 337
 
338
	mediator.onAddInventoryItem();
11 ddelon 339
 
12 ddelon 340
	}
11 ddelon 341
 
12 ddelon 342
 
343
	public void addelement() {
344
 
345
 
346
	if (mediator.inventoryItemIsValid()) {
347
 
348
		final InventoryItem inventoryItem=mediator.getInventoryItem();
349
 
350
		setStatusDisabled();
11 ddelon 351
 
352
				// On met a jour rapidement l'affichage puis on lance la requete  ....
353
 
354
		/*		int row = table.insertRow(table.getRowCount());
355
				// Case a cocher
356
				table.setWidget(row, 0, new CheckBox());
357
				// Nom saisi
358
				table.setText(row, 1, nameText);
359
 
360
				table.getFlexCellFormatter().setWidth(row, 0, "2%");
361
				table.getFlexCellFormatter()
362
						.setWidth(row, 1, "31%");*/
363
 
364
				// Recherche complement d'information
365
 
12 ddelon 366
				if (inventoryItem.getNomenclaturalNumber() !=null) {
11 ddelon 367
 
12 ddelon 368
					HTTPRequest.asyncGet(serviceBaseUrl + "/NameValid/" + inventoryItem.getNomenclaturalNumber(),
11 ddelon 369
							new ResponseTextHandler() {
370
 
371
								public void onCompletion(String strcomplete) {
372
 
373
									JSONValue jsonValue = JSONParser.parse(strcomplete);
374
									JSONArray jsonArray;
375
 
376
									if ((jsonArray = jsonValue.isArray()) != null) {
377
										// Nom retenu, Num Nomen nom retenu, Num Taxon,
378
										// Famille
12 ddelon 379
										addElement(inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(),
11 ddelon 380
												((JSONString) jsonArray.get(0))
381
														.stringValue(),
382
												((JSONString) jsonArray.get(1))
383
														.stringValue(),
384
												((JSONString) jsonArray.get(2))
385
														.stringValue(),
386
												((JSONString) jsonArray.get(3))
387
														.stringValue(),
12 ddelon 388
														inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
11 ddelon 389
									}
390
								}
391
 
392
							});
393
				}
394
				// Saisie libre
395
				else {
12 ddelon 396
					addElement(inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
11 ddelon 397
				}
398
 
12 ddelon 399
		}
400
	else {
401
		return;
11 ddelon 402
	}
12 ddelon 403
	}
11 ddelon 404
 
405
	/**
406
	 * Ajoute un element à l'inventaire
407
	 *
408
	 * @param nom_sel :
409
	 *            nom selectionne
410
	 * @param num_nom_sel :
411
	 *            numero nomenclatural nom selectionne
412
	 * @param nom_ret :
413
	 *            nom retenu
414
	 * @param num_nom_ret :
415
	 *            numero nomenclaturel nom retenu
416
	 * @param num_taxon :
417
	 *            numero taxonomique
418
	 * @param famille :
419
	 *            famille
420
	 */
421
 
12 ddelon 422
	private void addElement(String nom_sel, String num_nom_sel, String nom_ret,
423
			String num_nom_ret, String num_taxon, String famille,final String loc, String id_location,String dat, String complementLocation, String comment) {
11 ddelon 424
 
425
		// Calcul du nouveau numéro d'ordre
426
 
427
		count++;
428
		HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/", "identifiant="
429
				+ user + "&nom_sel=" + nom_sel + "&num_nom_sel=" + num_nom_sel
430
				+ "&nom_ret=" + nom_ret + "&num_nom_ret=" + num_nom_ret
12 ddelon 431
				+ "&num_taxon=" + num_taxon + "&famille=" + famille + "&location=" + loc + "&id_location=" + id_location + "&date_observation=" + dat
432
				+ "&station="+ complementLocation + "&commentaire="+ comment,
11 ddelon 433
 
434
		new ResponseTextHandler() {
435
 
436
			public void onCompletion(String str) {
437
					location=loc;
12 ddelon 438
					if (location.compareTo("")==0) {
439
						location="000null";
440
					}
11 ddelon 441
					updateCount();
442
			}
443
		});
444
	}
445
 
446
	/**
447
	 * Suppression d'un element lde l'inventaire, a partir de son numero d'ordre
448
	 *
449
	 */
450
 
451
	public void deleteElement() {
452
 
453
		setStatusDisabled();
454
		boolean checked = false;
455
		Vector parseChecked = new Vector();
456
 
12 ddelon 457
		// TODO : optimiser
11 ddelon 458
		// Lifo ...
459
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
12 ddelon 460
			 if (table.getWidget(i, 0)!=null) {
461
				 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
462
					 checked = true;
463
					 // Numero ordre
464
					 parseChecked.add(table.getText(i, 7));
465
					 count--;
466
				 }
467
			 }
11 ddelon 468
		}
12 ddelon 469
		StringBuffer ids=new StringBuffer();
11 ddelon 470
		for (Iterator it = parseChecked.iterator(); it.hasNext();) {
12 ddelon 471
			ids.append((String)it.next());
472
			if (it.hasNext()) ids.append(",");
473
		}
474
		HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
475
						+ "/" + ids.toString(), "action=DELETE",
11 ddelon 476
 
477
						new ResponseTextHandler() {
478
							public void onCompletion(String str) {
479
										updateCount();
480
							}
481
						});
482
 
483
		if (!checked) {
484
			setStatusEnabled();
485
		}
486
	}
487
 
488
	/**
489
	 * Selection de l'ensemble des elements affichés
490
	 *
491
	 */
492
 
493
	public void selectAll() {
494
 
12 ddelon 495
		// TODO : optimiser ...
11 ddelon 496
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
12 ddelon 497
			 if (table.getWidget(i, 0)!=null)
11 ddelon 498
			 ((CheckBox) table.getWidget(i, 0)).setChecked(true);
499
		}
500
	}
501
 
502
	public void deselectAll() {
503
 
12 ddelon 504
		// TODO : optimiser ...
11 ddelon 505
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
12 ddelon 506
			 if (table.getWidget(i, 0)!=null)
11 ddelon 507
			((CheckBox) table.getWidget(i, 0)).setChecked(false);
508
		}
509
	}
510
 
511
 
512
 
513
	/**
514
	 * Recherche nombre d'enregistrement pour l'utilisateur et la localite en cours
515
	 *
516
	 */
517
	public void updateCount() {
518
 
519
		setStatusDisabled();
12 ddelon 520
 
521
		String adate="all";
522
		if (date.compareTo("all")!=0) {
523
			adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
524
		}
11 ddelon 525
 
12 ddelon 526
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location + "/" + adate ,
11 ddelon 527
				new ResponseTextHandler() {
528
 
529
					public void onCompletion(String str) {
530
 
531
						JSONValue jsonValue = JSONParser.parse(str);
532
						JSONNumber jsonNumber;
533
						if ((jsonNumber = jsonValue.isNumber()) != null) {
534
							count = (int) jsonNumber.getValue();
535
							/*
536
							if (count==0) {
537
								location="all";
538
							}
539
							*/
540
							if (location.compareTo("")==0)
541
								location="000null";
542
							mediator.onInventoryItemUpdate(location);
543
							gotoEnd(); // Derniere page
544
							update();
545
						}
546
					}
547
				});
548
 
549
	}
550
 
551
	/**
552
	 * Mise a jour de l'affichage, à partir des données d'inventaire deja
553
	 * saisies. La valeur de this.startIndex permet de determiner quelles
554
	 * données seront affichées
555
	 *
556
	 *  @param deep : force une mise a jour totale
557
	 */
558
 
559
	public void update() {
560
 
561
		setStatusDisabled();
562
 
12 ddelon 563
		String adate="all";
564
		if (date.compareTo("all")!=0) {
565
			adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
566
		}
567
 
568
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/"+
11 ddelon 569
				+ startIndex + "/" + VISIBLE_TAXON_COUNT,
570
 
571
		new ResponseTextHandler() {
572
 
573
			public void onCompletion(String str) {
574
 
575
				JSONValue jsonValue = JSONParser.parse(str);
576
				JSONArray jsonArray;
577
				JSONArray jsonArrayNested;
578
 
12 ddelon 579
 
11 ddelon 580
				int row=0;
581
				int i=0;
582
				if ((jsonArray = jsonValue.isArray()) != null) {
583
					int arraySize = jsonArray.size();
584
					for (i = 0; i < arraySize; ++i) {
585
						if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
586
							if (i>=table.getRowCount()) {
587
								 row = table.insertRow(table.getRowCount());
588
							}
589
							else {
590
								row = i;
591
							}
12 ddelon 592
 
11 ddelon 593
							// Case a cocher
594
							table.setWidget(row, 0, new CheckBox());
595
							// Nom saisi
12 ddelon 596
 
11 ddelon 597
							table.setText(row, 1, ((JSONString) jsonArrayNested
598
									.get(0)).stringValue());
12 ddelon 599
 
11 ddelon 600
							// Nom retenu
12 ddelon 601
							String aname=((JSONString) jsonArrayNested .get(2)).stringValue();
602
 
603
							if (aname.compareTo("null")==0) {
604
								table.setText(row, 2, "");
605
							}
606
							else {
607
								table.setText(row, 2, aname);
608
							}
609
 
11 ddelon 610
							// Num nomenclatural
12 ddelon 611
							String ann=((JSONString) jsonArrayNested .get(3)).stringValue();
612
 
613
							if (ann.compareTo("0")==0) {
614
								table.setText(row, 3, "");
615
							}
616
							else {
617
								table.setText(row, 3, ann);
618
							}
619
 
620
 
11 ddelon 621
							// Num Taxonomique
12 ddelon 622
 
623
							String ant=((JSONString) jsonArrayNested .get(4)).stringValue();
624
 
625
							if (ant.compareTo("0")==0) {
626
								table.setText(row, 4, "");
627
							}
628
							else {
629
								table.setText(row, 4, ann);
630
							}
631
 
11 ddelon 632
							// Famille
12 ddelon 633
							String afamily=((JSONString) jsonArrayNested .get(5)).stringValue();
634
 
635
							if (afamily.compareTo("null")==0) {
636
								table.setText(row, 5, "");
637
							}
638
							else {
639
								table.setText(row, 5, afamily);
640
							}
11 ddelon 641
 
642
 
643
							table.getFlexCellFormatter().setWidth(row, 0, "2%");
644
							table.getFlexCellFormatter()
645
									.setWidth(row, 1, "31%");
646
							table.getFlexCellFormatter()
647
									.setWidth(row, 2, "31%");
12 ddelon 648
 
11 ddelon 649
						// TODO : Bool ici non ?
12 ddelon 650
 
651
							// Affichage contenu commune si tout demandé.
652
 
653
							String aloc=((JSONString) jsonArrayNested .get(6)).stringValue();
654
 
11 ddelon 655
							if (location.compareTo("all")==0) {
656
 
657
//								Localisation - Lieu
658
 
12 ddelon 659
								if (aloc.compareTo("000null")==0) {
11 ddelon 660
									table.setText(row, 6, "Inconnu");
661
								}
662
								else {
12 ddelon 663
									table.setText(row, 6, aloc );
11 ddelon 664
								}
665
 
12 ddelon 666
 
11 ddelon 667
								header.getCellFormatter().setVisible(0, 6,true);
12 ddelon 668
 
669
								table.getFlexCellFormatter().setWidth(row, 1, "31%");
670
								table.getFlexCellFormatter().setWidth(row, 2, "31%");
11 ddelon 671
 
12 ddelon 672
								table.getFlexCellFormatter().setWidth(row, 3, "9%");
673
								table.getFlexCellFormatter().setWidth(row, 4, "9%");
674
								table.getFlexCellFormatter().setWidth(row, 5, "9%");
675
								table.getFlexCellFormatter().setWidth(row, 6, "9%");
676
 
11 ddelon 677
							}
678
							else {
679
								header.getCellFormatter().setVisible(0, 6,false);
680
								table.getCellFormatter().setVisible(row, 6,false);
12 ddelon 681
 
682
								table.getFlexCellFormatter().setWidth(row, 1, "36%");
683
								table.getFlexCellFormatter().setWidth(row, 2, "36%");
684
 
685
								table.getFlexCellFormatter().setWidth(row, 3, "9%");
686
								table.getFlexCellFormatter().setWidth(row, 4, "9%");
687
								table.getFlexCellFormatter().setWidth(row, 5, "8%");
688
 
11 ddelon 689
							}
690
 
691
							// Numero d'ordre (caché)
692
							table.setText(row, 7, ((JSONString) jsonArrayNested
693
									.get(7)).stringValue());
694
 
695
							table.getCellFormatter().setVisible(row, 7, false);
696
 
697
 
698
						}
699
 
700
					}
701
				}
12 ddelon 702
 
703
 
11 ddelon 704
				// Suppression fin ancien affichage
705
				if (i<table.getRowCount()-1) {
706
					 for (int j = table.getRowCount() - 1; j > i-1; j--) {
707
						 table.removeRow(j);
708
					 }
709
				}
710
 
711
				setStatusEnabled();
712
 
713
			}
714
		});
715
 
716
	}
717
 
718
 
719
	/**
720
	 * Affichage message d'attente et désactivation navigation
721
	 *
722
	 * @param
723
	 * @return void
724
	 */
725
 
726
	private void setStatusDisabled() {
727
 
728
		navBar.gotoFirst.setEnabled(false);
729
		navBar.gotoPrev.setEnabled(false);
730
		navBar.gotoNext.setEnabled(false);
731
		navBar.gotoEnd.setEnabled(false);
732
 
733
		setStatusText("Patientez ...");
734
	}
735
 
736
	/**
737
	 * Affichage numero de page et gestion de la navigation
738
	 *
739
	 */
740
 
741
	private void setStatusEnabled() {
742
 
743
		// Il y a forcemment un disabled avant d'arriver ici
744
 
745
		if (count > 0) {
746
 
747
			if (startIndex >= VISIBLE_TAXON_COUNT) { // Au dela de la
748
														// premiere page
749
				navBar.gotoPrev.setEnabled(true);
750
				navBar.gotoFirst.setEnabled(true);
751
				if (startIndex < (count - VISIBLE_TAXON_COUNT)) { // Pas la
752
																	// derniere
753
																	// page
754
					navBar.gotoNext.setEnabled(true);
755
					navBar.gotoEnd.setEnabled(true);
756
					setStatusText((startIndex + 1) + " - "
757
							+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count );
758
				} else { // Derniere page
759
					setStatusText((startIndex + 1) + " - " + count + " sur " + count );
760
				}
761
			} else { // Premiere page
762
				if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres
763
					navBar.gotoNext.setEnabled(true);
764
					navBar.gotoEnd.setEnabled(true);
765
					setStatusText((startIndex + 1) + " - "
766
							+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count);
767
				} else {
768
					setStatusText((startIndex + 1) + " - " + count + " sur " + count);
769
				}
770
			}
771
		}
772
 
773
		else { // Pas d'inventaire, pas de navigation
774
			setStatusText("0 - 0 sur 0");
775
		}
776
	}
777
 
778
	/*
779
	 * Positionnement index de parcours (this.startIndex) pour affichage de la
780
	 * dernière page
781
	 *
782
	 * @param
783
	 * @return void
784
	 */
785
 
786
	private void gotoEnd() {
787
 
788
		if ((count == 0) || (count % VISIBLE_TAXON_COUNT) > 0) {
789
			startIndex = count - (count % VISIBLE_TAXON_COUNT);
790
		} else {
791
			startIndex = count - VISIBLE_TAXON_COUNT;
792
		}
793
 
794
	}
795
 
796
	/*
797
	 * Localite en cours
798
	 *
799
	 */
800
 
801
	public void setLocation(String location) {
802
		this.location = location;
803
	}
12 ddelon 804
 
805
 
806
 
807
	public void setDate(String date) {
808
		this.date = date;
809
	}
11 ddelon 810
 
811
 
812
 
813
 
814
 
815
 
816
}