Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 25 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25 Rev 26
Line -... Line 1...
-
 
1
/**
-
 
2
 David Delon david.delon@clapas.net 2007
-
 
3
 
-
 
4
 */
-
 
5
 
1
/*
6
/*
-
 
7
 * InventoryItemList.java  (Composite de Panel)
-
 
8
 *
-
 
9
 * Cas d'utilisation :
-
 
10
 * 
-
 
11
 * Affichage de releve 
-
 
12
 *
-
 
13
 * 1 : Recherche du nombre de releves associe au navigateur ou a l'utilisateur est connecte, en fonction des criteres de selection
-
 
14
 * 2 : Recherche des releves correspondant au critere precedent
-
 
15
 * 3 : Affichage des releves avec positionnement sur le dernier releve
-
 
16
 * 
-
 
17
 * Selection de releve
-
 
18
 * 
-
 
19
 * 1 : L'utilisateur selectionne un releve : lancement de l'affichage detaille pour le releve selectionne
-
 
20
 * 
-
 
21
 * 
-
 
22
 * Pagination :
-
 
23
 * 
-
 
24
 * 1 : Avancement ou recul d'une page
-
 
25
 *
-
 
26
 *
-
 
27
 * C(R)UD Element d'inventaire : (TODO : creer un nouvel objet pour cela)
-
 
28
 * 
2
 * Copyright 2006 Google Inc.
29
 * 1 : Ajoute d'un element
-
 
30
 * 2 : Modification d'un element
-
 
31
 * 3 : Suppression d'un element 
-
 
32
 */
-
 
33
 
-
 
34
 
-
 
35
/* Actions declenchees :
-
 
36
 * 
-
 
37
 * onInventoryItemSelected(numero d'ordre de la ligne selectionne) : selection d'une ligne
-
 
38
 * onInventoryItemUnselected(numero d'ordre de la ligne selectionne) : deselection d'une ligne
-
 
39
 * onInventoryUpdated(location) : action suite a la modification, suppression, creation d'un element d'inventaire
3
 * 
40
 * 
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
 */
41
 */
-
 
42
 
-
 
43
 
16
package org.tela_botanica.client;
44
package org.tela_botanica.client;
Line 17... Line 45...
17
 
45
 
18
import java.util.Iterator;
46
import java.util.Iterator;
Line -... Line 47...
-
 
47
import java.util.Vector;
19
import java.util.Vector;
48
 
20
 
49
import com.google.gwt.http.client.URL;
21
import com.google.gwt.json.client.JSONArray;
50
import com.google.gwt.json.client.JSONArray;
22
import com.google.gwt.json.client.JSONNumber;
51
import com.google.gwt.json.client.JSONNumber;
23
import com.google.gwt.json.client.JSONParser;
52
import com.google.gwt.json.client.JSONParser;
Line 32... Line 61...
32
import com.google.gwt.user.client.ui.HorizontalPanel;
61
import com.google.gwt.user.client.ui.HorizontalPanel;
33
import com.google.gwt.user.client.ui.Image;
62
import com.google.gwt.user.client.ui.Image;
34
import com.google.gwt.user.client.ui.SourcesTableEvents;
63
import com.google.gwt.user.client.ui.SourcesTableEvents;
35
import com.google.gwt.user.client.ui.TableListener;
64
import com.google.gwt.user.client.ui.TableListener;
36
import com.google.gwt.user.client.ui.VerticalPanel;
65
import com.google.gwt.user.client.ui.VerticalPanel;
37
import com.google.gwt.user.client.ui.DockPanel;
-
 
38
import com.google.gwt.user.client.ui.Button;
66
import com.google.gwt.user.client.ui.Button;
39
import com.google.gwt.user.client.ui.CheckBox;
67
import com.google.gwt.user.client.ui.CheckBox;
40
import com.google.gwt.user.client.ui.Widget;
68
import com.google.gwt.user.client.ui.Widget;
41
import com.google.gwt.user.client.ui.ClickListener;
69
import com.google.gwt.user.client.ui.ClickListener;
42
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
70
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
43
import com.google.gwt.user.client.ui.HasVerticalAlignment;
71
import com.google.gwt.user.client.ui.HasVerticalAlignment;
Line 44... Line -...
44
 
-
 
45
/*
-
 
46
 * Le retour de getUser appelle updateCount qui appelle update pour veiller à une
-
 
47
 * initialisation correcte
-
 
48
 * 
-
 
Line 49... Line 72...
49
 */
72
 
50
 
73
 
