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
 
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, 1);
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
 
148
 
149
		private NavBar navBar=null;
149
		private NavBar navBar=null;
150
 
150
 
151
		
151
		
152
		private int count = 65000;
152
		private int count = 65000;
153
		
153
		
154
		// Tous selectionné 
154
		// Tous selectionné 
155
		private int  selectedRow = -1;
155
		private int  selectedRow = -1;
156
		
156
		
157
		private Mediator mediator = null;
157
		private Mediator mediator = null;
158
 
158
 
159
		
159
		
160
		public LocationList(Mediator med) {
160
		public LocationList(Mediator med) {
161
			
161
			
162
			mediator=med;
162
			mediator=med;
163
 
163
 
164
			mediator.registerLocationList(this);
164
			mediator.registerLocationList(this);
165
 
165
 
166
			user=mediator.getUser();
166
			user=mediator.getUser();
167
			serviceBaseUrl = mediator.getServiceBaseUrl();
167
			serviceBaseUrl = mediator.getServiceBaseUrl();
168
			
168
			
169
			navBar = new NavBar();
169
			navBar = new NavBar();
170
			
170
			
171
			// Mise en forme du header
171
			// Mise en forme du header
172
 
172
 
173
			header.setCellSpacing(0);
173
			header.setCellSpacing(0);
174
			header.setCellPadding(2);
174
			header.setCellPadding(2);
175
			header.setWidth("100%");
175
			header.setWidth("100%");
176
 
176
 
177
			header.setStyleName("location-ListHeader");
177
			header.setStyleName("location-ListHeader");
178
 
178
 
179
			
179
			
180
			header.setHTML(0, 0, "Relev&eacute;s par commune&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");  // yeah !
180
			header.setWidget(0, 1,navBar);
181
 
-
 
182
			header.getCellFormatter().setWidth(0, 0, "100%");
181
			
183
 
182
 
184
 
183
 
185
			// Mise en forme de l'entree "Toutes localités"
184
			// Mise en forme de l'entree "Toutes localités"
186
 
185
 
187
			selector.setCellSpacing(0);
186
			selector.setCellSpacing(0);
188
			selector.setCellPadding(0);
187
			selector.setCellPadding(0);
189
			selector.setWidth("100%");
188
			selector.setWidth("100%");
190
 
189
 
191
			selector.setHTML(0, 0, "Toutes");
190
			selector.setHTML(0, 0, "Toutes");
192
 
191
 
193
			selector.getCellFormatter().setWidth(0, 0, "100%");
192
			selector.getCellFormatter().setWidth(0, 0, "100%");
194
 
193
 
195
 
194
 
196
			 // Hook up events.
195
			 // Hook up events.
197
			selector.addTableListener(new TableListener () {
196
			selector.addTableListener(new TableListener () {
198
		    	
197
		    	
199
				  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
198
				  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
200
					  	styleRow(selectedRow, false);
199
					  	styleRow(selectedRow, false);
201
				        selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
200
				        selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
202
					    mediator.onLocationSelected("all");
201
					    mediator.onLocationSelected("all");
203
					  }
202
					  }
204
 
203
 
205
		    });
204
		    });
206
			
205
			
207
			selector.setStyleName("location-ListElement");
206
			selector.setStyleName("location-ListElement");
208
 
207
 
209
			
208
			
210
			// Mise en forme du contenu 
209
			// Mise en forme du contenu 
211
 
210
 
212
			table.setCellSpacing(0);
211
			table.setCellSpacing(0);
213
			table.setBorderWidth(0);
212
			table.setBorderWidth(0);
214
			table.setCellPadding(2);
213
			table.setCellPadding(2);
215
			table.setWidth("100%");
214
			table.setWidth("100%");
216
 
215
 
217
			table.setStyleName("location-ListElement");
216
			table.setStyleName("location-ListElement");
218
 
217
 
219
			// Mise en forme barre navigation
218
			// Mise en forme barre navigation
