Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 30 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30 Rev 31
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.http.client.URL;
20
import com.google.gwt.json.client.JSONArray;
20
import com.google.gwt.json.client.JSONArray;
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
 
26
 
27
import net.mygwt.ui.client.data.Model;  
27
import net.mygwt.ui.client.data.Model;  
28
import net.mygwt.ui.client.viewer.IAsyncContentCallback;  
28
import net.mygwt.ui.client.viewer.IAsyncContentCallback;  
29
import net.mygwt.ui.client.viewer.IAsyncTreeContentProvider;  
29
import net.mygwt.ui.client.viewer.IAsyncTreeContentProvider;  
30
import net.mygwt.ui.client.viewer.IElementComparer;
30
import net.mygwt.ui.client.viewer.IElementComparer;
31
import net.mygwt.ui.client.viewer.ISelectionChangedListener;
31
import net.mygwt.ui.client.viewer.ISelectionChangedListener;
32
import net.mygwt.ui.client.viewer.ModelLabelProvider;  
32
import net.mygwt.ui.client.viewer.ModelLabelProvider;  
33
import net.mygwt.ui.client.viewer.SelectionChangedEvent;
33
import net.mygwt.ui.client.viewer.SelectionChangedEvent;
34
import net.mygwt.ui.client.viewer.TreeViewer;  
34
import net.mygwt.ui.client.viewer.TreeViewer;  
35
import net.mygwt.ui.client.viewer.Viewer;  
35
import net.mygwt.ui.client.viewer.Viewer;  
36
import net.mygwt.ui.client.widget.ExpandBar;
36
import net.mygwt.ui.client.widget.ExpandBar;
37
import net.mygwt.ui.client.widget.ExpandItem;
37
import net.mygwt.ui.client.widget.ExpandItem;
38
import net.mygwt.ui.client.widget.tree.Tree;  
38
import net.mygwt.ui.client.widget.tree.Tree;  
39
   
39
   
40
 
-
 
41
/**
-
 
42
 * A tree displaying a set of email folders.
-
 
43
 */
40
 
