Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 53 Rev 71
Line 11... Line 11...
11
import org.tela_botanica.client.modeles.ReferentielCommune;
11
import org.tela_botanica.client.modeles.ReferentielCommune;
12
import org.tela_botanica.client.modeles.ReferentielNom;
12
import org.tela_botanica.client.modeles.ReferentielNom;
13
import org.tela_botanica.client.observation.ObservationMediateur;
13
import org.tela_botanica.client.observation.ObservationMediateur;
Line -... Line 14...
-
 
14
 
14
 
15
 
15
 
16
import com.google.gwt.user.client.Window;
16
import com.gwtext.client.core.EventCallback;
17
import com.gwtext.client.core.EventCallback;
17
import com.gwtext.client.core.EventObject;
18
import com.gwtext.client.core.EventObject;
-
 
19
import com.gwtext.client.core.ListenerConfig;
18
import com.gwtext.client.core.ListenerConfig;
20
import com.gwtext.client.core.Position;
19
import com.gwtext.client.core.Position;
21
import com.gwtext.client.core.Template;
20
import com.gwtext.client.data.ArrayReader;
22
import com.gwtext.client.data.ArrayReader;
21
import com.gwtext.client.data.FieldDef;
23
import com.gwtext.client.data.FieldDef;
-
 
24
import com.gwtext.client.data.MemoryProxy;
22
import com.gwtext.client.data.MemoryProxy;
25
import com.gwtext.client.data.RecordDef;
23
import com.gwtext.client.data.RecordDef;
26
import com.gwtext.client.data.SimpleStore;
24
import com.gwtext.client.data.Store;
27
import com.gwtext.client.data.Store;
25
import com.gwtext.client.data.StringFieldDef;
28
import com.gwtext.client.data.StringFieldDef;
-
 
29
import com.gwtext.client.widgets.Button;
26
import com.gwtext.client.widgets.Button;
30
import com.gwtext.client.widgets.Panel;
27
import com.gwtext.client.widgets.Panel;
31
import com.gwtext.client.widgets.Toolbar;
28
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
32
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
29
import com.gwtext.client.widgets.form.ComboBox;
33
import com.gwtext.client.widgets.form.ComboBox;
30
import com.gwtext.client.widgets.form.DateField;
34
import com.gwtext.client.widgets.form.DateField;
Line 59... Line 63...
59
	private ComboBox  commune = null;
63
	private ComboBox  commune = null;
60
	private String departement = null;
64
	private String departement = null;
61
	private ComboBox  espece = null;
65
	private ComboBox  espece = null;
62
	private String numeroNom = null;
66
	private String numeroNom = null;
Line 63... Line 67...
63
 
67
 
64
	private Button boutonOK = new Button("Ok");
68
	private Button boutonOK = new Button("Créer");
Line 65... Line 69...
65
	private Button boutonAnnuler = new Button("Annuler");
69
	private Button boutonAnnuler = new Button("Annuler");
66
 
70
 
Line -... Line 71...
-
 
71
	private boolean selectionCommune=false;
-
 
72
	private boolean selectionEspece=false;
Line 67... Line 73...
67
	private boolean selectionCommune=false;
73
	
68
	private boolean selectionEspece=false;
74
	private boolean modification = false ;
69
	
75
	private Toolbar bt = null ;
70
	
76
	
Line 83... Line 89...
83
	private final int KEY_RIGHT = 39;
89
	private final int KEY_RIGHT = 39;
84
	private final int KEY_SHIFT = 16;
90
	private final int KEY_SHIFT = 16;
85
	private final int KEY_TAB = 9;
91
	private final int KEY_TAB = 9;
86
	private final int KEY_UP = 38;
92
	private final int KEY_UP = 38;
Line -... Line 93...
-
 
93
	
-
 
94
	/**
-
 
95
	 * Combobox permettant de selectionner le mode
-
 
96
	 * modification ou bien création
-
 
97
	 */
Line 87... Line -...
87
	
-
 
-
 
98
	private ComboBox selecteurMode = new ComboBox();
Line 88... Line 99...
88
	
99
	
89
	
100
	Store storeMode = null ;
90
 
101
 
91
	/**
102
	/**
Line 92... Line 103...
92
	 * Booleen d'instanciation
103
	 * Booleen d'instanciation
93
	 */
104
	 */
94
	boolean estInstancie = false ;
105
	boolean estInstancie = false ;
-
 
106
	
95
	
107
	/**
96
	/**
108
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
97
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
109
	 */
98
	 */
110
	@SuppressWarnings("unused")
Line 209... Line 221...
209
		panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
221
		panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
210
		panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
222
		panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
Line 211... Line 223...
211
		
223
		
Line -... Line 224...
-
 
224
		panneauFormulaire.add(panneauIntermediaire);
-
 
225
		
-
 
226
		/*final Template tp = new Template("<div class=\"x-combo-list-item\">"
-
 
227
				+ "{nom_mode}" + "<div class=\"x-clear\"></div></div>");
-
 
228
		tp.compile();*/
-
 
229
		
-
 
230
		Object[][] mode = {{"création",false} , {"modification", true} };
-
 
231
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
-
 
232
				mode);
-
 
233
		storeMode.load();
-
 
234
		selecteurMode.setStore(storeMode);
-
 
235
		selecteurMode.setDisplayField("nom_mode") ;
-
 
236
		selecteurMode.setLabel("mode ") ;
-
 
237
		selecteurMode.setForceSelection(true) ;
-
 
238
		selecteurMode.setValue("création") ;
