Subversion Repositories eFlore/Archives.cel-v1

Rev

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

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