Line 51... Line 74...
51
public class InventoryItemList extends Composite implements
74
public class InventoryItemList extends Composite 
Line 52... Line 75...
52
		AutoCompleteAsyncTextBoxListener {
75
		 {
Line 53... Line -...
53
 
-
 
54
	// Barre de navigation
-
 
55
 
76
 
56
	private class NavBar extends Composite implements ClickListener {
-
 
57
 
77
	// Debut Barre de navigation
58
		public final DockPanel bar = new DockPanel();
-
 
59
 
78
 
60
		public final Button gotoFirst = new Button("<<", this);
-
 
61
 
79
	private class NavBar extends Composite implements ClickListener {
62
		public final Button gotoNext = new Button(">", this);
-
 
63
 
-
 
64
		public final Button gotoPrev = new Button("<", this);
80
 
Line 65... Line 81...
65
 
81
		public final Button gotoFirst = new Button("<<", this);
Line 66... Line 82...
66
		public final Button gotoEnd = new Button(">>", this);
82
		public final Button gotoNext = new Button(">", this);
-
 
83
		public final Button gotoPrev = new Button("<", this);
67
		
84
		public final Button gotoEnd = new Button(">>", this);
68
		 
85
		public final HTML status = new HTML();
Line 69... Line -...
69
		public final HTML status = new HTML();
-
 
70
		
-
 
71
 
-
 
72
		public NavBar() {
-
 
73
			
-
 
74
			
-
 
75
			initWidget(bar);
-
 
76
			bar.setStyleName("navbar");
-
 
77
			status.setStyleName("status");
-
 
78
			
-
 
79
			HorizontalPanel buttons = new HorizontalPanel();
-
 
80
			
-
 
81
			buttons.add(status);
-
 
82
			buttons.setCellHorizontalAlignment(status,
-
 
83
					HasHorizontalAlignment.ALIGN_RIGHT);
-
 
84
			buttons.setCellVerticalAlignment(status,
-
 
85
					HasVerticalAlignment.ALIGN_MIDDLE);
-
 
Line -... Line 86...
-
 
86
		
86
			buttons.setCellWidth(status, "100%");
87
 
-
 
88
		public NavBar() {
-
 
89
			
-
 
90
			
-
 
91
			HorizontalPanel bar = new HorizontalPanel();
-
 
92
			
-
 
93
			bar.setStyleName("navbar");
-
 
94
			status.setStyleName("status");
Line 87... Line -...
87
 
-
 
Line -... Line 95...
-
 
95
			
Line 88... Line 96...
88
 
96
			
Line 89... Line -...
89
			buttons.add(gotoFirst);
-
 
90
			buttons.add(gotoPrev);
97
			bar.add(status);
91
			buttons.add(gotoNext);
98
			bar.setCellHorizontalAlignment(status, HasHorizontalAlignment.ALIGN_RIGHT);
92
			buttons.add(gotoEnd);
99
			bar.setCellVerticalAlignment(status, HasVerticalAlignment.ALIGN_MIDDLE);
93
			bar.add(buttons, DockPanel.EAST);
100
			bar.setCellWidth(status, "100%");
94
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
101
 
Line 128... Line 135...
128
			update();
135
			update();
129
		}
136
		}
Line 130... Line 137...
130
 
137
 
Line 131... Line -...
131
	}
-
 
132
 
138
	}
133
	private void setStatusText(String text) {
-
 
Line 134... Line -...
134
		navBar.status.setText(text);
-
 
Line -... Line 139...
-
 
139
 
Line 135... Line 140...
135
	}
140
	// Fin Barre de navigation
136
 
-
 
137
	private static final int VISIBLE_TAXON_COUNT = 15;
141
 
138
	
-
 
139
 
142
 
Line 140... Line -...
140
 
-
 
Line -... Line 143...
-
 
143
 
141
	private Grid header = new Grid(1, 3);
144
	// Conteneur (header et table sont dans panel)
142
 
-
 
143
	private FlexTable table = new FlexTable();
-
 
144
 
-
 
145
	private VerticalPanel panel = new VerticalPanel();
145
	
146
 
-
 
147
	private int startIndex = 0;
-
 
148
 
-
 
149
	private String serviceBaseUrl = null;
146
	private Grid header = new Grid(1, 3);
Line -... Line 147...
-
 
147
	private FlexTable table = new FlexTable();
-
 
148
	private VerticalPanel panel = new VerticalPanel();
-
 
149
 
-
 
150
 
-
 
151
	// Services 
150
 
152
	private String serviceBaseUrl = null;
Line -... Line 153...
-
 
153
	private String user;
-
 
154
	private Mediator mediator = null;
151
	private int count = 65000;
155
 
152
 
156
	// Navigation
153
	private String user;
157
	private int startIndex = 0;
154
 
158
	private int count = 0;
Line -... Line 159...
-
 
159
	private static final int VISIBLE_TAXON_COUNT = 15;
155
	private NavBar navBar=null;
160
	private NavBar navBar=null;
Line 156... Line -...
156
	
-
 
Line -... Line 161...
-
 
161
	private int  selectedRow = -1;
-
 
162
 
-
 
163
	// Filtre par defaut :
157
	private Mediator mediator = null;
164
	
Line 158... Line 165...
158
 
165
	private String location = "all";
159
	private int  selectedRow = -1;
166
	private String date = "all";
Line 160... Line 167...
160
	
167
	private String search = "all";
161
	private String location = "all";
-
 
Line 162... Line -...
162
	private String date = "all";
-
 
163
	private String search = "all";
168
	private String station = "all";
Line 164... Line 169...
164
	private String station = "all";
169
 
Line 165... Line 170...
165
 
170
 
166
	public InventoryItemList(Mediator med) {
171
	public InventoryItemList(Mediator med) {
Line 186... Line 191...
186
 
191
 
Line 187... Line 192...
187
		header.setStyleName("inventoryItem-ListHeader");
192
		header.setStyleName("inventoryItem-ListHeader");
Line 188... Line 193...
188
 
193
 
Line 189... Line 194...
189
		header.setWidget(0, 2, navBar);
194
		header.setWidget(0, 2, navBar);
190
 
195
 
191
		// Mise en forme de la table.
196
		// Mise en forme de la table (contenu)
192
 
197
 
Line 193... Line -...
193
		table.setCellSpacing(0);
-
 
194
		table.setBorderWidth(0);
-
 
195
		table.setCellPadding(2);
-
 
196
		table.setWidth("100%");
-
 
197
		
198
		table.setCellSpacing(0);
Line 198... Line -...
198
 
-
 
199
		// Mise en forme barre navigation
199
		table.setBorderWidth(0);
200
 
200
		table.setCellPadding(2);
Line 201... Line -...
201
		navBar.setWidth("100%");
-
 
202
 
201
		table.setWidth("100%");
Line 203... Line 202...
203
		table.setStyleName("inventoryItem-List");
202
		
Line 204... Line 203...
204
 
203
 
-
 
204
		table.setStyleName("inventoryItem-List");
205
		//panel.add(navBar);
205
 
206
		panel.add(header);
206
		panel.add(header);
207
		panel.add(table);
207
		panel.add(table);
208
 
208
 
-
 
209
		
-
 
210
	    table.addTableListener(new TableListener () {
-
 
211
	    	
-
 
212
			  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
-
 
213
				   
-
 
214
				  if ((table.getWidget(row, 0)!=null) && (cell>0)){
-
 
215
					  if (row!=selectedRow) {
-
 
216
						  selectRow(row);
209
		
217
						  // Numero d'ordre
Line 210... Line 218...
210
		 // Hook up events.
218
						  mediator.onInventoryItemSelected(table.getText(row, 5));
Line 211... Line -...
211
	    table.addTableListener(new TableListener () {
-
 
212
	    	
-
 
213
			  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
-
 
214
				   
-
 
215
				  if ((table.getWidget(row, 0)!=null) && (cell>0)){
219
					  }
Line 216... Line -...
216
				      selectRow(row);
-
 
217
				      // Numero d'ordre
220
					  // Deselection 
Line -... Line 221...
-
 
221
					  else {
-
 
222
						   styleRow(row, false);
-
 
223
						   selectedRow=-1;
-
 
224
						   // Numero d'ordre
Line 218... Line 225...
218
				      mediator.onInventoryItemSelected(table.getText(row, 5));
225
						 mediator.onInventoryItemUnselected(table.getText(row, 5));
Line -... Line 226...
-
 
226
					  }
219
				  }
227
				  }
220
			  }
228
			  }
221
 
-
 
222
	    });
229
 
Line 223... Line 230...
223
	    
230
	    });
Line 224... Line -...
224
 
-
 
225
		//updateCount();
231
	    
226
		// update()
232
 
227
 
233
		initWidget(panel);
228
		
234
		
229
		initWidget(panel);
235
 
Line 254... Line 260...
254
			    	}
260
		    	}
