Subversion Repositories eFlore/Archives.cel-v1

Rev

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

Rev 26 Rev 27
1
/**
1
/**
2
 David Delon david.delon@clapas.net 2007
2
 David Delon david.delon@clapas.net 2007
3
 
3
 
4
 */
4
 */
5
 
5
 
6
/*
6
/*
7
 * EntryPanel.java  (Composite de Panel)
7
 * EntryPanel.java  (Composite de Panel)
8
 * 
8
 * 
9
 * Cas d'utilisation :
9
 * Cas d'utilisation :
10
 * Saisie assistee (completion nom et completion commune) de releves. 
10
 * Saisie assistee (completion nom et completion commune) de releves. 
11
 * L'identification n'est pas obligatoire
11
 * L'identification n'est pas obligatoire
12
 *
12
 *
13
 * 1 : L'utilisateur saisit a minima un nom de plante 
13
 * 1 : L'utilisateur saisit a minima un nom de plante 
14
 * 		1: Le nom de plante provient d'une application externe : il est deduit du nuremo nomenclatural transmis en historique
14
 * 		1: Le nom de plante provient d'une application externe : il est deduit du nuremo nomenclatural transmis en historique
15
 * 2 : Le programme assiste la saisie de nom de plante ou de localite par interrogation du systeme distant
15
 * 2 : Le programme assiste la saisie de nom de plante ou de localite par interrogation du systeme distant
16
 * 3 : L'utilisateur choisi le type de mise (ajout ou modification)
16
 * 3 : L'utilisateur choisi le type de mise (ajout ou modification)
17
 * 3 : L'utilisateur valide sa saisie
17
 * 3 : L'utilisateur valide sa saisie
18
 * 4 : Le programme transmet au systeme distant la nouvelle saisie pour l'identifiant en cours
18
 * 4 : Le programme transmet au systeme distant la nouvelle saisie pour l'identifiant en cours
19
 * 5 : Le programme transmet au systeme local un evenement annoncant une nouvelle saisie
19
 * 5 : Le programme transmet au systeme local un evenement annoncant une nouvelle saisie
20
 * 
20
 * 
21
 * 
21
 * 
22
 * Affichage detail d'un observation
22
 * Affichage detail d'un observation
23
 * 1 : Le programme affiche les donnees d'inventaire pour l'identifiant enregistre et pour le numero d'ordre transmis
23
 * 1 : Le programme affiche les donnees d'inventaire pour l'identifiant enregistre et pour le numero d'ordre transmis
24
 *
24
 *
25
 */
25
 */
26
 
26
 
27
 
27
 
28
package org.tela_botanica.client;
28
package org.tela_botanica.client;
29
 
29
 
30
import java.util.Date;
30
import java.util.Date;
31
 
31
 
32
import com.google.gwt.json.client.JSONArray;
32
import com.google.gwt.json.client.JSONArray;
33
import com.google.gwt.json.client.JSONParser;
33
import com.google.gwt.json.client.JSONParser;
34
import com.google.gwt.json.client.JSONString;
34
import com.google.gwt.json.client.JSONString;
35
import com.google.gwt.json.client.JSONValue;
35
import com.google.gwt.json.client.JSONValue;
36
import com.google.gwt.user.client.HTTPRequest;
36
import com.google.gwt.user.client.HTTPRequest;
37
import com.google.gwt.user.client.History;
37
import com.google.gwt.user.client.History;
38
import com.google.gwt.user.client.ResponseTextHandler;
38
import com.google.gwt.user.client.ResponseTextHandler;
39
import com.google.gwt.user.client.ui.Button;
39
import com.google.gwt.user.client.ui.Button;
40
import com.google.gwt.user.client.ui.ChangeListener;
40
import com.google.gwt.user.client.ui.ChangeListener;
41
import com.google.gwt.user.client.ui.ClickListener;
41
import com.google.gwt.user.client.ui.ClickListener;
42
import com.google.gwt.user.client.ui.Composite;
42
import com.google.gwt.user.client.ui.Composite;
43
import com.google.gwt.user.client.ui.Grid;
43
import com.google.gwt.user.client.ui.Grid;
44
import com.google.gwt.user.client.ui.HTML;
44
import com.google.gwt.user.client.ui.HTML;
45
import com.google.gwt.user.client.ui.HorizontalPanel;
45
import com.google.gwt.user.client.ui.HorizontalPanel;
46
import com.google.gwt.user.client.ui.KeyboardListener;
46
import com.google.gwt.user.client.ui.KeyboardListener;
47
import com.google.gwt.user.client.ui.PopupPanel;
47
import com.google.gwt.user.client.ui.PopupPanel;
48
import com.google.gwt.user.client.ui.TextBox;
48
import com.google.gwt.user.client.ui.TextBox;
49
import com.google.gwt.user.client.ui.VerticalPanel;
49
import com.google.gwt.user.client.ui.VerticalPanel;
50
import com.google.gwt.user.client.ui.Widget;
50
import com.google.gwt.user.client.ui.Widget;
51
 
