Subversion Repositories eFlore/Archives.cel-v1

Rev

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

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