Subversion Repositories eFlore/Archives.cel-v1

Rev

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

Rev 28 Rev 29
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
 * EntryView.java  (Composite de Panel)
7
 * EntryView.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
// TODO : onvalidate dans mediator
28
// TODO : onvalidate dans mediator
29
 
29
 
30
 
30
 
31
package org.tela_botanica.client;
31
package org.tela_botanica.client;
32
 
32
 
33
import java.util.Date;
33
import java.util.Date;
34
 
34
 
35
import net.mygwt.ui.client.Style;
35
import net.mygwt.ui.client.Style;
-
 
36
import net.mygwt.ui.client.event.BaseEvent;
-
 
37
import net.mygwt.ui.client.event.SelectionListener;
-
 
38
import net.mygwt.ui.client.widget.Button;
36
import net.mygwt.ui.client.widget.ContentPanel;
39
import net.mygwt.ui.client.widget.ContentPanel;
37
import net.mygwt.ui.client.widget.WidgetContainer;
40
import net.mygwt.ui.client.widget.WidgetContainer;
38
import net.mygwt.ui.client.widget.layout.BorderLayoutData;
41
import net.mygwt.ui.client.widget.layout.BorderLayoutData;
39
import net.mygwt.ui.client.widget.layout.FlowLayout;
42
import net.mygwt.ui.client.widget.layout.FlowLayout;
40
 
43
 
41
import com.google.gwt.json.client.JSONArray;
44
import com.google.gwt.json.client.JSONArray;
42
import com.google.gwt.json.client.JSONParser;
45
import com.google.gwt.json.client.JSONParser;
43
import com.google.gwt.json.client.JSONString;
46
import com.google.gwt.json.client.JSONString;
44
import com.google.gwt.json.client.JSONValue;
47
import com.google.gwt.json.client.JSONValue;
45
import com.google.gwt.user.client.HTTPRequest;
48
import com.google.gwt.user.client.HTTPRequest;
46
import com.google.gwt.user.client.History;
49
import com.google.gwt.user.client.History;
47
import com.google.gwt.user.client.ResponseTextHandler;
50
import com.google.gwt.user.client.ResponseTextHandler;
48
import com.google.gwt.user.client.ui.Button;
-
 
49
import com.google.gwt.user.client.ui.ChangeListener;
51
import com.google.gwt.user.client.ui.ChangeListener;
50
import com.google.gwt.user.client.ui.ClickListener;
-
 
51
import com.google.gwt.user.client.ui.Grid;
52
import com.google.gwt.user.client.ui.Grid;
-
 
53
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-
 
54
import com.google.gwt.user.client.ui.HasVerticalAlignment;
52
import com.google.gwt.user.client.ui.HorizontalPanel;
55
import com.google.gwt.user.client.ui.HorizontalPanel;
53
import com.google.gwt.user.client.ui.KeyboardListener;
56
import com.google.gwt.user.client.ui.KeyboardListener;
54
import com.google.gwt.user.client.ui.Label;
57
import com.google.gwt.user.client.ui.Label;
55
import com.google.gwt.user.client.ui.PopupPanel;
58
import com.google.gwt.user.client.ui.PopupPanel;
56
import com.google.gwt.user.client.ui.TextBox;
59
import com.google.gwt.user.client.ui.TextBox;
57
import com.google.gwt.user.client.ui.VerticalPanel;
60
import com.google.gwt.user.client.ui.VerticalPanel;
58
import com.google.gwt.user.client.ui.Widget;
61
import com.google.gwt.user.client.ui.Widget;
59
 
62
 
60
 
63
 