255
			    }
261
		    }
256
			  }
262
	  }
Line 257... Line -...
257
 
-
 
258
 
-
 
259
 
-
 
260
		/**
-
 
261
		 * Action lancee par la completion d'un nom dans l'assistant de saisie
-
 
262
		 * Recherche d'information complémentaires ....
-
 
263
		 * 
-
 
264
		 * @return void
-
 
265
		 */
-
 
266
		  
-
 
267
		public void onComplete(ResponseTextHandler sender, String str, String value) {
-
 
268
			
-
 
269
			if (sender instanceof NameAssistant) {
-
 
270
				mediator.onNameCompleted(value);
-
 
271
			}
-
 
272
 
-
 
273
		}	
-
 
274
		  
-
 
275
	
263
 
276
 
-
 
277
	/**
-
 
278
	 * Action lancee par la selection d'un nom dans l'assistant de saisie. Lance
264
 
279
	 * la recherche d'informations complémentaires (famille, numero
265
	/**
280
	 * nomenclaturaux etc) et met a jour l'inventaire (addelement())
-
 
281
	 * 
266
	 *  Lancement de la mise a jour d'une ligne d'inventaire (appele par Mediator.onModifyInventoryItem())
282
	 * @return void
-
 
283
	 */
-
 
284
	public void onValidate(SourcesAutoCompleteAsyncTextBoxEvents sender,
-
 
285
			  String str, String value) {
-
 
286
	
-
 
287
	  	if (mediator.getEntryPanel().getOrdre()==null) {
-
 
288
			     mediator.onAddInventoryItem(); 
-
 
289
		  	}
-
 
290
		else {
-
 
291
		     mediator.onModifyInventoryItem(mediator.getEntryPanel().getOrdre()); 
-
 
292
		     mediator.getEntryPanel().setOrdre(null);
-
 
293
		 }
-
 
294
 
-
 
295
	}
-
 
296
	
-
 
297
 
-
 
Line 298... Line 267...
298
	// Action sur modification d'un element 
267
	 *
Line 299... Line 268...
299
	
268
	 */
Line 300... Line 269...
300
	
269
	  
