Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 107 Rev 110
Line 9... Line 9...
9
import org.tela_botanica.client.modeles.ListeReferentielNom;
9
import org.tela_botanica.client.modeles.ListeReferentielNom;
10
import org.tela_botanica.client.modeles.Observation;
10
import org.tela_botanica.client.modeles.Observation;
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;
14
 
-
 
15
 
-
 
16
import com.google.gwt.user.client.Window;
14
import com.google.gwt.user.client.Window;
17
import com.gwtext.client.core.EventCallback;
15
import com.gwtext.client.core.EventCallback;
18
import com.gwtext.client.core.EventObject;
16
import com.gwtext.client.core.EventObject;
19
import com.gwtext.client.core.ListenerConfig;
17
import com.gwtext.client.core.ListenerConfig;
20
import com.gwtext.client.core.Position;
18
import com.gwtext.client.core.Position;
Line 32... Line 30...
32
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
30
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
33
import com.gwtext.client.widgets.form.ComboBox;
31
import com.gwtext.client.widgets.form.ComboBox;
34
import com.gwtext.client.widgets.form.DateField;
32
import com.gwtext.client.widgets.form.DateField;
35
import com.gwtext.client.widgets.form.FormPanel;
33
import com.gwtext.client.widgets.form.FormPanel;
36
import com.gwtext.client.widgets.form.Hidden;
34
import com.gwtext.client.widgets.form.Hidden;
-
 
35
import com.gwtext.client.widgets.form.TextArea;
37
import com.gwtext.client.widgets.form.TextField;
36
import com.gwtext.client.widgets.form.TextField;
38
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
37
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
39
import com.gwtext.client.widgets.layout.ColumnLayout;
38
import com.gwtext.client.widgets.layout.ColumnLayout;
40
import com.gwtext.client.widgets.layout.ColumnLayoutData;
39
import com.gwtext.client.widgets.layout.ColumnLayoutData;
41
import com.gwtext.client.widgets.layout.FormLayout;
40
import com.gwtext.client.widgets.layout.FormLayout;
Line 64... Line 63...
64
	private ComboBox  commune = null;
63
	private ComboBox  commune = null;
65
	private String departement = null;
64
	private String departement = null;
66
	private ComboBox  espece = null;
65
	private ComboBox  espece = null;
67
	private String numeroNom = null;
66
	private String numeroNom = null;
68
	private String numeroOrdre = null;
67
	private String numeroOrdre = null;
-
 
68
	private TextArea motsCles = null;
Line -... Line 69...
-
 
69
 
69
 
70
	private String formatDate = null ;
70
 
71
	
71
	private Button boutonOK = new Button("Créer");
72
	private Button boutonOK = new Button("Créer");
Line 72... Line 73...
72
	private Button boutonAnnuler = new Button("Réinitialiser");
73
	private Button boutonAnnuler = new Button("Réinitialiser");
73
 
74
 
Line 180... Line 181...
180
	    station.setAllowBlank(true);  
181
	    station.setAllowBlank(true);  
181
	    panneauPremierColonne.add(station);  
182
	    panneauPremierColonne.add(station);  
Line 182... Line 183...
182
	    
183
	    
183
	    date = new DateField("Date", "date", 100);  
184
	    date = new DateField("Date", "date", 100);  
-
 
185
	    date.setAllowBlank(true);
184
	    date.setAllowBlank(true);
186
	    formatDate = "d/m/Y";
185
	    date.setFormat("d/m/Y") ;
187
	    date.setFormat(formatDate) ;
Line 186... Line 188...
186
	    panneauPremierColonne.add(date);  
188
	    panneauPremierColonne.add(date);  
Line 215... Line 217...
215
	    panneauSecondeColonne.add(lieudit);  
217
	    panneauSecondeColonne.add(lieudit);  
Line 216... Line 218...
216
	       
218
	       
217
	
219
	
218
	    milieu = new TextField("Milieu", "milieu", 275);  
220
	    milieu = new TextField("Milieu", "milieu", 275);  