61
public class EntryView  {
64
public class EntryView  {
62
	
65
	
63
	
66
	
64
  private ContentPanel panel=null;
67
  private ContentPanel panel=null;
65
  private Label infoOrdre=new Label("Nouvelle observation");
68
  private Label infoOrdre=new Label("Nouvelle observation");
66
  private NameAssistant nameAssistant = null;
69
  private NameAssistant nameAssistant = null;
67
  private LocationAssistant locationAssistant = null;
70
  private LocationAssistant locationAssistant = null;
68
  private TextBox date = new TextBox();
71
  private TextBox date = new TextBox();
69
  private TextBox lieudit = new TextBox();
72
  private TextBox lieudit = new TextBox();
70
  private TextBox milieu = new TextBox();
73
  private TextBox station = new TextBox();
71
  private TextBox comment = new TextBox();
74
  private TextBox comment = new TextBox();
72
  private Button dateSelector = new Button("...");
75
  private Button dateSelector = new Button("...");
73
  private Button validButton = new Button("Ajouter");
-
 
74
 
76
 
75
  boolean visible=false;
77
  boolean visible=false;
76
  private Mediator mediator=null;
78
  private Mediator mediator=null;
77
  
79
  
78
  
80
  
79
  private String user= null;
81
  private String user= null;
80
  private String ordre =null;
82
  private String ordre =null;
81
  
83
  
82
  private CalendarWidget calendar = null; // Lazy instantiation
84
  private CalendarWidget calendar = null; // Lazy instantiation
83
  private PopupPanel choicesPopup = null; // Lazy instantiation
85
  private PopupPanel choicesPopup = null; // Lazy instantiation
84
  
86
  
85
 
87
 
86
  public EntryView(final Mediator med) {
88
  public EntryView(final Mediator med) {
87
	 
89
	 
88
	  
90
	  
89
	  
91
	  
90
  Grid observation = new Grid(4,4);
92
  Grid observation = new Grid(4,4);
91
  
93
  
92
  infoOrdre.setWordWrap(false);
94
  infoOrdre.setWordWrap(false);
93
  
95
  
94
  // Formatage affichage 
96
  // Formatage affichage 
95
  
97
  
96
  for (int i=0; i<4;i++) {
98
  for (int i=0; i<4;i++) {
97
	observation.getCellFormatter().setWidth(i, 0, "3%");
99
	observation.getCellFormatter().setWidth(i, 0, "3%");
98
	observation.getCellFormatter().setWidth(i, 1, "47%");
100
	observation.getCellFormatter().setWidth(i, 1, "47%");
99
	observation.getCellFormatter().setWidth(i, 2, "3%");
101
	observation.getCellFormatter().setWidth(i, 2, "3%");
100
	observation.getCellFormatter().setWidth(i, 3, "47%");
102
	observation.getCellFormatter().setWidth(i, 3, "47%");
101
  }  
103
  }  
102
  
104
  
103
 
105
 
104
   mediator=med;
106
   mediator=med;
105
   user=mediator.getUser();
107
   user=mediator.getUser();
106
 
108
 
107
   
109
   
108
   // Declaration des elements du dialogue de saisie aupres du mediator
110
   // Declaration des elements du dialogue de saisie aupres du mediator
109
   
111
   
110
   mediator.registerDate(date);
112
   mediator.registerDate(date);
111
   mediator.registerComment(comment);
113
   mediator.registerComment(comment);
112
   mediator.registerMilieu(milieu);
114
   mediator.registerStation(station);
113
   mediator.registerLieudit(lieudit);
115
   mediator.registerLieudit(lieudit);
114
   
116
   
115
   panel= new ContentPanel(Style.HEADER);
117
   panel= new ContentPanel(Style.HEADER);
116
   panel.setLayout(new FlowLayout());
118
   panel.setLayout(new FlowLayout());
117
   panel.setText("Observation");
119
   panel.setText("Observation");
118
 
120
 
119
   VerticalPanel outer = new VerticalPanel();
121
   VerticalPanel outer = new VerticalPanel();
120
 
122
 
121
// Name assistant et location assistant : widget auto-completion sur nom scientifique ou commune 
123
// Name assistant et location assistant : widget auto-completion sur nom scientifique ou commune 
122
 
124
 
123
	nameAssistant = new NameAssistant(mediator);
125
	nameAssistant = new NameAssistant(mediator);
124
	locationAssistant = new LocationAssistant(mediator);
126
	locationAssistant = new LocationAssistant(mediator);
125
 
127
 
126
	
128
	
127
 
129
 
128
	 // Saisie Commune
130
	 // Saisie Commune
129
	 
131
	 
130
     observation.setHTML(2,0,"Commune:&nbsp;");
132
     observation.setHTML(0,0,"Commune:&nbsp;");
131
     observation.setWidget(2,1,locationAssistant);
133
     observation.setWidget(0,1,locationAssistant);
132
     
134
     
133
     locationAssistant.setWidth("100%");
135
     locationAssistant.setWidth("100%");
134
 
136
 
135
 
137
 
136
	 // Saisie lieu-dit
138
	 // Saisie lieu-dit
137
	 
139
	 
138
     observation.setHTML(2,2,"Lieu-dit:&nbsp;");
140
     observation.setHTML(0,2,"Lieu-dit:&nbsp;");
139
     observation.setWidget(2,3,lieudit);
141
     observation.setWidget(0,3,lieudit);
140
     
142
     
141
     lieudit.setWidth("100%");
143
     lieudit.setWidth("100%");
142
 
144
 
143
 
145
 
144
     
146
     
145
     lieudit.addKeyboardListener( new KeyboardListener() {
147
     lieudit.addKeyboardListener( new KeyboardListener() {
146
 
148
 
147
 		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
149
 		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
148
 			  if(arg1 == KEY_ENTER)
150
 			  if(arg1 == KEY_ENTER)
149
 			    {
151
 			    {
150
 				 onValidateTextBox(lieudit);
152
 				 onValidateTextBox(lieudit);
151
 			    }
153
 			    }
152
 
154
 
153
 		  }
155
 		  }
154
 		  
156
 		  
155
 		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
157
 		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
156
 
158
 
157
 		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
159
 		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
158
 		  
160
 		  
159
 		  }
161
 		  }
160
     );
162
     );
161
 
163
 
162
 
164
 
163
     
165
     
164
	 // Saisie (milieu)
166
	 // Saisie (station)
165
	 
167
	 
166
     observation.setHTML(3,0,"Milieu:&nbsp;");
168
     observation.setHTML(1,0,"Station:&nbsp;");
167
     observation.setWidget(3,1,milieu);
169
     observation.setWidget(1,1,station);
168
 
170
 
169
     milieu.setWidth("100%");
171
     station.setWidth("100%");
170
 
172
 
171
     
173
     
172
     // Validation par entree sur cette zone de texte
174
     // Validation par entree sur cette zone de texte
173
     
175
     
174
     milieu.addKeyboardListener( new KeyboardListener() {
176
     station.addKeyboardListener( new KeyboardListener() {
175
 
177
 
176
 		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
178
 		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
177
 			  if(arg1 == KEY_ENTER)
179
 			  if(arg1 == KEY_ENTER)
178
 			    {
180
 			    {
179
 				 onValidateTextBox(milieu);
181
 				 onValidateTextBox(station);
180
 			    }
182
 			    }
181
 
183
 
182
 		  }
184
 		  }
183
 		  
185
 		  
184
 		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
186
 		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
185
 
187
 
186
 		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
188
 		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
187
 		  
189
 		  
188
 		  }
190
 		  }
189
     );
191
     );