51
 
52
 
52
 
53
public class EntryPanel extends Composite   {
53
public class EntryPanel extends Composite   {
54
	
54
	
55
  private NameAssistant nameAssistant = null;
55
  private NameAssistant nameAssistant = null;
56
  private LocationAssistant locationAssistant = null;
56
  private LocationAssistant locationAssistant = null;
57
  private TextBox date = new TextBox();
57
  private TextBox date = new TextBox();
58
  private TextBox complementLocation = new TextBox();
58
  private TextBox lieudit = new TextBox();
-
 
59
  private TextBox milieu = new TextBox();
59
  private TextBox comment = new TextBox();
60
  private TextBox comment = new TextBox();
60
  private Button dateSelector = new Button("...");
61
  private Button dateSelector = new Button("...");
-
 
62
  private Button validButton = new Button("Ajouter");
-
 
63
 
61
  boolean visible=false;
64
  boolean visible=false;
62
  private Mediator mediator=null;
65
  private Mediator mediator=null;
63
  
66
  
64
  
67
  
65
  private String user= null;
68
  private String user= null;
66
  private String ordre =null;
69
  private String ordre =null;
67
  
70
  
68
  private CalendarWidget calendar = null; // Lazy instantiation
71
  private CalendarWidget calendar = null; // Lazy instantiation
69
  private PopupPanel choicesPopup = null; // Lazy instantiation
72
  private PopupPanel choicesPopup = null; // Lazy instantiation
70
  
73
  
71
 
74
 
72
  public EntryPanel(final Mediator med) {
75
  public EntryPanel(final Mediator med) {
73
	 
76
	 
74
	  
77
	  
-
 
78
  Grid observation = new Grid(4,4);
-
 
79
  
-
 
80
  
-
 
81
  // Formatage affichage 
-
 
82
  
-
 
83
  for (int i=0; i<4;i++) {
-
 
84
	observation.getCellFormatter().setWidth(i, 0, "3%");
-
 
85
	observation.getCellFormatter().setWidth(i, 1, "47%");
-
 
86
	observation.getCellFormatter().setWidth(i, 2, "3%");
-
 
87
	observation.getCellFormatter().setWidth(i, 3, "47%");
-
 
88
  }  
75
	  Grid inner = new Grid(3,4);
-
 
76
 
-
 
77
	  
89
  
78
	  
90
 
79
   mediator=med;
91
   mediator=med;
80
   user=mediator.getUser();
92
   user=mediator.getUser();
81
 
-
 
-
 
93
 
-
 
94
   
-
 
95
   // Declaration des elements du dialogue de saisie aupres du mediator
82
   mediator.registerEntryPanel(this);
96
   
83
   
97
   mediator.registerEntryPanel(this);
-
 
98
   mediator.registerDate(date);
84
   mediator.registerDate(date);
99
   mediator.registerComment(comment);
85
   mediator.registerComment(comment);
100
   mediator.registerMilieu(milieu);
86
   mediator.registerComplementLocation(complementLocation);
101
   mediator.registerLieudit(lieudit);
87
   
102
   
88
 
103
 
89
   VerticalPanel outer = new VerticalPanel();
104
   VerticalPanel outer = new VerticalPanel();
90
   
105
 
-
 
106
// Name assistant et location assistant : widget auto-completion sur nom scientifique ou commune 
-
 
107
 
91
 
108
	nameAssistant = new NameAssistant(mediator);
92
   outer.add(new HTML("<b>Saisir&nbsp;un&nbsp;relev&eacute;&nbsp;:</b>"));
109
	locationAssistant = new LocationAssistant(mediator);
93
 
110
 
-
 
111
	
94
   
112
 
95
 
113
	 // Saisie Commune
-
 
114
	 
96
   for (int i=0; i<3;i++) {
115
     observation.setHTML(2,0,"Commune:&nbsp;");
97
	inner.getCellFormatter().setWidth(i, 0, "3%");
-
 
98
	inner.getCellFormatter().setWidth(i, 1, "47%");
-
 
-
 
116
     observation.setWidget(2,1,locationAssistant);
99
	inner.getCellFormatter().setWidth(i, 2, "3%");
117
     
-
 
118
     locationAssistant.setWidth("100%");
-
 
119
 
-
 
120
 
-
 
121
	 // Saisie lieu-dit
100
	inner.getCellFormatter().setWidth(i, 3, "47%");
-
 
101
   }  
-
 
102
 
122
	 
103
 
-
 
104
   
-
 
105
 
-
 
106
	nameAssistant = new NameAssistant(mediator);
123
     observation.setHTML(2,2,"Lieu-dit:&nbsp;");
107
	locationAssistant = new LocationAssistant(mediator);
-
 
108
 
-
 
-
 
124
     observation.setWidget(2,3,lieudit);
-
 
125
     
-
 
126
     lieudit.setWidth("100%");
109
	
127
 
-
 
128
 
-
 
129
     
-
 
130
     lieudit.addKeyboardListener( new KeyboardListener() {
110
	// Saisie Nom
131
 
111
	
132
 		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
-
 
133
 			  if(arg1 == KEY_ENTER)
112
     inner.setHTML(0,0,"Esp&egrave;ce:&nbsp;");
134
 			    {
-
 
135
 				 onValidateTextBox(lieudit);
-
 
136
 			    }
-
 
137
 
113
     inner.setWidget(0,1,nameAssistant);
-
 
114
    
138
 		  }
-
 
139
 		  
115
     nameAssistant.setWidth("100%");
140
 		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
-
 
141
 
-
 
142
 		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
-
 
143
 		  
-
 
144
 		  }
-
 
145
     );
-
 
146
 
-
 
147
 
-
 
148
     
-
 
149
	 // Saisie (milieu)
-
 
150
	 
-
 
151
     observation.setHTML(3,0,"Milieu:&nbsp;");
-
 
152
     observation.setWidget(3,1,milieu);
-
 
153
 
-
 
154
     milieu.setWidth("100%");
-
 
155
 
-
 
156
     
-
 
157
     // Validation par entree sur cette zone de texte
-
 
158
     
-
 
159
     milieu.addKeyboardListener( new KeyboardListener() {
-
 
160
 
-
 
161
 		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
-
 
162
 			  if(arg1 == KEY_ENTER)
-
 
163
 			    {
-
 
164
 				 onValidateTextBox(milieu);
-
 
165
 			    }
-
 
166
 
-
 
167
 		  }
-
 
168
 		  
-
 
169
 		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
116
 
170
 
117
	 // Saisie lieu
171
 		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
118
	 
172
 		  
119
     inner.setHTML(1,0,"Commune:&nbsp;");
173
 		  }
120
     inner.setWidget(1,1,locationAssistant);
174
     );
121
 
175
 
122
     locationAssistant.setWidth("100%");
176
     
123
   
177
     // Selecteur de Date 
124
     // Saisie Date 
178
     // Releve 
125
	 
179
 
126
     
180
     
127
     dateSelector.addClickListener(new ClickListener () {
181
     dateSelector.addClickListener(new ClickListener () {
128
    
182
    
129
       public void onClick(Widget w) {
183
       public void onClick(Widget w) {
130
    	  
184
    	  
131
    	   if (visible) {
185
    	   if (visible) {
132
    		  visible=false; 
186
    		  visible=false; 
133
    		  choicesPopup.hide();
187
    		  choicesPopup.hide();
134
    	   }
188
    	   }
135
    	   else {
189
    	   else {
136
    		visible=true; 
190
    		visible=true; 
137
    		if (calendar==null) {  // Lazy instantiation
191
    		if (calendar==null) {  // Lazy instantiation
138
    		  calendar = new CalendarWidget();
192
    		  calendar = new CalendarWidget();
139
    		  choicesPopup = new PopupPanel(true);
193
    		  choicesPopup = new PopupPanel(true);
140
    		  choicesPopup.add(calendar);
194
    		  choicesPopup.add(calendar);
141
    		  calendar.addChangeListener(new ChangeListener() {
195
    		  calendar.addChangeListener(new ChangeListener() {
142
 
196
 
143
    			     public void onChange(Widget sender) {
197
    			     public void onChange(Widget sender) {
144
    			    	 
198
    			    	 
145
    			       Date dateSelected=calendar.getDate();
199
    			       Date dateSelected=calendar.getDate();
146
    			       date.setText(dateSelected.getDate()+"/"+(dateSelected.getMonth()+1)+"/"+(dateSelected.getYear()+1900));
200
    			       date.setText(dateSelected.getDate()+"/"+(dateSelected.getMonth()+1)+"/"+(dateSelected.getYear()+1900));
147
    			       visible=false; 
201
    			       visible=false; 
148
    			       choicesPopup.hide();
202
    			       choicesPopup.hide();
149
    			     }
203
    			     }
150
    			     });
204
    			     });
151
    		  
205
    		  
152
    	   	}
206
    	   	}
153
 
207
 
154
    	    choicesPopup.show();
208
    	    choicesPopup.show();
155
	        choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(),
209
	        choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(),
156
	        dateSelector.getAbsoluteTop()  - dateSelector.getOffsetHeight() - choicesPopup.getOffsetHeight());
210
	        dateSelector.getAbsoluteTop()  - dateSelector.getOffsetHeight() - choicesPopup.getOffsetHeight());
157
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
211
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
158
    	   }
212
    	   }
159
       }
213
       }
160
     
214
     
161
     });
215
     });
