Subversion Repositories eFlore/Archives.cel-v1

Rev

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

Rev 13 Rev 14
Line 3... Line 3...
3
 
3
 
4
// TODO : sortie User vers une classe ...
4
// TODO : sortie User vers une classe ...
Line 5... Line 5...
5
// TODO : sortie les boutons supprimer et exporter et inclure ici
5
// TODO : sortie les boutons supprimer et exporter et inclure ici
-
 
6
 
-
 
7
import com.google.gwt.i18n.client.Dictionary;
6
 
8
import com.google.gwt.json.client.JSONArray;
7
import com.google.gwt.i18n.client.Dictionary;
9
import com.google.gwt.json.client.JSONBoolean;
8
import com.google.gwt.json.client.JSONParser;
10
import com.google.gwt.json.client.JSONParser;
9
import com.google.gwt.json.client.JSONString;
11
import com.google.gwt.json.client.JSONString;
10
import com.google.gwt.json.client.JSONValue;
12
import com.google.gwt.json.client.JSONValue;
-
 
13
import com.google.gwt.user.client.HTTPRequest;
11
import com.google.gwt.user.client.HTTPRequest;
14
import com.google.gwt.user.client.ResponseTextHandler;
Line 12... Line 15...
12
import com.google.gwt.user.client.ResponseTextHandler;
15
import com.google.gwt.user.client.ui.Label;
Line 13... Line 16...
13
import com.google.gwt.user.client.ui.TextBox;
16
import com.google.gwt.user.client.ui.TextBox;
14
 
17
 