190
 
192
 
191
     
193
     
192
     // Selecteur de Date 
194
     // Selecteur de Date 
193
     // Releve 
195
     // Releve 
194
 
196
 
195
     
197
     
-
 
198
     dateSelector.addSelectionListener(
-
 
199
    	 
-
 
200
    	 new SelectionListener() {
196
     dateSelector.addClickListener(new ClickListener () {
-
 
197
    
-
 
198
       public void onClick(Widget w) {
201
				public void widgetSelected(BaseEvent be) { 
199
    	  
202
    
200
    	   if (visible) {
203
    	   if (visible) {
201
    		  visible=false; 
204
    		  visible=false; 
202
    		  choicesPopup.hide();
205
    		  choicesPopup.hide();
203
    	   }
206
    	   }
204
    	   else {
207
    	   else {
205
    		visible=true; 
208
    		visible=true; 
206
    		if (calendar==null) {  // Lazy instantiation
209
    		if (calendar==null) {  // Lazy instantiation
207
    		  calendar = new CalendarWidget();
210
    		  calendar = new CalendarWidget();
208
    		  choicesPopup = new PopupPanel(true);
211
    		  choicesPopup = new PopupPanel(true);
209
    		  choicesPopup.add(calendar);
212
    		  choicesPopup.add(calendar);
210
    		  calendar.addChangeListener(new ChangeListener() {
213
    		  calendar.addChangeListener(new ChangeListener() {
211
 
214
 
212
    			     public void onChange(Widget sender) {
215
    			     public void onChange(Widget sender) {
213
    			    	 
216
    			    	 
214
    			       Date dateSelected=calendar.getDate();
217
    			       Date dateSelected=calendar.getDate();
215
    			       date.setText(dateSelected.getDate()+"/"+(dateSelected.getMonth()+1)+"/"+(dateSelected.getYear()+1900));
218
    			       date.setText(dateSelected.getDate()+"/"+(dateSelected.getMonth()+1)+"/"+(dateSelected.getYear()+1900));
216
    			       visible=false; 
219
    			       visible=false; 
217
    			       choicesPopup.hide();
220
    			       choicesPopup.hide();
218
    			     }
221
    			     }
219
    			     });
222
    			     });
220
    		  
223
    		  
221
    	   	}
224
    	   	}
222
 
225
 
223
    	    choicesPopup.show();
226
    	    choicesPopup.show();
224
	        choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(),
227
	        choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(),
225
	        dateSelector.getAbsoluteTop()  - dateSelector.getOffsetHeight() - choicesPopup.getOffsetHeight());
228
	        dateSelector.getAbsoluteTop()  - dateSelector.getOffsetHeight() - choicesPopup.getOffsetHeight());
226
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
229
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
227
    	   }
230
    	   }
228
       }
231
       }
229
     
232
     
230
     });