-
 
216
 
-
 
217
     
162
     
218
 	// Saisie Espece 
-
 
219
 	
-
 
220
   observation.setHTML(0,0,"Esp&egrave;ce:&nbsp;");
-
 
221
   observation.setWidget(0,1,nameAssistant);
-
 
222
  
-
 
223
   nameAssistant.setWidth("100%");
163
         
224
 
164
    inner.setHTML(2,0,"Date:&nbsp;");
225
   observation.setHTML(0,2,"Date:&nbsp;");
165
    
226
    
166
    HorizontalPanel datePanel = new HorizontalPanel();
227
    HorizontalPanel datePanel = new HorizontalPanel();
167
    datePanel.add(date);
228
    datePanel.add(date);
168
    datePanel.add(dateSelector);
229
    datePanel.add(dateSelector);
169
    inner.setWidget(2,1,datePanel);
230
    observation.setWidget(0,3,datePanel);
170
    
231
    
-
 
232
    // Saisie date   
-
 
233
    // Validation par entree sur cette zone de texte
171
    // Saisie date   
234
 
172
   
235
   
173
    date.addKeyboardListener( new KeyboardListener() {
236
    date.addKeyboardListener( new KeyboardListener() {
174
 
237
 
175
    		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
238
    		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
176
    			  if(arg1 == KEY_ENTER)
239
    			  if(arg1 == KEY_ENTER)
177
    			    {
240
    			    {
178
    				 if (ordre==null) {
-
 
179
       				     mediator.onAddInventoryItem(); 
-
 
180
       				     date.setText("");
241
    				  onValidateTextBox(date);
181
    				 }
-
 
182
       				 else {
-
 
183
       				     mediator.onModifyInventoryItem(ordre); 
-
 
184
       				     ordre=null;
-
 
185
       				 }
-
 
186
    			    }
242
    			    }
187
    		  }
243
    		  }
188
    		  
244
    		  
189
    		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
245
    		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
190
    		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
246
    		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
191
    		  
247
    		  
192
    		  }
248
    		  }