44
public class LocationFilterView {
41
public class LocationFilterView {
45
	
42
	
46
	
43
	
47
	
44
	
48
		private static final String VALUE_UNKNOWN = "Inconnu";
45
		private static final String VALUE_UNKNOWN = "Inconnu";
49
 
46
 
50
 
47
 
51
		private String user;
48
		private String user;
52
		private String serviceBaseUrl = null;
49
		private String serviceBaseUrl = null;
53
 
50
 
54
		private String id_location = "all";
51
		private String id_location = "all";
55
		private String location = "all";
52
		private String location = "all";
56
		private String lieudit = "all";
53
		private String lieudit = "all";
57
 
54
 
58
		
55
		
59
		private Mediator mediator = null;
56
		private Mediator mediator = null;
60
		
57
		
61
	    private SALB[] salbs=null;
58
	    private SALB[] salbs=null;
62
	    private TALB[] talbs=null;
59
	    private TALB[] talbs=null;
63
	    private FALB[] falbs=null;
60
	    private FALB[] falbs=null;
64
		private Model root = null; 
61
		private Model root = null; 
65
		private RALB ralb = null; 
62
		private RALB ralb = null; 
66
		private Tree tree = null;
63
		private Tree tree = null;
67
		private TreeViewer viewer=null;
64
		private TreeViewer viewer=null;
68
		
65
		
69
		public LocationFilterView(Mediator med,InventoryFilterView inventoryFilterView) {
66
		public LocationFilterView(Mediator med,InventoryFilterView inventoryFilterView) {
70
			
67
			
71
			
68
			
72
			mediator=med;
69
			mediator=med;
73
 
70
 
74
 
71
 
75
			user=mediator.getUser();
72
			user=mediator.getUser();
76
			serviceBaseUrl = mediator.getServiceBaseUrl();
73
			serviceBaseUrl = mediator.getServiceBaseUrl();
77
		
74
		
78
			mediator.registerLocationFilterView(this);
75
			mediator.registerLocationFilterView(this);
79
			
76
			
80
 
77
 
81
			initTree(); 
78
			initTree(); 
82
 
79
 
83
			
80
			
84
			ExpandItem locationfilter = new ExpandItem();  
81
			ExpandItem locationfilter = new ExpandItem();  
85
			locationfilter.setText("Lieux");  
82
			locationfilter.setText("Lieux");  
86
			
83
			
87
			
84
			
88
			ExpandBar expandBar=inventoryFilterView.getExpandBar();
85
			ExpandBar expandBar=inventoryFilterView.getExpandBar();
89
			locationfilter.getContainer().add(tree);
86
			locationfilter.getContainer().add(tree);
90
			expandBar.add(locationfilter);  
87
			expandBar.add(locationfilter);  
91
					
88
					
92
			locationfilter.setExpanded(true);  
89
			locationfilter.setExpanded(true);  
93
					
90
					
94
			
91
			
95
			
92
			
96
  }
93
  }
97
		
94
		
98
 // Initialisation noeud de base
95
 // Initialisation noeud de base
99
		
96
		
100
  void initTree() {
97
  void initTree() {
101
		
98
		
102
	  
99
	  
103
	  // Enregistrement Mise à jour asynchrone
100
	  // Enregistrement Mise à jour asynchrone
104
	  
101
	  
105
	   IAsyncTreeContentProvider cp = new IAsyncTreeContentProvider() {  
102
	   IAsyncTreeContentProvider cp = new IAsyncTreeContentProvider() {  
106
	    	
103
	    	
107
	   public Object[] getElements(Object input) {  
104
	   public Object[] getElements(Object input) {  
108
		      Model m = (Model) input;  
105
		      Model m = (Model) input;  
109
		       return m.getChildren().toArray();  
106
		       return m.getChildren().toArray();  
110
	   }  
107
	   }  
111
		     
108
		     
112
	   public Object getParent(Object element) {  
109
	   public Object getParent(Object element) {  
113
		   return ((Model) element).getParent();  
110
		   return ((Model) element).getParent();  
114
	   }  
111
	   }  
115
     
112
     
116
	   public boolean hasChildren(Object parent) {  
113
	   public boolean hasChildren(Object parent) {  
117
	          if (parent instanceof FALB) {  // Station
114
	          if (parent instanceof FALB) {  // Station
118
	        	  return false;  
115
	        	  return false;  
119
		      }
116
		      }
120
	          else  {
117
	          else  {
121
	        	  if (parent instanceof SALB) {  // Departement 
118
	        	  if (parent instanceof SALB) {  // Departement 
122
	        		  if (((SALB)parent).toString().compareTo(VALUE_UNKNOWN)==0)
119
	        		  if (((SALB)parent).toString().compareTo(VALUE_UNKNOWN)==0)
123
	        			  return false; 
120
	        			  return false; 
124
	        		  else 
121
	        		  else 
125
	        			  return true;  
122
	        			  return true;  
126
	        	  }
123
	        	  }
127
	        	  else {
124
	        	  else {
128
	        		  return true;
125
	        		  return true;
129
	        	  }
126
	        	  }
130
	          }
127
	          }
131
	    }  
128
	    }  
132
		     
129
		     
133
	    public void getChildren(final Object parent, final IAsyncContentCallback callback) {  
130
	    public void getChildren(final Object parent, final IAsyncContentCallback callback) {  
134
		           
131
		           
135
	          if (parent instanceof SALB) {  
132
	          if (parent instanceof SALB) {  
136
	        	  
133
	        	  
137
	        	  // Departement + commune
134
	        	  // Departement + commune
138
	        	  
135
	        	  
139
		           HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/"  
136
		           HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/"  
140
							+ ((SALB) parent).getAsString("path"),
137
							+ ((SALB) parent).getAsString("path"),
141
 
138
 
142
							new ResponseTextHandler() {
139
							new ResponseTextHandler() {
143
 
140
 
144
								public void onCompletion(String str) {
141
								public void onCompletion(String str) {
145
									
142
									
146
									JSONValue jsonValue = JSONParser.parse(str);
143
									JSONValue jsonValue = JSONParser.parse(str);
147
									JSONArray jsonArray;
144
									JSONArray jsonArray;
148
									JSONArray jsonArrayNested;
145
									JSONArray jsonArrayNested;
149
							
146
							
150
									int i=0;
147
									int i=0;
151
									
148
									
152
									if ((jsonArray = jsonValue.isArray()) != null) {
149
									if ((jsonArray = jsonValue.isArray()) != null) {
153
										int arraySize = jsonArray.size();
150
										int arraySize = jsonArray.size();
154
										talbs=new TALB[arraySize];
151
										talbs=new TALB[arraySize];
155
										for (i = 0; i < arraySize; ++i) {
152
										for (i = 0; i < arraySize; ++i) {
156
											if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
153
											if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
157
												String dep=Util.toCelString(((JSONString)jsonArrayNested.get(0)).toString());
154
												String dep=Util.toCelString(((JSONString)jsonArrayNested.get(0)).toString());
158
												if (dep.compareTo("000null")==0) dep=VALUE_UNKNOWN;
155
												if (dep.compareTo("000null")==0) dep=VALUE_UNKNOWN;
159
												talbs[i]=new TALB((SALB) parent,dep);
156
												talbs[i]=new TALB((SALB) parent,dep);
160
											}
157
											}
161
										}
158
										}
162
										callback.setElements(talbs);  
159
										callback.setElements(talbs);  
163
									}
160
									}
164
									
161
									
165
 
162
 
166
								}
163
								}
167
							});
164
							});
168
		           
165
		           
169
		         }  
166
		         }  
170
	          else if (parent instanceof TALB) {  
167
	          else if (parent instanceof TALB) {  
171
	        	  
168
	        	  
172
	        	  // Commune + station
169
	        	  // Commune + station
173
	        	  
170
	        	  
174
		           HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/"  
171
		           HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user + "/"  
175
							+ ((TALB) parent).getAsString("path") ,
172
							+ ((TALB) parent).getAsString("path") ,
176
							
173
							
177
							new ResponseTextHandler() {
174
							new ResponseTextHandler() {
178
 
175
 
179
								public void onCompletion(String str) {
176
								public void onCompletion(String str) {
180
									
177
									
181
									JSONValue jsonValue = JSONParser.parse(str);
178
									JSONValue jsonValue = JSONParser.parse(str);
182
									JSONArray jsonArray;
179
									JSONArray jsonArray;
183
									JSONArray jsonArrayNested;
180
									JSONArray jsonArrayNested;
184
							
181
							
185
									int i=0;
182
									int i=0;
186
									
183
									
187
									if ((jsonArray = jsonValue.isArray()) != null) {
184
									if ((jsonArray = jsonValue.isArray()) != null) {
188
										int arraySize = jsonArray.size();
185
										int arraySize = jsonArray.size();
189
										falbs=new FALB[arraySize];
186
										falbs=new FALB[arraySize];
190
										for (i = 0; i < arraySize; ++i) {
187
										for (i = 0; i < arraySize; ++i) {
191
											if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
188
											if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
192
												String com=Util.toCelString(((JSONString)jsonArrayNested.get(0)).toString());
189
												String com=Util.toCelString(((JSONString)jsonArrayNested.get(0)).toString());
193
												if (com.compareTo("000null")==0) com=VALUE_UNKNOWN;
190
												if (com.compareTo("000null")==0) com=VALUE_UNKNOWN;
194
												falbs[i]=new FALB((TALB) parent, com);
191
												falbs[i]=new FALB((TALB) parent, com);
195
											}
192
											}
196
										}
193
										}
197
										callback.setElements(falbs);  
194
										callback.setElements(falbs);  
198
										
195
										
199
									}
196
									}
200
									
197
									
201
 
198
 
202
								}
199
								}
203
							});
200
							});
204
		           
201
		           
205
 
202
 
206
	          }
203
	          }