233
     });
231
 
234
 
232
     
235
     
233
 	// Saisie Espece 
236
 	// Saisie Espece 
234
 	
237
 	
235
   observation.setHTML(0,0,"Esp&egrave;ce:&nbsp;");
238
   observation.setHTML(2,0,"Esp&egrave;ce:&nbsp;");
236
   observation.setWidget(0,1,nameAssistant);
239
   observation.setWidget(2,1,nameAssistant);
237
  
240
  
238
   nameAssistant.setWidth("100%");
241
   nameAssistant.setWidth("100%");
239
 
242
 
240
   observation.setHTML(0,2,"Date:&nbsp;");
243
   observation.setHTML(1,2,"Date:&nbsp;");
241
    
244
    
242
    HorizontalPanel datePanel = new HorizontalPanel();
245
    HorizontalPanel datePanel = new HorizontalPanel();
243
    datePanel.add(date);
246
    datePanel.add(date);
244
    datePanel.add(dateSelector);
247
    datePanel.add(dateSelector);
245
    observation.setWidget(0,3,datePanel);
248
    observation.setWidget(1,3,datePanel);
246
    
249
    
247
    // Saisie date   
250
    // Saisie date   
248
    // Validation par entree sur cette zone de texte
251
    // Validation par entree sur cette zone de texte
249
 
252
 
250
   
253
   
251
    date.addKeyboardListener( new KeyboardListener() {
254
    date.addKeyboardListener( new KeyboardListener() {
252
 
255
 
253
    		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
256
    		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
254
    			  if(arg1 == KEY_ENTER)
257
    			  if(arg1 == KEY_ENTER)
255
    			    {
258
    			    {
256
    				  onValidateTextBox(date);
259
    				  onValidateTextBox(date);
257
    			    }
260
    			    }
258
    		  }
261
    		  }
259
    		  
262
    		  
260
    		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
263
    		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
261
    		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
264
    		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
262
    		  
265
    		  
263
    		  }
266
    		  }
264
    );
267
    );
265
    
268
    
266
  
269
  
267
 
270
 
268
    
271
    
269
	 // Saisie Commentaire
272
	 // Saisie Commentaire
270
	 
273
	 
271
    observation.setHTML(1,0,"Notes:&nbsp;");
274
    observation.setHTML(3,0,"Notes:&nbsp;");
272
    observation.setWidget(1,1,comment);
275
    observation.setWidget(3,1,comment);
273
 
276
 
274
    comment.setWidth("100%");
277
    comment.setWidth("100%");
275
 
278
 