193
    );
249
    );
194
    
250
    
195
  
251
  
196
 
-
 
197
	 // Saisie Complement de lieu  (station)
-
 
198
	 
-
 
199
    inner.setHTML(1,2,"Station:&nbsp;");
-
 
200
    inner.setWidget(1,3,complementLocation);
-
 
201
 
-
 
202
    complementLocation.setWidth("100%");
-
 
203
 
-
 
204
    
-
 
205
    complementLocation.addKeyboardListener( new KeyboardListener() {
-
 
206
 
-
 
207
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
-
 
208
			  if(arg1 == KEY_ENTER)
-
 
209
			    {
-
 
210
				  	if (ordre==null) {
-
 
211
   				     mediator.onAddInventoryItem(); 
-
 
212
   				     complementLocation.setText("");
-
 
213
   				  	}
-
 
214
   				  	else {
-
 
215
   				     mediator.onModifyInventoryItem(ordre); 
-
 
216
   				     ordre=null;
-
 
217
   				 }
-
 
218
			    }
-
 
219
 
-
 
220
		  }
-
 
221
		  
-
 
222
		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
-
 
223
 
-
 
224
		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
-
 
225
		  
-
 
226
		  }
-
 
227
    );
-
 
228
 
252
 
229
    
253
    
230
	 // Saisie Commentaire