Line 301... Line 270...
301
	public void updateElement() {
270
	public void updateElement() {
Line -... Line 271...
-
 
271
	
-
 
272
 
302
	
273
	if (mediator.inventoryItemIsValid()) {
Line 303... Line 274...
303
	
274
	
304
	if (mediator.inventoryItemIsValid()) {
275
		final InventoryItem inventoryItem=mediator.getInventoryItem();
Line 316... Line 287...
316
		
287
		
317
									JSONValue jsonValue = JSONParser.parse(strcomplete);
288
									JSONValue jsonValue = JSONParser.parse(strcomplete);
Line 318... Line 289...
318
									JSONArray jsonArray;
289
									JSONArray jsonArray;
319
		
290
		
320
									if ((jsonArray = jsonValue.isArray()) != null) {
-
 
321
										// Nom retenu, Num Nomen nom retenu, Num Taxon,
291
									if ((jsonArray = jsonValue.isArray()) != null) {
322
										// Famille
292
										// Nom retenu, Num Nomen nom retenu, Num Taxon,  Famille
323
										updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(),
293
										updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), inventoryItem.getNomenclaturalNumber(),
324
												((JSONString) jsonArray.get(0))
294
												((JSONString) jsonArray.get(0))
325
														.stringValue(),
295
														.stringValue(),
Line 333... Line 303...
333
									}
303
									}
334
								}
304
								}
Line 335... Line 305...
335
		
305
		
336
							});
306
							});
337
				}
307
				}
338
				// Saisie libre
308
				//  Modification d'un nom ne faisant pas parti du referentiel (saisie libre)
339
				else {
309
				else {
340
					updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
310
					updateElement(inventoryItem.getOrdre(),inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
Line 341... Line 311...
341
				}
311
				}
342
			
312
			
-
 
313
		}
343
		}
314
	else {
344
	else {
315
		// TODO : message d'erreur
345
		return;
316
		return;
Line 346... Line 317...
346
	}
317
	}
347
	}
318
	}
-
 
319
 
-
 
320
	
Line 348... Line 321...
348
 
321
	/**
Line 358... Line 331...
358
	
331
	
Line 359... Line 332...
359
		final InventoryItem inventoryItem=mediator.getInventoryItem();
332
		final InventoryItem inventoryItem=mediator.getInventoryItem();
Line 360... Line 333...
360
	
333
	
361
		setStatusDisabled();
-
 
362
		
-
 
363
				// On met a jour rapidement l'affichage puis on lance la requete  ....
-
 
364
				
-
 
365
		/*		int row = table.insertRow(table.getRowCount());
-
 
366
				// Case a cocher
-
 
367
				table.setWidget(row, 0, new CheckBox());
-
 
368
				// Nom saisi
-
 
369
				table.setText(row, 1, nameText);
-
 
370
				
-
 
371
				table.getFlexCellFormatter().setWidth(row, 0, "2%");
-
 
372
				table.getFlexCellFormatter()
-
 
Line 373... Line 334...
373
						.setWidth(row, 1, "31%");*/
334
		setStatusDisabled();
Line 374... Line 335...
374
				
335
		
375
				// Recherche complement d'information
336
				// Creation d'un nom faisant parti du referentiel : recherche du nom valide correspondant
Line 407... Line 368...
407
					addElement(inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
368
					addElement(inventoryItem.getName(), " ", " ", " ", " ", " ",inventoryItem.getLocation(),inventoryItem.getLocation_id(),inventoryItem.getDate(),inventoryItem.getComplementlocation(),inventoryItem.getComment());
408
				}
369
				}
Line 409... Line 370...
409
			
370
			
410
		}
371
		}
-
 
372
	else {
411
	else {
373
		// TODO : message d'erreur
412
		return;
374
		return;
413
	}
375
	}
Line -... Line 376...
-
 
376
	}
-
 
377
 
414
	}
378
	
415
 
379
	
416
	/**
380
	/**
417
	 * Ajoute un element à l'inventaire
381
	 * Ajoute effectif d'un element a l'inventaire (appel interne)
418
	 * 
382
	 * 
419
	 * @param nom_sel :
383
	 * @param nom_sel :
420
	 *            nom selectionne
384
	 *            nom selectionne
Line 447... Line 411...
447
					location=loc;
411
					location=loc;
448
					if (location.compareTo("")==0) {
412
					if (location.compareTo("")==0) {
449
						location="000null";
413
						location="000null";
450
					}
414
					}
451
					mediator.onInventoryUpdated(location);
415
					mediator.onInventoryUpdated(location);
452
					updateCount();
-
 
453
			}
416
			}
454
		});
417
		});
455
	}
418
	}
Line 456... Line 419...
456
 
419
 
457
	
420
	
458
 
421
 
459
	/**
422
	/**
460
	 * Modifie un element de l'inventaire
423
	 * Modification effective d'un element de l'inventaire (appel interne)
461
	 * 
424
	 * 
462
	 * @param ordre : numero d'ordre
425
	 * @param ordre : numero d'ordre
Line 486... Line 449...
486
 
449
 
Line 487... Line 450...
487
		new ResponseTextHandler() {
450
		new ResponseTextHandler() {
488
 
451
 
489
			public void onCompletion(String str) {
-
 
490
				mediator.onInventoryUpdated(location);
452
			public void onCompletion(String str) {
491
				update();
453
				mediator.onInventoryUpdated(location);
492
			}
454
			}
Line -... Line 455...
-
 
455
		});
-
 
456
	}
493
		});
457
	
494
	}
458
	
495
 
459
 
496
	/**
460
	/**
Line 497... Line -...
497
	 * Transmission de releve à Tela
-
 
498
	 * 
-
 
499
	 */
461
	 * Suppression effective d'un element lde l'inventaire, a partir de son numero d'ordre
Line 500... Line 462...
500
 
462
	 * 
501
	
463
	 */
Line 502... Line -...
502
	
-
 
