Subversion Repositories eFlore/Archives.cel-v1

Rev

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

Rev 14 Rev 26
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
 
18
 
19
import com.google.gwt.json.client.JSONArray;
19
import com.google.gwt.json.client.JSONArray;
20
import com.google.gwt.json.client.JSONNumber;
20
import com.google.gwt.json.client.JSONNumber;
21
import com.google.gwt.json.client.JSONParser;
21
import com.google.gwt.json.client.JSONParser;
22
import com.google.gwt.json.client.JSONString;
22
import com.google.gwt.json.client.JSONString;
23
import com.google.gwt.json.client.JSONValue;
23
import com.google.gwt.json.client.JSONValue;
24
import com.google.gwt.user.client.HTTPRequest;
24
import com.google.gwt.user.client.HTTPRequest;
25
import com.google.gwt.user.client.ResponseTextHandler;
25
import com.google.gwt.user.client.ResponseTextHandler;
26
import com.google.gwt.user.client.ui.Button;
26
import com.google.gwt.user.client.ui.Button;
27
import com.google.gwt.user.client.ui.ClickListener;
27
import com.google.gwt.user.client.ui.ClickListener;
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.DockPanel;
29
import com.google.gwt.user.client.ui.DockPanel;
30
import com.google.gwt.user.client.ui.FlexTable;
30
import com.google.gwt.user.client.ui.FlexTable;
31
import com.google.gwt.user.client.ui.Grid;
31
import com.google.gwt.user.client.ui.Grid;
32
import com.google.gwt.user.client.ui.HTML;
32
import com.google.gwt.user.client.ui.HTML;
33
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
33
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
34
import com.google.gwt.user.client.ui.HasVerticalAlignment;
34
import com.google.gwt.user.client.ui.HasVerticalAlignment;
35
import com.google.gwt.user.client.ui.HorizontalPanel;
35
import com.google.gwt.user.client.ui.HorizontalPanel;
36
import com.google.gwt.user.client.ui.SourcesTableEvents;
36
import com.google.gwt.user.client.ui.SourcesTableEvents;
37
import com.google.gwt.user.client.ui.TableListener;
37
import com.google.gwt.user.client.ui.TableListener;
38
import com.google.gwt.user.client.ui.VerticalPanel;
38
import com.google.gwt.user.client.ui.VerticalPanel;
39
import com.google.gwt.user.client.ui.Widget;
39
import com.google.gwt.user.client.ui.Widget;
40
 
40
 
41
/**
41
/**
42
 * A tree displaying a set of email folders.
42
 * A tree displaying a set of email folders.
43
 */
43
 */