254
	 // Saisie Commentaire
231
	 
255
	 
232
    inner.setHTML(2,2,"Notes:&nbsp;");
256
    observation.setHTML(1,0,"Notes:&nbsp;");
233
    inner.setWidget(2,3,comment);
257
    observation.setWidget(1,1,comment);
234
 
258
 
235
    comment.setWidth("100%");
259
    comment.setWidth("100%");
236
 
260
 
-
 
261
 
-
 
262
    // Validation par entree sur cette zone de texte
237
   
263
 
238
    comment.addKeyboardListener( new KeyboardListener() {
264
    comment.addKeyboardListener( new KeyboardListener() {
239
 
265
 
240
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
266
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
241
			  if(arg1 == KEY_ENTER)
267
			  if(arg1 == KEY_ENTER)
242
			    {
268
			    {
243
				  	if (ordre==null) {
-
 
244
   				     mediator.onAddInventoryItem(); 
-
 
245
   				     comment.setText("");
269
    				  onValidateTextBox(comment);
246
   				  	}
-
 
247
   				  	else {
-
 
248
   				     mediator.onModifyInventoryItem(ordre); 
-
 
249
   				     ordre=null;
-
 
250
   				  	}
-
 
251
			    }
270
			    }
252
 
271
 
253
		  }
272
		  }
254
		  
273
		  
255
		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
274
		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
256
		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
275
		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
257
		  
276
		  
258
		  }
277
		  }
259
  );
278
  );
260
    
-
 
261
   
-
 
262
    Button validButton = new Button("Valider");
-
 
-
 
279
    
-
 
280
 
-
 
281
    // Validation par click sur bouton valider 