220
			
-
 
221
			outer.add(navBar);
-
 
222
			
219
			
223
			navBar.setWidth("100%");
220
			navBar.setWidth("100%");
224
			
221
			
225
			outer.add(header);
222
			outer.add(header);
226
			inner.add(selector); // Toutes localités
223
			inner.add(selector); // Toutes localités
227
			inner.add(table);
224
			inner.add(table);
228
			inner.setStyleName("location-List");
225
			inner.setStyleName("location-List");
229
			inner.setWidth("100%");
226
			inner.setWidth("100%");
230
			outer.setWidth("100%");
227
			outer.setWidth("100%");
231
			outer.add(inner);
228
			outer.add(inner);
232
			
229
			
233
			 // Hook up events.
230
			 // Hook up events.
234
		    table.addTableListener(new TableListener () {
231
		    table.addTableListener(new TableListener () {
235
		    	
232
		    	
236
				  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
233
				  public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
237
					  
234
					  
238
					      selectRow(row);
235
					      selectRow(row);
239
					      String loc=table.getText(row,cell);
236
					      String loc=table.getText(row,cell);
240
					      if (loc.compareTo(VALUE_UNKNOWN)!=0) {
237
					      if (loc.compareTo(VALUE_UNKNOWN)!=0) {
241
					    	  mediator.onLocationSelected(table.getText(row,cell));
238
					    	  mediator.onLocationSelected(table.getText(row,cell));
242
					      }
239
					      }
243
					      else {
240
					      else {
244
					    	  mediator.onLocationSelected("000null");
241
					    	  mediator.onLocationSelected("000null");
245
					      }
242
					      }
246
					    
243
					    
247
					  }
244
					  }
248
 
245
 
249
		    });
246
		    });
250
		    
247
		    
251
		  	styleRow(selectedRow, false);
248
		  	styleRow(selectedRow, false);
252
	        selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
249
	        selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
253
		   // mediator.onLocationSelected("all");
250
		   // mediator.onLocationSelected("all");
254
		    		
251
		    		
255
		    
252
		    
256
			//updateCount();
253
			//updateCount();
257
			// update()
254
			// update()
258
			
255
			
259
			initWidget(outer);
256
			initWidget(outer);
260
 
257
 
261
 
258
 
262
  }
259
  }
263
 
260
 
264
		/**
261
		/**
265
		 * Recherche nombre d'enregistrement pour l'utilisateur en cours
262
		 * Recherche nombre d'enregistrement pour l'utilisateur en cours
266
		 * 
263
		 * 
267
		 * 
264
		 * 
268
		 */
265
		 */
269
		
266
		
270
		public void updateCount() {
267
		public void updateCount() {
271
			
268
			
272
			setStatusDisabled();
269
			setStatusDisabled();
273
 
270
 
274
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user ,
271
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location ,
275
					new ResponseTextHandler() {
272
					new ResponseTextHandler() {
276
 
273
 
277
						public void onCompletion(String str) {
274
						public void onCompletion(String str) {
278
							JSONValue jsonValue = JSONParser.parse(str);
275
							JSONValue jsonValue = JSONParser.parse(str);
279
							JSONNumber jsonNumber;
276
							JSONNumber jsonNumber;
280
							if ((jsonNumber = jsonValue.isNumber()) != null) {
277
							if ((jsonNumber = jsonValue.isNumber()) != null) {
281
								count = (int) jsonNumber.getValue();
278
								count = (int) jsonNumber.getValue();
282
								mediator.onLocationUpdate(location);
279
								mediator.onLocationUpdate(location);
283
								update();
280
								update();
284
							}
281
							}
285
						}
282
						}
286
					});
283
					});
287
 
284
 
288
		}
285
		}
289
 
286
 
290
	
287
	
