Subversion Repositories eFlore/Archives.cel-v1

Rev

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

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