276
 
279
 
277
    // Validation par entree sur cette zone de texte
280
    // Validation par entree sur cette zone de texte
278
 
281
 
279
    comment.addKeyboardListener( new KeyboardListener() {
282
    comment.addKeyboardListener( new KeyboardListener() {
280
 
283
 
281
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
284
		  public void onKeyDown(Widget arg0, char arg1, int arg2) {
282
			  if(arg1 == KEY_ENTER)
285
			  if(arg1 == KEY_ENTER)
283
			    {
286
			    {
284
    				  onValidateTextBox(comment);
287
    				  onValidateTextBox(comment);
285
			    }
288
			    }
286
 
289
 
287
		  }
290
		  }
288
		  
291
		  
289
		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
292
		  public void onKeyUp(Widget arg0, char arg1, int arg2) { }
290
		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
293
		  public void onKeyPress(Widget arg0, char arg1, int arg2) { }
291
		  
294
		  
292
		  }
295
		  }
293
  );
296
  );
294
    
297
    
295
 
-
 
296
    // Validation par click sur bouton valider 
-
 
297
 
-
 
298
    
-
 
299
    validButton.addClickListener(
-
 
300
    
-
 
301
    		new ClickListener() {
-
 
302
    			
-
 
303
    			  public void onClick(Widget w) {
-
 
304
    				  // Numero ordre vide : ajout d'une observation
-
 
305
    				  	if (ordre==null) {
-
 
306
    				     mediator.onAddInventoryItem(); 
-
 
307
    				  	}
-
 
308
    				  	else {
-
 
309
    				     mediator.onModifyInventoryItem(ordre); 
-
 
310
    				     ordre=null;
-
 
311
    				  	}
-
 
312
    			  }
-
 
313
    		}
-
 
314
    );
-
 
315
    
-
 
316
    
-
 
317
   
298
 
318
    HorizontalPanel actionPanel= new HorizontalPanel();
299
    HorizontalPanel actionPanel= new HorizontalPanel();
319
   
300
   
320
 //   actionPanel.add(validButton);
301
 //   actionPanel.add(validButton);
321
    
302
    
322
 
303
 
323
	observation.setWidth("100%");
304
	observation.setWidth("100%");
324
 
305
 
325
	outer.add(observation);
306
	outer.add(observation);
326
	outer.setCellWidth(observation, "100%");
307
	outer.setCellWidth(observation, "100%");
327
	outer.setSpacing(10);
308
	outer.setSpacing(10);
328
	 
309
	 
329
	outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
310
	outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
330
    outer.add(actionPanel);
311
    outer.add(actionPanel);
331
    
312
    
332
    outer.setWidth("100%");
313
    outer.setWidth("100%");
333
 
314
 
334
           
315
           
335
    panel.add(outer);
316
    panel.add(outer);
-
 
317
    
-
 
318
    HorizontalPanel inner=new HorizontalPanel();
-
 
319
    
-
 
320
    Button newButton=new Button("#",
-
 
321
   
-
 
322
    // Init
-
 
323
    	new SelectionListener() {
-
 
324
				public void widgetSelected(BaseEvent be) {  
-
 
325
					
-
 
326
					nameAssistant.setText("");
-
 
327
					nameAssistant.setValue(null);
-
 
328
					locationAssistant.setText("");
-
 
329
					locationAssistant.setValue(null); // Null ?
-
 
330
					date.setText(""); 
-
 
331
					lieudit.setText(""); 
-
 
332
					station.setText(""); 
-
 
333
					comment.setText(""); 
-
 
334
					ordre=null;
-
 
335
					infoOrdre.setText("Nouvelle observation");
-
 
336
 
-
 
337
	    		}
-
 
338
	     	}
-
 
339
    );
-
 
340
    
-
 
341
    inner.add(infoOrdre);
-
 
342
    inner.add(newButton);
-
 
343
 
-
 
344
	inner.setCellHorizontalAlignment(infoOrdre, HasHorizontalAlignment.ALIGN_RIGHT);
-
 
345
	inner.setCellVerticalAlignment(infoOrdre, HasVerticalAlignment.ALIGN_MIDDLE);
-
 