291
		  private void selectRow(int row) {
288
		  private void selectRow(int row) {
292
			  
289
			  
293
		    styleRow(selectedRow, false);
290
		    styleRow(selectedRow, false);
294
		    styleRow(row, true);
291
		    styleRow(row, true);
295
 
292
 
296
		    selectedRow = row;
293
		    selectedRow = row;
297
		    
294
		    
298
		  }
295
		  }
299
		  
296
		  
300
		  
297
		  
301
		  private void styleRow(int row, boolean selected) {
298
		  private void styleRow(int row, boolean selected) {
302
			    if (row != -1) {
299
			    if (row != -1) {
303
				   selector.getRowFormatter().removeStyleName(0, "location-SelectedRow");
300
				   selector.getRowFormatter().removeStyleName(0, "location-SelectedRow");
304
			      if (selected)
301
			      if (selected)
305
			        table.getRowFormatter().addStyleName(row, "location-SelectedRow");
302
			        table.getRowFormatter().addStyleName(row, "location-SelectedRow");
306
			      else
303
			      else
307
			    	if (row < table.getRowCount()) { 
304
			    	if (row < table.getRowCount()) { 
308
			    		table.getRowFormatter().removeStyleName(row, "location-SelectedRow");
305
			    		table.getRowFormatter().removeStyleName(row, "location-SelectedRow");
309
			    	}
306
			    	}
310
			    }
307
			    }
311
			  }
308
			  }
312
 
309
 
313
		  
310
		  
314
	/**
311
	/**
315
	 * 
312
	 * 
316
	 * 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
317
	 * saisies. La valeur de this.startIndex permet de determiner quelles
314
	 * saisies. La valeur de this.startIndex permet de determiner quelles
318
	 * données seront affichées
315
	 * données seront affichées
319
	 * 
316
	 * 
320
	 */	
317
	 */	
321
 
318
 
322
		public void update() {
319
		public void update() {
323
 
320
 
324
			
321
			
325
			setStatusDisabled();
322
			setStatusDisabled();
326
 
323
 
327
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/"
324
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/" + location + "/"
328
					+ startIndex + "/" + VISIBLE_LOCATION_COUNT,
325
					+ startIndex + "/" + VISIBLE_LOCATION_COUNT,
329
 
326
 
330
			new ResponseTextHandler() {
327
			new ResponseTextHandler() {
331
 
328
 
332
				public void onCompletion(String str) {
329
				public void onCompletion(String str) {
333
 
330
 
334
					JSONValue jsonValue = JSONParser.parse(str);
331
					JSONValue jsonValue = JSONParser.parse(str);
335
					JSONArray jsonArray;
332
					JSONArray jsonArray;
336
					JSONArray jsonArrayNested;
333
					JSONArray jsonArrayNested;
337
			
334
			
338
					int row=0;
335
					int row=0;
339
					int i=0;
336
					int i=0;
340
					
337
					
341
					if ((jsonArray = jsonValue.isArray()) != null) {
338
					if ((jsonArray = jsonValue.isArray()) != null) {
342
						int arraySize = jsonArray.size();
339
						int arraySize = jsonArray.size();
343
						for (i = 0; i < arraySize; ++i) {
340
						for (i = 0; i < arraySize; ++i) {
344
							if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
341
							if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
345
								if (i>=table.getRowCount()) {
342
								if (i>=table.getRowCount()) {
346
									 row = table.insertRow(table.getRowCount());
343
									 row = table.insertRow(table.getRowCount());
347
								}
344
								}
348
								else {
345
								else {
349
									row = i;
346
									row = i;
350
								}
347
								}
351
								// Lieu
348
								// Lieu
352
							    	
349
							    	
353
								String loc=((JSONString)jsonArrayNested.get(0)).stringValue();
350
								String loc=((JSONString)jsonArrayNested.get(0)).stringValue();
354
								
351
								
355
								if (loc.compareTo("000null")!=0) {
352
								if (loc.compareTo("000null")!=0) {
356
									table.setText(row, 0,loc); 
353
									table.setText(row, 0,loc); 
357
								}
354
								}
358
								else {
355
								else {
359
									table.setText(row, 0,VALUE_UNKNOWN);
356
									table.setText(row, 0,VALUE_UNKNOWN);
360
								}
357
								}
361
								
358
								
362
								if (loc.compareTo(location)==0) {
359
								if (loc.compareTo(location)==0) {
363
								  styleRow(row, true);
360
								  styleRow(row, true);
364
								}
361
								}
365
								else {
362
								else {
366
								  styleRow(row, false);
363
								  styleRow(row, false);
367
								}
364
								}
368
 
365
 
369
								table.getFlexCellFormatter().setWidth(row, 0, "100%");
366
								table.getFlexCellFormatter().setWidth(row, 0, "100%");
370
							}
367
							}
371
 
368
 
372
						}
369
						}
373
					}
370
					}
374
					
371
					
375
					if (location.compareTo("all")==0) {
372
					if (location.compareTo("all")==0) {
376
							selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
373
							selector.getRowFormatter().addStyleName(0, "location-SelectedRow");
377
					}
374
					}
378
 
375
 
379
					
376
					
380
					// Suppression fin ancien affichage
377
					// Suppression fin ancien affichage
381
					if (i<table.getRowCount()-1) {
378
					if (i<table.getRowCount()) {
382
						 for (int j = table.getRowCount() - 1; j > i-1; j--) {
379
						 for (int j = table.getRowCount() -1 ; j >= i; j--) {
383
							 table.removeRow(j);
380
							 table.removeRow(j);
384
						 }
381
						 }
385
					}
382
					}
-
 
383
 
386
					setStatusEnabled();
384
					setStatusEnabled();
387
 
385
 
388
 
386
 
389
				}
387
				}
390
			});