207
	          	else if (parent instanceof RALB) {  
204
	          	else if (parent instanceof RALB) {  
208
	          		
205
	          		
209
	          		 // Rafraichissement Racine 
206
	          		 // Rafraichissement Racine 
210
		        	  
207
		        	  
211
			           HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user ,  
208
			           HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user ,  
212
								
209
								
213
								new ResponseTextHandler() {
210
								new ResponseTextHandler() {
214
 
211
 
215
									public void onCompletion(String str) {
212
									public void onCompletion(String str) {
216
										
213
										
217
										JSONValue jsonValue = JSONParser.parse(str);
214
										JSONValue jsonValue = JSONParser.parse(str);
218
										JSONArray jsonArray;
215
										JSONArray jsonArray;
219
										JSONArray jsonArrayNested;
216
										JSONArray jsonArrayNested;
220
								
217
								
221
										int i=0;
218
										int i=0;
222
										
219
										
223
										if ((jsonArray = jsonValue.isArray()) != null) {
220
										if ((jsonArray = jsonValue.isArray()) != null) {
224
											int arraySize = jsonArray.size();
221
											int arraySize = jsonArray.size();
225
											salbs=new SALB[arraySize];
222
											salbs=new SALB[arraySize];
226
											for (i = 0; i < arraySize; ++i) {
223
											for (i = 0; i < arraySize; ++i) {
227
												if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
224
												if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
228
													String all=Util.toCelString(((JSONString)jsonArrayNested.get(0)).toString());
225
													String all=Util.toCelString(((JSONString)jsonArrayNested.get(0)).toString());
229
													if (all.compareTo("000null")==0) all=VALUE_UNKNOWN;
226
													if (all.compareTo("000null")==0) all=VALUE_UNKNOWN;
230
													salbs[i]=new SALB(all);
227
													salbs[i]=new SALB(all);
231
												}
228
												}
232
											}
229
											}
233
 
230
 
234
											callback.setElements(salbs);  
231
											callback.setElements(salbs);  
235
											
232
											
236
											Model m=new Model();
233
											Model m=new Model();
237
											m.set("name",id_location);
234
											m.set("name",id_location);
238
											viewer.setExpanded(m,true);
235
											viewer.setExpanded(m,true);
239
											
236
											
240
										}
237
										}
241
										
238
										
242
 
239
 
243
									}
240
									}
244
								});