44
public class LocationList extends Composite {
44
public class LocationList extends Composite {
45
	
45
	
46
	
46
	
47
	
47
	
48
	// Barre de navigation
48
	// Barre de navigation
49
 
49
 
50
	private class NavBar extends Composite implements ClickListener {
50
	private class NavBar extends Composite implements ClickListener {
51
 
51
 
52
		public final DockPanel bar = new DockPanel();
52
		public final DockPanel bar = new DockPanel();
53
 
53
 
54
		public final Button gotoFirst = new Button("<<", this);
54
		public final Button gotoFirst = new Button("<<", this);
55
 
55
 
56
		public final Button gotoNext = new Button(">", this);
56
		public final Button gotoNext = new Button(">", this);
57
 
57
 
58
		public final Button gotoPrev = new Button("<", this);
58
		public final Button gotoPrev = new Button("<", this);
59
 
59
 
60
		public final Button gotoEnd = new Button(">>", this);
60
		public final Button gotoEnd = new Button(">>", this);
61
 
61
 
62
		public final HTML status = new HTML();
62
		public final HTML status = new HTML();
63
		
63
		
64
 
64
 
65
		public NavBar() {
65
		public NavBar() {
66
			initWidget(bar);
66
			initWidget(bar);
67
			bar.setStyleName("navbar");
67
			bar.setStyleName("navbar");
68
			status.setStyleName("status");
68
			status.setStyleName("status");
69
			status.setWordWrap(false);
69
			status.setWordWrap(false);
70
			
70
			
71
			HorizontalPanel buttons = new HorizontalPanel();
71
			HorizontalPanel buttons = new HorizontalPanel();
72
			
72
			
73
			buttons.add(status);
73
			buttons.add(status);
74
			buttons.setCellHorizontalAlignment(status,
74
			buttons.setCellHorizontalAlignment(status,
75
					HasHorizontalAlignment.ALIGN_RIGHT);
75
					HasHorizontalAlignment.ALIGN_RIGHT);
76
			buttons.setCellVerticalAlignment(status,
76
			buttons.setCellVerticalAlignment(status,
77
					HasVerticalAlignment.ALIGN_MIDDLE);
77
					HasVerticalAlignment.ALIGN_MIDDLE);
78
			buttons.setCellWidth(status, "100%");
78
			buttons.setCellWidth(status, "100%");
79
 
79
 
80
 
80
 
81
			buttons.add(gotoFirst);
81
			buttons.add(gotoFirst);
82
			buttons.add(gotoPrev);
82
			buttons.add(gotoPrev);
83
			buttons.add(gotoNext);
83
			buttons.add(gotoNext);
84
			buttons.add(gotoEnd);
84
			buttons.add(gotoEnd);
85
			bar.add(buttons, DockPanel.EAST);
85
			bar.add(buttons, DockPanel.EAST);
86
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
86
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
87
			
87
			
88
			
88
			
89
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT);
89
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_LEFT);
90
 
90
 
91
			bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
91
			bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
92
			
92
			
93
					
93
					
94
			
94
			
95
	
95
	
96
			
96
			
97
		}
97
		}
98
 
98
 
99
		public void onClick(Widget sender) {
99
		public void onClick(Widget sender) {
100
			if (sender == gotoNext) {
100
			if (sender == gotoNext) {
101
				// Move forward a page.
101
				// Move forward a page.
102
				startIndex += VISIBLE_LOCATION_COUNT;
102
				startIndex += VISIBLE_LOCATION_COUNT;
103
				if (startIndex >= count)
103
				if (startIndex >= count)
104
					startIndex -= VISIBLE_LOCATION_COUNT;
104
					startIndex -= VISIBLE_LOCATION_COUNT;
105
			} else {
105
			} else {
106
				if (sender == gotoPrev) {
106
				if (sender == gotoPrev) {
107
					// Move back a page.
107
					// Move back a page.
108
					startIndex -= VISIBLE_LOCATION_COUNT;
108
					startIndex -= VISIBLE_LOCATION_COUNT;
109
					if (startIndex < 0)
109
					if (startIndex < 0)
110
						startIndex = 0;
110
						startIndex = 0;
111
				} else {
111
				} else {
112
					if (sender == gotoEnd) {
112
					if (sender == gotoEnd) {
113
						gotoEnd();
113
						gotoEnd();
114
					} else {
114
					} else {
115
						if (sender == gotoFirst) {
115
						if (sender == gotoFirst) {
116
							startIndex = 0;
116
							startIndex = 0;
117
						}
117
						}
118
					}
118
					}
119
				}
119
				}
120
			}
120
			}
121
			update();
121
			update();
122
		}
122
		}
123
 
123
 
124
	}
124
	}
125
 
125
 
126
 
126
 
127
 
127
 
128
		private static final int VISIBLE_LOCATION_COUNT = 10;
128
		private static final int VISIBLE_LOCATION_COUNT = 10;
129
		private static final String VALUE_UNKNOWN = "Inconnues";
129
		private static final String VALUE_UNKNOWN = "Inconnues";
130
 
130
 
131
		private Grid header = new Grid(1, 2);
131
		private Grid header = new Grid(1, 2);
132
		
132
		
133
		private Grid selector = new Grid(1, 1);
133
		private Grid selector = new Grid(1, 1);
134
 
134
 
135
		private FlexTable table = new FlexTable();
135
		private FlexTable table = new FlexTable();
136
 
136
 
137
		private VerticalPanel outer = new VerticalPanel();