346
    
336
    
347
    inner.setWidth("100%");
337
    panel.getHeader().addWidget(infoOrdre);
348
    panel.getHeader().addWidget(inner);
338
    
349
    
339
	WidgetContainer center=mediator.getCenterContainer();
350
	WidgetContainer center=mediator.getCenterContainer();
340
	BorderLayoutData centerData = new BorderLayoutData(Style.NORTH, .25f, 100, 300);
351
	BorderLayoutData centerData = new BorderLayoutData(Style.NORTH, .25f, 100, 300);
341
	center.add(panel,centerData);
352
	center.add(panel,centerData);
342
 
353
 
343
 
354
 
344
    // Initialisation si provenance d'un lien
355
    // Initialisation si provenance d'un lien
345
    
356
    
346
    if (History.getToken().length()>0) {
357
    if (History.getToken().length()>0) {
347
 
358
 
348
    	final String anum=History.getToken();
359
    	final String anum=History.getToken();
349
 
360
 
350
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Name/" + anum,
361
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Name/" + anum,
351
				new ResponseTextHandler() {
362
				new ResponseTextHandler() {
352
 
363
 
353
					public void onCompletion(String strcomplete) {
364
					public void onCompletion(String strcomplete) {
354
 
365
 
355
						JSONValue jsonValue = JSONParser.parse(strcomplete);
366
						JSONValue jsonValue = JSONParser.parse(strcomplete);
356
						JSONArray jsonArray;
367
						JSONArray jsonArray;
357
 
368
 
358
						if ((jsonArray = jsonValue.isArray()) != null) {
369
						if ((jsonArray = jsonValue.isArray()) != null) {
359
		
370
		
360
								String aname = Util.toCelString(((JSONString) jsonArray.get(0)).toString());
371
								String aname = Util.toCelString(((JSONString) jsonArray.get(0)).toString());
361
								
372
								
362
								// Nom  
373
								// Nom  
363
								if (aname.compareTo("null")!=0) {
374
								if (aname.compareTo("null")!=0) {
364
									nameAssistant.setText(aname);
375
									nameAssistant.setText(aname);
365
									// Numero nomenclatural 
376
									// Numero nomenclatural 
366
									nameAssistant.setValue(anum);
377
									nameAssistant.setValue(anum);
367
								}
378
								}
368
							
379
							
369
						}
380
						}
370
					}
381
					}
371
 
382
 
372
				});
383
				});
373
 
384
 
374
    	
385
    	
375
    }
386
    }
376
 
387
 
377
	 
388
	 
378
  }
389
  }
379
 
390
 
380
	/*
391
	/*
381
	 * Numero d'ordre du releve affiche + mise à jour bouton
392
	 * Numero d'ordre du releve affiche + mise à jour bouton
382
	 * 
393
	 * 
383
	 */
394
	 */
384
	
395
	
385
	public void setOrdre(String ordre) {
396
	public void setOrdre(String ordre) {
386
		this.ordre = ordre;
397
		this.ordre = ordre;
387
		if (ordre==null) {
398
		if (ordre==null) {
388
			infoOrdre.setText("Nouvelle observation");
399
			infoOrdre.setText("Nouvelle observation");
389
		}
400
		}
390
		else {
401
		else {
391
			infoOrdre.setText("Modification de l'observation n°: "+ordre);
402
			infoOrdre.setText("Modification de l'observation n°: "+ordre);
392
		}
403
		}
393
	}
404
	}
394
 
405
 
395
 
406
 
396
	/*
407
	/*
397
	 * Numero d'ordre du releve affiche
408
	 * Numero d'ordre du releve affiche
398
	 * 
409
	 * 
399
	 */
410
	 */
400
	
411
	
401
	public String getOrdre() {
412
	public String getOrdre() {
402
		return this.ordre;
413
		return this.ordre;
403
	}
414
	}
404
 
415
 
405
 
416
 
406
    // Validation par entree sur cette zone de texte
417
    // Validation par entree sur cette zone de texte
407
    
418
    
