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