Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 25 | Go to most recent revision | Show entire file | Ignore 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
 * 
2
 * Copyright 2006 Google Inc.
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
3
 * 
20
 * 
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
 * 
21
 * 
8
 * http://www.apache.org/licenses/LICENSE-2.0
22
 * Pagination :
9
 * 
23
 * 
10
 * Unless required by applicable law or agreed to in writing, software
24
 * 1 : Avancement ou recul d'une page
-
 
25
 *
-
 
26
 *
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
27
 * C(R)UD Element d'inventaire : (TODO : creer un nouvel objet pour cela)
-
 
28
 * 
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
29
 * 1 : Ajoute d'un element
13
 * License for the specific language governing permissions and limitations under
30
 * 2 : Modification d'un element
14
 * the License.
31
 * 3 : Suppression d'un element 
15
 */
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
-
 
40
 * 
-
 
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,
-
 
Line -... Line 86...
-
 
86
		
-
 
87
 
-
 
88
		public NavBar() {
-
 
89
			
-
 
90
			
-
 
91
			HorizontalPanel bar = new HorizontalPanel();
-
 
92
			
-
 
93
			bar.setStyleName("navbar");
-
 
94
			status.setStyleName("status");
Line 85... Line -...
85
					HasVerticalAlignment.ALIGN_MIDDLE);
-
 
86
			buttons.setCellWidth(status, "100%");
-
 
87
 
-
 
Line -... Line 95...
-
 
95
			
Line 88... Line 96...
88
 
96
			
Line 89... Line -...
89
			buttons.add(gotoFirst);
-
 
Line 90... Line 97...
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%");
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);
-
 
135
	}
-
 
Line -... Line 139...
-
 
139
 
-
 
140
	// Fin Barre de navigation
136
 
141
 
137
	private static final int VISIBLE_TAXON_COUNT = 15;
-
 
138
	
142
 
139
 
-
 
140
 
143
 
Line 141... Line -...
141
	private Grid header = new Grid(1, 3);
-
 
Line -... Line 144...
-
 
144
	// Conteneur (header et table sont dans panel)
142
 
145
	
143
	private FlexTable table = new FlexTable();
-
 
144
 
-
 
145
	private VerticalPanel panel = new VerticalPanel();
-
 
146
 
146
	private Grid header = new Grid(1, 3);
147
	private int startIndex = 0;
-
 
148
 
-
 
149
	private String serviceBaseUrl = null;
-
 
150
 
147
	private FlexTable table = new FlexTable();
Line -... Line 148...
-
 
148
	private VerticalPanel panel = new VerticalPanel();
-
 
149
 
-
 
150
 
-
 
151
	// Services 
-
 
152
	private String serviceBaseUrl = null;
151
	private int count = 65000;
153
	private String user;
-
 
154
	private Mediator mediator = null;
-
 
155
 
Line 152... Line 156...
152
 
156
	// Navigation
153
	private String user;
157
	private int startIndex = 0;
154
 
158
	private int count = 0;
155
	private NavBar navBar=null;
159
	private static final int VISIBLE_TAXON_COUNT = 15;
Line -... Line 160...
-
 
160
	private NavBar navBar=null;
156
	
161
	private int  selectedRow = -1;
-
 
162
 
-
 
163
	// Filtre par defaut :
-
 
164
	
Line 157... Line 165...
157
	private Mediator mediator = null;
165
	private String location = "all";
158
 
-
 
159
	private int  selectedRow = -1;
166
	private String date = "all";
160
	
167
	private String search = "all";
161
	private String location = "all";
168
	private String station = "all";
162
	private String date = "all";
169
 
Line -... Line 170...
-
 
170
 
-
 