408
    private void onValidateTextBox(TextBox textbox) {
419
    private void onValidateTextBox(TextBox textbox) {
409
   	
420
   	
410
		  	if (ordre==null) {
421
		  	if (ordre==null) {
411
			  // Numero ordre vide : ajout d'une observation
422
			  // Numero ordre vide : ajout d'une observation
412
			     mediator.onAddInventoryItem(); 
423
			     mediator.onAddInventoryItem(); 
413
			     textbox.setText("");
424
			     textbox.setText("");
414
			     infoOrdre.setText("Nouvelle observation");
425
			     infoOrdre.setText("Nouvelle observation");
415
			}
426
			}
416
			else {
427
			else {
417
			  // Modification  d'une observation
428
			  // Modification  d'une observation
418
			     mediator.onModifyInventoryItem(ordre); 
429
			     mediator.onModifyInventoryItem(ordre); 
419
  				infoOrdre.setText(ordre);
430
			 	 infoOrdre.setText("Modification de l'observation n°: "+ordre);
420
			}
431
			}
421
    }
432
    }
422
 
433
 
423
	
434
	
424
  
435
  
425
  /**
436
  /**
426
	 * Mise a jour de l'affichage a partir de donnees deja saisie
437
	 * Mise a jour de l'affichage a partir de donnees deja saisie
427
	 * 
438
	 * 
428
	 */
439
	 */
429
 
440
 
430
	public void update() {
441
	public void update() {
431
 
442
 
432
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Inventory/" + user + "/" + ordre, 
443
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/Inventory/" + user + "/" + ordre, 
433
 
444
 
434
		new ResponseTextHandler() {
445
		new ResponseTextHandler() {
435
 
446
 
436
			public void onCompletion(String str) {
447
			public void onCompletion(String str) {
437
 
448
 
438
				JSONValue jsonValue = JSONParser.parse(str);
449
				JSONValue jsonValue = JSONParser.parse(str);
439
				JSONArray jsonArray;
450
				JSONArray jsonArray;
440
				
451
				
441
				
452
				
442
				if ((jsonArray = jsonValue.isArray()) != null) {
453
				if ((jsonArray = jsonValue.isArray()) != null) {
443
					
454
					
444
							// Nom saisi
455
							// Nom saisi
445
							nameAssistant.setText(Util.toCelString(((JSONString) jsonArray.get(0)).toString()));
456
							nameAssistant.setText(Util.toCelString(((JSONString) jsonArray.get(0)).toString()));
446
							
457
							
447
							
458
							
448
							// Numero nomenclatural
459
							// Numero nomenclatural
449
						
460
						
450
							String ann=((JSONString) jsonArray .get(3)).stringValue();
461
							String ann=((JSONString) jsonArray .get(3)).stringValue();
451
							
462
							
452
							if (ann.compareTo("0")!=0) {
463
							if (ann.compareTo("0")!=0) {
453
								nameAssistant.setValue(ann);
464
								nameAssistant.setValue(ann);
454
								mediator.getInfoPopup().setImageUrl(ann);
465
								mediator.getInfoPopup().setImageUrl(ann);
455
							}
466
							}
456
							else {
467
							else {
457
								nameAssistant.setValue(null);
468
								nameAssistant.setValue(null);
458
							}
469
							}
459
							
470
							
460
							// Commune
471
							// Commune
461
							String aloc=Util.toCelString(((JSONString) jsonArray .get(6)).toString());
472
							String aloc=Util.toCelString(((JSONString) jsonArray .get(6)).toString());
462
							
473
							
463
							if (aloc.compareTo("000null")!=0) {
474
							if (aloc.compareTo("000null")!=0) {
464
								locationAssistant.setText(aloc);
475
								locationAssistant.setText(aloc);
465
							}
476
							}
466
							else { 
477
							else { 
467
								locationAssistant.setText("");
478
								locationAssistant.setText("");
468
							}
479
							}
-
 
480
							
-
 
481
//							 Departement
-
 
482
							String adep=Util.toCelString(((JSONString) jsonArray .get(7)).toString());
-
 
483
							
-
 
484
							if (adep.compareTo("000null")!=0) {
-
 
485
								locationAssistant.setValue(adep);
-
 
486
							}
-
 
487
							else { 
-
 
488
								locationAssistant.setValue(null);
-
 
489
							}
469
							
490
							
470
							String adate=((JSONString) jsonArray .get(8)).stringValue();
491
							String adate=((JSONString) jsonArray .get(9)).stringValue();
471
							
492
							
472
//							Date 
493
//							Date 
473
							if (adate.compareTo("0000-00-00 00:00:00")!=0) {
494
							if (adate.compareTo("0000-00-00 00:00:00")!=0) {
474
								date.setText(adate); 
495
								date.setText(adate); 
475
							}
496
							}
476
							else {
497
							else {
477
								date.setText(""); 
498
								date.setText(""); 
478
							}
499
							}
479
 
500
 
-
 
501
 
-
 
502
							String alieudit=Util.toCelString(((JSONString) jsonArray .get(10)).toString());
-
 
503
							
-
 
504
//							Lieudit 
-
 
505
							if (alieudit.compareTo("000null")!=0) {
-
 
506
								lieudit.setText(alieudit); 
-
 
507
							}
-
 
508
							else {
-
 
509
								lieudit.setText(""); 
-
 
510
							}
480
 
511
							
481
							String astation=Util.toCelString(((JSONString) jsonArray .get(9)).toString());
512
							String astation=Util.toCelString(((JSONString) jsonArray .get(11)).toString());
482
							
513
							
483
//							Station 
514
//							Station 
484
							if (astation.compareTo("000null")!=0) {
515
							if (astation.compareTo("000null")!=0) {
485
								milieu.setText(astation); 
516
								station.setText(astation); 
486
							}
517
							}
487
							else {
518
							else {
488
								milieu.setText(""); 
519
								station.setText(""); 
489
							}
520
							}
490
							
521
							
491
 
522
 
492
							String acomment=Util.toCelString(((JSONString) jsonArray .get(10)).toString());
523
							String acomment=Util.toCelString(((JSONString) jsonArray .get(12)).toString());
493
//							Notes
524
//							Notes
494
							if (acomment.compareTo("null")!=0) {
525
							if (acomment.compareTo("null")!=0) {
495
								comment.setText(acomment); 
526
								comment.setText(acomment); 
496
							}
527
							}
497
							else {
528
							else {
498
								comment.setText(""); 
529
								comment.setText(""); 
499
							}
530
							}
500
							
531
							
501
				}
532
				}
502
 
533
 
503
				
534
				
504
			}
535
			}
505
		});
536
		});
