Subversion Repositories eFlore/Archives.cel-v1

Rev

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

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