137
		private VerticalPanel outer = new VerticalPanel();
138
		private VerticalPanel inner = new VerticalPanel();
138
		private VerticalPanel inner = new VerticalPanel();
139
 
139
 
140
		private int startIndex = 0;
140
		private int startIndex = 0;
141
 
141
 
142
		private String user;
142
		private String user;
143
 
143
 
144
		private String serviceBaseUrl = null;
144
		private String serviceBaseUrl = null;
145
 
145
 
146
		private String location = "all";
146
		private String location = "all";
147
 
147
 
148
		private NavBar navBar=null;
148
		private NavBar navBar=null;
149
 
-
 
150
		
149
 
151
		private int count = 65000;
150
		private int count = 0;
152
		
151
		
153
		// Tous selectionné 
152
		// Tous selectionné 
154
		private int  selectedRow = -1;
153
		private int  selectedRow = -1;
155
		
154
		
156
		private Mediator mediator = null;
155
		private Mediator mediator = null;
157
 
156
 
158
		
157
		
159
		public LocationList(Mediator med) {
158
		public LocationList(Mediator med) {
160
			
159
			
161
			mediator=med;
160
			mediator=med;
162
 
161
 
163
			mediator.registerLocationList(this);
162
			mediator.registerLocationList(this);
164
 
163
 
165
			user=mediator.getUser();
164
			user=mediator.getUser();
166
			serviceBaseUrl = mediator.getServiceBaseUrl();
165
			serviceBaseUrl = mediator.getServiceBaseUrl();
167
			
166
			
168
			navBar = new NavBar();
167
			navBar = new NavBar();
169
			
168
			
170
			// Mise en forme du header
169
			// Mise en forme du header
171
 
170
 
172
			header.setCellSpacing(0);
171
			header.setCellSpacing(0);
173
			header.setCellPadding(2);
172
			header.setCellPadding(2);
174
			header.setWidth("100%");
173
			header.setWidth("100%");
175
 
174
 
176
			header.setStyleName("location-ListHeader");
175
			header.setStyleName("location-ListHeader");
177
 
176
 
178
			
177
			
179
			header.setWidget(0, 1,navBar);
178
			header.setWidget(0, 1,navBar);
180
			
179
			
181
 
180
 
182
 
181
 
183
			// Mise en forme de l'entree "Toutes localités"
182
			// Mise en forme de l'entree "Toutes localités"
184
 
183
 
185
			selector.setCellSpacing(0);
184
			selector.setCellSpacing(0);
186
			selector.setCellPadding(0);
185
			selector.setCellPadding(0);
187
			selector.setWidth("100%");
186
			selector.setWidth("100%");
188
 
187
 
189
			selector.setHTML(0, 0, "Toutes");
188
			selector.setHTML(0, 0, "Toutes");
190
 
189
 
191
			selector.getCellFormatter().setWidth(0, 0, "100%");
190
			selector.getCellFormatter().setWidth(0, 0, "100%");
192
 
191
 
193
 
192
 
194
			 // Hook up events.
193
			 // Hook up events.
195
			selector.addTableListener(new TableListener () {
194
			selector.addTableListener(new TableListener () {
196
		    	
195
		    	
197
				  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
196
				  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
198
					  	styleRow(selectedRow, false);
197
					  	styleRow(selectedRow, false);
199
				        selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
198
				        selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
200
					    mediator.onLocationSelected("all");
199
					    mediator.onLocationSelected("all");
201
					  }
200
					  }
202
 
201
 
203
		    });
202
		    });
204
			
203
			
205
			selector.setStyleName("location-ListElement");
204
			selector.setStyleName("location-ListElement");
206
 
205
 
207
			
206
			
208
			// Mise en forme du contenu 
207
			// Mise en forme du contenu 
209
 
208
 
210
			table.setCellSpacing(0);
209
			table.setCellSpacing(0);
211
			table.setBorderWidth(0);
210
			table.setBorderWidth(0);
212
			table.setCellPadding(2);
211
			table.setCellPadding(2);
213
			table.setWidth("100%");
212
			table.setWidth("100%");
