| 28 |
ddelon |
1 |
/**
|
|
|
2 |
David Delon david.delon@clapas.net 2007
|
|
|
3 |
|
|
|
4 |
*/
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
/*
|
|
|
8 |
* InventoryListView.java (Composite de Panel)
|
|
|
9 |
*
|
|
|
10 |
* Cas d'utilisation :
|
|
|
11 |
*
|
|
|
12 |
* Affichage de releve
|
|
|
13 |
*
|
|
|
14 |
* 1 : Recherche du nombre de releves associe au navigateur ou a l'utilisateur est connecte, en fonction des criteres de selection
|
|
|
15 |
* 2 : Recherche des releves correspondant au critere precedent
|
|
|
16 |
* 3 : Affichage des releves avec positionnement sur le dernier releve
|
|
|
17 |
*
|
|
|
18 |
* Selection de releve
|
|
|
19 |
*
|
|
|
20 |
* 1 : L'utilisateur selectionne un releve : lancement de l'affichage detaille pour le releve selectionne
|
|
|
21 |
*
|
|
|
22 |
*
|
|
|
23 |
* Pagination :
|
|
|
24 |
*
|
|
|
25 |
* 1 : Avancement ou recul d'une page
|
|
|
26 |
*
|
|
|
27 |
*
|
|
|
28 |
*
|
|
|
29 |
* Suppression d'une liste d'element
|
|
|
30 |
*/
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
/* Actions declenchees :
|
|
|
34 |
*
|
|
|
35 |
* onInventoryItemSelected(numero d'ordre de la ligne selectionne) : selection d'une ligne
|
|
|
36 |
* onInventoryItemUnselected(numero d'ordre de la ligne selectionne) : deselection d'une ligne
|
|
|
37 |
* onInventoryUpdated(location) : action suite a la modification, suppression, creation d'un element d'inventaire
|
|
|
38 |
*
|
|
|
39 |
*/
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
package org.tela_botanica.client;
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
import net.mygwt.ui.client.Events;
|
|
|
46 |
import net.mygwt.ui.client.Style;
|
|
|
47 |
import net.mygwt.ui.client.event.BaseEvent;
|
|
|
48 |
import net.mygwt.ui.client.event.Listener;
|
|
|
49 |
import net.mygwt.ui.client.widget.ContentPanel;
|
|
|
50 |
import net.mygwt.ui.client.widget.WidgetContainer;
|
|
|
51 |
import net.mygwt.ui.client.widget.layout.BorderLayoutData;
|
|
|
52 |
import net.mygwt.ui.client.widget.layout.FillLayout;
|
|
|
53 |
import net.mygwt.ui.client.widget.table.Table;
|
|
|
54 |
import net.mygwt.ui.client.widget.table.TableColumn;
|
|
|
55 |
import net.mygwt.ui.client.widget.table.TableColumnModel;
|
|
|
56 |
import net.mygwt.ui.client.widget.table.TableItem;
|
|
|
57 |
|
|
|
58 |
import com.google.gwt.http.client.URL;
|
|
|
59 |
import com.google.gwt.json.client.JSONArray;
|
|
|
60 |
import com.google.gwt.json.client.JSONNumber;
|
|
|
61 |
import com.google.gwt.json.client.JSONParser;
|
|
|
62 |
import com.google.gwt.json.client.JSONString;
|
|
|
63 |
import com.google.gwt.json.client.JSONValue;
|
|
|
64 |
import com.google.gwt.user.client.HTTPRequest;
|
|
|
65 |
import com.google.gwt.user.client.ResponseTextHandler;
|
|
|
66 |
import com.google.gwt.user.client.ui.Composite;
|
|
|
67 |
import com.google.gwt.user.client.ui.DockPanel;
|
|
|
68 |
import com.google.gwt.user.client.ui.HTML;
|
|
|
69 |
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
70 |
import com.google.gwt.user.client.ui.Image;
|
|
|
71 |
import com.google.gwt.user.client.ui.Button;
|
|
|
72 |
import com.google.gwt.user.client.ui.Label;
|
|
|
73 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
74 |
import com.google.gwt.user.client.ui.ClickListener;
|
|
|
75 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
|
|
76 |
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
public class InventoryListView
|
|
|
80 |
{
|
|
|
81 |
|
|
|
82 |
// Debut Barre de navigation
|
|
|
83 |
|
|
|
84 |
private class NavBar extends Composite implements ClickListener {
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
public final DockPanel bar = new DockPanel();
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
public final Button gotoFirst = new Button("<<", this);
|
|
|
91 |
public final Button gotoNext = new Button(">", this);
|
|
|
92 |
public final Button gotoPrev = new Button("<", this);
|
|
|
93 |
public final Button gotoEnd = new Button(">>", this);
|
|
|
94 |
public final Label status = new Label();
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
public NavBar() {
|
|
|
98 |
|
|
|
99 |
initWidget(bar);
|
|
|
100 |
|
|
|
101 |
status.setWordWrap(false);
|
|
|
102 |
|
|
|
103 |
HorizontalPanel buttons = new HorizontalPanel();
|
|
|
104 |
|
|
|
105 |
buttons.add(status);
|
|
|
106 |
buttons.setCellHorizontalAlignment(status, HasHorizontalAlignment.ALIGN_RIGHT);
|
|
|
107 |
buttons.setCellVerticalAlignment(status, HasVerticalAlignment.ALIGN_MIDDLE);
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
buttons.add(gotoFirst);
|
|
|
111 |
buttons.add(gotoPrev);
|
|
|
112 |
buttons.add(gotoNext);
|
|
|
113 |
buttons.add(gotoEnd);
|
|
|
114 |
|
|
|
115 |
bar.add(buttons, DockPanel.EAST);
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
public void onClick(Widget sender) {
|
|
|
122 |
if (sender == gotoNext) {
|
|
|
123 |
// Move forward a page.
|
|
|
124 |
startIndex += VISIBLE_TAXON_COUNT;
|
|
|
125 |
if (startIndex >= count)
|
|
|
126 |
startIndex -= VISIBLE_TAXON_COUNT;
|
|
|
127 |
} else {
|
|
|
128 |
if (sender == gotoPrev) {
|
|
|
129 |
// Move back a page.
|
|
|
130 |
startIndex -= VISIBLE_TAXON_COUNT;
|
|
|
131 |
if (startIndex < 0)
|
|
|
132 |
startIndex = 0;
|
|
|
133 |
} else {
|
|
|
134 |
if (sender == gotoEnd) {
|
|
|
135 |
gotoEnd();
|
|
|
136 |
} else {
|
|
|
137 |
if (sender == gotoFirst) {
|
|
|
138 |
startIndex = 0;
|
|
|
139 |
}
|
|
|
140 |
}
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
update();
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
// Fin Barre de navigation
|
|
|
149 |
|
|
|
150 |
// Conteneur (header et table sont dans panel)
|
|
|
151 |
private ContentPanel panel =null;
|
|
|
152 |
private Table table = null;
|
|
|
153 |
|
|
|
154 |
// Services
|
|
|
155 |
private String serviceBaseUrl = null;
|
|
|
156 |
private String user;
|
|
|
157 |
private Mediator mediator = null;
|
|
|
158 |
|
|
|
159 |
// Navigation
|
|
|
160 |
private int startIndex = 0;
|
|
|
161 |
private int count = 0;
|
|
|
162 |
private static final int VISIBLE_TAXON_COUNT = 15;
|
|
|
163 |
private NavBar navBar=null;
|
|
|
164 |
|
|
|
165 |
// Filtre par defaut :
|
|
|
166 |
|
|
|
167 |
private String location = "all";
|
|
|
168 |
private String date = "all";
|
|
|
169 |
private String search = "all";
|
|
|
170 |
private String station = "all";
|
|
|
171 |
private String ordre= null;
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
public InventoryListView(Mediator med) {
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
// Traitement contexte utilisateur et service
|
|
|
180 |
|
|
|
181 |
mediator=med;
|
|
|
182 |
|
|
|
183 |
user=mediator.getUser();
|
|
|
184 |
serviceBaseUrl = mediator.getServiceBaseUrl();
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
panel= new ContentPanel(Style.HEADER);
|
|
|
188 |
panel.setLayout(new FillLayout());
|
|
|
189 |
|
|
|
190 |
|
|
|
191 |
// Barre navigation integree au header
|
|
|
192 |
|
|
|
193 |
navBar = new NavBar();
|
|
|
194 |
panel.getHeader().addWidget(navBar);
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
// Contenu :
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
// Colonnes :
|
|
|
201 |
|
|
|
202 |
TableColumn[] columns = new TableColumn[5];
|
|
|
203 |
|
|
|
204 |
// TODO : renderer date, alignement etc
|
|
|
205 |
|
|
|
206 |
columns[0] = new TableColumn("etat","Transmis", 50);
|
|
|
207 |
columns[0].setSortable(false);
|
|
|
208 |
|
|
|
209 |
columns[1] = new TableColumn("nom","Nom saisi", 200);
|
|
|
210 |
columns[1].setSortable(false);
|
|
|
211 |
|
|
|
212 |
columns[2] = new TableColumn("observation","Observation", 650);
|
|
|
213 |
columns[2].setSortable(false);
|
|
|
214 |
|
|
|
215 |
columns[3] = new TableColumn("date","Date", 75);
|
|
|
216 |
columns[3].setSortable(false);
|
|
|
217 |
|
|
|
218 |
columns[4] = new TableColumn("ordre","Ordre", 50);
|
|
|
219 |
columns[4].setSortable(false);
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
TableColumnModel cm = new TableColumnModel(columns);
|
|
|
223 |
|
|
|
224 |
// Table :
|
|
|
225 |
|
|
|
226 |
table = new Table(Style.MULTI | Style.HORIZONTAL, cm);
|
|
|
227 |
table.setBorders(false);
|
|
|
228 |
|
|
|
229 |
|
|
|
230 |
panel.add(table);
|
|
|
231 |
|
|
|
232 |
WidgetContainer center=mediator.getCenterContainer();
|
|
|
233 |
BorderLayoutData centerData = new BorderLayoutData(Style.CENTER, .75f, 100, 1000);
|
|
|
234 |
center.add(panel,centerData);
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
|
|
|
238 |
table.addListener(Events.RowClick, new Listener() {
|
|
|
239 |
|
|
|
240 |
public void handleEvent(BaseEvent be) {
|
|
|
241 |
TableItem item=(TableItem) be.item;
|
|
|
242 |
if (item!=null) {
|
|
|
243 |
if (ordre==null) {
|
|
|
244 |
ordre= (String) item.getValue(4);
|
|
|
245 |
mediator.onInventoryItemSelected(ordre);
|
|
|
246 |
}
|
|
|
247 |
else {
|
|
|
248 |
if (ordre.compareTo((String) item.getValue(4))==0) {
|
|
|
249 |
ordre=null;
|
|
|
250 |
table.deselect(be.rowIndex);
|
|
|
251 |
mediator.onInventoryItemUnselected();
|
|
|
252 |
}
|
|
|
253 |
else {
|
|
|
254 |
ordre= (String) item.getValue(4);
|
|
|
255 |
mediator.onInventoryItemSelected(ordre);
|
|
|
256 |
}
|
|
|
257 |
|
|
|
258 |
}
|
|
|
259 |
}
|
|
|
260 |
}
|
|
|
261 |
});
|
|
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
}
|
|
|
268 |
|
|
|
269 |
|
|
|
270 |
/**
|
|
|
271 |
* Suppression d'un ensemble d'element de la liste d'inventaire, on garde ici car s'applique a plusieurs elements
|
|
|
272 |
*
|
|
|
273 |
*/
|
|
|
274 |
|
|
|
275 |
public void deleteElement() {
|
|
|
276 |
|
|
|
277 |
setStatusDisabled();
|
|
|
278 |
TableItem[] selection=table.getSelection();
|
|
|
279 |
|
|
|
280 |
StringBuffer ids=new StringBuffer();
|
|
|
281 |
for (int i = 0; i < selection.length; i++) {
|
|
|
282 |
ids.append((String)(((TableItem) selection[i]).getValue(4)));
|
|
|
283 |
if (i<(selection.length-1)) ids.append(",");
|
|
|
284 |
}
|
|
|
285 |
|
|
|
286 |
if (ids.length()>0) {
|
|
|
287 |
|
|
|
288 |
HTTPRequest.asyncPost(serviceBaseUrl + "/Inventory/" + user
|
|
|
289 |
+ "/" + ids.toString(), "action=DELETE",
|
|
|
290 |
|
|
|
291 |
new ResponseTextHandler() {
|
|
|
292 |
public void onCompletion(String str) {
|
|
|
293 |
mediator.onInventoryUpdated(location);
|
|
|
294 |
}
|
|
|
295 |
});
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
setStatusEnabled();
|
|
|
299 |
|
|
|
300 |
}
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
|
305 |
/**
|
|
|
306 |
* Transmission de releve a Tela, on garde ici car s'applique a plusieurs elements
|
|
|
307 |
*/
|
|
|
308 |
|
|
|
309 |
|
|
|
310 |
public void transmitElement() {
|
|
|
311 |
|
|
|
312 |
setStatusDisabled();
|
|
|
313 |
|
|
|
314 |
TableItem[] selection=table.getSelection();
|
|
|
315 |
|
|
|
316 |
StringBuffer ids=new StringBuffer();
|
|
|
317 |
for (int i = 0; i < selection.length; i++) {
|
|
|
318 |
ids.append((String)(((TableItem) selection[i]).getValue(4)));
|
|
|
319 |
if (i<(selection.length-1)) ids.append(",");
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
if (ids.length()>0) {
|
|
|
323 |
|
|
|
324 |
HTTPRequest.asyncPost(serviceBaseUrl + "/InventoryTransmit/" + user
|
|
|
325 |
+ "/" + ids.toString(), "transmission=1",
|
|
|
326 |
|
|
|
327 |
new ResponseTextHandler() {
|
|
|
328 |
public void onCompletion(String str) {
|
|
|
329 |
update(); // Pour affichage logo
|
|
|
330 |
}
|
|
|
331 |
});
|
|
|
332 |
}
|
|
|
333 |
|
|
|
334 |
setStatusEnabled();
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
}
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
/**
|
|
|
341 |
* Recherche nombre d'enregistrement pour l'utilisateur et la localite en cours
|
|
|
342 |
*
|
|
|
343 |
*/
|
|
|
344 |
|
|
|
345 |
public void updateCount () {
|
|
|
346 |
|
|
|
347 |
setStatusDisabled();
|
|
|
348 |
|
|
|
349 |
|
|
|
350 |
// Transformation de la date selectionne vers date time stamp
|
|
|
351 |
|
|
|
352 |
String adate="all";
|
|
|
353 |
if (date.compareTo("all")!=0) {
|
|
|
354 |
adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
|
|
|
355 |
}
|
|
|
356 |
|
|
|
357 |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + URL.encodeComponent(location) + "/" + adate + "/" + URL.encodeComponent(search) + "/" + URL.encodeComponent(station),
|
|
|
358 |
new ResponseTextHandler() {
|
|
|
359 |
|
|
|
360 |
public void onCompletion(String str) {
|
|
|
361 |
|
|
|
362 |
JSONValue jsonValue = JSONParser.parse(str);
|
|
|
363 |
JSONNumber jsonNumber;
|
|
|
364 |
if ((jsonNumber = jsonValue.isNumber()) != null) {
|
|
|
365 |
count = (int) jsonNumber.getValue();
|
|
|
366 |
// if (location.compareTo("")==0) location="000null";
|
|
|
367 |
gotoEnd(); // Derniere page
|
|
|
368 |
update();
|
|
|
369 |
}
|
|
|
370 |
}
|
|
|
371 |
});
|
|
|
372 |
|
|
|
373 |
}
|
|
|
374 |
|
|
|
375 |
/**
|
|
|
376 |
* Mise a jour de l'affichage, a partir des donnaes d'inventaire deja
|
|
|
377 |
* saisies. La valeur de this.startIndex permet de determiner quelles
|
|
|
378 |
* donnaes seront affichees
|
|
|
379 |
*
|
|
|
380 |
*/
|
|
|
381 |
|
|
|
382 |
public void update() {
|
|
|
383 |
|
|
|
384 |
|
|
|
385 |
|
|
|
386 |
// TODO : optimisation (ne pas supprimer mais remplacer)
|
|
|
387 |
|
|
|
388 |
|
|
|
389 |
|
|
|
390 |
// Ligne d'information
|
|
|
391 |
|
|
|
392 |
// Toutes date par defaut
|
|
|
393 |
|
|
|
394 |
String adate="all";
|
|
|
395 |
if (date.compareTo("all")!=0) {
|
|
|
396 |
adate=date.substring(6,10)+"-"+date.substring(3,5)+"-"+date.substring(0,2)+" 00:00:00";
|
|
|
397 |
}
|
|
|
398 |
|
|
|
399 |
HTTPRequest.asyncGet(serviceBaseUrl + "/InventoryItemList/" + user + "/" + URL.encodeComponent(location) +"/" + adate + "/" + URL.encodeComponent(search) + "/" + URL.encodeComponent(station) + "/"
|
|
|
400 |
+ startIndex + "/" + VISIBLE_TAXON_COUNT,
|
|
|
401 |
|
|
|
402 |
new ResponseTextHandler() {
|
|
|
403 |
|
|
|
404 |
public void onCompletion(String str) {
|
|
|
405 |
|
|
|
406 |
JSONValue jsonValue = JSONParser.parse(str);
|
|
|
407 |
JSONArray jsonArray;
|
|
|
408 |
JSONArray jsonArrayNested;
|
|
|
409 |
|
|
|
410 |
int row=0;
|
|
|
411 |
int i=0;
|
|
|
412 |
|
|
|
413 |
if ((jsonArray = jsonValue.isArray()) != null) {
|
|
|
414 |
|
|
|
415 |
StringBuffer observationText=null;
|
|
|
416 |
|
|
|
417 |
int arraySize = jsonArray.size();
|
|
|
418 |
|
|
|
419 |
for (i = 0; i < arraySize; ++i) {
|
|
|
420 |
if ((jsonArrayNested = jsonArray.get(i).isArray()) != null) {
|
|
|
421 |
|
|
|
422 |
|
|
|
423 |
Object[] values = new Object[5];
|
|
|
424 |
|
|
|
425 |
observationText=new StringBuffer();
|
|
|
426 |
|
|
|
427 |
// Statut Observation transmise ?
|
|
|
428 |
|
|
|
429 |
|
|
|
430 |
String atransmit=((JSONString) jsonArrayNested .get(11)).stringValue();
|
|
|
431 |
|
|
|
432 |
if (atransmit.compareTo("1")==0) {
|
|
|
433 |
values[0] = new Image("tela.gif");
|
|
|
434 |
}
|
|
|
435 |
else {
|
|
|
436 |
values[0] = new HTML(" ");
|
|
|
437 |
}
|
|
|
438 |
|
|
|
439 |
|
|
|
440 |
// Nom saisi
|
|
|
441 |
|
|
|
442 |
values[1] = new HTML("<b>"+Util.toCelString(((JSONString) jsonArrayNested .get(0)).toString())+"</b>");
|
|
|
443 |
|
|
|
444 |
|
|
|
445 |
|
|
|
446 |
// Texte decrivant l'observation
|
|
|
447 |
|
|
|
448 |
// Nom retenu
|
|
|
449 |
String aname=Util.toCelString(((JSONString) jsonArrayNested .get(2)).toString());
|
|
|
450 |
|
|
|
451 |
if (aname.compareTo("null")==0) {
|
|
|
452 |
}
|
|
|
453 |
else {
|
|
|
454 |
observationText.append(aname+", ");
|
|
|
455 |
}
|
|
|
456 |
|
|
|
457 |
// Num nomenclatural
|
|
|
458 |
String ann=((JSONString) jsonArrayNested .get(3)).stringValue();
|
|
|
459 |
|
|
|
460 |
if (ann.compareTo("0")!=0) {
|
|
|
461 |
observationText.append(""+ann+"-");
|
|
|
462 |
}
|
|
|
463 |
else {
|
|
|
464 |
observationText.append("0-");
|
|
|
465 |
}
|
|
|
466 |
|
|
|
467 |
|
|
|
468 |
// Num Taxonomique
|
|
|
469 |
|
|
|
470 |
String ant=((JSONString) jsonArrayNested .get(4)).stringValue();
|
|
|
471 |
|
|
|
472 |
if (ant.compareTo("0")!=0) {
|
|
|
473 |
observationText.append(ant+", ");
|
|
|
474 |
}
|
|
|
475 |
else {
|
|
|
476 |
observationText.append("0, ");
|
|
|
477 |
}
|
|
|
478 |
|
|
|
479 |
// Famille
|
|
|
480 |
String afamily=Util.toCelString(((JSONString) jsonArrayNested .get(5)).toString());
|
|
|
481 |
|
|
|
482 |
if (afamily.compareTo("null")==0) {
|
|
|
483 |
//
|
|
|
484 |
}
|
|
|
485 |
else {
|
|
|
486 |
observationText.append(afamily+", ");
|
|
|
487 |
}
|
|
|
488 |
|
|
|
489 |
|
|
|
490 |
String aloc=Util.toCelString(((JSONString) jsonArrayNested .get(6)).toString());
|
|
|
491 |
// Localisation - Lieu
|
|
|
492 |
|
|
|
493 |
if (aloc.compareTo("000null")==0) {
|
|
|
494 |
if (observationText.length()==0) {
|
|
|
495 |
observationText.append("Commune absente");
|
|
|
496 |
}
|
|
|
497 |
else {
|
|
|
498 |
observationText.append("commune absente");
|
|
|
499 |
}
|
|
|
500 |
}
|
|
|
501 |
else {
|
|
|
502 |
if (observationText.length()==0) {
|
|
|
503 |
observationText.append("Commune de "+aloc);
|
|
|
504 |
}
|
|
|
505 |
else {
|
|
|
506 |
observationText.append("commune de "+aloc);
|
|
|
507 |
}
|
|
|
508 |
|
|
|
509 |
}
|
|
|
510 |
|
|
|
511 |
|
|
|
512 |
String alieudit=Util.toCelString(((JSONString) jsonArrayNested .get(9)).toString());
|
|
|
513 |
|
|
|
514 |
// Localisation - Lieu dit
|
|
|
515 |
|
|
|
516 |
if (alieudit.compareTo("000null")!=0) {
|
|
|
517 |
observationText.append(", "+alieudit);
|
|
|
518 |
}
|
|
|
519 |
|
|
|
520 |
String acomment=Util.toCelString(((JSONString) jsonArrayNested .get(10)).toString());
|
|
|
521 |
// Commentaire
|
|
|
522 |
|
|
|
523 |
if (acomment.compareTo("null")!=0) {
|
|
|
524 |
observationText.append(", "+acomment);
|
|
|
525 |
}
|
|
|
526 |
|
|
|
527 |
|
|
|
528 |
String adate=((JSONString) jsonArrayNested .get(8)).stringValue();
|
|
|
529 |
|
|
|
530 |
// Date
|
|
|
531 |
if (adate.compareTo("0000-00-00 00:00:00")!=0) {
|
|
|
532 |
values[3]=new HTML("<b>"+adate+"</b>");
|
|
|
533 |
}
|
|
|
534 |
else {
|
|
|
535 |
values[3] = new HTML(" ");
|
|
|
536 |
}
|
|
|
537 |
|
|
|
538 |
|
|
|
539 |
|
|
|
540 |
values[2] = observationText;
|
|
|
541 |
|
|
|
542 |
String aordre=((JSONString) jsonArrayNested.get(7)).stringValue();
|
|
|
543 |
|
|
|
544 |
// Numero d'ordre (cache)
|
|
|
545 |
|
|
|
546 |
values[4] = aordre;
|
|
|
547 |
|
|
|
548 |
|
|
|
549 |
|
|
|
550 |
|
|
|
551 |
if (i>=table.getItemCount()) {
|
|
|
552 |
TableItem item = new TableItem(values);
|
|
|
553 |
table.add(item);
|
|
|
554 |
}
|
|
|
555 |
else {
|
|
|
556 |
TableItem item=table.getItem(i);
|
|
|
557 |
item.setValue(0,values[0]);
|
|
|
558 |
item.setValue(1,values[1]);
|
|
|
559 |
item.setValue(2,values[2]);
|
|
|
560 |
item.setValue(3,values[3]);
|
|
|
561 |
item.setValue(4,values[4]);
|
|
|
562 |
}
|
|
|
563 |
|
|
|
564 |
// Spagetti
|
|
|
565 |
if (ordre!=null) {
|
|
|
566 |
if (aordre.compareTo(ordre)==0) {
|
|
|
567 |
table.select(i);
|
|
|
568 |
}
|
|
|
569 |
else {
|
|
|
570 |
table.deselect(i);
|
|
|
571 |
}
|
|
|
572 |
}
|
|
|
573 |
|
|
|
574 |
}
|
|
|
575 |
|
|
|
576 |
}
|
|
|
577 |
}
|
|
|
578 |
|
|
|
579 |
// Suppression fin ancien affichage
|
|
|
580 |
if (i<table.getItemCount()) {
|
|
|
581 |
for (int j = table.getItemCount() -1 ; j >= i; j--) {
|
|
|
582 |
TableItem item=table.getItem(j);
|
|
|
583 |
table.remove(item);
|
|
|
584 |
}
|
|
|
585 |
}
|
|
|
586 |
|
|
|
587 |
setStatusEnabled();
|
|
|
588 |
|
|
|
589 |
|
|
|
590 |
}
|
|
|
591 |
});
|
|
|
592 |
|
|
|
593 |
|
|
|
594 |
}
|
|
|
595 |
|
|
|
596 |
|
|
|
597 |
/**
|
|
|
598 |
* Affichage message d'attente et desactivation navigation
|
|
|
599 |
*
|
|
|
600 |
* @param
|
|
|
601 |
* @return void
|
|
|
602 |
*/
|
|
|
603 |
|
|
|
604 |
private void setStatusDisabled() {
|
|
|
605 |
|
|
|
606 |
navBar.gotoFirst.setEnabled(false);
|
|
|
607 |
navBar.gotoPrev.setEnabled(false);
|
|
|
608 |
navBar.gotoNext.setEnabled(false);
|
|
|
609 |
navBar.gotoEnd.setEnabled(false);
|
|
|
610 |
|
|
|
611 |
navBar.status.setText("Patientez ...");
|
|
|
612 |
}
|
|
|
613 |
|
|
|
614 |
/**
|
|
|
615 |
* Affichage numero de page et gestion de la navigation
|
|
|
616 |
*
|
|
|
617 |
*/
|
|
|
618 |
|
|
|
619 |
private void setStatusEnabled() {
|
|
|
620 |
|
|
|
621 |
// Il y a forcemment un disabled avant d'arriver ici
|
|
|
622 |
|
|
|
623 |
if (count > 0) {
|
|
|
624 |
|
|
|
625 |
if (startIndex >= VISIBLE_TAXON_COUNT) { // Au dela de la
|
|
|
626 |
// premiere page
|
|
|
627 |
navBar.gotoPrev.setEnabled(true);
|
|
|
628 |
navBar.gotoFirst.setEnabled(true);
|
|
|
629 |
if (startIndex < (count - VISIBLE_TAXON_COUNT)) { // Pas la
|
|
|
630 |
// derniere
|
|
|
631 |
// page
|
|
|
632 |
navBar.gotoNext.setEnabled(true);
|
|
|
633 |
navBar.gotoEnd.setEnabled(true);
|
|
|
634 |
navBar.status.setText((startIndex + 1) + " - "
|
|
|
635 |
+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count );
|
|
|
636 |
} else { // Derniere page
|
|
|
637 |
navBar.status.setText((startIndex + 1) + " - " + count + " sur " + count );
|
|
|
638 |
}
|
|
|
639 |
} else { // Premiere page
|
|
|
640 |
if (count > VISIBLE_TAXON_COUNT) { // Des pages derrieres
|
|
|
641 |
navBar.gotoNext.setEnabled(true);
|
|
|
642 |
navBar.gotoEnd.setEnabled(true);
|
|
|
643 |
navBar.status.setText((startIndex + 1) + " - "
|
|
|
644 |
+ (startIndex + VISIBLE_TAXON_COUNT) + " sur " + count);
|
|
|
645 |
} else {
|
|
|
646 |
navBar.status.setText((startIndex + 1) + " - " + count + " sur " + count);
|
|
|
647 |
}
|
|
|
648 |
}
|
|
|
649 |
}
|
|
|
650 |
|
|
|
651 |
else { // Pas d'inventaire, pas de navigation
|
|
|
652 |
navBar.status.setText("0 - 0 sur 0");
|
|
|
653 |
}
|
|
|
654 |
}
|
|
|
655 |
|
|
|
656 |
/*
|
|
|
657 |
* Positionnement index de parcours (this.startIndex) pour affichage de la
|
|
|
658 |
* derniere page
|
|
|
659 |
*
|
|
|
660 |
* @param
|
|
|
661 |
* @return void
|
|
|
662 |
*/
|
|
|
663 |
|
|
|
664 |
private void gotoEnd() {
|
|
|
665 |
|
|
|
666 |
if ((count == 0) || (count % VISIBLE_TAXON_COUNT) > 0) {
|
|
|
667 |
startIndex = count - (count % VISIBLE_TAXON_COUNT);
|
|
|
668 |
} else {
|
|
|
669 |
startIndex = count - VISIBLE_TAXON_COUNT;
|
|
|
670 |
}
|
|
|
671 |
|
|
|
672 |
}
|
|
|
673 |
|
|
|
674 |
/*
|
|
|
675 |
* Recherche en cours
|
|
|
676 |
*
|
|
|
677 |
*/
|
|
|
678 |
|
|
|
679 |
public void setSearch(String search) {
|
|
|
680 |
this.search = search;
|
|
|
681 |
}
|
|
|
682 |
|
|
|
683 |
|
|
|
684 |
/*
|
|
|
685 |
* Localite en cours
|
|
|
686 |
*
|
|
|
687 |
*/
|
|
|
688 |
|
|
|
689 |
public void setLocation(String location) {
|
|
|
690 |
this.location = location;
|
|
|
691 |
}
|
|
|
692 |
|
|
|
693 |
|
|
|
694 |
|
|
|
695 |
/*
|
|
|
696 |
* Station en cours
|
|
|
697 |
*
|
|
|
698 |
*/
|
|
|
699 |
|
|
|
700 |
public void setStation(String station) {
|
|
|
701 |
this.station = station;
|
|
|
702 |
}
|
|
|
703 |
|
|
|
704 |
|
|
|
705 |
|
|
|
706 |
/*
|
|
|
707 |
* Date en cours
|
|
|
708 |
*
|
|
|
709 |
*/
|
|
|
710 |
|
|
|
711 |
|
|
|
712 |
public void setDate(String date) {
|
|
|
713 |
this.date = date;
|
|
|
714 |
}
|
|
|
715 |
|
|
|
716 |
|
|
|
717 |
/*
|
|
|
718 |
* Utilisateur en cours
|
|
|
719 |
*
|
|
|
720 |
*/
|
|
|
721 |
|
|
|
722 |
|
|
|
723 |
|
|
|
724 |
public void setUser(String user) {
|
|
|
725 |
this.user = user;
|
|
|
726 |
}
|
|
|
727 |
|
|
|
728 |
|
|
|
729 |
public void displayFilter() {
|
|
|
730 |
|
|
|
731 |
|
|
|
732 |
|
|
|
733 |
// Mise a jour boutton export feuille de calcul
|
|
|
734 |
|
|
|
735 |
mediator.getActionView().getExportButton().setHTML("<a href=\""+mediator.getServiceBaseUrl()+"/InventoryExport/"
|
|
|
736 |
+ user + "/"
|
|
|
737 |
+ URL.encodeComponent(location) + "/"
|
|
|
738 |
+ URL.encodeComponent(station)+ "/"
|
|
|
739 |
+ URL.encodeComponent(search) + "/"
|
|
|
740 |
+ date +
|
|
|
741 |
"\">"+"Export tableur</a>");
|
|
|
742 |
|
|
|
743 |
// Mise a jour ligne de selection
|
|
|
744 |
|
|
|
745 |
|
|
|
746 |
|
|
|
747 |
String com;
|
|
|
748 |
if (location.compareTo("all")==0) {
|
|
|
749 |
com="Toutes communes";
|
|
|
750 |
}
|
|
|
751 |
else {
|
|
|
752 |
if (location.compareTo("000null")==0) {
|
|
|
753 |
com="Communes non renseignées";
|
|
|
754 |
}
|
|
|
755 |
else {
|
|
|
756 |
com="Commune de "+location;
|
|
|
757 |
}
|
|
|
758 |
}
|
|
|
759 |
|
|
|
760 |
|
|
|
761 |
String dat;
|
|
|
762 |
|
|
|
763 |
if (date.compareTo("all")==0) {
|
|
|
764 |
dat=", toutes périodes";
|
|
|
765 |
}
|
|
|
766 |
else {
|
|
|
767 |
if (date.compareTo("00/00/0000")==0) {
|
|
|
768 |
dat=", périodes non renseignées";
|
|
|
769 |
}
|
|
|
770 |
else {
|
|
|
771 |
dat=", le "+ date;
|
|
|
772 |
}
|
|
|
773 |
}
|
|
|
774 |
|
|
|
775 |
|
|
|
776 |
String stat;
|
|
|
777 |
|
|
|
778 |
if (station.compareTo("all")==0) {
|
|
|
779 |
stat=", toutes stations";
|
|
|
780 |
}
|
|
|
781 |
else {
|
|
|
782 |
if (station.compareTo("000null")==0) {
|
|
|
783 |
stat=", stations non renseignées";
|
|
|
784 |
}
|
|
|
785 |
else {
|
|
|
786 |
stat=", station "+ station;
|
|
|
787 |
}
|
|
|
788 |
}
|
|
|
789 |
|
|
|
790 |
|
|
|
791 |
panel.getHeader().setText(com + dat + stat );
|
|
|
792 |
|
|
|
793 |
|
|
|
794 |
|
|
|
795 |
}
|
|
|
796 |
|
|
|
797 |
|
|
|
798 |
}
|
|
|
799 |
|
|
|
800 |
/* +--Fin du code ---------------------------------------------------------------------------------------+
|
|
|
801 |
* $Log$
|
|
|
802 |
* Revision 1.8 2007-12-22 14:48:53 ddelon
|
|
|
803 |
* Documentation et refactorisation
|
|
|
804 |
*
|
|
|
805 |
* Revision 1.7 2007-09-17 19:25:34 ddelon
|
|
|
806 |
* Documentation
|
|
|
807 |
*
|
|
|
808 |
*/
|