Subversion Repositories eFlore/Archives.cel-v1

Rev

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

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