214
 
213
 
215
			table.setStyleName("location-ListElement");
214
			table.setStyleName("location-ListElement");
216
 
215
 
217
			// Mise en forme barre navigation
216
			// Mise en forme barre navigation
218
			
217
			
219
			navBar.setWidth("100%");
218
			navBar.setWidth("100%");
220
			
219
			
221
			outer.add(header);
220
			outer.add(header);
222
			inner.add(selector); // Toutes localités
221
			inner.add(selector); // Toutes localités
223
			inner.add(table);
222
			inner.add(table);
224
			inner.setStyleName("location-List");
223
			inner.setStyleName("location-List");
225
			inner.setWidth("100%");
224
			inner.setWidth("100%");
226
			outer.setWidth("100%");
225
			outer.setWidth("100%");
227
			outer.add(inner);
226
			outer.add(inner);
228
			
227
			
229
			 // Hook up events.
228
			 // Hook up events.
230
		    table.addTableListener(new TableListener () {
229
		    table.addTableListener(new TableListener () {
231
		    	
230
		    	
232
				  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
231
				  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
233
					  
232
					  
234
					      selectRow(row);
233
					      selectRow(row);
235
					      String loc=table.getText(row,cell);
234
					      String loc=table.getText(row,cell);
236
					      if (loc.compareTo(VALUE_UNKNOWN)!=0) {
235
					      if (loc.compareTo(VALUE_UNKNOWN)!=0) {
237
					    	  location=loc;
236
					    	  location=loc;
238
					    	  mediator.onLocationSelected(table.getText(row,cell));
237
					    	  mediator.onLocationSelected(table.getText(row,cell));
239
					      }
238
					      }
240
					      else {
239
					      else {
241
					    	  location="000null";
240
					    	  location="000null";
242
					    	  mediator.onLocationSelected("000null");
241
					    	  mediator.onLocationSelected("000null");
243
					      }
242
					      }
244
					    
243
					    
245
					  }
244
					  }
246
 
245
 
247
		    });
246
		    });
248
		    
247
		    
249
		  	styleRow(selectedRow, false);
248
		  	styleRow(selectedRow, false);
250
	        selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
249
	        selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
251
		   // mediator.onLocationSelected("all");
250
		   // mediator.onLocationSelected("all");
252
		    		
251
		    		
253
		    
252
		    
254
			//updateCount();
253
			//updateCount();
255
			// update()
254
			// update()
256
			
255
			
257
			initWidget(outer);
256
			initWidget(outer);
258
 
257
 
259
 
258
 
260
  }
259
  }
261
 
260
 
262
		/**
261
		/**
263
		 * Recherche nombre d'enregistrement pour l'utilisateur en cours
262
		 * Recherche nombre d'enregistrement pour l'utilisateur en cours
264
		 * 
263
		 * 
265
		 * 
264
		 * 
266
		 */
265
		 */
267
		
266
		
268
		public void updateCount() {
267
		public void updateCount() {
269
			
268
			
270
			setStatusDisabled();
269
			setStatusDisabled();
271
 
270
 
272
//			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/"  ,
271
//			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/"  ,
273
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user ,
272
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user ,
274
					new ResponseTextHandler() {
273
					new ResponseTextHandler() {
275
 
274
 
276
						public void onCompletion(String str) {
275
						public void onCompletion(String str) {
277
							JSONValue jsonValue = JSONParser.parse(str);
276
							JSONValue jsonValue = JSONParser.parse(str);
278
							JSONNumber jsonNumber;
277
							JSONNumber jsonNumber;
279
							if ((jsonNumber = jsonValue.isNumber()) != null) {
278
							if ((jsonNumber = jsonValue.isNumber()) != null) {
280
								count = (int) jsonNumber.getValue();
279
								count = (int) jsonNumber.getValue();
281
								update();
280
								update();
282
							}
281
							}
283
						}
282
						}
284
					});
283
					});
285
 
284
 
286
		}
285
		}
287
 
286
 
288
	
287
	