171
	public InventoryItemList(Mediator med) {
163
	private String search = "all";
172
		
Line 164... Line -...
164
	private String station = "all";
-
 
165
 
-
 
166
	public InventoryItemList(Mediator med) {
-
 
167
 
-
 
168
		mediator=med;
173
		
Line 169... Line 174...
169
		
174
		// Traitement contexte utilisateur et service
170
	    mediator.registerInventoryItemList(this);
175
 
171
		
176
		mediator=med;
Line 172... Line 177...
172
		user=mediator.getUser();
177
	    mediator.registerInventoryItemList(this);
Line 173... Line 178...
173
	    serviceBaseUrl = mediator.getServiceBaseUrl();
178
	    
Line 174... Line 179...
174
	
179
		user=mediator.getUser();
Line 175... Line 180...
175
		navBar = new NavBar();
180
	    serviceBaseUrl = mediator.getServiceBaseUrl();
176
		
181
	
177
 
182
	    // Barre navigation integree au header 
178
		// Information complementaire : un tableau associe au retour de
183
	    
Line 179... Line -...
179
		// l'assistant de saisie
-
 
180
 
-
 
181
		// Mise en forme du header
-
 
182
 
-
 
183
		header.setCellSpacing(0);
184
		navBar = new NavBar();
Line 184... Line -...
184
		header.setCellPadding(2);
-
 
185
		header.setWidth("100%");
185
		
186
 
186
		// Mise en forme du header
Line 187... Line -...
187
		header.setStyleName("inventoryItem-ListHeader");
-
 
188
 
187
 
Line 189... Line 188...
189
		header.setWidget(0, 2, navBar);
188
		header.setCellSpacing(0);
Line 190... Line 189...
190
 
189
		header.setCellPadding(2);
-
 
190
		header.setWidth("100%");
191
		// Mise en forme de la table.
191
 
192
 
192
		header.setStyleName("inventoryItem-ListHeader");
193
		table.setCellSpacing(0);
193
 
-
 
194
		header.setWidget(0, 2, navBar);
-
 
195
 
-
 
196
		// Mise en forme de la table (contenu)
-
 
197
 
-
 
198
		table.setCellSpacing(0);
-
 
199
		table.setBorderWidth(0);
-
 
200
		table.setCellPadding(2);
-
 
201
		table.setWidth("100%");
194
		table.setBorderWidth(0);
202
		
195
		table.setCellPadding(2);
203
 
Line 196... Line 204...
196
		table.setWidth("100%");
204
		table.setStyleName("inventoryItem-List");
Line 197... Line -...
197
		
-
 
198
 
-
 
199
		// Mise en forme barre navigation
-
 
200
 
-
 
201
		navBar.setWidth("100%");
205
 
Line 202... Line -...
202
 
-
 
203
		table.setStyleName("inventoryItem-List");
206
		panel.add(header);
Line -... Line 207...
-
 
207
		panel.add(table);
-
 
208
 
-
 
209
		
-
 
210
	    table.addTableListener(new TableListener () {
204
 
211
	    	
205
		//panel.add(navBar);
212
			  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
-
 
213
				   
Line 206... Line 214...
206
		panel.add(header);
214
				  if ((table.getWidget(row, 0)!=null) && (cell>0)){
207
		panel.add(table);
215
					  if (row!=selectedRow) {
208
 
-
 
209
		
216
						  selectRow(row);
Line 210... Line 217...
210
		 // Hook up events.
217
						  // Numero d'ordre
Line 211... Line -...
211
	    table.addTableListener(new TableListener () {
-
 
212
	    	
218
						  mediator.onInventoryItemSelected(table.getText(row, 5));
213
			  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
219
					  }
214
				   
220
					  // Deselection 
215
				  if ((table.getWidget(row, 0)!=null) && (cell>0)){
221
					  else {
216
				      selectRow(row);
222
						   styleRow(row, false);
217
				      // Numero d'ordre
223
						   selectedRow=-1;
218
				      mediator.onInventoryItemSelected(table.getText(row, 5));
224
						   // Numero d'ordre
219
				  }
225
						 mediator.onInventoryItemUnselected(table.getText(row, 5));
220
			  }
226
					  }
221
 
227
				  }
222
	    });
-
 
Line 223... Line -...
223
	    
-
 
224
 
-
 
225
		//updateCount();
-
 
226
		// update()
-
 
227
 
-
 
228
		
-
 
229
		initWidget(panel);
-
 
230
		
-
 
231
 
-
 
232
 
-
 
233
	}
-
 
234
	
-
 
235
	
-
 
236
	 
-
 
237
	  private void selectRow(int row) {
-
 
238
		  
-
 
239
		    styleRow(selectedRow, false);
-
 
240
		    styleRow(row, true);
228
			  }
241
 
-
 
242
		    selectedRow = row;
-
 
243
		    
229
 
244
		  }
230
	    });
245
		  
-
 
246
		  
231
	    
247
		  private void styleRow(int row, boolean selected) {
-
 
248
			    if (row != -1) {
-
 
249
			      if (selected)
232
 
250
			        table.getRowFormatter().addStyleName(row, "inventoryItem-SelectedRow");
-
 
251
			      else
-
 
252
			    	if (row < table.getRowCount()) { 
-
 
253
			    		table.getRowFormatter().removeStyleName(row, "inventoryItem-SelectedRow");
-
 
254
			    	}
-
 
255
			    }
-
 
256
			  }