388
			});
391
 
389
 
392
		}
390
		}
393
 
391
 
394
		public void setLocation(String location) {
392
		public void setLocation(String location) {
395
			this.location = location;
393
			this.location = location;
396
		}
394
		}
397
		
395
		
398
		
396
		
399
			
397
			
400
		/*
398
		/*
401
		 * Positionnement index de parcours (this.startIndex) pour affichage de la
399
		 * Positionnement index de parcours (this.startIndex) pour affichage de la
402
		 * dernière page
400
		 * dernière page
403
		 * 
401
		 * 
404
		 * @param
402
		 * @param
405
		 * @return void
403
		 * @return void
406
		 */
404
		 */
407
 
405
 
408
		private void gotoEnd() {
406
		private void gotoEnd() {
409
 
407
 
410
			if ((count == 0) || (count % VISIBLE_LOCATION_COUNT) > 0) {
408
			if ((count == 0) || (count % VISIBLE_LOCATION_COUNT) > 0) {
411
				startIndex = count - (count % VISIBLE_LOCATION_COUNT);
409
				startIndex = count - (count % VISIBLE_LOCATION_COUNT);
412
			} else {
410
			} else {
413
				startIndex = count - VISIBLE_LOCATION_COUNT;
411
				startIndex = count - VISIBLE_LOCATION_COUNT;
414
			}
412
			}
415
 
413
 
416
		}
414
		}
417
		
415
		
418
		
416
		
419
		/**
417
		/**
420
		 * Affichage message d'attente et désactivation navigation
418
		 * Affichage message d'attente et désactivation navigation
421
		 * 
419
		 * 
422
		 * @param
420
		 * @param
423
		 * @return void
421
		 * @return void
424
		 */
422
		 */
425
 
423
 
426
		private void setStatusDisabled() {
424
		private void setStatusDisabled() {
427
 
425
 
428
			navBar.gotoFirst.setEnabled(false);
426
			navBar.gotoFirst.setEnabled(false);
429
			navBar.gotoPrev.setEnabled(false);
427
			navBar.gotoPrev.setEnabled(false);
430
			navBar.gotoNext.setEnabled(false);
428
			navBar.gotoNext.setEnabled(false);
431
			navBar.gotoEnd.setEnabled(false);
429
			navBar.gotoEnd.setEnabled(false);
432
 
430
 
433
			setStatusText("Patientez ...");
431
			setStatusText("Patientez ...");
434
		}
432
		}