-
 
239
		selecteurMode.setEditable(false) ;
-
 
240
		
-
 
241
		bt = new Toolbar() ;
-
 
242
		bt.addSpacer() ;
Line 212... Line 243...
212
		panneauFormulaire.add(panneauIntermediaire);
243
		bt.addText("Mode de saisie ") ;
Line 213... Line -...
213
		
-
 
214
		
244
		bt.addField(selecteurMode) ;
215
		panneauFormulaire.addButton(boutonOK);
245
		
-
 
246
		panneauFormulaire.addButton(boutonOK);
-
 
247
		    
-
 
248
		panneauFormulaire.addButton(boutonAnnuler);
-
 
249
		
-
 
250
		selecteurMode.addListener(new ComboBoxListenerAdapter() {
-
 
251
 
-
 
252
			public void onSelect(ComboBox comboBox, Record record, int index) {
-
 
253
				
-
 
254
				// et on met la valeur à jour dans la combobox
-
 
255
				comboBox.setValue(record.getAsString("nom_mode"));
Line 216... Line 256...
216
		    
256
				setModification(record.getAsString("mode")) ;
-
 
257
			}
Line 217... Line 258...
217
		  
258
 
Line 378... Line 419...
378
 
419
 
Line 379... Line 420...
379
		boutonOK.addListener(new ButtonListenerAdapter() {
420
		boutonOK.addListener(new ButtonListenerAdapter() {
Line -... Line 421...
-
 
421
			
-
 
422
			public void onClick(Button button, EventObject e) {
-
 
423
				
-
 
424
				if(modification)
-
 
425
				{
-
 
426
					modifierObservation() ;
380
			
427
				}
-
 
428
				else
-
 
429
				{
Line 381... Line 430...
381
			public void onClick(Button button, EventObject e) {
430
					ajouterObservation();
382
				
-
 
Line 383... Line 431...
383
				ajouterObservation();
431
				}
Line 384... Line 432...
384
				
432
				
385
			}
433
				
Line 503... Line 551...
503
				
551
				
Line -... Line 552...
-
 
552
					
-
 
553
							
-
 
554
			}
-
 
555
			
504
					
556
			if(nouvelleDonnees instanceof Observation)
Line 505... Line 557...
505
							
557
			{
Line 506... Line 558...
506
			}
558
				Observation obs = (Observation)nouvelleDonnees ;
Line 533... Line 585...
533
 
585
 
534
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getText());	
586
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getText());	
535
		observationMediateur.ajouterObservation(obs);
587
		observationMediateur.ajouterObservation(obs);
Line -... Line 588...
-
 
588
	}
-
 
589
	
-
 
590
	private void modifierObservation() {
-
 
591
		// TODO appeler le médiateur et mettre en place la modif
-
 
592
		
-
 
593
	}
-
 
594
 
-
 
595
	
-
 
596
	public void afficherDetailsObservation(Observation obs)
-
 
597
	{
-
 
598
		viderChampsObservation() ;
-
 
599
		
-
 
600
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) {
-
 
601
			String[] dateEtHeure = obs.getDate().split(" ", 2);
-
 
602
			date.setRawValue(dateEtHeure[0]) ;
-
 
603
		}
-
 
604
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
-
 
605
			lieudit.setValue(obs.getLieudit()) ;
-
 
606
		}
-
 
607
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
-
 
608
			station.setValue(obs.getStation()) ;
-
 
609
		}
-
 
610
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
-
 
611
			milieu.setValue(obs.getMilieu()) ;
-
 
612
		}
-
 
613
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
-
 
614
			comment.setValue(obs.getCommentaire()) ;
-
 
615
		}
-
 
616
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
-
 
617
			commune.setValue(obs.getLocalite()) ;
-
 
618
		}
-
 
619
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
-
 
620
			departement = obs.getIdentifiantLocalite();
-
 
621
		}
-
 
622
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
-
 
623
			espece.setValue(obs.getNomSaisi()) ;
-
 
624
		}
-
 
625
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
-
 
626
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
-
 
627
		}
-
 
628
	}
-
 
629
	
-
 
630
	public void viderChampsObservation()
-
 
631
	{
-
 
632
 
-
 
633
		date.reset() ;
-
 
634
		lieudit.reset() ;
-
 
635
		station.reset() ;
-
 
636
		milieu.reset();
-
 
637
		comment.reset();
-
 
638
		commune.reset();
-
 
639
		departement = "";
-
 
640
		espece.reset();
-
 
641
		numeroNom = "" ;
-
 
642
		
-
 
643
	}
-
 
644
	
-
 
645
	private void setModification(String mode)
-
 
646
	{
-
 
647
		if(mode.equals("true")) {
-
 
648
 
-
 
649
			boutonOK.setText("Modifier") ;
-
 
650
			setTitle("Modification") ;
-
 
651
			modification = true ;
-
 
652
		}
-
 
653
		else
-
 
654
		{
-
 
655
 
-
 
656
			boutonOK.setText("Créer") ;
-
 
657
			setTitle("Saisir") ;
-
 
658
			modification = false ;
-
 
659
		}
-
 
660
		
-
 
661
	}
-
 
662
	
-
 
663
	
-
 
664
	/**
-
 
665
	 * renvoie vrai si on est en mode modification, faux si on est en mode création
-
 
666
	 * @return
-
 
667
	 */
-
 
668
	public boolean getModification()
-
 
669
	{
-
 
670
		return modification ;
Line 536... Line 671...
536
	}
671
	}