241
								});
245
 
242
 
246
	        	  
243
	        	  
247
 
244
 
248
	          	}
245
	          	}
249
 
246
 
250
	    	}
247
	    	}
251
		     
248
		     
252
		    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {  
249
		    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {  
253
		     
250
		     
254
		    }  
251
		    }  
255
		     
252
		     
256
		 };  
253
		 };  
257
	  
254
	  
258
		 tree = new Tree();  
255
		 tree = new Tree();  
259
		
256
		
260
		 viewer = new TreeViewer(tree);  
257
		 viewer = new TreeViewer(tree);  
261
		 viewer.setContentProvider(cp);  
258
		 viewer.setContentProvider(cp);  
262
		 
259
		 
263
		 viewer.setLabelProvider(new ModelLabelProvider());
260
		 viewer.setLabelProvider(new ModelLabelProvider());
264
 
261
 
265
		 viewer.setComparer(new IElementComparer() {
262
		 viewer.setComparer(new IElementComparer() {
266
			 
263
			 
267
			 public boolean equals(Object a, Object b) {
264
			 public boolean equals(Object a, Object b) {
268
				
265
				
269
				 if ((a==null) || b==null) 
266
				 if ((a==null) || b==null) 
270
					 return false;
267
					 return false;
271
				 if (((Model) a).getAsString("name").compareTo(((Model) b).getAsString("name"))==0) {
268
				 if (((Model) a).getAsString("name").compareTo(((Model) b).getAsString("name"))==0) {
272
					 return true;
269
					 return true;
273
				 }
270
				 }
274
				 else return false;
271
				 else return false;
275
				 
272
				 
276
			 }
273
			 }
277
				 
274
				 
278
		 }
275
		 }
279
		 );
276
		 );