503
	public void transmitElement() {
-
 
504
	
464
 
505
		setStatusDisabled();
465
	public void deleteElement() {
506
		Vector parseChecked = new Vector();
466
 
507
 
467
		setStatusDisabled();
508
		// TODO : optimiser
468
		Vector parseChecked = new Vector();
-
 
469
 
509
		// Lifo ...
470
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
510
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
471
			 if (table.getWidget(i, 0)!=null) {
511
			 if (table.getWidget(i, 0)!=null) {
472
				 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
512
				 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
473
					 // Numero ordre
513
					 // Numero ordre
474
					 parseChecked.add(table.getText(i, 5));
514
					 parseChecked.add(table.getText(i, 5));
475
					 count--;
515
				 }
476
				 }
516
			 }
477
			 }
517
		}
-
 
518
		StringBuffer ids=new StringBuffer();
478
		}
Line 519... Line 479...
519
		for (Iterator it = parseChecked.iterator(); it.hasNext();) {
479
		StringBuffer ids=new StringBuffer();
520
			ids.append((String)it.next());
480
		for (Iterator it = parseChecked.iterator(); it.hasNext();) {
Line 521... Line 481...
521
			if (it.hasNext()) ids.append(",");
481
			ids.append((String)it.next());
522
		}
482
			if (it.hasNext()) ids.append(",");
523
		
483
		}
524
		if (ids.length()>0) {
484
		if (ids.length()>0) {
525
		
485
			
526
			HTTPRequest.asyncPost(serviceBaseUrl + "/InventoryTransmit/" + user
486
			HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
Line 527... Line 487...
527
							+ "/" + ids.toString(), "transmission=1",
487
							+ "/" + ids.toString(), "action=DELETE",
Line 528... Line -...
528
							
-
 
529
							new ResponseTextHandler() {
488
							
Line -... Line 489...
-
 
489
							new ResponseTextHandler() {
-
 
490
								public void onCompletion(String str) {
530
								public void onCompletion(String str) {
491
											mediator.onInventoryUpdated(location);
531
											update();
492
								}
532
								}
-
 
533
							});
493
							});
Line -... Line 494...
-
 
494
		}
534
		}
495
	
Line 535... Line 496...
535
	
496
		setStatusEnabled();
536
		setStatusEnabled();
497
 
Line 537... Line -...
537
 
-
 
538
		
-
 
539
	}
498
	}
540
	
499
	
541
	
500
	
542
	/**
501
	
543
	 * Suppression d'un element lde l'inventaire, a partir de son numero d'ordre
502
	
544
	 * 
-
 
545
	 */
503
	/**
546
 
504
	 * Transmission de releve a Tela  (TODO : a appeler par Mediator)
547
	public void deleteElement() {
505
	 */
-
 
506
 
548
 
507
	
549
		setStatusDisabled();
508
	public void transmitElement() {
550
		Vector parseChecked = new Vector();
509
	
551
 
510
		setStatusDisabled();
552
		// TODO : optimiser
511
		Vector parseChecked = new Vector();
-
 
512
 
553
		// Lifo ...
513
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
Line 554... Line 514...
554
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
514
			 if (table.getWidget(i, 0)!=null) {
555
			 if (table.getWidget(i, 0)!=null) {
515
				 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
Line 556... Line 516...
556
				 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
516
					 // Numero ordre
557
					 // Numero ordre
517
					 parseChecked.add(table.getText(i, 5));
558
					 parseChecked.add(table.getText(i, 5));
518
				 }
559
					 count--;
-
 
560
				 }
519
			 }
561
			 }
520
		}
562
		}
521
		
Line 563... Line 522...
563
		StringBuffer ids=new StringBuffer();
522
		StringBuffer ids=new StringBuffer();
-
 
523
		for (Iterator it = parseChecked.iterator(); it.hasNext();) {
-
 
524
			ids.append((String)it.next());
564
		for (Iterator it = parseChecked.iterator(); it.hasNext();) {
525
			if (it.hasNext()) ids.append(",");
Line -... Line 526...
-
 
526
		}
-
 
527
		
565
			ids.append((String)it.next());
528
		if (ids.length()>0) {
566
			if (it.hasNext()) ids.append(",");
529
		
567
		}
530
			HTTPRequest.asyncPost(serviceBaseUrl + "/InventoryTransmit/" + user
568
		if (ids.length()>0) {
531
							+ "/" + ids.toString(), "transmission=1",
Line 569... Line 532...
569
			
532
							
Line 570... Line -...
570
			HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
-
 
571
							+ "/" + ids.toString(), "action=DELETE",
533
							new ResponseTextHandler() {
572
							
534
								public void onCompletion(String str) {
573
							new ResponseTextHandler() {
535
											update(); // Pour affichage logo 
574
								public void onCompletion(String str) {
536
								}
575
											mediator.onInventoryUpdated("all");
537
							});
Line 576... Line 538...
576
											updateCount();
538
		}
Line 577... Line -...
577
								}
-
 
578
							});
539
	
579
		}
540
		setStatusEnabled();
580
	
541
 
581
		setStatusEnabled();
542
		
582
	}
543
	}
Line 608... Line 569...
608
 
569
 
609
	/**
570
	/**
610
	 * Recherche nombre d'enregistrement pour l'utilisateur et la localite en cours
571
	 * Recherche nombre d'enregistrement pour l'utilisateur et la localite en cours
611
	 * 
572
	 * 
-
 
573
	 */
612
	 */
574
	