263
    
282
 
264
 
283
    
265
    validButton.addClickListener(
284
    validButton.addClickListener(
266
    
285
    
267
    		new ClickListener() {
286
    		new ClickListener() {
268
    			
287
    			
269
    			  public void onClick(Widget w) {
288
    			  public void onClick(Widget w) {
-
 
289
    				  // Numero ordre vide : ajout d'une observation
270
    				  	if (ordre==null) {
290
    				  	if (ordre==null) {
271
    				     mediator.onAddInventoryItem(); 
291
    				     mediator.onAddInventoryItem(); 
272
    				  	}
292
    				  	}
273
    				  	else {
293
    				  	else {
274
    				     mediator.onModifyInventoryItem(ordre); 
294
    				     mediator.onModifyInventoryItem(ordre); 
275
    				     ordre=null;
295
    				     ordre=null;
276
    				  	}
296
    				  	}
277
    			  }
297
    			  }
278
    		}
298
    		}
279
    );
299
    );
280
    
300
    
281
    
301
    
282
   
302
   
283
    HorizontalPanel actionPanel= new HorizontalPanel();
303
    HorizontalPanel actionPanel= new HorizontalPanel();
284
   
304
   
285
    actionPanel.add(validButton);
305
    actionPanel.add(validButton);
286
    
306
    
287
 
307
 
288
	inner.setWidth("100%");
308
	observation.setWidth("100%");
289
 
309
 
290
	outer.add(inner);
310
	outer.add(observation);
291
	outer.setCellWidth(inner, "100%");
311
	outer.setCellWidth(observation, "100%");
292
	outer.setSpacing(10);
312
	outer.setSpacing(10);
293
	 
313
	 
294
	outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
314
	outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
295
    outer.add(actionPanel);
315
    outer.add(actionPanel);
296
 
316
 
297
 
317
 
298
    // Initialisation si provenance d'un lien
318
    // Initialisation si provenance d'un lien
299
    
319
    
300
    if (History.getToken().length()>0) {
320
    if (History.getToken().length()>0) {
301
 
321
 
302
    	final String anum=History.getToken();
322
    	final String anum=History.getToken();
303
 
323
 
304
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Name/" + anum,
324
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Name/" + anum,
305
				new ResponseTextHandler() {
325
				new ResponseTextHandler() {
306
 
326
 
307
					public void onCompletion(String strcomplete) {
327
					public void onCompletion(String strcomplete) {
308
 
328
 
309
						JSONValue jsonValue = JSONParser.parse(strcomplete);
329
						JSONValue jsonValue = JSONParser.parse(strcomplete);
310
						JSONArray jsonArray;
330
						JSONArray jsonArray;
311
 
331
 
312
						if ((jsonArray = jsonValue.isArray()) != null) {
332
						if ((jsonArray = jsonValue.isArray()) != null) {
313
		
333
		
314
								String aname = ((JSONString) jsonArray.get(0)).stringValue();
334
								String aname = Util.toCelString(((JSONString) jsonArray.get(0)).toString());
315
								
-
 
316
								// Nom  
335
								
317
							
336
								// Nom  
318
								if (aname.compareTo("null")!=0) {
-
 
319
									nameAssistant.setText(((JSONString) jsonArray.get(0)).stringValue());
337
								if (aname.compareTo("null")!=0) {
320
							
-
 
321
									// Numero nomenclatural 
338
									nameAssistant.setText(aname);
322
							
-
 
323
									nameAssistant.setValue(anum);
339
									// Numero nomenclatural 
324
									
340
									nameAssistant.setValue(anum);
325
								}
341
								}
326
							
342
							
327
						}
343
						}
328
					}
344
					}
329
 
345
 
330
				});
346
				});
331
 
347
 
332
    	
348
    	
333
    }
349
    }
334
 
350
 
335
	 
351
	 
336
    initWidget(outer);
352
    initWidget(outer);
337
   
353
   
338
    
