Subversion Repositories eFlore/Archives.cel-v1

Rev

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

Rev 10 Rev 11
1
package org.tela_botanica.client;
1
package org.tela_botanica.client;
2
 
2
 
3
 
3
 
4
// TODO : sortie User vers une classe ...
4
// TODO : sortie User vers une classe ...
5
// TODO : sortie les boutons supprimer et exporter et inclure ici
5
// TODO : sortie les boutons supprimer et exporter et inclure ici
6
 
6
 
7
import com.google.gwt.i18n.client.Dictionary;
7
import com.google.gwt.i18n.client.Dictionary;
8
import com.google.gwt.json.client.JSONParser;
8
import com.google.gwt.json.client.JSONParser;
9
import com.google.gwt.json.client.JSONString;
9
import com.google.gwt.json.client.JSONString;
10
import com.google.gwt.json.client.JSONValue;
10
import com.google.gwt.json.client.JSONValue;
11
import com.google.gwt.user.client.HTTPRequest;
11
import com.google.gwt.user.client.HTTPRequest;
12
import com.google.gwt.user.client.ResponseTextHandler;
12
import com.google.gwt.user.client.ResponseTextHandler;
13
 
13
 
14
public class Mediator {
14
public class Mediator {
15
		
15
		
16
		
16
		
17
		private String serviceBaseUrl = getServiceBaseUrlFromDictionnary();
17
		private String serviceBaseUrl = getServiceBaseUrlFromDictionnary();
18
		private String user = null;
18
		private String user = null;
19
		private TaxonList taxonlist = null;
19
		private InventoryItemList inventoryItemList = null;
20
		private LocationList locationList = null;
20
		private LocationList locationList = null;
-
 
21
		private NameAssistant nameAssistant=null;
-
 
22
		private LocationAssistant locationAssistant=null;
-
 
23
		
21
		private Cel cel = null;
24
		private Cel cel = null;
22
 
25
 
23
		
26
		
24
		Mediator() {
27
		Mediator() {
25
			
28
			
26
			
29
			
27
		}
30
		}
28
	
31
	
29
		/**
32
		/**
30
		 * Recuperation information utilisateur
33
		 * Recuperation information utilisateur
31
		 *
34
		 *
32
		 */
35
		 */
33
		
36
		
34
		public void initUser() {
37
		public void initUser() {
35
			getUserFromService();
38
			getUserFromService();
36
			
39
			
37
		}
40
		}
38
	
41
	
39
		/**
42
		/**
40
		 * Action sur selection d'un lieu
43
		 * Action sur selection d'un lieu : affichage de la liste des taxons correspondants
41
		 *
44
		 *
42
		 */
45
		 */
43
		
46
		
44
		public void onLocationSelected(String loc) {
47
		public void onLocationSelected(String loc) {
45
		
48
		
46
			taxonlist.setLocation(loc);
49
			inventoryItemList.setLocation(loc);
-
 
50
			inventoryItemList.updateCount();
-
 
51
			
-
 
52
			if ((loc.compareTo("000null")==0) || (loc.compareTo("all")==0)) {
-
 
53
				locationAssistant.setText("");
-
 
54
			}
-
 
55
			else {
47
			taxonlist.updateCount();
56
				locationAssistant.setText(loc);
48
			
57
			}
49
			
58
			
50
		}
59
		}
51
	
60
	
52
		/**
61
		/**
53
		 * Action sur ajout d'un taxon
62
		 * Action sur ajout d'un taxon : affichage du lieu corresondant
54
		 */
63
		 */
55
		
64
		
56
	
65
	
57
		public void onTaxonListUpdate(String loc) {
66
		public void onInventoryItemUpdate(String loc) {
58
 
67
 
59
			locationList.setLocation(loc);
68
			locationList.setLocation(loc);
60
			locationList.update();
69
			locationList.updateCount();
61
		
70
		
62
		}
71
		}
63
		
72
		
64
		/**
73
		/**
65
		 * Enregistrement TaxonList
74
		 * Declaration InventoryItemList 
66
		 * @param taxonlist
75
		 * @param inventoryItemList
67
		 */
76
		 */
68
		
77
		
69
		public void registerTaxonList(TaxonList taxonlist) {
78
		public void registerInventoryItemList(InventoryItemList inventoryItemList) {
70
			
79
			
71
			this.taxonlist=taxonlist;
80
			this.inventoryItemList=inventoryItemList;
72
		
81
		
73
		}
82
		}
74
	
83
	
75
		/**
84
		/**
76
		 * Enregistremnt LocationList
85
		 * Declaration LocationList
77
		 * @param locationList
86
		 * @param locationList
78
		 */
87
		 */
79
		
88
		
80
		public void registerLocationList(LocationList locationList) {
89
		public void registerLocationList(LocationList locationList) {
81
			
90
			
82
			this.locationList=locationList;
91
			this.locationList=locationList;
83
		}
92
		}
84
		
93
		
85
		/**
94
		/**
86
		 * Enregistrement Cel
95
		 * Declaration Cel
87
		 * @param cel
96
		 * @param cel
88
		 */
97
		 */
89
 
98
 
90
		public void registerCel(Cel cel) {
99
		public void registerCel(Cel cel) {
91
			
100
			
92
			this.cel=cel;
101
			this.cel=cel;
93
		}
102
		}
94
 
103
 
-
 
104
		
-
 
105
		/**
-
 
106
		 * Declaration NameAssistant 
-
 
107
		 * @param nameassistant
-
 
108
		 */
-
 
109
		
-
 
110
		public void registerNameAssistant(NameAssistant nameAssistant) {
-
 
111
			this.nameAssistant=nameAssistant;
-
 
112
			
-
 
113
		}
-
 
114
		
-
 
115
		/**
-
 
116
		 * Declaration LocationAssistant 
-
 
117
		 * @param locationassistant
-
 
118
		 */
-
 
119
		
-
 
120
		public void registerLocationAssistant(LocationAssistant locationAssistant) {
-
 
121
			this.locationAssistant=locationAssistant;
-
 
122
			
-
 
123
		}
95
		
124
		
96
 
125
 
97
		/**
126
		/**
98
		 * Recherche distante et asynchrone de l'utilisateur connecté, en retour lancement methode initialisation
127
		 * Recherche distante et asynchrone de l'utilisateur connecté, en retour lancement methode initialisation
99
		 * de l'appellant Cel. (initAsunc)
128
		 * de l'appellant Cel. (initAsync)
100
		 * 
129
		 * 
101
		 */
130
		 */
102
		
131
		
103
		private void getUserFromService() {
132
		private void getUserFromService() {
104
 
133
 
105
 
134
 
106
			HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
135
			HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
107
					new ResponseTextHandler() {
136
					new ResponseTextHandler() {
108
 
137
 
109
						public void onCompletion(String str) {
138
						public void onCompletion(String str) {
110
							JSONValue jsonValue = JSONParser.parse(str);
139
							JSONValue jsonValue = JSONParser.parse(str);
111
							JSONString jsonString;
140
							JSONString jsonString;
112
							if ((jsonString = jsonValue.isString()) != null) {
141
							if ((jsonString = jsonValue.isString()) != null) {
113
								user = jsonString.stringValue();
142
								user = jsonString.stringValue();
114
							}
143
							}
115
							cel.initAsync();
144
							cel.initAsync();
116
						}
145
						}
117
					});
146
					});
118
 
147
 
119
		}
148
		}