506
 
537
 
507
	}
538
	}
508
 
539
 
509
	public void setUser(String user) {
540
	public void setUser(String user) {
510
		this.user = user;
541
		this.user = user;
511
	}
542
	}
512
	
543
	
513
 
544
 
514
}
545
}
515
 
546
 
516
/* +--Fin du code ---------------------------------------------------------------------------------------+
547
/* +--Fin du code ---------------------------------------------------------------------------------------+
517
* $Log$
548
* $Log$
-
 
549
* Revision 1.1  2008-01-02 21:26:04  ddelon
-
 
550
* mise en place mygwt
-
 
551
*
518
* Revision 1.8  2007-12-22 14:48:53  ddelon
552
* Revision 1.8  2007-12-22 14:48:53  ddelon
519
* Documentation et refactorisation
553
* Documentation et refactorisation
520
*
554
*
521
* Revision 1.7  2007-09-17 19:25:34  ddelon
555
* Revision 1.7  2007-09-17 19:25:34  ddelon
522
* Documentation
556
* Documentation
523
*
557
*
524
* Revision 1.6  2007-06-06 13:29:30  ddelon
558
* Revision 1.6  2007-06-06 13:29:30  ddelon
525
* v0.09
559
* v0.09
526
*
560
*
527
* Revision 1.5  2007-05-22 14:27:08  ddelon
561
* Revision 1.5  2007-05-22 14:27:08  ddelon
528
* reglage modification
562
* reglage modification
529
*
563
*
530
* Revision 1.4  2007-05-21 21:01:35  ddelon
564
* Revision 1.4  2007-05-21 21:01:35  ddelon
531
* Modification comportement boutons
565
* Modification comportement boutons
532
*
566
*
533
* 
567
* 
534
*/
568
*/