280
		 
277
		 
281
		 
278
		 
282
		   viewer.addSelectionListener(new ISelectionChangedListener() {  
279
		   viewer.addSelectionListener(new ISelectionChangedListener() {  
283
			        public void selectionChanged(SelectionChangedEvent se) {  
280
			        public void selectionChanged(SelectionChangedEvent se) {  
284
			          Model m = (Model) se.getSelection().getFirstElement();  
281
			          Model m = (Model) se.getSelection().getFirstElement();  
285
			       //   Info.show("Selection Changed", "{0} was selected", m.getAsString("path"));  
282
			       //   Info.show("Selection Changed", "{0} was selected", m.getAsString("path"));  
286
			         
283
			         
287
			          if (m instanceof TALB) { // Commune
284
			          if (m instanceof TALB) { // Commune
288
			        	  location=m.getAsString("name");
285
			        	  location=m.getAsString("name");
289
			        	  if (location.compareTo(VALUE_UNKNOWN)==0) location="000null";
286
			        	  if (location.compareTo(VALUE_UNKNOWN)==0) location="000null";
290
			        	  id_location=m.getAsString("salb");
287
			        	  id_location=m.getAsString("salb");
291
			        	  if (id_location.compareTo(VALUE_UNKNOWN)==0) id_location="000null";
288
			        	  if (id_location.compareTo(VALUE_UNKNOWN)==0) id_location="000null";
292
			        	  lieudit="all";
289
			        	  lieudit="all";
293
			        	  mediator.onLocationSelected(id_location,location,lieudit);
290
			        	  mediator.onLocationSelected(id_location,location,lieudit);
294
			          }
291
			          }
295
			          else 
292
			          else 
296
				          if (m instanceof FALB) { // Station
293
				          if (m instanceof FALB) { // Station
297
				        	  id_location=m.getAsString("salb");
294
				        	  id_location=m.getAsString("salb");
298
				        	  if (id_location.compareTo(VALUE_UNKNOWN)==0) id_location="000null";
295
				        	  if (id_location.compareTo(VALUE_UNKNOWN)==0) id_location="000null";
299
				        	  location=m.getAsString("talb");
296
				        	  location=m.getAsString("talb");
300
				        	  if (location.compareTo(VALUE_UNKNOWN)==0) location="000null";
297
				        	  if (location.compareTo(VALUE_UNKNOWN)==0) location="000null";
301
				        	  lieudit=m.getAsString("name");
298
				        	  lieudit=m.getAsString("name");
302
				        	  if (lieudit.compareTo(VALUE_UNKNOWN)==0) lieudit="000null";
299
				        	  if (lieudit.compareTo(VALUE_UNKNOWN)==0) lieudit="000null";
303
				        	  mediator.onLocationSelected(id_location,location,lieudit);
300
				        	  mediator.onLocationSelected(id_location,location,lieudit);
304
				          }
301
				          }
305
			          
302
			          
306
				          else 
303
				          else 
307
				        	 
304
				        	 
308
				          if (m instanceof SALB) { // Departement
305
				          if (m instanceof SALB) { // Departement
309
				        	  id_location=m.getAsString("name");
306
				        	  id_location=m.getAsString("name");
310
				        	  if (id_location.compareTo(VALUE_UNKNOWN)==0) id_location="000null";
307
				        	  if (id_location.compareTo(VALUE_UNKNOWN)==0) id_location="000null";
311
				        	  location="all";
308
				        	  location="all";
312
				        	  lieudit="all";
309
				        	  lieudit="all";
313
				        	  mediator.onLocationSelected(id_location,location,lieudit);
310
				        	  mediator.onLocationSelected(id_location,location,lieudit);
314
				          }
311
				          }
315
			          
312
			          
316
			          		if (m instanceof RALB) { // Pays
313
			          		if (m instanceof RALB) { // Pays
317
			          				id_location="all";
314
			          				id_location="all";
318
			          				location="all";
315
			          				location="all";
319
			          				lieudit="all";
316
			          				lieudit="all";
320
			          				mediator.onLocationSelected(id_location,location,lieudit);
317
			          				mediator.onLocationSelected(id_location,location,lieudit);
321
			          		}
318
			          		}
322
 
319
 
323
 
320
 
324
			          
321
			          
325
			        }  
322
			        }  
326
		});  
323
		});  