120
	
149
	
121
		/**
150
		/**
122
		 * Accesseur Url de base
151
		 * Accesseur Url de base
123
		 * @return Url de base
152
		 * @return Url de base
124
		 */
153
		 */
125
		
154
		
126
		public String getServiceBaseUrl() {
155
		public String getServiceBaseUrl() {
127
			
156
			
128
			return serviceBaseUrl;
157
			return serviceBaseUrl;
129
 
158
 
130
		}
159
		}
131
 
160
 
132
		
161
		
133
		/**
162
		/**
134
		 * Recuperation du prefixe d'appel des services
163
		 * Recuperation du prefixe d'appel des services
135
		 * @return prefix appel des service
164
		 * @return prefix appel des service
136
		 */
165
		 */
137
 
166
 
138
		private String getServiceBaseUrlFromDictionnary() {
167
		private String getServiceBaseUrlFromDictionnary() {
139
 
168
 
140
			Dictionary theme = Dictionary.getDictionary("Parameters");
169
			Dictionary theme = Dictionary.getDictionary("Parameters");
141
			return theme.get("serviceBaseUrl");
170
			return theme.get("serviceBaseUrl");
142
 
171
 
143
		}
172
		}
144
 
173
 
145
 
174
 
146
		/**
175
		/**
147
		 *  Accesseur Utilisateur
176
		 *  Accesseur Utilisateur
148
		 * @return utilisateur connecté ou identifiant de session
177
		 * @return utilisateur connecté ou identifiant de session
149
		 */
178
		 */
150
		
179
		
151
		public String getUser() {
180
		public String getUser() {
152
			return user;
181
			return user;
153
		}
182
		}
-
 
183
		
-
 
184
 
-
 
185
		
-
 
186
		public InventoryItemList getInventoryItemList() {
-
 
187
			return inventoryItemList;
-
 
188
		}
-
 
189
 
-
 
190
		public LocationList getLocationList() {
-
 
191
			return locationList;
-
 
192
		}
-
 
193
 
-
 
194
		public NameAssistant getNameAssistant() {
-
 
195
			return nameAssistant;
-
 
196
		}
-
 
197
 
-
 
198
		public LocationAssistant getLocationAssistant() {
-
 
199
			return locationAssistant;
-
 
200
		}
154
 
201
 
155
 
202
 
156
 
203
 
157
	}
204
	}