354
    
339
  }
355
  }
340
 
356
 
341
	/*
357
	/*
342
	 * Numero d'ordre du relev� affich�
358
	 * Numero d'ordre du releve affiche + mise à jour bouton
343
	 * 
359
	 * 
344
	 */
360
	 */
345
	
361
	
346
	public void setOrdre(String ordre) {
362
	public void setOrdre(String ordre) {
347
		this.ordre = ordre;
363
		this.ordre = ordre;
-
 
364
		if (ordre==null) {
-
 
365
			this.validButton.setText("Ajouter");
-
 
366
		}
-
 
367
		else {
-
 
368
			this.validButton.setText("Modifier");
-
 
369
		}
348
	}
370
	}
349
 
371
 
350
 
372
 
351
	/*
373
	/*
352
	 * Numero d'ordre du relev� affich�
374
	 * Numero d'ordre du releve affiche
353
	 * 
375
	 * 
354
	 */
376
	 */
355
	
377
	
356
	public String getOrdre() {
378
	public String getOrdre() {
357
		return this.ordre;
379
		return this.ordre;
358
	}
380
	}
359
 
381
 
-
 
382
 
-
 
383
    // Validation par entree sur cette zone de texte
-
 
384
    
-
 
385
    private void onValidateTextBox(TextBox textbox) {
-
 
386
   	
-
 
387
		  	if (ordre==null) {
-
 
388
			  // Numero ordre vide : ajout d'une observation
-
 
389
			     mediator.onAddInventoryItem(); 
-
 
390
			     textbox.setText("");
-
 
391
			  	}
-
 
392
			  	else {
-
 
393
			     mediator.onModifyInventoryItem(ordre); 
-
 
394
			     ordre=null;
-
 
395
			 }
-
 
396
 
-
 
397
    }
-
 
398
 
360
 
399
	
361
  
400
  
362
  /**
401
  /**
363
	 * Mise a jour de l'affichage a partir de donn�es deja saisie
402
	 * Mise a jour de l'affichage a partir de donnees deja saisie
364
	 * 
403
	 * 
365
	 */
404
	 */
366
 
405
 