-
 
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
233
		initWidget(panel);
Line 265... Line 234...
265
		 */
234
		
266
		  
235
 
Line 267... Line 236...
267
		public void onComplete(ResponseTextHandler sender, String str, String value) {
236
	}
Line 268... Line 237...
268
			
237
	
-
 
238
	
-
 
239
	/**
Line 269... Line 240...
269
			if (sender instanceof NameAssistant) {
240
	 * Gestion affichage selection/deselection d'un element d'inventaire
Line 270... Line 241...
270
				mediator.onNameCompleted(value);
241
	 * 
271
			}
242
	 */
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()
-
 
373
						.setWidth(row, 1, "31%");*/
334
		setStatusDisabled();
374
				
335
		
Line 375... Line 336...
375
				// Recherche complement d'information
336
				// Creation d'un nom faisant parti du referentiel : recherche du nom valide correspondant
376
		
337
 
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
			}
-
 
455
		});
-
 
456
	}
Line 493... Line 457...
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
500
 
462
	 * 
501
	
463
	 */
502
	
464
 
Line 503... Line -...
503
	public void transmitElement() {
-
 
504
	
-
 
505
		setStatusDisabled();
465
	public void deleteElement() {
506
		Vector parseChecked = new Vector();
466
 
507
 
467
		setStatusDisabled();
508
		// TODO : optimiser
468
		Vector parseChecked = new Vector();
509
		// Lifo ...
469
 
-
 
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
		}
478
		}
518
		StringBuffer ids=new StringBuffer();
-
 
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();) {
521
			if (it.hasNext()) ids.append(",");
481
			ids.append((String)it.next());
522
		}
482
			if (it.hasNext()) ids.append(",");
Line 523... Line 483...
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
527
							+ "/" + ids.toString(), "transmission=1",
487
							+ "/" + ids.toString(), "action=DELETE",
528
							
488
							
Line 529... Line 489...
529
							new ResponseTextHandler() {
489
							new ResponseTextHandler() {
Line 530... Line -...
530
								public void onCompletion(String str) {
-
 
531
											update();
490
								public void onCompletion(String str) {
Line -... Line 491...
-
 
491
											mediator.onInventoryUpdated(location);
-
 
492
								}
532
								}
493
							});
533
							});
494
		}
534
		}
-
 
535
	
495
	
Line -... Line 496...
-
 
496
		setStatusEnabled();
536
		setStatusEnabled();
497
 
537
 
498
	}
538
		
499
	
539
	}
500
	
Line 540... Line -...
540
	
-
 
541
	
-
 
542
	/**
501
	
543
	 * Suppression d'un element lde l'inventaire, a partir de son numero d'ordre
502
	
544
	 * 
503
	/**
545
	 */
504
	 * Transmission de releve a Tela  (TODO : a appeler par Mediator)
546
 
505
	 */
547
	public void deleteElement() {
-
 
548
 
506
 
549
		setStatusDisabled();
507
	
550
		Vector parseChecked = new Vector();
508
	public void transmitElement() {
-
 
509
	
551
 
510
		setStatusDisabled();
552
		// TODO : optimiser
511
		Vector parseChecked = new Vector();
553
		// Lifo ...
512
 
554
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
513
		for (int i = table.getRowCount() - 1; i >= 0; i--) {
555
			 if (table.getWidget(i, 0)!=null) {
514
			 if (table.getWidget(i, 0)!=null) {
-
 
515
				 if (((CheckBox) table.getWidget(i, 0)).isChecked()) {
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--;
519
			 }
Line 560... Line 520...
560
				 }
520
		}
561
			 }
521
		
562
		}
522
		StringBuffer ids=new StringBuffer();
563
		StringBuffer ids=new StringBuffer();
-
 
564
		for (Iterator it = parseChecked.iterator(); it.hasNext();) {
523
		for (Iterator it = parseChecked.iterator(); it.hasNext();) {
565
			ids.append((String)it.next());
524
			ids.append((String)it.next());
566
			if (it.hasNext()) ids.append(",");
525
			if (it.hasNext()) ids.append(",");
Line 567... Line 526...
567
		}
526
		}
-
 
527
		
-
 
528
		if (ids.length()>0) {
568
		if (ids.length()>0) {
529
		
Line -... Line 530...
-
 
530
			HTTPRequest.asyncPost(serviceBaseUrl + "/InventoryTransmit/" + user
-
 
531
							+ "/" + ids.toString(), "transmission=1",
569
			
532
							
570
			HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
533
							new ResponseTextHandler() {
571
							+ "/" + ids.toString(), "action=DELETE",
534
								public void onCompletion(String str) {
572
							
535
											update(); // Pour affichage logo 
Line 573... Line 536...
573
							new ResponseTextHandler() {
536
								}
Line 574... Line -...
574
								public void onCompletion(String str) {
-
 
575
											mediator.onInventoryUpdated("all");
537
							});
576
											updateCount();
538
		}
577
								}
539
	
578
							});
540
		setStatusEnabled();
579
		}
