Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 14 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14 Rev 26
Line 14... Line 14...
14
 * the License.
14
 * the License.
15
 */
15
 */
16
package org.tela_botanica.client;
16
package org.tela_botanica.client;
Line -... Line 17...
-
 
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.Composite;
28
import com.google.gwt.user.client.ui.ClickListener;
29
import com.google.gwt.user.client.ui.DockPanel;
29
import com.google.gwt.user.client.ui.Composite;
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;
Line 42... Line 42...
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 {
Line 45... Line -...
45
	
-
 
46
	
45
	
Line 47... Line 46...
47
	
46
	
Line 48... Line -...
48
	// Barre de navigation
-
 
49
 
-
 
50
	private class NavBar extends Composite implements ClickListener {
47
	// Debut Barre de navigation
51
 
-
 
52
		public final DockPanel bar = new DockPanel();
48
 
53
 
-
 
54
		public final Button gotoFirst = new Button("<<", this);
49
	private class NavBar extends Composite implements ClickListener {
55
 
-
 
56
		public final Button gotoNext = new Button(">", this);
50
 
57
 
-
 
58
		public final Button gotoPrev = new Button("<", this);
51
		public final Button gotoFirst = new Button("<<", this);
Line 59... Line 52...
59
 
52
		public final Button gotoNext = new Button(">", this);
60
		public final Button gotoEnd = new Button(">>", this);
-
 
61
 
-
 
62
		public final HTML status = new HTML();
-
 
63
		
-
 
Line 64... Line -...
64
 
-
 
Line 65... Line -...
65
		public NavBar() {
-
 
66
			initWidget(bar);
53
		public final Button gotoPrev = new Button("<", this);
67
			bar.setStyleName("navbar");
-
 
68
			status.setStyleName("status");
-
 
69
			status.setWordWrap(false);
-
 
70
			
-
 
71
			HorizontalPanel buttons = new HorizontalPanel();
-
 
72
			
54
		public final Button gotoEnd = new Button(">>", this);
73
			buttons.add(status);
55
		public final HTML status = new HTML();
74
			buttons.setCellHorizontalAlignment(status,
-
 
75
					HasHorizontalAlignment.ALIGN_RIGHT);
56
		
76
			buttons.setCellVerticalAlignment(status,
-
 
77
					HasVerticalAlignment.ALIGN_MIDDLE);
-
 
78
			buttons.setCellWidth(status, "100%");
-
 
Line -... Line 57...
-
 
57
 
79
 
58
		public NavBar() {
-
 
59
			
-
 
60
			
80
 
61
			HorizontalPanel bar = new HorizontalPanel();
-
 
62
			
81
			buttons.add(gotoFirst);
63
			bar.setStyleName("navbar");
-
 
64
			status.setStyleName("status");
-
 
65
			
Line 82... Line -...
82
			buttons.add(gotoPrev);
-
 
Line 83... Line -...
83
			buttons.add(gotoNext);
-
 
-
 
66
			
Line 84... Line 67...
84
			buttons.add(gotoEnd);
67
			bar.add(status);
-
 
68
			bar.setCellHorizontalAlignment(status, HasHorizontalAlignment.ALIGN_RIGHT);
Line 85... Line 69...
85
			bar.add(buttons, DockPanel.EAST);
69
			bar.setCellVerticalAlignment(status, HasVerticalAlignment.ALIGN_MIDDLE);
86
			bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
70
			bar.setCellWidth(status, "100%");
87
			
71
 
88
			
72
			bar.add(gotoFirst);
Line 121... Line 105...
121
			update();
105
			update();
122
		}
106
		}
Line 123... Line 107...
123
 
107
 
Line -... Line 108...
-
 
108
	}
-
 
109
 
124
	}
110
	// Fin Barre de navigation
125
 
111
 
Line 126... Line 112...
126
		private static final int VISIBLE_STATION_COUNT = 10;
112
		private static final int VISIBLE_STATION_COUNT = 10;
Line 258... Line 244...
258
		
244
		
Line 259... Line 245...
259
		public void updateCount() {
245
		public void updateCount() {
Line 260... Line 246...
260
			
246
			
261
			setStatusDisabled();
247
			setStatusDisabled();
Line 262... Line 248...
262
 
248
 
263
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryStationList/" + user + "/" + location ,
249
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryStationList/" + user + "/" + URL.encodeComponent(location) ,
264
					new ResponseTextHandler() {
250
					new ResponseTextHandler() {
Line 310... Line 296...
310
		public void update() {
296
		public void update() {
Line 311... Line 297...
311
 
297
 
Line 312... Line 298...
312
			
298
			
313
			setStatusDisabled();
299
			setStatusDisabled();
Line 314... Line 300...
314
 
300
 
Line 315... Line 301...
315
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryStationList/" + user + "/" + location + "/" 
301
			HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryStationList/" + user + "/" + URL.encodeComponent(location) + "/" 
Line 419... Line 405...
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);
Line 423... Line 409...
423
 
409
 
424
			setStatusText("Patientez ...");
410
			navBar.status.setText("Patientez ...");
Line 425... Line 411...
425
		}
411
		}
426
 
412
 
427
		/**
413
		/**
Line 442... Line 428...
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
			}
Line 463... Line 449...
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
			}
Line 467... Line -...
467
		}
-
 
468
 
-
 
469
 
-
 
470
 
-
 
471
		private void setStatusText(String text) {
-
 
Line 472... Line 453...
472
			navBar.status.setText(text);
453
		}
473
		}
454
 
474
		
455
 
Line 475... Line -...
475
		
-
 
Line 476... Line 456...
476
		public void setUser(String user) {
456
		
477
			this.user = user;
457
		public void setUser(String user) {
478
		}
458
			this.user = user;