367
	public void update() {
406
	public void update() {
368
 
407
 
369
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Inventory/" + user + "/" + ordre, 
408
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Inventory/" + user + "/" + ordre, 
370
 
409
 
371
		new ResponseTextHandler() {
410
		new ResponseTextHandler() {
372
 
411
 
373
			public void onCompletion(String str) {
412
			public void onCompletion(String str) {
374
 
413
 
375
				JSONValue jsonValue = JSONParser.parse(str);
414
				JSONValue jsonValue = JSONParser.parse(str);
376
				JSONArray jsonArray;
415
				JSONArray jsonArray;
377
				
416
				
378
				
417
				
379
				if ((jsonArray = jsonValue.isArray()) != null) {
418
				if ((jsonArray = jsonValue.isArray()) != null) {
-
 
419
					
380
							// Nom saisi
420
							// Nom saisi
381
							nameAssistant.setText(((JSONString) jsonArray.get(0)).stringValue());
421
							nameAssistant.setText(Util.toCelString(((JSONString) jsonArray.get(0)).toString()));
-
 
422
							
382
							
423
							
383
							// Numero nomenclatural
424
							// Numero nomenclatural
384
						
425
						
385
							String ann=((JSONString) jsonArray .get(3)).stringValue();
426
							String ann=((JSONString) jsonArray .get(3)).stringValue();
386
							
427
							
387
							if (ann.compareTo("0")!=0) {
428
							if (ann.compareTo("0")!=0) {
388
								nameAssistant.setValue(ann);
429
								nameAssistant.setValue(ann);
389
								mediator.getInfoPopup().setImageUrl(ann);
430
								mediator.getInfoPopup().setImageUrl(ann);
390
							}
431
							}
391
							else {
432
							else {
392
								nameAssistant.setValue(null);
433
								nameAssistant.setValue(null);
393
							}
434
							}
394
							
435
							
395
							// Commune
436
							// Commune
396
							String aloc=((JSONString) jsonArray .get(6)).stringValue();
437
							String aloc=Util.toCelString(((JSONString) jsonArray .get(6)).toString());
397
							
438
							
398
							if (aloc.compareTo("000null")!=0) {
439
							if (aloc.compareTo("000null")!=0) {
399
								locationAssistant.setText(aloc);
440
								locationAssistant.setText(aloc);
400
							}
441
							}
401
							else { 
442
							else { 
402
								locationAssistant.setText("");
443
								locationAssistant.setText("");
403
							}
444
							}
404
							
445
							
405
							String adate=((JSONString) jsonArray .get(8)).stringValue();
446
							String adate=((JSONString) jsonArray .get(8)).stringValue();
406
							
447
							
407
//							Date 
448
//							Date 
408
							if (adate.compareTo("0000-00-00 00:00:00")!=0) {
449
							if (adate.compareTo("0000-00-00 00:00:00")!=0) {
409
								date.setText(adate); 
450
								date.setText(adate); 
410
							}
451
							}
411
							else {
452
							else {
412
								date.setText(""); 
453
								date.setText(""); 
413
							}
454
							}
414
 
455
 
415
 
456
 
416
							String astation=((JSONString) jsonArray .get(9)).stringValue();
457
							String astation=Util.toCelString(((JSONString) jsonArray .get(9)).toString());
417
							
458
							
418
//							Station 
459
//							Station 
419
							if (astation.compareTo("000null")!=0) {
460
							if (astation.compareTo("000null")!=0) {
420
								complementLocation.setText(astation); 
461
								milieu.setText(astation); 
421
							}
462
							}
422
							else {
463
							else {
423
								complementLocation.setText(""); 
464
								milieu.setText(""); 
424
							}
465
							}
425
							
466
							
426
 
467
 
427
							String acomment=((JSONString) jsonArray .get(10)).stringValue();
468
							String acomment=Util.toCelString(((JSONString) jsonArray .get(10)).toString());
428
//							Notes
469
//							Notes
429
							if (acomment.compareTo("null")!=0) {
470
							if (acomment.compareTo("null")!=0) {
430
								comment.setText(acomment); 
471
								comment.setText(acomment); 
431
							}
472
							}
432
							else {
473
							else {
433
								comment.setText(""); 
474
								comment.setText(""); 
434
							}
475
							}
435
							
476
							
436
				}
477
				}
437
 
478
 
438
				
479
				
439
			}
480
			}
440
		});
481
		});
441
 
482
 
442
	}
483
	}
443
 
484
 
444
	public void setUser(String user) {
485
	public void setUser(String user) {
445
		this.user = user;
486
		this.user = user;
446
	}
487
	}
447
	
488
	
448
 
489
 
449
}
490
}
450
 
491
 
451
/* +--Fin du code ---------------------------------------------------------------------------------------+
492
/* +--Fin du code ---------------------------------------------------------------------------------------+
452
* $Log$
493
* $Log$
-
 
494
* Revision 1.7  2007-09-17 19:25:34  ddelon
-
 
495
* Documentation
-
 
496
*
453
* Revision 1.6  2007-06-06 13:29:30  ddelon
497
* Revision 1.6  2007-06-06 13:29:30  ddelon
454
* v0.09
498
* v0.09
455
*
499
*
456
* Revision 1.5  2007-05-22 14:27:08  ddelon
500
* Revision 1.5  2007-05-22 14:27:08  ddelon
457
* reglage modification
501
* reglage modification
458
*
502
*
459
* Revision 1.4  2007-05-21 21:01:35  ddelon
503
* Revision 1.4  2007-05-21 21:01:35  ddelon
460
* Modification comportement boutons
504
* Modification comportement boutons
461
*
505
*
462
* 
506
* 
463
*/
507
*/