289
		  private void selectRow(int row) {
288
		  private void selectRow(int row) {
290
			  
289
			  
291
		    styleRow(selectedRow, false);
290
		    styleRow(selectedRow, false);
292
		    styleRow(row, true);
291
		    styleRow(row, true);
293
 
292
 
294
		    selectedRow = row;
293
		    selectedRow = row;
295
		    
294
		    
296
		  }
295
		  }
297
		  
296
		  
298
		  
297
		  
299
		  private void styleRow(int row, boolean selected) {
298
		  private void styleRow(int row, boolean selected) {
300
			    if (row != -1) {
299
			    if (row != -1) {
301
				   selector.getRowFormatter().removeStyleName(0, "location-SelectedRow");
300
				   selector.getRowFormatter().removeStyleName(0, "location-SelectedRow");
302
			      if (selected)
301
			      if (selected)
303
			        table.getRowFormatter().addStyleName(row, "location-SelectedRow");
302
			        table.getRowFormatter().addStyleName(row, "location-SelectedRow");
304
			      else
303
			      else
305
			    	if (row < table.getRowCount()) { 
304
			    	if (row < table.getRowCount()) { 
306
			    		table.getRowFormatter().removeStyleName(row, "location-SelectedRow");
305
			    		table.getRowFormatter().removeStyleName(row, "location-SelectedRow");
307
			    	}
306
			    	}
308
			    }
307
			    }
309
			  }
308
			  }
310
 
309
 
311
		  
310
		  
312
	/**
311
	/**
313
	 * 
312
	 * 
314
	 * Mise a jour de l'affichage, à partir des données d'inventaire deja
313
	 * Mise a jour de l'affichage, à partir des données d'inventaire deja
315
	 * saisies. La valeur de this.startIndex permet de determiner quelles
314
	 * saisies. La valeur de this.startIndex permet de determiner quelles
316
	 * données seront affichées
315
	 * données seront affichées
317
	 * 
316
	 * 
318
	 */	
317
	 */	
319
 
318
 
320
		public void update() {
319
		public void update() {
321
 
320
 
322
			
321
			
323
			setStatusDisabled();
322
			setStatusDisabled();
324
 
323
 
325
//			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/" +  
324
//			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/" +  
326
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" +  
325
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" +  
327
					+ startIndex + "/" + VISIBLE_LOCATION_COUNT,
326
					+ startIndex + "/" + VISIBLE_LOCATION_COUNT,
328
 
327
 
329
			new ResponseTextHandler() {
328
			new ResponseTextHandler() {
330
 
329
 
331
				public void onCompletion(String str) {
330
				public void onCompletion(String str) {
332
 
331
 
333
					JSONValue jsonValue = JSONParser.parse(str);
332
					JSONValue jsonValue = JSONParser.parse(str);
334
					JSONArray jsonArray;
333
					JSONArray jsonArray;
335
					JSONArray jsonArrayNested;
334
					JSONArray jsonArrayNested;
336
			
335
			
337
					int row=0;
336
					int row=0;
338
					int i=0;
337
					int i=0;
339
					
338
					
340
					if ((jsonArray = jsonValue.isArray()) != null) {
339
					if ((jsonArray = jsonValue.isArray()) != null) {
341
						int arraySize = jsonArray.size();
340
						int arraySize = jsonArray.size();
342
						for (i = 0; i < arraySize; ++i) {
341
						for (i = 0; i < arraySize; ++i) {
343
							if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
342
							if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
344
								if (i>=table.getRowCount()) {
343
								if (i>=table.getRowCount()) {
345
									 row = table.insertRow(table.getRowCount());
344
									 row = table.insertRow(table.getRowCount());
346
								}
345
								}
347
								else {
346
								else {
348
									row = i;
347
									row = i;
349
								}
348
								}
350
								// Lieu
349
								// Lieu
351
							    	
350
							    	
352
								String loc=((JSONString)jsonArrayNested.get(0)).stringValue();
351
								String loc=((JSONString)jsonArrayNested.get(0)).stringValue();
353
								
352
								
354
								if (loc.compareTo("000null")!=0) {
353
								if (loc.compareTo("000null")!=0) {
355
									table.setText(row, 0,loc); 
354
									table.setText(row, 0,loc); 
356
								}
355
								}
357
								else {
356
								else {
358
									table.setText(row, 0,VALUE_UNKNOWN);
357
									table.setText(row, 0,VALUE_UNKNOWN);
359
								}
358
								}
360
								
359
								
361
								if (loc.compareTo(location)==0) {
360
								if (loc.compareTo(location)==0) {
362
								  styleRow(row, true);
361
								  styleRow(row, true);
363
								}
362
								}
364
								else {
363
								else {
365
								  styleRow(row, false);
364
								  styleRow(row, false);
366
								}
365
								}
367
 
366
 
368
								table.getFlexCellFormatter().setWidth(row, 0, "100%");
367
								table.getFlexCellFormatter().setWidth(row, 0, "100%");
369
							}
368
							}
370
 
369
 
371
						}
370
						}
372
					}
371
					}
373
					
372
					
374
					if (location.compareTo("all")==0) {
373
					if (location.compareTo("all")==0) {
375
							selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
374
							selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
376
					}
375
					}
377
 
376
 
378
					
377
					
379
					// Suppression fin ancien affichage
378
					// Suppression fin ancien affichage
380
					if (i<table.getRowCount()) {
379
					if (i<table.getRowCount()) {
381
						 for (int j = table.getRowCount() -1 ; j >= i; j--) {
380
						 for (int j = table.getRowCount() -1 ; j >= i; j--) {
382
							 table.removeRow(j);
381
							 table.removeRow(j);
383
						 }
382
						 }
384
					}
383
					}
385
 
384
 
386
					setStatusEnabled();
385
					setStatusEnabled();
387
 
386
 
388
 
387
 
389
				}
388
				}
390
			});
