Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2 Rev 7
Line 1... Line 1...
1
package org.tela_botanica.client.observation;
1
package org.tela_botanica.client.observation;
Line 2... Line -...
2
 
-
 
3
 
-
 
4
 
-
 
5
 
2
 
6
import org.tela_botanica.client.CarnetEnLigneMediateur;
3
import org.tela_botanica.client.CarnetEnLigneMediateur;
7
import org.tela_botanica.client.interfaces.iMediateur;
4
import org.tela_botanica.client.interfaces.iMediateur;
8
import org.tela_botanica.client.interfaces.iRetourObservation;
5
import org.tela_botanica.client.interfaces.iRetourObservation;
Line 9... Line 6...
9
import org.tela_botanica.client.modeles.Observation;
6
import org.tela_botanica.client.modeles.Observation;
10
 
7
 
11
import com.google.gwt.user.client.Window;
8
import com.google.gwt.user.client.Window;
Line 12... Line 9...
12
import com.google.gwt.user.client.ui.RootPanel;
9
import com.google.gwt.user.client.ui.RootPanel;
13
import com.google.gwt.user.client.ui.VerticalPanel;
-
 
Line 14... Line 10...
14
 
10
import com.google.gwt.user.client.ui.VerticalPanel;
15
public class ObservationMediateur implements iMediateur{
11
 
Line 16... Line 12...
16
 
12
public class ObservationMediateur implements iMediateur {
17
 
-
 
18
	// Evenenements
-
 
19
	final static public  int NOMBRE_OBSERVATION=1;
-
 
20
 
-
 
Line -... Line 13...
-
 
13
 
-
 
14
	// Evenenements
21
	final static public  int LISTE_OBSERVATION=2;
15
	final static public int NOMBRE_OBSERVATION = 1;
Line -... Line 16...
-
 
16
 
-
 
17
	final static public int LISTE_OBSERVATION = 2;
22
	
18
 
23
	
19
	private CarnetEnLigneMediateur carnetEnLigneMediateur = null; // Mediateur
Line 24... Line 20...
24
	private CarnetEnLigneMediateur carnetEnLigneMediateur=null;  // Mediateur General
20
																	// General
25
	private final ObservationModele observationModele=new ObservationModele();
21
	private final ObservationModele observationModele = new ObservationModele();
26
 
22
 
-
 
23
	private Observation observation = null;
27
	private Observation observation=null; 
24
 
-
 
25
	// Variable interne
-
 
26
	private final String texteDeconnexion = "Utilisez ce carnet en ligne pour saisir vos observations, <u>identifiez-vous</u> pour les transmettre à Tela Botanica";
-
 
27
 
28
 
28
	// Composants graphiques
-
 
29
 
29
	// Variable interne 
30
	private EtatConnexionVue etatConnexionVue = null; // Vue Etat de la
30
	private final String texteDeconnexion="Utilisez ce carnet en ligne pour saisir vos observations, <u>identifiez-vous</u> pour les transmettre à Tela Botanica"; 
31
														// connexion utilisateur
31
 
-
 
32
	// Composants graphiques
32
	private FormulaireDeConnexionVue formulaireDeConnexionVue = null; // Formulaire
33
	
33
																		// de
34
	private EtatConnexionVue etatConnexionVue=null; // Vue Etat de la connexion utilisateur
-
 
Line 35... Line 34...
35
	private FormulaireDeConnexionVue formulaireDeConnexionVue=null; // Formulaire de connexion utilisateur
34
																		// connexion
36
	private ListeObservationsVue listeObservationsVue = null;  // Liste de releves
35
																		// utilisateur
37
 
36
	private ListeObservationsVue listeObservationsVue = null; // Liste de
38
    // 
37
																// releves
39
		
38
 
40
	
39
	// 
41
	public ObservationMediateur(CarnetEnLigneMediateur carnetEnLigneMediateur) {
40
 
42
		
41
	public ObservationMediateur(CarnetEnLigneMediateur carnetEnLigneMediateur) {
43
 
42
 
44
		this.carnetEnLigneMediateur=carnetEnLigneMediateur;
43
		this.carnetEnLigneMediateur = carnetEnLigneMediateur;
45
		
-
 
Line 46... Line 44...
46
		etatConnexionVue=new EtatConnexionVue(this);
44
 
47
		listeObservationsVue=new ListeObservationsVue(this);
45
		etatConnexionVue = new EtatConnexionVue(this);
48
		
46
		listeObservationsVue = new ListeObservationsVue(this);
49
		VerticalPanel panel=new VerticalPanel();
47
 
50
		
48
		VerticalPanel panel = new VerticalPanel();
Line 51... Line -...
51
		panel.add(etatConnexionVue);
-
 
52
	
49
 
Line 53... Line 50...
53
		panel.add(listeObservationsVue);
50
		panel.add(etatConnexionVue);
54
	
51
 
55
 
52
		panel.add(listeObservationsVue);
56
		RootPanel.get().add(panel);
53
 
57
		
54
		RootPanel.get().add(panel);
58
		onInitialisation();
55
 
59
		
56
		onInitialisation();
60
	}
-
 
61
 
57
 
62
	
58
	}
63
	/// Methodes privees 
59
 
64
 
60
	// / Methodes privees
65
	/**
-
 
66
	 * 
61
 
67
	 * Initialisations
62
	/**
68
	 * 
63
	 * 
69
	 */
64
	 * Initialisations
70
	
65
	 * 
71
	private void onInitialisation() {
66
	 */
-
 
67
 
72
	
68
	private void onInitialisation() {
73
	
69
 
74
		afficheEtatConnexion();
70
		afficheEtatConnexion();
-
 
71
		onFiltrageListeObservation("all", "all", "all");
Line 75... Line 72...
75
		onFiltrageListeObservation("all","all","all");
72
 
76
		
73
	}
77
	
74
 
78
	}
75
	// Filtre selection lieu
79
	
76
 
Line 80... Line 77...
80
	// Filtre  selection lieu
77
	/**
81
	
78
	 * Action sur selection d'un lieu : affichage de la liste des taxons
Line 82... Line -...
82
	/**
-
 
83
	 * Action sur selection d'un lieu : affichage de la liste des taxons correspondants au filtrage
79
	 * correspondants au filtrage
84
	 */
-
 
85
	
-
 
Line -... Line 80...
-
 
80
	 */
Line 86... Line -...
86
	public void onFiltrageListeObservation(String id_loc, String loc,String lieu) {
-
 
87
 
-
 
88
		// Positionnement Filtre affichage
-
 
89
		listeObservationsVue.setIdLocation(id_loc);
-
 
90
		listeObservationsVue.setLocalite(loc);
81
 
91
		listeObservationsVue.setLieudit(lieu);
82
	public void onFiltrageListeObservation(String id_loc, String loc,
92
		listeObservationsVue.initialiser();
83
			String lieu) {
93
 
-
 
94
		// Affichage des filtres
84
 
95
		listeObservationsVue.displayFilter();
85
		// Positionnement Filtre affichage
96
 
86
		listeObservationsVue.setIdLocation(id_loc);
97
		
87
		listeObservationsVue.setLocalite(loc);
98
	}
-
 
99
	
88
		listeObservationsVue.setLieudit(lieu);
100
 
89
		listeObservationsVue.initialiser();
-
 
90
 
-
 
91
		// Affichage des filtres
101
 
92
		listeObservationsVue.displayFilter();
102
 
93
 
103
	
94
	}
Line 104... Line -...
104
	/// UTILISATEUR
-
 
105
 
95
 
106
	
96
	// / UTILISATEUR
107
	/**
97
 
108
	 *  Affichage etat de la connexion
98
	/**
109
	 */
99
	 * Affichage etat de la connexion
110
	
100
	 */
111
	
101
 
112
	private void afficheEtatConnexion() {
102
	private void afficheEtatConnexion() {
113
		 if (!carnetEnLigneMediateur.getUtilisateur().isIdentifie()) {
103
		if (!carnetEnLigneMediateur.getUtilisateur().isIdentifie()) {
114
			    etatConnexionVue.setEtat(texteDeconnexion,false);
104
			etatConnexionVue.setEtat(texteDeconnexion, false);
115
		 }
105
		} else {
116
		 else {
106
			etatConnexionVue.setEtat(carnetEnLigneMediateur.getUtilisateur()
117
		    etatConnexionVue.setEtat(carnetEnLigneMediateur.getUtilisateur().getIdentifiant()+ " (deconnexion)",true);
107
					.getIdentifiant()
118
		 }
108
					+ " (deconnexion)", true);
119
		
109
		}
120
	}
110
 
121
 
111
	}
122
	
112
 
Line 123... Line -...
123
	/**
-
 
124
	 * 
113
	/**
125
	 * Affichage boite de connexion
114
	 * 
126
	 *
115
	 * Affichage boite de connexion
127
	 */
116
	 * 
128
	
117
	 */
129
	public void afficherDialogueConnexion() {
118
 
130
		
119
	public void afficherDialogueConnexion() {
131
		  // TODO : singleton ? 
120
 
132
		  formulaireDeConnexionVue = new FormulaireDeConnexionVue(this);
-
 
133
 
-
 
Line -... Line 121...
-
 
121
		// TODO : singleton ?
Line 134... Line 122...
134
		  // Position it roughly in the middle of the screen.
122
		formulaireDeConnexionVue = new FormulaireDeConnexionVue(this);
135
		  int left = (Window.getClientWidth() - 512) / 2;
123
 
-
 
124
		// Position it roughly in the middle of the screen.
136
		  int top = (Window.getClientHeight() - 256) / 2;
125
		int left = (Window.getClientWidth() - 512) / 2;
137
		  formulaireDeConnexionVue.setPopupPosition(left, top);
126
		int top = (Window.getClientHeight() - 256) / 2;
138
		  formulaireDeConnexionVue.show();
127
		formulaireDeConnexionVue.setPopupPosition(left, top);
139
		
-
 
140
	}
128
		formulaireDeConnexionVue.show();
141
 
129
 
142
	
130
	}
143
	/**
131
 
144
	 * Deconnexion de l'utilisateur en cours 
132
	/**
Line 145... Line 133...
145
	 */
133
	 * Deconnexion de l'utilisateur en cours
146
	
-
 
Line -... Line 134...
-
 
134
	 */
Line 147... Line -...
147
	public void deconnecterUtilisateur() {
-
 
148
		
-
 
149
	//	carnetEnLigneMediateur.addListener(CarnetEnLigneMediateur.DECONNEXION,this);
135
 
150
		carnetEnLigneMediateur.deconnecterUtilisateur();
136
	public void deconnecterUtilisateur() {
-
 
137
 
151
	
138
		// carnetEnLigneMediateur.addListener(CarnetEnLigneMediateur.DECONNEXION,this);
152
	}
139
		carnetEnLigneMediateur.deconnecterUtilisateur();
153
 
-
 
154
 
-
 
155
	/**
-
 
156
	 * Tentative de connexion utilisateur
-
 
157
	 * @param login
-
 
158
	 * @param password
-
 
159
	 */
-
 
160
	
-
 
161
	
-
 
162
	public void connecterUtilisateur(String login, String password) {
-
 
163
		
-
 
164
	//	carnetEnLigneMediateur.addListener(CarnetEnLigneMediateur.CONNEXION,this);
-
 
165
		carnetEnLigneMediateur.connecterUtilisateur(login, password);
-
 
166
 
-
 
167
	}
-
 
168
 
-
 
169
 
-
 
170
 
-
 
171
	/// OBSERVATION
-
 
172
	
-
 
Line -... Line 140...
-
 
140
 
173
	/**
141
	}
-
 
142
 
174
	 * Recherche nombre d'enregistrement pour l'utilisateur et la localite en cours
143
	/**
175
	 * 
-
 
176
	 */
144
	 * Tentative de connexion utilisateur
177
	
-
 
178
	
145
	 * 
179
	public void getNombreObservation (String identifiantLocalite, String localite, String annee,  String mois,  String jour, String lieudit, String rechercheLibre ) {
146
	 * @param login
180
		
147
	 * @param password
181
 
148
	 */
182
		observationModele.getNombreObservation(
-
 
183
				new iRetourObservation() {
149
 
184
					public void onRetour(Observation obs) {
150
	public void connecterUtilisateur(String login, String password) {
185
						observation=obs;
-
 
-
 
151
 
186
						//fireEvent(NOMBRE_OBSERVATION); 
152
		// carnetEnLigneMediateur.addListener(CarnetEnLigneMediateur.CONNEXION,this);
187
					}
-
 
188
 
-
 
Line -... Line 153...
-
 
153
		carnetEnLigneMediateur.connecterUtilisateur(login, password);
Line 189... Line -...
189
					
-
 
190
				}, carnetEnLigneMediateur.getUtilisateur().getIdentifiant(), identifiantLocalite, localite , annee, mois, jour, lieudit ,rechercheLibre
-
 
191
				
-
 
192
		);
154
 
Line -... Line 155...
-
 
155
	}
-
 
156
 
-
 
157
	// / OBSERVATION
-
 
158
 
-
 
159
	/**
-
 
160
	 * Recherche nombre d'enregistrement pour l'utilisateur et la localite en
-
 
161
	 * cours
-
 
162
	 * 
-
 
163
	 */
-
 
164
 
-
 
165
	public void getNombreObservation(String identifiantLocalite,
-
 
166
			String localite, String annee, String mois, String jour,
-
 
167
			String lieudit, String rechercheLibre) {
Line 193... Line 168...
193
		
168
 
Line 194... Line -...
194
		
-
 
195
		  
-
 
196
	}
-
 
197
 
-
 
198
	 public void getListeObservation (String identifiantLocalite, String localite, String annee, String mois, String jour, String lieudit, String rechercheLibre, int debut, int longueur) {
-
 
199
 
-
 
200
			
-
 
201
			observationModele.getListeObservation(
-
 
202
					new iRetourObservation() {
-
 
203
						public void onRetour(Observation obs) {
-
 
204
							observation=obs;
-
 
205
							//fireEvent(LISTE_OBSERVATION); 
-
 
206
						}
-
 
207
 
-
 
208
						
-
 
209
					}, carnetEnLigneMediateur.getUtilisateur().getIdentifiant(), identifiantLocalite, localite , annee, mois, jour, lieudit ,rechercheLibre, debut, longueur
-
 
210
					
-
 
211
			);
-
 
212
 
-
 
213
	}
-
 
214
 
-
 
215
 
-
 
216
			
169
		observationModele.getNombreObservation(new iRetourObservation() {
Line -... Line 170...
-
 
170
			public void onRetour(Observation obs) {
-
 
171
				observation = obs;
217
	 public Observation getObservation() {
172
				// fireEvent(NOMBRE_OBSERVATION);
218
			return observation;
-
 
219
	}
-
 
220
 
-
 
Line -... Line 173...
-
 
173
			}
Line -... Line 174...
-
 
174
 
-
 
175
		}, carnetEnLigneMediateur.getUtilisateur().getIdentifiant(),
-
 
176
				identifiantLocalite, localite, annee, mois, jour, lieudit,
-
 
177
				rechercheLibre
221
 
178
 
-
 
179
		);
-
 
180
 
-
 
181
	}
-
 
182
 
-
 
183
	public void getListeObservation(String identifiantLocalite,
-
 
184
			String localite, String annee, String mois, String jour,
-
 
185
			String lieudit, String rechercheLibre, int debut, int longueur) {
-
 
186
 
-
 
187
		observationModele.getListeObservation(new iRetourObservation() {
Line 222... Line 188...
222
	
188
			public void onRetour(Observation obs) {