327
		 
324
		 
328
		 // Initialisation premier niveau (doublon obligatoire avec rafraichissement asynchrone)
325
		 // Initialisation premier niveau (doublon obligatoire avec rafraichissement asynchrone)
329
		 
326
		 
330
		 root = new Model();
327
		 root = new Model();
331
		 HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user ,
328
		 HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryLocationList/" + user ,
332
 
329
 
333
					new ResponseTextHandler() {
330
					new ResponseTextHandler() {
334
 
331
 
335
						public void onCompletion(String str) {
332
						public void onCompletion(String str) {
336
							
333
							
337
							JSONValue jsonValue = JSONParser.parse(str);
334
							JSONValue jsonValue = JSONParser.parse(str);
338
							JSONArray jsonArray;
335
							JSONArray jsonArray;
339
							JSONArray jsonArrayNested;
336
							JSONArray jsonArrayNested;
340
					
337
					
341
							int i=0;
338
							int i=0;
342
							
339
							
343
							if ((jsonArray = jsonValue.isArray()) != null) {
340
							if ((jsonArray = jsonValue.isArray()) != null) {
344
								int arraySize = jsonArray.size();
341
								int arraySize = jsonArray.size();
345
								salbs=new SALB[arraySize];
342
								salbs=new SALB[arraySize];
346
								ralb = new RALB("France");
343
								ralb = new RALB("France");
347
								for (i = 0; i < arraySize; ++i) {
344
								for (i = 0; i < arraySize; ++i) {
348
									if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
345
									if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
349
										String all=Util.toCelString(((JSONString)jsonArrayNested.get(0)).toString());
346
										String all=Util.toCelString(((JSONString)jsonArrayNested.get(0)).toString());
350
										if (all.compareTo("000null")==0) all=VALUE_UNKNOWN;
347
										if (all.compareTo("000null")==0) all=VALUE_UNKNOWN;
351
										salbs[i]=new SALB(all);
348
										salbs[i]=new SALB(all);
352
										ralb.add(salbs[i]);
349
										ralb.add(salbs[i]);
353
									}
350
									}
354
								}
351
								}
355
								root.add(ralb);
352
								root.add(ralb);
356
								viewer.setInput(root);  
353
								viewer.setInput(root);  
357
							}
354
							}
358
							
355
							
359
 
356
 
360
						}
357
						}
361
					});
358
					});
362
		 
359
		 
363
      }
360
      }
364
 
361
 
365
		
362
		
366
 
363
 
367
		public void setLocation(String location) {
364
		public void setLocation(String location) {
368
			this.location = location;
365
			this.location = location;
369
		}
366
		}
370
		
367
		
371
 
368
 
372
 
369
 
373
		public void setIDLocation(String id_location) {
370
		public void setIDLocation(String id_location) {
374
			this.id_location = id_location;
371
			this.id_location = id_location;
375
		}
372
		}
376
 
373
 
377
 
374
 
378
 
375
 
379
		public void setLieudit(String lieudit) {
376
		public void setLieudit(String lieudit) {
380
			this.lieudit = lieudit;
377
			this.lieudit = lieudit;
381
		}
378
		}
382
 
379
 
383
		
380
		
384
		public void setUser(String user) {
381
		public void setUser(String user) {
385
			this.user = user;
382
			this.user = user;
386
		}
383
		}
387
 
384
 
388
 
385
 