389
			});
391
 
390
 
392
		}
391
		}
393
 
392
 
394
		public void setLocation(String location) {
393
		public void setLocation(String location) {
395
			this.location = location;
394
			this.location = location;
396
		}
395
		}
397
		
396
		
398
		
397
		
399
			
398
			
400
		/*
399
		/*
401
		 * Positionnement index de parcours (this.startIndex) pour affichage de la
400
		 * Positionnement index de parcours (this.startIndex) pour affichage de la
402
		 * dernière page
401
		 * dernière page
403
		 * 
402
		 * 
404
		 * @param
403
		 * @param
405
		 * @return void
404
		 * @return void
406
		 */
405
		 */
407
 
406
 
408
		private void gotoEnd() {
407
		private void gotoEnd() {
409
 
408
 
410
			if ((count == 0) || (count % VISIBLE_LOCATION_COUNT) > 0) {
409
			if ((count == 0) || (count % VISIBLE_LOCATION_COUNT) > 0) {
411
				startIndex = count - (count % VISIBLE_LOCATION_COUNT);
410
				startIndex = count - (count % VISIBLE_LOCATION_COUNT);
412
			} else {
411
			} else {
413
				startIndex = count - VISIBLE_LOCATION_COUNT;
412
				startIndex = count - VISIBLE_LOCATION_COUNT;
414
			}
413
			}
415
 
414
 
416
		}
415
		}
417
		
416
		
418
		
417
		
419
		/**
418
		/**
420
		 * Affichage message d'attente et désactivation navigation
419
		 * Affichage message d'attente et désactivation navigation
421
		 * 
420
		 * 
422
		 * @param
421
		 * @param
423
		 * @return void
422
		 * @return void
424
		 */
423
		 */
425
 
424
 
426
		private void setStatusDisabled() {
425
		private void setStatusDisabled() {
427
 
426
 
428
			navBar.gotoFirst.setEnabled(false);
427
			navBar.gotoFirst.setEnabled(false);
429
			navBar.gotoPrev.setEnabled(false);
428
			navBar.gotoPrev.setEnabled(false);
430
			navBar.gotoNext.setEnabled(false);
429
			navBar.gotoNext.setEnabled(false);
431
			navBar.gotoEnd.setEnabled(false);
430
			navBar.gotoEnd.setEnabled(false);
432
 
431
 
433
			setStatusText("Patientez ...");
432
			setStatusText("Patientez ...");
434
		}
433
		}
