Subversion Repositories eFlore/Applications.cel

Rev

Rev 12 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12 Rev 13
Line 1... Line 1...
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
Line -... Line 2...
-
 
2
 
-
 
3
 
-
 
4
 
-
 
5
import java.util.Iterator;
-
 
6
 
2
 
7
import org.tela_botanica.client.interfaces.Rafraichissable;
Line -... Line 8...
-
 
8
import org.tela_botanica.client.modeles.ListeReferentielCommune;
-
 
9
import org.tela_botanica.client.modeles.ReferentielCommune;
-
 
10
import org.tela_botanica.client.observation.ObservationMediateur;
-
 
11
 
3
 
12
 
-
 
13
import com.google.gwt.user.client.Window;
-
 
14
import com.gwtext.client.core.EventCallback;
-
 
15
import com.gwtext.client.core.EventObject;
-
 
16
import com.gwtext.client.core.ListenerConfig;
-
 
17
import com.gwtext.client.core.Position;
-
 
18
import com.gwtext.client.data.ArrayReader;
4
 
19
import com.gwtext.client.data.FieldDef;
5
import org.tela_botanica.client.observation.ObservationMediateur;
20
import com.gwtext.client.data.MemoryProxy;
-
 
21
import com.gwtext.client.data.RecordDef;
6
 
22
import com.gwtext.client.data.Store;
7
 
23
import com.gwtext.client.data.StringFieldDef;
8
import com.gwtext.client.core.Position;
24
import com.gwtext.client.widgets.Button;
-
 
25
import com.gwtext.client.widgets.Panel;
9
import com.gwtext.client.widgets.Button;
26
import com.gwtext.client.widgets.form.ComboBox;
10
import com.gwtext.client.widgets.Panel;
27
import com.gwtext.client.widgets.form.DateField;
11
import com.gwtext.client.widgets.form.DateField;
28
import com.gwtext.client.widgets.form.FormPanel;
-
 
29
import com.gwtext.client.widgets.form.TextField;
Line 12... Line 30...
12
import com.gwtext.client.widgets.form.FormPanel;
30
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
13
import com.gwtext.client.widgets.form.TextField;
31
import com.gwtext.client.widgets.layout.ColumnLayout;
14
import com.gwtext.client.widgets.layout.ColumnLayout;
32
import com.gwtext.client.widgets.layout.ColumnLayoutData;
15
import com.gwtext.client.widgets.layout.ColumnLayoutData;
33
import com.gwtext.client.widgets.layout.FormLayout;
16
import com.gwtext.client.widgets.layout.FormLayout;
34
import com.gwtext.client.data.Record;
17
 
35
 
Line 18... Line 36...
18
/**
36
/**
19
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
37
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
20
 * @author aurelien
38
 * @author aurelien
21
 *
39
 *
Line 22... Line 40...
22
 */
40
 */
