Subversion Repositories eFlore/Archives.cel-v1

Rev

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

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