15
public class Mediator {
18
public class Mediator {
16
		
19
		
17
		
20
		
-
 
21
		private String serviceBaseUrl = getServiceBaseUrlFromDictionnary();
18
		private String serviceBaseUrl = getServiceBaseUrlFromDictionnary();
22
		private String user = null;
19
		private String user = null;
23
		private InventoryItemList inventoryItemList = null;
20
		private InventoryItemList inventoryItemList = null;
24
		private LocationList locationList = null;
21
		private LocationList locationList = null;
25
		private DateList dateList = null;
22
		private DateList dateList = null;
26
		private StationList stationList = null;
23
		private NameAssistant nameAssistant=null;
27
		private NameAssistant nameAssistant=null;
-
 
28
		private LocationAssistant locationAssistant=null;
-
 
29
		private InventoryItem inventoryItem=null;
Line 24... Line 30...
24
		private LocationAssistant locationAssistant=null;
30
		private EntryPanel entryPanel=null;
25
		private InventoryItem inventoryItem=null;
31
		private ActionPanel actionPanel=null;
26
		private EntryPanel entryPanel=null;
32
		private SearchPanel searchPanel=null;
Line 27... Line -...
27
		private ActionPanel actionPanel=null;
-
 
-
 
33
		private LoginDialog loginDialog=null;
Line 28... Line 34...
28
		private SearchPanel searchPanel=null;
34
		private TopPanel topPanel=null;
Line 58... Line 64...
58
		 */
64
		 */
Line 59... Line 65...
59
		
65
		
Line -... Line 66...
-
 
66
	
-
 
67
		public void onInit() {
-
 
68
 
-
 
69
			
60
	
70
			locationList.setLocation("all");
Line 61... Line 71...
61
		public void onInit() {
71
			locationList.updateCount();
Line -... Line 72...
-
 
72
 
-
 
73
			this.onLocationSelected("all");
-
 
74
			
-
 
75
		}
-
 
76
		
-
 
77
		
-
 
78
		/**
-
 
79
		 * Action suite ajout, modification, suppression element inventaire
-
 
80
		 */
-
 
81
		
-
 
82
	
-
 
83
		public void onInventoryUpdated(String location) {
-
 
84
 
-
 
85
			
-
 
86
			locationList.setLocation(location);
Line 62... Line 87...
62
 
87
			locationList.updateCount();
63
			this.onLocationSelected("all");
88
 
64
			
89
			this.onLocationSelected(location);
Line 78... Line 103...
78
			
103
			
Line 79... Line 104...
79
		}
104
		}
80
 
105
 
81
		
106
		
Line 82... Line 107...
82
		/**
107
		/**
Line 83... Line 108...
83
		 * Action sur selection d'un lieu : affichage de la liste des taxons correspondants
108
		 * Action sur recherche  : affichage de la liste des taxons correspondants
Line 95... Line 120...
95
 
120
 
96
		
121
		
-
 
122
		
97
		
123
		/**
Line 98... Line 124...
98
		/**
124
		 * Action sur selection d'un lieu : affichage de la liste des taxons correspondants
Line 99... Line 125...
99
		 * Action sur selection d'un lieu : affichage de la liste des taxons correspondants
125
		 * TODO : gerer asynchronicite ?
100
		 */
126
		 */
-
 
127
		
101
		
128
		public void onLocationSelected(String loc) {
Line -... Line 129...
-
 
129
		
-
 
130
			inventoryItemList.setLocation(loc);
-
 
131
			inventoryItemList.setDate("all");
-
 
132
			inventoryItemList.setStation("all");
-
 
133
			inventoryItemList.updateCount();
-
 
134
			
Line 102... Line -...
102
		public void onLocationSelected(String loc) {
-
 
103
		
-
 
104
			inventoryItemList.setLocation(loc);
-
 
105
			inventoryItemList.setDate("all");
-
 
106
			inventoryItemList.updateCount();
-
 
107
			
-
 
108
			
-
 
109
			if ((loc.compareTo("000null")==0) || (loc.compareTo("all")==0)) {
135
			dateList.setLocation(loc);
110
				locationAssistant.setText("");
-
 
Line 111... Line 136...
111
			}
136
			dateList.setDate("all");
112
			else {
137
			dateList.updateCount();
-
 
138
			stationList.setLocation(loc);
113
				locationAssistant.setText(loc);
139
			stationList.setStation("all");
Line 114... Line -...
114
			}
-
 
115
		
-
 
116
		}
-
 
117
 
-
 
118
		
-
 
119
		/**
-
 
120
		 * Action sur selection d'une date : affichage de la liste des taxons correspondants
-
 
121
		 */
-
 
122
		
-
 
123
		public void onDateSelected(String date) {
-
 
124
 
-
 
125
			inventoryItemList.setDate(date);
-
 
126
			inventoryItemList.updateCount();
-
 
127
 
-
 
128
			/*
-
 
Line -... Line 140...
-
 
140
			stationList.updateCount();
-
 
141
			
-
 
142
		}
-
 
143
		
-
 
144
		/**
-
 
145
		 * Action sur login
-
 
146
		 * @param user
-
 
147
		 */
-
 
148
		
-
 
149
		
-
 
150
		public void onLogin(String user) {
-
 
151
			
129
			
152
			
130
				if ((loc.compareTo("000null")==0) || (loc.compareTo("all")==0)) {
153
			this.user=user;
Line 131... Line 154...
131
					locationAssistant.setText("");
154
			topPanel.getSignLabel().setText(user+ " (deconnexion)");
132
				}
155
			inventoryItemList.setUser(user);
-
 
156
			dateList.setUser(user);
133
				else {
157
			stationList.setUser(user);
Line 134... Line 158...
134
					locationAssistant.setText(loc);
158
			entryPanel.setUser(user);
135
				}
159
			locationList.setUser(user);
-
 
160
			this.onInit();
-
 
161
			
-
 
162
		}
-
 
163
		
-
 
164
		
-
 
165
		/**
-
 
166
		 * Action sur logoff
-
 
167
		 * @param user
-
 
168
		 */
-
 
169
		
-
 
170
		
Line -... Line 171...
-
 
171
		public void onLogoff(String user) {
136
					
172
			
137
			*/
173
			this.user=user;
Line -... Line 174...
-
 
174
			topPanel.getSignLabel().setText("Connexion");
-
 
175
			inventoryItemList.setUser(user);
-
 
176
			dateList.setUser(user);
-
 
177
			stationList.setUser(user);
-
 
178
			entryPanel.setUser(user);
138
		
179
			locationList.setUser(user);
-
 
180
			this.onInit();
139
		}
181
			
-
 
182
		}
Line 140... Line 183...
140
 
183
 
141
		
184
		/**
142
		/**
185
		 * Action sur selection d'une station : affichage de la liste des taxons correspondants
-
 
186
		 */
-
 
187
		
Line -... Line 188...
-
 
188
		public void onStationSelected(String station) {
143
		 * Action posterieure à l'affichage des observations : mise a jour affichage des localites
189
 
Line 144... Line -...
144
		 */
-
 
145
		
-
 
146
	
-
 
147
		public void onInventoryItemUpdate(String loc) {
-
 
148
 
190
			inventoryItemList.setStation(station);
-
 
191
			inventoryItemList.updateCount();
-
 
192
 
Line 149... Line 193...
149
			locationList.setLocation(loc);
193
		}
150
			locationList.updateCount();
194
 
151
		
195
 
Line 250... Line 294...
250
			
294
			
251
			this.dateList=dateList;
295
			this.dateList=dateList;
Line -... Line 296...
-
 
296
		}
-
 
297
 
-
 
298
		
-
 
299
		/**
-
 
300
		 * Declaration StationList
-
 
301
		 * @param locationList
-
 
302
		 */
-
 
303
		
-
 
304
		public void registerStationList(StationList stationList) {
-
 
305
			
-
 
306
			this.stationList=stationList;
Line 252... Line 307...
252
		}
307
		}
253
 
308
 
254
		
309
		
255
		
310
		
Line 323... Line 378...
323
		
378
		
324
	    public void  registerSearchPanel(SearchPanel searchPanel) {
379
	    public void  registerSearchPanel(SearchPanel searchPanel) {
325
	    	this.searchPanel=searchPanel;
380
	    	this.searchPanel=searchPanel;
Line -... Line 381...
-
 
381
		}
-
 
382
 
-
 
383
	    public void  registerTopPanel(TopPanel topPanel) {
Line -... Line 384...
-
 
384
	    	this.topPanel=topPanel;
-
 
385
		}
-
 
386
 
-
 
387
	    
-
 
388
	    
-
 
389
	    public void  registerLoginDialog(LoginDialog loginDialog) {
-
 
390
	    	this.loginDialog=loginDialog;
-
 
391
		}
326
		}
392
 
327
 
393
	    
328
 
394
	    
329
		/**
395
		/**
Line 351... Line 417...
351
			HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
417
			HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
352
					new ResponseTextHandler() {
418
					new ResponseTextHandler() {
Line 353... Line 419...
353
 
419
 
354
						public void onCompletion(String str) {
420
						public void onCompletion(String str) {
355
							JSONValue jsonValue = JSONParser.parse(str);
421
							JSONValue jsonValue = JSONParser.parse(str);
356
							JSONString jsonString;
422
							JSONArray jsonArray;
357
							if ((jsonString = jsonValue.isString()) != null) {
423
							if ((jsonArray = jsonValue.isArray()) != null) {
-
 
424
									user = ((JSONString) jsonArray.get(0)).stringValue();
358
								user = jsonString.stringValue();
425
									connected = ((JSONBoolean) jsonArray.get(1)).booleanValue();
359
							}
426
							}
360
							cel.initAsync();
427
							cel.initAsync();
361
						}
428
						}
Line 394... Line 461...
394
		 */
461
		 */
Line 395... Line 462...
395
		
462
		
396
		public String getUser() {
463
		public String getUser() {
397
			return user;
464
			return user;
-
 
465
		}
Line -... Line 466...
-
 
466
 
-
 
467
		
-
 
468
 
-
 
469
		public void setUser(String user) {
-
 
470
			this.user=user;
Line 398... Line 471...
398
		}
471
		}
399
		
472
 
400
 
473
 
Line 427... Line 500...
427
		public EntryPanel getEntryPanel() {
500
		public EntryPanel getEntryPanel() {
428
			return entryPanel;
501
			return entryPanel;
429
		}
502
		}
Line -... Line 503...
-
 
503
 
-
 
504
 
-
 
505
		public void setConnected(boolean connected) {
-
 
506
		
-
 
507
			this.connected=connected;
-
 
508
		}
-
 
509
		
-
 
510
		public boolean getConnected() {
-
 
511
			
-
 
512
			return this.connected;
Line 430... Line 513...
430
 
513
		}