23
public class FormulaireSaisieObservationVue extends Panel  {
-
 
24
 
41
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable  {
25
 
42
 
26
	/**
43
 
27
	 * Le médiateur associé à la vue
44
	/**
28
	 */
45
	 * Le médiateur associé à la vue
-
 
46
	 */
-
 
47
	private ObservationMediateur	observationMediateur		= null;
-
 
48
	
Line -... Line 49...
-
 
49
	
-
 
50
	private TextField nameAssistant = null;
-
 
51
	private DateField date = null;
-
 
52
	private TextField lieudit = null;
-
 
53
	private TextField station = null;
-
 
54
	private TextField milieu = null;
-
 
55
	private TextField comment = null;
-
 
56
	private ComboBox  commune = null;
-
 
57
	
-
 
58
	private boolean selectionCommune=false;
-
 
59
	
-
 
60
	  public static final int KEY_ALT = 18;
-
 
61
	  public static final int KEY_BACKSPACE = 8;
-
 
62
	  public static final int KEY_CTRL = 17;
-
 
63
	  public static final int KEY_DELETE = 46;
-
 
64
	  public static final int KEY_DOWN = 40;
-
 
65
	  public static final int KEY_END = 35;
-
 
66
	  public static final int KEY_ENTER = 13;
-
 
67
	  public static final int KEY_ESCAPE = 27;
-
 
68
	  public static final int KEY_HOME = 36;
-
 
69
	  public static final int KEY_LEFT = 37;
-
 
70
	  public static final int KEY_PAGEDOWN = 34;
-
 
71
	  public static final int KEY_PAGEUP = 33;
Line 29... Line 72...
29
	private ObservationMediateur	observationMediateur		= null;
72
	  public static final int KEY_RIGHT = 39;
30
	
73
	  public static final int KEY_SHIFT = 16;
31
	
74
	  public static final int KEY_TAB = 9;
Line 86... Line 129...
86
		//create second panel and add fields to it  
129
		//create second panel and add fields to it  
87
	    Panel panneauSecondeColonne = new Panel();  
130
	    Panel panneauSecondeColonne = new Panel();  
88
		panneauSecondeColonne.setLayout(new FormLayout());  
131
		panneauSecondeColonne.setLayout(new FormLayout());  
89
		panneauSecondeColonne.setBorder(false);
132
		panneauSecondeColonne.setBorder(false);
Line -... Line 133...
-
 
133
	
-
 
134
	/*
-
 
135
	    //	  creation du store
-
 
136
		FieldDef defCommune = new StringFieldDef("commune");
-
 
137
		FieldDef defDepartement = new StringFieldDef("departement");
-
 
138
		
-
 
139
		
-
 
140
		FieldDef[] defTab = { defCommune, defDepartement};
-
 
141
		
-
 
142
		RecordDef rd = new RecordDef(defTab);
-
 
143
		
-
 
144
		
-
 
145
		store = new Store(rd);
-
 
146
		
-
 
147
		//store.load();*/
-
 
148
		
-
 
149
		commune=new ComboBox("Commune","commune",275 );  
-
 
150
		
-
 
151
	
-
 
152
		//commune.setStore(store);
-
 
153
		
-
 
154
		final String resultTpl = "<div class=\"search-item\">{commune}</div>";  
-
 
155
 
-
 
156
		
-
 
157
		commune.setTpl(resultTpl);
-
 
158
		commune.setMode(ComboBox.REMOTE);
-
 
159
		// commune.setPageSize(10); // Ne fonctionne pas 
-
 
160
		commune.setItemSelector("div.search-item");
-
 
161
		
-
 
162
		
-
 
163
		//commune.setDisplayField("title");
-
 
164
		
-
 
165
		commune.setTypeAhead(true);  
-
 
166
		commune.setLoadingText("Recherche...");  
-
 
167
		  
-
 
168
		commune.setHideTrigger(true);
-
 
169
		
-
 
170
		
-
 
171
		/*
-
 
172
		final String resultTpl = "<div class=\"search-item\"><h3><span>{lastPost:date(\"M j, Y\")}"  
-
 
173
			                                 +  "<br/>by {author}</span>{title}</h3>{excerpt}</div>";  
-
 
174
		
-
 
175
		commune.setTpl(resultTpl);
-
 
176
		*/
-
 
177
		
-
 
178
		//commune.setMode(ComboBox.REMOTE);
-
 
179
		
-
 
180
		/*
-
 
181
		commune.setTitle("ExtJS Forums");  
-
 
182
		commune.setHideLabel(true);  
-
 
183
		commune.setItemSelector("div.search-item");
-
 
184
		
-
 
185
		  */
-
 
186
   
-
 
187
		
-
 
188
	    
-
 
189
		
-
 
190
        commune.addListener(new ComboBoxListenerAdapter() {  
-
 
191
             public void onSelect(ComboBox comboBox, Record record, int index) {  
-
 
192
                 commune.setValue(record.getAsString("commune"));
-
 
193
                 selectionCommune=true;
-
 
194
             }  
-
 
195
         });  
-
 
196
         
-
 
197
        
-
 
198
//      Selection parmi la liste déroulante
-
 
199
	    
-
 
200
        
-
 
201
		ListenerConfig listenerConfig=new ListenerConfig();
-
 
202
		listenerConfig.setDelay(10);
-
 
203
		listenerConfig.setStopPropagation(false);
-
 
204
		listenerConfig.setStopEvent(false);
-
 
205
		
-
 
206
 
-
 
207
	
-
 
208
	    commune.addKeyPressListener(new EventCallback()	{
-
 
209
	    	
-
 
210
	    	    public void execute(EventObject e) {
-
 
211
	    	    	
-
 
212
	    	    		  
-
 
213
	    	    		  switch(e.getKey()) {
-
 
214
	    	    	      	    		  
-
 
215
	    	    		  
-
 
216
	    	    		  case KEY_ALT:
-
 
217
	    	    	      case KEY_CTRL:
-
 
218
	    	    	      case KEY_DOWN:
-
 
219
	    	    	      case KEY_END:
-
 
220
	    	    	      
-
 
221
	    	    	      case KEY_ESCAPE:
-
 
222
	    	    	      case KEY_HOME:
-
 
223
	    	    	      case KEY_LEFT:
-
 
224
	    	    	      case KEY_PAGEDOWN:
-
 
225
	    	    	      case KEY_PAGEUP:
-
 
226
	    	    	      case KEY_RIGHT:
-
 
227
	    	    	      case KEY_SHIFT:
-
 
228
	    	    	      case KEY_TAB:
-
 
229
	    	    	      case KEY_UP:
-
 
230
	    	    	    	
-
 
231
	    	    	        break;
-
 
232
	    	    	      
-
 
233
	    	    	      case KEY_ENTER:
-
 
234
	    	    	    	  
-
 
235
	    	    	    	 if (selectionCommune) {
-
 
236
	    	    	    		 selectionCommune=false;
-
 
237
	    	    	    	 }
-
 
238
	    	    	    	 else {
-
 
239
	    	    	    		// lancer mise a jour 	    	    	    		 
-
 
240
	    	    	    	 }
-
 
241
	    	    	    	
-
 
242
	    	    	    	
-
 
243
	    	    	    	  break;
-
 
244
	    	    	       
-
 
245
	    	    	      default:
-
 
246
	    	    	    	  
-
 
247
	    	    	    	  obtenirListeReferentielCommune();
-
 
248
	    	    	    	  	    	    	        
-
 
249
	    	    	        break;
-
 
250
	    	    	    }
-
 
251
 
-
 
252
	    	    	 
-
 
253
	    	    	
-
 
254
	     		}
-
 
255
	    	 
-
 
256
	    		},    listenerConfig
-
 
257
	    	
-
 
258
		);
-
 
259
	    
-
 
260
	    
-
 
261
 
-
 
262
 
-
 
263
 
-
 
264
	    panneauPremierColonne.add(commune);  
Line 90... Line -...
90
	
-
 
91
		
-
 
Line 92... Line 265...
92
	    locationAssistant = new LocationAssistantVue(obs);  
265
 
93
	    panneauPremierColonne.add(locationAssistant);  
266
		
94
	    
267
	    
Line 117... Line 290...
117
	
290
	
118
	    milieu = new TextField("Milieu", "milieu", 275);  
291
	    milieu = new TextField("Milieu", "milieu", 275);  
119
	    milieu.setAllowBlank(true);  
292
	    milieu.setAllowBlank(true);  
Line 120... Line -...
120
	    panneauSecondeColonne.add(milieu);  
-
 
121
	   
293
	    panneauSecondeColonne.add(milieu);  
Line 122... Line 294...
122
	  
294
	   
123
		
295
	 
Line 124... Line 296...
124
		
296
		
Line 180... Line 352...
180
	 */
352
	 */
181
	public void activerPanneau()
353
	public void activerPanneau()
182
	{
354
	{
183
		this.setDisabled(false) ;
355
		this.setDisabled(false) ;
184
	}
356
	}
-
 
357
 
-
 
358
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
-
 
359
		// 
-
 
360
		
-
 
361
		
-
 
362
		// si l'on a reçu une liste de commune
-
 
363
			if(nouvelleDonnees instanceof ListeReferentielCommune)
-
 
364
			{
-
 
365
				
-
 
366
					ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
-
 
367
					Object[][] communeData = new Object[data.size()][2];
-
 
368
					int i = 0 ;
-
 
369
				
-
 
370
					// on la parse et on récupère les informations quiç nous interessent
-
 
371
					for (Iterator it = data.keySet().iterator(); it.hasNext();) 
-
 
372
					{
-
 
373
						
-
 
374
						ReferentielCommune ref=(ReferentielCommune) data.get(it.next());
-
 
375
						
-
 
376
						communeData[i][0]= ref.getCommune();
-
 
377
						communeData[i][1]= ref.getDepartement();
-
 
378
						
-
 
379
																	
-
 
380
						i++ ;
-
 
381
					}
-
 
382
					
-
 
383
					   //	  creation du store
-
 
384
					FieldDef defCommune = new StringFieldDef("commune");
-
 
385
					FieldDef defDepartement = new StringFieldDef("departement");
-
 
386
					
-
 
387
					
-
 
388
					FieldDef[] defTab = { defCommune, defDepartement};
-
 
389
					
-
 
390
					RecordDef rd = new RecordDef(defTab);
-
 
391
					
-
 
392
					final MemoryProxy dataProxy = new MemoryProxy(communeData);
-
 
393
					final ArrayReader reader = new ArrayReader(rd);		
-
 
394
					
-
 
395
					store=new Store(dataProxy,reader);
-
 
396
					store.load() ;
-
 
397
		
-
 
398
					commune.setStore(store);
-
 
399
				
-
 
400
					
-
 
401
							
-
 
402
			}
-
 
403
	}
Line -... Line 404...
-
 
404
	
-
 
405
 
-
 
406
	public void obtenirListeReferentielCommune() {
-
 
407
	  observationMediateur.obtenirListeReferentielCommune(this,commune.getText());
-
 
408
	 
Line 185... Line 409...
185
	
409
	}