-
 
221
	    milieu.setAllowBlank(true);  
-
 
222
	    panneauSecondeColonne.add(milieu);
-
 
223
	   
-
 
224
	    motsCles = new TextArea("Mots clés","motscles") ;
-
 
225
	    motsCles.setAllowBlank(true);
Line 219... Line -...
219
	    milieu.setAllowBlank(true);  
-
 
220
	    panneauSecondeColonne.add(milieu);  
-
 
221
	   
226
	    motsCles.setWidth(275);
222
	 
227
	    panneauSecondeColonne.add(motsCles);
Line 223... Line 228...
223
		
228
	   
Line 599... Line 604...
599
	}
604
	}
Line 600... Line 605...
600
   
605
   
Line 601... Line 606...
601
 
606
 
602
	public void ajouterObservation() {
607
	public void ajouterObservation() {
603
 
608
 
Line 604... Line 609...
604
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue());	
609
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),date.getRawValue(),motsCles.getValueAsString());	
Line 605... Line 610...
605
		observationMediateur.ajouterObservation(obs);
610
		observationMediateur.ajouterObservation(obs);
606
	}
611
	}
607
	
612
	
Line 608... Line 613...
608
	private void modifierObservation() {
613
	private void modifierObservation() {
Line 623... Line 628...
623
	{
628
	{
624
		raz() ;
629
		raz() ;
Line 625... Line 630...
625
		
630
		
626
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) {
631
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) {
-
 
632
			String[] dateEtHeure = obs.getDate().split(" ", 2);
627
			String[] dateEtHeure = obs.getDate().split(" ", 2);
633
			if(verifierFormatDate(dateEtHeure[0])) {
-
 
634
				date.setValue(dateEtHeure[0]) ;
-
 
635
			}
-
 
636
			else
-
 
637
			{
-
 
638
				date.setRawValue(""); 
628
			date.setValue(dateEtHeure[0]) ;
639
			}
629
		}
640
		}
630
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
641
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
631
			lieudit.setValue(obs.getLieudit()) ;
642
			lieudit.setValue(obs.getLieudit()) ;
632
		}
643
		}
Line 652... Line 663...
652
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
663
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
653
		}
664
		}
654
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000nu2ll")) {
665
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000nu2ll")) {
655
			numeroOrdre = obs.getNumeroOrdre() ;
666
			numeroOrdre = obs.getNumeroOrdre() ;
656
		}
667
		}
-
 
668
		if(!obs.getMotsCles().equals("null") && !obs.getMotsCles().equals("000null")) {
-
 
669
			motsCles.setValue(obs.getMotsCles());
-
 
670
		}
Line 657... Line 671...
657
		
671
		
Line 658... Line 672...
658
	}
672
	}
659
	
673
	
Line 664... Line 678...
664
		lieudit.reset() ;
678
		lieudit.reset() ;
665
		station.reset() ;
679
		station.reset() ;
666
		milieu.reset();
680
		milieu.reset();
667
		comment.reset();
681
		comment.reset();
668
		commune.reset();
682
		commune.reset();
-
 
683
		motsCles.reset();
669
		departement = "";
684
		departement = "";
670
		espece.reset();
685
		espece.reset();
671
		numeroNom = "" ;
686
		numeroNom = "" ;
672
		numeroOrdre = "";
687
		numeroOrdre = "";
Line 706... Line 721...
706
	 */
721
	 */
707
	public boolean getModification()
722
	public boolean getModification()
708
	{
723
	{
709
		return modification ;
724
		return modification ;
710
	}
725
	}
-
 
726
	
-
 
727
	public boolean verifierFormatDate(String date) {
-
 
728
		
-
 
729
		String regex = "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" ;
-
 
730
		if(date.matches(regex) && !date.equals("0000-00-00")) {
-
 
731
			return true ;
-
 
732
		}
-
 
733
		else {
-
 
734
			return false;
-
 
735
		}
-
 
736
	}
Line 711... Line 737...
711
 
737