435
 
434
 
436
		/**
435
		/**
437
		 * Affichage numero de page et gestion de la navigation
436
		 * Affichage numero de page et gestion de la navigation
438
		 * 
437
		 * 
439
		 */
438
		 */
440
 
439
 
441
		private void setStatusEnabled() {
440
		private void setStatusEnabled() {
442
 
441
 
443
			// Il y a forcemment un disabled avant d'arriver ici
442
			// Il y a forcemment un disabled avant d'arriver ici
444
 
443
 
445
			if (count > 0) {
444
			if (count > 0) {
446
 
445
 
447
				if (startIndex >= VISIBLE_LOCATION_COUNT) { // Au dela de la
446
				if (startIndex >= VISIBLE_LOCATION_COUNT) { // Au dela de la
448
															// premiere page
447
															// premiere page
449
					navBar.gotoPrev.setEnabled(true);
448
					navBar.gotoPrev.setEnabled(true);
450
					navBar.gotoFirst.setEnabled(true);
449
					navBar.gotoFirst.setEnabled(true);
451
					if (startIndex < (count - VISIBLE_LOCATION_COUNT)) { // Pas la
450
					if (startIndex < (count - VISIBLE_LOCATION_COUNT)) { // Pas la
452
																		// derniere
451
																		// derniere
453
																		// page
452
																		// page
454
						navBar.gotoNext.setEnabled(true);
453
						navBar.gotoNext.setEnabled(true);
455
						navBar.gotoEnd.setEnabled(true);
454
						navBar.gotoEnd.setEnabled(true);
456
						setStatusText((startIndex + 1) + " - "
455
						setStatusText((startIndex + 1) + " - "
457
								+ (startIndex + VISIBLE_LOCATION_COUNT) + " sur " + count );
456
								+ (startIndex + VISIBLE_LOCATION_COUNT) + " sur " + count );
458
					} else { // Derniere page
457
					} else { // Derniere page
459
						setStatusText((startIndex + 1) + " - " + count + " sur " + count );
458
						setStatusText((startIndex + 1) + " - " + count + " sur " + count );
460
					}
459
					}
461
				} else { // Premiere page
460
				} else { // Premiere page
462
					if (count > VISIBLE_LOCATION_COUNT) { // Des pages derrieres
461
					if (count > VISIBLE_LOCATION_COUNT) { // Des pages derrieres
463
						navBar.gotoNext.setEnabled(true);
462
						navBar.gotoNext.setEnabled(true);
464
						navBar.gotoEnd.setEnabled(true);
463
						navBar.gotoEnd.setEnabled(true);
465
						setStatusText((startIndex + 1) + " - "
464
						setStatusText((startIndex + 1) + " - "
466
								+ (startIndex + VISIBLE_LOCATION_COUNT) + " sur " + count);
465
								+ (startIndex + VISIBLE_LOCATION_COUNT) + " sur " + count);
467
					} else {
466
					} else {
468
						setStatusText((startIndex + 1) + " - " + count + " sur " + count);
467
						setStatusText((startIndex + 1) + " - " + count + " sur " + count);
469
					}
468
					}
470
				}
469
				}
471
			}
470
			}
472
 
471
 
473
			else { // Pas d'inventaire, pas de navigation
472
			else { // Pas d'inventaire, pas de navigation
474
				setStatusText("0 - 0 sur 0");
473
				setStatusText("0 - 0 sur 0");
475
			}
474
			}
476
		}
475
		}
477
 
476
 
478
 
477
 
479
 
478
 
480
		private void setStatusText(String text) {
479
		private void setStatusText(String text) {
481
			navBar.status.setText(text);
480
			navBar.status.setText(text);
482
		}
481
		}
483
		
482
		
484
		public void setUser(String user) {
483
		public void setUser(String user) {
485
			this.user = user;
484
			this.user = user;
486
		}
485
		}
487
 
486
 
488
}
487
}