435
 
433
 
436
		/**
434
		/**
437
		 * Affichage numero de page et gestion de la navigation
435
		 * Affichage numero de page et gestion de la navigation
438
		 * 
436
		 * 
439
		 */
437
		 */
440
 
438
 
441
		private void setStatusEnabled() {
439
		private void setStatusEnabled() {
442
 
440
 
443
			// Il y a forcemment un disabled avant d'arriver ici
441
			// Il y a forcemment un disabled avant d'arriver ici
444
 
442
 
445
			if (count > 0) {
443
			if (count > 0) {
446
 
444
 
447
				if (startIndex >= VISIBLE_LOCATION_COUNT) { // Au dela de la
445
				if (startIndex >= VISIBLE_LOCATION_COUNT) { // Au dela de la
448
															// premiere page
446
															// premiere page
449
					navBar.gotoPrev.setEnabled(true);
447
					navBar.gotoPrev.setEnabled(true);
450
					navBar.gotoFirst.setEnabled(true);
448
					navBar.gotoFirst.setEnabled(true);
451
					if (startIndex < (count - VISIBLE_LOCATION_COUNT)) { // Pas la
449
					if (startIndex < (count - VISIBLE_LOCATION_COUNT)) { // Pas la
452
																		// derniere
450
																		// derniere
453
																		// page
451
																		// page
454
						navBar.gotoNext.setEnabled(true);
452
						navBar.gotoNext.setEnabled(true);
455
						navBar.gotoEnd.setEnabled(true);
453
						navBar.gotoEnd.setEnabled(true);
456
						setStatusText((startIndex + 1) + " - "
454
						setStatusText((startIndex + 1) + " - "
457
								+ (startIndex + VISIBLE_LOCATION_COUNT) + " sur " + count );
455
								+ (startIndex + VISIBLE_LOCATION_COUNT) + " sur " + count );
458
					} else { // Derniere page
456
					} else { // Derniere page
459
						setStatusText((startIndex + 1) + " - " + count + " sur " + count );
457
						setStatusText((startIndex + 1) + " - " + count + " sur " + count );
460
					}
458
					}
461
				} else { // Premiere page
459
				} else { // Premiere page
462
					if (count > VISIBLE_LOCATION_COUNT) { // Des pages derrieres
460
					if (count > VISIBLE_LOCATION_COUNT) { // Des pages derrieres
463
						navBar.gotoNext.setEnabled(true);
461
						navBar.gotoNext.setEnabled(true);
464
						navBar.gotoEnd.setEnabled(true);
462
						navBar.gotoEnd.setEnabled(true);
465
						setStatusText((startIndex + 1) + " - "
463
						setStatusText((startIndex + 1) + " - "
466
								+ (startIndex + VISIBLE_LOCATION_COUNT) + " sur " + count);
464
								+ (startIndex + VISIBLE_LOCATION_COUNT) + " sur " + count);
467
					} else {
465
					} else {
468
						setStatusText((startIndex + 1) + " - " + count + " sur " + count);
466
						setStatusText((startIndex + 1) + " - " + count + " sur " + count);
469
					}
467
					}
470
				}
468
				}
471
			}
469
			}
472
 
470
 
473
			else { // Pas d'inventaire, pas de navigation
471
			else { // Pas d'inventaire, pas de navigation
474
				setStatusText("0 - 0 sur 0");
472
				setStatusText("0 - 0 sur 0");
475
			}
473
			}
476
		}
474
		}
477
 
475
 
478
 
476
 
479
 
477
 
480
		private void setStatusText(String text) {
478
		private void setStatusText(String text) {
481
			navBar.status.setText(text);
479
			navBar.status.setText(text);
482
		}
480
		}
483
 
481
 
484
}
482
}