389
		private class RALB extends Model {  // Root Administrative level boundaries (pays)
386
		private class RALB extends Model {  // Root Administrative level boundaries (pays)
390
 
387
 
391
			  public RALB(String name) {
388
			  public RALB(String name) {
392
			    set("name", name);
389
			    set("name", name);
393
			    set("path", URL.encodeComponent(name));
390
			    set("path", URL.encodeComponent(name));
394
			  }
391
			  }
395
 
392
 
396
			  public String toString() {
393
			  public String toString() {
397
			    return getAsString("name");
394
			    return getAsString("name");
398
			  }
395
			  }
399
 
396
 
400
		}
397
		}
401
 
398
 
402
		
399
		
403
		private class SALB extends Model {  // Second Administrative level boundaries (departerment)
400
		private class SALB extends Model {  // Second Administrative level boundaries (departerment)
404
 
401
 
405
			  public SALB(String name) {
402
			  public SALB(String name) {
406
			    set("name", name);
403
			    set("name", name);
407
			    set("path", URL.encodeComponent(name));
404
			    set("path", URL.encodeComponent(name));
408
			  }
405
			  }
409
 
406
 
410
			  public String toString() {
407
			  public String toString() {
411
				    return getAsString("name");
408
				    return getAsString("name");
412
			  }
409
			  }
413
 
410
 
414
		}
411
		}
415
		
412
		
416
		
413
		
417
		private class TALB extends Model {  // Tierce Administrative level boundaries (Commune)
414
		private class TALB extends Model {  // Tierce Administrative level boundaries (Commune)
418
 
415
 
419
			  public TALB(SALB parent, String name) {
416
			  public TALB(SALB parent, String name) {
420
			    set("name", name);
417
			    set("name", name);
421
			    set("salb", parent.get("name"));
418
			    set("salb", parent.get("name"));
422
			    set("path", parent.get("path")+"/"+URL.encodeComponent(name));
419
			    set("path", parent.get("path")+"/"+URL.encodeComponent(name));
423
			  }
420
			  }
424
 
421
 
425
			  public String toString() {
422
			  public String toString() {
426
				    return getAsString("name");
423
				    return getAsString("name");
427
 
424
 
428
			  }
425
			  }
429
 
426
 
430
		}
427
		}
431
		
428
		
432
	 		
429
	 		
433
		private class FALB extends Model {  // Forth Administrative level boundaries (Station)
430
		private class FALB extends Model {  // Forth Administrative level boundaries (Station)
434
 
431
 
435
			  public FALB(TALB parent,String name) {
432
			  public FALB(TALB parent,String name) {
436
			    set("name", name);
433
			    set("name", name);
437
			    set("salb", parent.get("salb"));
434
			    set("salb", parent.get("salb"));
438
			    set("talb", parent.get("name"));
435
			    set("talb", parent.get("name"));
439
			    set("path", parent.get("path")+"/"+URL.encodeComponent(name));
436
			    set("path", parent.get("path")+"/"+URL.encodeComponent(name));
440
			  }
437
			  }
441
 
438
 
442
			  public String toString() {
439
			  public String toString() {
443
				    return getAsString("name");
440
				    return getAsString("name");
444
			  }
441
			  }
445
 
442
 
446
		}
443
		}
447
		
444
		
448
 
445
 
449
		public void update() {
446
		public void update() {
450
		
447
		
451
 
448
 
452
			
449
			
453
			Model m=new Model();
450
			Model m=new Model();
454
			m.set("name",id_location);
451
			m.set("name",id_location);
455
			
452
			
456
			if (viewer.findItem(m)!=null) {
453
			if (viewer.findItem(m)!=null) {
457
				viewer.refresh(m); // Rafraichissement branche departemental
454
				viewer.refresh(m); // Rafraichissement branche departemental
458
				
455
				
459
			}
456
			}
460
			else { // Pas de branche departementale ? : rafraichissement total
457
			else { // Pas de branche departementale ? : rafraichissement total
461
				Model r=new Model();
458
				Model r=new Model();
462
				r.set("name","France");
459
				r.set("name","France");
463
				viewer.refresh(r); 
460
				viewer.refresh(r); 
464
			}
461
			}
465
			
462
			
466
		
463
		
467
		}
464
		}
468
 
465
 
469
		
466
		
470
}
467
}