Line 613... Line 575...
613
	public void updateCount	() {
575
	public void updateCount	() {
Line -... Line 576...
-
 
576
		
-
 
577
		setStatusDisabled();
-
 
578
 
614
		
579
		
615
		setStatusDisabled();
580
		// Transformation de la date selectionne vers date time stamp
616
		
581
		
617
		String adate="all";
582
		String adate="all";
Line 618... Line 583...
618
		if (date.compareTo("all")!=0) {
583
		if (date.compareTo("all")!=0) {
619
			adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
584
			adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
Line 620... Line 585...
620
		}
585
		}
Line 621... Line 586...
621
 
586
 
622
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location + "/" + adate  + "/" + search +  "/" + station, 
587
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + URL.encodeComponent(location) + "/" + adate  + "/" + URL.encodeComponent(search) +  "/" + URL.encodeComponent(station), 
623
				new ResponseTextHandler() {
588
				new ResponseTextHandler() {
624
 
589
 
625
					public void onCompletion(String str) {
-
 
626
 
-
 
627
						JSONValue jsonValue = JSONParser.parse(str);
-
 
628
						JSONNumber jsonNumber;
-
 
629
						if ((jsonNumber = jsonValue.isNumber()) != null) {
-
 
630
							count = (int) jsonNumber.getValue();
590
					public void onCompletion(String str) {
631
							/*
-
 
632
							if (count==0) {
-
 
633
								location="all";
591
 
634
							}
592
						JSONValue jsonValue = JSONParser.parse(str);
635
							*/
593
						JSONNumber jsonNumber;
636
							if (location.compareTo("")==0)
594
						if ((jsonNumber = jsonValue.isNumber()) != null) {
637
								location="000null";
595
							count = (int) jsonNumber.getValue();
Line 638... Line 596...
638
						//	mediator.onInventoryItemUpdate(location);
596
						//	if (location.compareTo("")==0) location="000null";
Line -... Line 597...
-
 
597
							gotoEnd(); // Derniere page
Line 639... Line 598...
639
							gotoEnd(); // Derniere page
598
							update();
640
							update();
599
						}
641
						}
600
					}
Line 642... Line 601...
642
					}
601
				});
643
				});
602
 
644
 
603
	}
645
	}
604
	
646
	
605
   //	Utilitaire affichage
647
	
-
 
648
	private String subLeft(String text, int length) {
606
	
Line 649... Line 607...
649
		return (text.length() < length) ? text : text.substring(0, length)+ " ...";
607
	private String subLeft(String text, int length) {
Line 650... Line -...
650
	} 
-
 
Line 651... Line -...
651
 
-
 
652
	/**
-
 
653
	 * Mise a jour de l'affichage, à partir des données d'inventaire deja
-
 
654
	 * saisies. La valeur de this.startIndex permet de determiner quelles
-
 
655
	 * données seront affichées
-
 
656
	 * 
-
 
657
	 *  @param deep : force une mise a jour totale
608
		return (text.length() < length) ? text : text.substring(0, length)+ " ...";
Line 658... Line 609...
658
	 */
609
	} 
-
 
610
 
659
 
611
	/**
Line 660... Line 612...
660
	public void update() {
612
	 * Mise a jour de l'affichage, a partir des donnaes d'inventaire deja
661
 
613
	 * saisies. La valeur de this.startIndex permet de determiner quelles
662
		
614
	 * donnaes seront affichees
663
		// Mise a jour boutton export feuille de calcul
615
	 * 
Line 664... Line -...
664
		
-
 
665
		mediator.getActionPanel().getExportButton().setHTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" 
-
 
666
				+  user + "/"
-
 
667
				+ location + "/"
-
 
668
				+ station + "/"
-
 
669
				+ search + "/"
-
 
670
				+ date + 
-
 
671
				"\">"+"Export&nbsp;tableur</a>");
-
 
672
 
-
 
673
		
-
 
674
//		table.setBorderWidth(1);
-
 
675
		setStatusDisabled();
-
 
676
 
-
 
677
		String adate="all";
-
 
678
		if (date.compareTo("all")!=0) {
-
 
679
			adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
-
 
680
		}
-
 
681
		
-
 
682
		
-
 
683
		String com;
-
 
684
		if (location.compareTo("all")==0) {
-
 
685
			com="Toutes communes";
-
 
686
		}
-
 
687
		else {
-
 
688
			if (location.compareTo("000null")==0) {
-
 
689
				com="Communes non renseign&eacute;es";
-
 
690
			}
-
 
691
			else {
-
 
692
			com="Commune de "+location;
-
 
693
			}
-
 
694
		}
-
 
695
 
-
 
696
		
-
 
697
		String dat;
-
 
698
		
-
 
699
		if (date.compareTo("all")==0) {
-
 
700
			dat=", toutes p&eacute;riodes";
-
 
701
		}
-
 
702
		else {
-
 
703
			if (date.compareTo("00/00/0000")==0) {
-
 
704
				dat=", p&eacute;riodes non renseign&eacute;es";
-
 
705
			}
-
 
706
			else {
-
 
707
				dat=", le "+ date;
-
 
708
			}
-
 
709
		}
-
 
710
	
-
 
711
		
616
	 */
712
		String stat;
617
 
Line 713... Line 618...
713
		
