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