541
 
Line 580... Line 542...
580
	
542
		
Line 581... Line -...
581
		setStatusEnabled();
-
 
582
	}
543
	}
583
	
544
	
584
	/**
545
	
585
	 * Selection de l'ensemble des elements affichés
546
	
586
	 * 
547
	/**
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	() {
-
 
576
		
-
 
577
		setStatusDisabled();
-
 
578
 
Line 614... Line 579...
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)+ " ...";
-
 
609
	} 
658
	 */
610
 
-
 
611
	/**
Line 659... Line -...
659
 
-
 
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
	 * 
664
		
616
	 */
665
		mediator.getActionPanel().getExportButton().setHTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/" 
617
 
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";
-
 
Line 680... Line -...
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
		
-
 
712
		String stat;
-
 
713
		
618
	public void update() {
714
		if (station.compareTo("all")==0) {
619
 
Line 715... Line 620...
715
			stat=", toutes stations";
620
		
Line 716... Line 621...
716
		}
621
		
Line 717... Line 622...
717
		else {
622
//		table.setBorderWidth(1); // Debug
718
			if (station.compareTo("000null")==0) {
623
	
719
				stat=", stations non renseign&eacute;es";
624
		
Line 720... Line -...
720
			}
-
 
721
			else {
-
 
722
				stat=", station "+ station;
-
 
723
			}
-
 
724
		}
-
 
725
	
-
 
Line 726... Line 625...
726
		
625
//      Ligne d'information 
727
		header.setHTML(0, 0, com +  dat + stat );
626
		
728
		
627
		setStatusDisabled();
-
 
628
		
-
 
629
		String adate="all";
-
 
630
		if (date.compareTo("all")!=0) {
-
 
631
			adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
-
 
632
		}
729
		HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + location +"/" + adate + "/" + search + "/" + station + "/"
633
 
-
 
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() {
733
 
638
 
734
			public void onCompletion(String str) {
639
			public void onCompletion(String str) {
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 1023... Line 912...
1023
	
912
	
1024
	public void setSearch(String search) {
913
	public void setSearch(String search) {
1025
		this.search = search;
914
		this.search = search;
Line 1026... Line -...
1026
	}
-
 
Line 1027... Line 915...
1027
 
915
	}
1028
 
916
 
1029
	
917
	
1030
	/*
918
	/*
Line 1035... Line 923...
1035
	public void setLocation(String location) {
923
	public void setLocation(String location) {
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
	 * 
Line 1038... Line 944...
1038
 
944
	 */
1039
 
945
	
1040
 
946
 
Line -... Line 947...
-
 
947
	public void setDate(String date) {
-
 
948
		this.date = date;
-
 
949
	}
-
 
950
 
-
 
951
	
-
 
952
	/*
Line -... Line 953...
-
 
953
	 * Utilisateur en cours 
1041
	public void setDate(String date) {
954
	 * 
1042
		this.date = date;
955
	 */
1043
	}
956
	
-
 
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
	}
-
 
972
 
-
 
973
 
-
 
974
	public String getSearch() {
-
 
975
		return search;
-
 
976
	}
-
 
977
 
-
 
978
 
-
 
979
	public String getStation() {
-
 
980
		return station;
-
 
981
	}
Line 1044... Line 982...
1044
 
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) {
1045
 
1008
		com="Toutes communes";
-
 
1009
	}
-
 
1010
	else {
-
 
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";
-
 
1024
	}
1046
	public void setUser(String user) {
1025
	else {
Line -... Line 1026...
-
 
1026
		if (date.compareTo("00/00/0000")==0) {
-
 
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
	}
Line -... Line 1040...
-
 
1040
	else {
-
 
1041
		if (station.compareTo("000null")==0) {
Line -... Line 1042...
-
 
1042
			stat=", stations non renseign&eacute;es";
-
 
1043
		}
-
 
1044
		else {
Line 1047... Line 1045...
1047
		this.user = user;
1045
			stat=", station "+ station;
-
 
1046
		}
-
 
1047
	}
-
 
1048
 
-
 
1049
	
1048
	}
1050
	header.setHTML(0, 0, com +  dat + stat );