618
	public void update() {
Line 714... Line 619...
714
		if (station.compareTo("all")==0) {
619
 
Line 715... Line 620...
715
			stat=", toutes stations";
620
		
716
		}
621
		
717
		else {
622
//		table.setBorderWidth(1); // Debug
Line 718... Line -...
718
			if (station.compareTo("000null")==0) {
-
 
719
				stat=", stations non renseign&eacute;es";
-
 
720
			}
-
 
721
			else {
-
 
722
				stat=", station "+ station;
-
 
723
			}
-
 
Line 724... Line 623...
724
		}
623
	
725
	
624
		
726
		
625
//      Ligne d'information 
-
 
626
		
-
 
627
		setStatusDisabled();
-
 
628
		
-
 
629
		String adate="all";
-
 
630
		if (date.compareTo("all")!=0) {
727
		header.setHTML(0, 0, com +  dat + stat );
631
			adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
-
 
632
		}
728
		
633
 
729
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/" + search + "/" + station + "/"
634
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + URL.encodeComponent(location) +"/" + adate + "/" + search + "/" + URL.encodeComponent(station) + "/"
730
				+ startIndex + "/" + VISIBLE_TAXON_COUNT,
635
				+ startIndex + "/" + VISIBLE_TAXON_COUNT,
731
 
636
 
732
		new ResponseTextHandler() {
637
		new ResponseTextHandler() {
Line 886... Line 791...
886
							table.getCellFormatter().setWidth(row,4,"7%");
791
							table.getCellFormatter().setWidth(row,4,"7%");
Line 887... Line 792...
887
							
792
							
Line 888... Line 793...
888
							
793
							
Line 889... Line 794...
889
							String aordre=((JSONString) jsonArrayNested.get(7)).stringValue();
794
							String aordre=((JSONString) jsonArrayNested.get(7)).stringValue();
890
						
-
 
891
							// Numero d'ordre (caché)
-
 
892
		
-
 
893
							
-
 
894
							table.setText(row, 5, aordre);
-
 
895
 
-
 
896
							/*
-
 
897
							if (add){
-
 
898
								if (i ==(arraySize -1)) {
-
 
899
									selectRow(row);
-
 
900
									mediator.getEntryPanel().setOrdre(aordre);
-
 
901
								}
-
 
902
								
-
 
903
							}
-
 
904
							else {
-
 
905
								if ((mediator.getEntryPanel().getOrdre()!=null) && (mediator.getEntryPanel().getOrdre().compareTo(aordre)==0)) {
-
 
906
									selectRow(row);
795
						
Line 907... Line 796...
907
								}
796
							// Numero d'ordre (cache)
Line 938... Line 827...
938
 
827
 
Line 939... Line 828...
939
	}
828
	}
940
 
829
 
941
 
830
 
942
	/**
831
	/**
943
	 * Affichage message d'attente et désactivation navigation
832
	 * Affichage message d'attente et desactivation navigation
944
	 * 
833
	 * 
Line 951... Line 840...
951
		navBar.gotoFirst.setEnabled(false);
840
		navBar.gotoFirst.setEnabled(false);
952
		navBar.gotoPrev.setEnabled(false);
841
		navBar.gotoPrev.setEnabled(false);
953
		navBar.gotoNext.setEnabled(false);
842
		navBar.gotoNext.setEnabled(false);
954
		navBar.gotoEnd.setEnabled(false);
843
		navBar.gotoEnd.setEnabled(false);
Line 955... Line 844...
955
 
844
 
956
		setStatusText("Patientez ...");
845
		navBar.status.setText("Patientez ...");
Line 957... Line 846...
957
	}
846
	}
958
 
847
 
959
	/**
848
	/**
Line 974... Line 863...
974
				if (startIndex < (count - VISIBLE_TAXON_COUNT)) { // Pas la
863
				if (startIndex < (count - VISIBLE_TAXON_COUNT)) { // Pas la
975
																	// derniere
864
																	// derniere
976
																	// page
865
																	// page
977
					navBar.gotoNext.setEnabled(true);
866
					navBar.gotoNext.setEnabled(true);
978
					navBar.gotoEnd.setEnabled(true);
867
					navBar.gotoEnd.setEnabled(true);
979
					setStatusText((startIndex + 1) + " - "
868
					navBar.status.setText((startIndex + 1) + " - "
980
							+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count );
869
							+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count );
981
				} else { // Derniere page
870
				} else { // Derniere page
982
					setStatusText((startIndex + 1) + " - " + count + " sur " + count );
871
					navBar.status.setText((startIndex + 1) + " - " + count + " sur " + count );
983
				}
872
				}
984
			} else { // Premiere page
873
			} else { // Premiere page
985
				if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres
874
				if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres
986
					navBar.gotoNext.setEnabled(true);
875
					navBar.gotoNext.setEnabled(true);
987
					navBar.gotoEnd.setEnabled(true);
876
					navBar.gotoEnd.setEnabled(true);
988
					setStatusText((startIndex + 1) + " - "
877
					navBar.status.setText((startIndex + 1) + " - "
989
							+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count);
878
							+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count);
990
				} else {
879
				} else {
991
					setStatusText((startIndex + 1) + " - " + count + " sur " + count);
880
					navBar.status.setText((startIndex + 1) + " - " + count + " sur " + count);
992
				}
881
				}
993
			}
882
			}
994
		}
883
		}
Line 995... Line 884...
995
 
884
 
996
		else { // Pas d'inventaire, pas de navigation
885
		else { // Pas d'inventaire, pas de navigation
997
			setStatusText("0 - 0 sur 0");
886
			navBar.status.setText("0 - 0 sur 0");
998
		}
887
		}
Line 999... Line 888...
999
	}
888
	}
1000
 
889
 
1001
	/*
890
	/*
1002
	 * Positionnement index de parcours (this.startIndex) pour affichage de la
891
	 * Positionnement index de parcours (this.startIndex) pour affichage de la
1003
	 * dernière page
892
	 * derniere page
1004
	 * 
893
	 * 
1005
	 * @param
894
	 * @param
Line 1024... Line 913...
1024
	public void setSearch(String search) {
913
	public void setSearch(String search) {
1025
		this.search = search;
914
		this.search = search;
1026
	}
915
	}
Line 1027... Line -...
1027
 
-
 
1028
 
916
 
1029
	
917
	
1030
	/*
918
	/*
1031
	 * Localite en cours 
919
	 * Localite en cours 
Line 1036... Line 924...
1036
		this.location = location;
924
		this.location = location;
1037
	}
925
	}
Line -... Line 926...
-
 
926
 
-
 
927
 
-
 
928
	
-
 
929
	/*
-
 
930
	 * Station en cours 
-
 
931
	 * 
-
 
932
	 */
-
 
933
 
-
 
934
	public void setStation(String station) {
-
 
935
		this.station = station;
-
 
936
	}
-
 
937
 
-
 
938
 
-
 
939
	
-
 
940
	
-
 
941
	/*
-
 
942
	 * Date en cours 
-
 
943
	 * 
1038
 
944
	 */
1039
 
945
	
1040
 
946
 
Line -... Line 947...
-
 
947
	public void setDate(String date) {
-
 
948
		this.date = date;
-
 
949
	}
-
 
950
 
-
 
951
	
-
 
952
	/*
-
 
953
	 * Utilisateur en cours 
1041
	public void setDate(String date) {
954
	 * 
1042
		this.date = date;
955
	 */
1043
	}
956
	
Line -... Line 957...
-
 
957
 
-
 
958
	
-
 
959
	public void setUser(String user) {
-
 
960
		this.user = user;
-
 
961
	}
-
 
962
 
-
 
963
 
-
 
964
	public String getDate() {
-
 
965
		return date;
-
 
966
	}
-
 
967
 
-
 
968
 
-
 
969
	public String getLocation() {
-
 
970
		return location;
-
 
971
	}
1044
 
972
 
1045
 
973
 
-
 
974
	public String getSearch() {
-
 
975
		return search;
-
 
976
	}
-
 
977
 
-
 
978
 
-
 
979
	public String getStation() {
-
 
980
		return station;
-
 
981
	}
-
 
982
 
-
 
983
 
-
 
984
	public Grid getHeader() {
-
 
985
		return header;
-
 
986
	}
-
 
987
	
-
 
988
 
-
 
989
	public void displayFilter() {
-
 
990
	
-
 
991
	// Mise a jour boutton export feuille de calcul
-
 
992
	
-
 
993
	mediator.getActionPanel().getExportButton().setHTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" 
-
 
994
			+  user + "/"
-
 
995
			+ URL.encodeComponent(location) + "/"
-
 
996
			+ URL.encodeComponent(station)+ "/"
-
 
997
			+ URL.encodeComponent(search) + "/"
-
 
998
			+ date + 
-
 
999
			"\">"+"Export&nbsp;tableur</a>");
-
 
1000
 
-
 
1001
	// Mise a jour ligne de selection 
-
 
1002
	
-
 
1003
 
-
 
1004
	
-
 
1005
	
-
 
1006
	String com;
-
 
1007
	if (location.compareTo("all")==0) {
-
 
1008
		com="Toutes communes";
-
 
1009
	}
1046
	public void setUser(String user) {
1010
	else {
Line -... Line 1011...
-
 
1011
		if (location.compareTo("000null")==0) {
-
 
1012
			com="Communes non renseign&eacute;es";
-
 
1013
		}
-
 
1014
		else {
-
 
1015
		com="Commune de "+location;
-
 
1016
		}
-
 
1017
	}
-
 
1018
 
-
 
1019
	
-
 
1020
	String dat;
-
 
1021
	
-
 
1022
	if (date.compareTo("all")==0) {
-
 
1023
		dat=", toutes p&eacute;riodes";
Line -... Line 1024...
-
 
1024
	}
Line -... Line 1025...
-
 
1025
	else {
-
 
1026
		if (date.compareTo("00/00/0000")==0) {
1047
		this.user = user;
1027
			dat=", p&eacute;riodes non renseign&eacute;es";
-
 
1028
		}
-
 
1029
		else {
-
 
1030
			dat=", le "+ date;
-
 
1031
		}
-
 
1032
	}
-
 
1033
 
-
 
1034
	
-
 
1035
	String stat;
-
 
1036
	
-
 
1037
	if (station.compareTo("all")==0) {
-
 
1038
		stat=", toutes stations";
-
 
1039
	}
-
 
1040
	else {
-
 
1041
		if (station.compareTo("000null")==0) {
-
 
1042
			stat=", stations non renseign&eacute;es";
-
 
1043
		}
-
 
1044
		else {
-
 
1045
			stat=", station "+ station;
-
 
1046
		}
-
 
1047
	}
-
 
1048
 
-
 
1049
	
1048
	}
1050
	header.setHTML(0, 0, com +  dat + stat );