| 12 | david | 1 | /**
 | 
        
           |  |  | 2 |  David Delon david.delon@clapas.net 2007
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 |   | 
        
           |  |  | 5 |  */
 | 
        
           |  |  | 6 |   | 
        
           |  |  | 7 | /*
 | 
        
           |  |  | 8 |  * LoginDialog.java  (DialogBox)
 | 
        
           |  |  | 9 |  *
 | 
        
           |  |  | 10 |  * Cas d'utilisation :
 | 
        
           |  |  | 11 |  * Dialogue de validation de l'identification utilisateur
 | 
        
           |  |  | 12 |  *
 | 
        
           |  |  | 13 |  * 1 : L'utilisateur saisit son identifiant (e-mail) et son mot de passe
 | 
        
           |  |  | 14 |  * 2 : Le dialogue controle aupres du systeme distant la validite des informations saisies
 | 
        
           |  |  | 15 |  * 3 : Le dialogue transmet au systeme local les informations d'identification
 | 
        
           |  |  | 16 |  * 		3a : Le dialogue informe l'utilisateur que les elements d'identification ne sont pas valide : retour au point 1, ou passe au point 4.
 | 
        
           |  |  | 17 |  * 4 : Cloture du dialogue
 | 
        
           |  |  | 18 |  * 5 : Appel du dialogue d'importation
 | 
        
           |  |  | 19 |  */
 | 
        
           |  |  | 20 |   | 
        
           |  |  | 21 | package org.tela_botanica.client.vues;
 | 
        
           |  |  | 22 |   | 
        
           |  |  | 23 | // TODO : controle de forme sur saisie (regex integree) ...
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 | import org.tela_botanica.client.CarnetEnLigneMediateur;
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 | import com.google.gwt.user.client.ui.DialogBox;
 | 
        
           |  |  | 28 | import com.google.gwt.user.client.ui.KeyboardListener;
 | 
        
           | 173 | aurelien | 29 | import com.google.gwt.user.client.ui.Label;
 | 
        
           | 12 | david | 30 | import com.gwtext.client.core.EventObject;
 | 
        
           |  |  | 31 | import com.gwtext.client.core.Position;
 | 
        
           |  |  | 32 | import com.gwtext.client.widgets.Button;
 | 
        
           |  |  | 33 | import com.gwtext.client.widgets.Panel;
 | 
        
           |  |  | 34 | import com.gwtext.client.widgets.event.ButtonListenerAdapter;
 | 
        
           |  |  | 35 | import com.gwtext.client.widgets.event.KeyListener;
 | 
        
           |  |  | 36 | import com.gwtext.client.widgets.form.FormPanel;
 | 
        
           |  |  | 37 | import com.gwtext.client.widgets.form.TextField;
 | 
        
           |  |  | 38 |   | 
        
           |  |  | 39 | public class FormulaireDeConnexionVue extends DialogBox  {
 | 
        
           |  |  | 40 |   | 
        
           |  |  | 41 |   | 
        
           |  |  | 42 | 	/**
 | 
        
           |  |  | 43 | 	 * Médiateur associé à la vue
 | 
        
           |  |  | 44 | 	 */
 | 
        
           |  |  | 45 |   | 
        
           |  |  | 46 | 	private CarnetEnLigneMediateur carnetEnLigneMediateur = null ;
 | 
        
           |  |  | 47 |   | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 | 	/**
 | 
        
           |  |  | 50 | 	 * email saisi
 | 
        
           |  |  | 51 | 	 */
 | 
        
           |  |  | 52 |   | 
        
           | 42 | jpm | 53 | 	private TextField ident=null;
 | 
        
           | 12 | david | 54 |   | 
        
           |  |  | 55 | 	/**
 | 
        
           |  |  | 56 | 	 * mot de passe saisi
 | 
        
           |  |  | 57 | 	 */
 | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 | 	private TextField motDePasse=null;
 | 
        
           |  |  | 60 |   | 
        
           | 173 | aurelien | 61 | 	private Label saisieInvalide = null ;
 | 
        
           |  |  | 62 |   | 
        
           | 12 | david | 63 |   | 
        
           |  |  | 64 |   | 
        
           |  |  | 65 |   public FormulaireDeConnexionVue(CarnetEnLigneMediateur cm) {
 | 
        
           |  |  | 66 |   | 
        
           |  |  | 67 |   | 
        
           |  |  | 68 | 	carnetEnLigneMediateur=cm;
 | 
        
           |  |  | 69 |   | 
        
           |  |  | 70 |   | 
        
           |  |  | 71 |   | 
        
           |  |  | 72 |     Panel panneauPrincipalDialogue=new Panel();
 | 
        
           |  |  | 73 |   | 
        
           |  |  | 74 |     FormPanel panneauFormulaire = new FormPanel(Position.RIGHT);
 | 
        
           |  |  | 75 |   | 
        
           |  |  | 76 |   | 
        
           |  |  | 77 |     panneauFormulaire.setTitle("Connexion");
 | 
        
           |  |  | 78 |   | 
        
           |  |  | 79 |     panneauFormulaire.setWidth(350);
 | 
        
           |  |  | 80 |     panneauFormulaire.setLabelWidth(100);
 | 
        
           |  |  | 81 |   | 
        
           |  |  | 82 |   | 
        
           |  |  | 83 |   | 
        
           |  |  | 84 | /*
 | 
        
           |  |  | 85 |  *  E-Mail : Zone_saisie_email
 | 
        
           |  |  | 86 |  *  Mot-de-passe : Zone_saisie_mot_de_passe
 | 
        
           |  |  | 87 |  *  Message d'information
 | 
        
           |  |  | 88 |  *  Bouton_Ok   Bouton_Annuler
 | 
        
           |  |  | 89 |  */
 | 
        
           |  |  | 90 |   | 
        
           |  |  | 91 |     /**
 | 
        
           |  |  | 92 |      * On ajoute les differents elements du formulaire
 | 
        
           |  |  | 93 |      */
 | 
        
           |  |  | 94 |   | 
        
           |  |  | 95 |     // Email
 | 
        
           |  |  | 96 |   | 
        
           | 231 | david | 97 |     ident = new TextField("Mail", "ident", 200);
 | 
        
           | 42 | jpm | 98 |     ident.setAllowBlank(false);
 | 
        
           | 231 | david | 99 |     ident.setInvalidText("Mail vide ou incorrect");
 | 
        
           | 173 | aurelien | 100 |     ident.setTabIndex(800);
 | 
        
           | 42 | jpm | 101 |     panneauFormulaire.add(ident);
 | 
        
           | 12 | david | 102 |   | 
        
           |  |  | 103 |     // Mot de passe
 | 
        
           |  |  | 104 |   | 
        
           |  |  | 105 |     motDePasse = new TextField("Mot de passe", "motDePasse", 200);
 | 
        
           | 173 | aurelien | 106 |     motDePasse.setAllowBlank(false);
 | 
        
           |  |  | 107 |     ident.setInvalidText("Mot de passe vide ou incorrect");
 | 
        
           | 12 | david | 108 |     motDePasse.setPassword(true);
 | 
        
           | 173 | aurelien | 109 |     motDePasse.setTabIndex(801);
 | 
        
           | 12 | david | 110 |   | 
        
           |  |  | 111 |     panneauFormulaire.add(motDePasse);
 | 
        
           |  |  | 112 |   | 
        
           |  |  | 113 |   | 
        
           |  |  | 114 |   | 
        
           |  |  | 115 |     Button boutonOK = new Button("Ok");
 | 
        
           | 173 | aurelien | 116 |     boutonOK.setTabIndex(802);
 | 
        
           | 12 | david | 117 |     panneauFormulaire.addButton(boutonOK);
 | 
        
           |  |  | 118 |   | 
        
           | 173 | aurelien | 119 |     Button boutonAnnuler = new Button("Annuler");
 | 
        
           |  |  | 120 |     boutonAnnuler.setTabIndex(803);
 | 
        
           | 12 | david | 121 |     panneauFormulaire.addButton(boutonAnnuler);
 | 
        
           |  |  | 122 |   | 
        
           |  |  | 123 |   | 
        
           |  |  | 124 |     // Click sur bouton de validation
 | 
        
           |  |  | 125 |   | 
        
           |  |  | 126 |     boutonOK.addListener(
 | 
        
           |  |  | 127 |   | 
        
           |  |  | 128 |     new ButtonListenerAdapter() {
 | 
        
           |  |  | 129 |   | 
        
           |  |  | 130 |     	public void onClick(Button button, EventObject e) {
 | 
        
           | 42 | jpm | 131 |     		carnetEnLigneMediateur.connecterUtilisateur(ident.getText(),motDePasse.getText());
 | 
        
           | 12 | david | 132 |   | 
        
           |  |  | 133 |     	}
 | 
        
           |  |  | 134 |   | 
        
           |  |  | 135 |     }
 | 
        
           |  |  | 136 |   | 
        
           |  |  | 137 |     );
 | 
        
           |  |  | 138 |   | 
        
           |  |  | 139 |   | 
        
           |  |  | 140 |     // Click sur  bouton d'annulation
 | 
        
           |  |  | 141 |   | 
        
           |  |  | 142 |   | 
        
           |  |  | 143 |     boutonAnnuler.addListener(
 | 
        
           |  |  | 144 |   | 
        
           |  |  | 145 |     new ButtonListenerAdapter() {
 | 
        
           |  |  | 146 |   | 
        
           |  |  | 147 |     	public void onClick(Button button, EventObject e) {
 | 
        
           | 173 | aurelien | 148 | 	        cacher();
 | 
        
           | 12 | david | 149 |     	}
 | 
        
           |  |  | 150 |   | 
        
           |  |  | 151 |     }
 | 
        
           |  |  | 152 |   | 
        
           |  |  | 153 |     );
 | 
        
           |  |  | 154 |   | 
        
           |  |  | 155 |   | 
        
           |  |  | 156 |  /**
 | 
        
           |  |  | 157 |   * Validation directe depuis un champ de saisie
 | 
        
           |  |  | 158 |   *
 | 
        
           |  |  | 159 |   */
 | 
        
           |  |  | 160 |   | 
        
           |  |  | 161 |     // Email
 | 
        
           |  |  | 162 |   | 
        
           |  |  | 163 | 	// gestion de la touche entrée
 | 
        
           | 42 | jpm | 164 |     ident.addKeyListener(EventObject.ENTER, new KeyListener() {
 | 
        
           | 12 | david | 165 |   | 
        
           |  |  | 166 | 		public void onKey(int key, EventObject e) {
 | 
        
           | 42 | jpm | 167 | 			carnetEnLigneMediateur.connecterUtilisateur(ident.getText(),motDePasse.getText());
 | 
        
           | 12 | david | 168 |   | 
        
           |  |  | 169 | 		}
 | 
        
           |  |  | 170 |     });
 | 
        
           |  |  | 171 |   | 
        
           |  |  | 172 |     // Mot de passe
 | 
        
           |  |  | 173 |   | 
        
           |  |  | 174 |     motDePasse.addKeyListener(EventObject.ENTER, new KeyListener() {
 | 
        
           |  |  | 175 |   | 
        
           |  |  | 176 | 		public void onKey(int key, EventObject e) {
 | 
        
           | 42 | jpm | 177 | 			carnetEnLigneMediateur.connecterUtilisateur(ident.getText(),motDePasse.getText());
 | 
        
           | 12 | david | 178 |   | 
        
           |  |  | 179 | 		}
 | 
        
           | 38 | jpm | 180 |     });
 | 
        
           | 12 | david | 181 |   | 
        
           | 173 | aurelien | 182 |   | 
        
           |  |  | 183 |   	saisieInvalide = new Label("");
 | 
        
           |  |  | 184 |   	saisieInvalide.setStyleName("saisie_invalide_invisible");
 | 
        
           |  |  | 185 |   	panneauFormulaire.add(saisieInvalide);
 | 
        
           | 12 | david | 186 |   | 
        
           |  |  | 187 |   	 panneauPrincipalDialogue.add(panneauFormulaire);
 | 
        
           |  |  | 188 |   | 
        
           |  |  | 189 |      setWidget(panneauPrincipalDialogue);
 | 
        
           |  |  | 190 |   | 
        
           |  |  | 191 |   | 
        
           |  |  | 192 |   }
 | 
        
           |  |  | 193 |   | 
        
           |  |  | 194 |   | 
        
           |  |  | 195 |   /*
 | 
        
           |  |  | 196 |    * On sort sur touche echappement
 | 
        
           |  |  | 197 |    */
 | 
        
           |  |  | 198 |   | 
        
           |  |  | 199 |   public boolean onKeyDownPreview(char key, int modifiers) {
 | 
        
           |  |  | 200 | 	    switch (key) {
 | 
        
           |  |  | 201 | 	      case KeyboardListener.KEY_ESCAPE:
 | 
        
           |  |  | 202 | 	        hide();
 | 
        
           |  |  | 203 | 	        break;
 | 
        
           |  |  | 204 | 	    }
 | 
        
           |  |  | 205 |   | 
        
           |  |  | 206 | 	    return true;
 | 
        
           |  |  | 207 |   }
 | 
        
           |  |  | 208 |   | 
        
           |  |  | 209 |   public void afficherMessageAlerte() {
 | 
        
           |  |  | 210 |   | 
        
           | 173 | aurelien | 211 | 	  saisieInvalide.setText("Identifiant ou mot de passe invalide");
 | 
        
           |  |  | 212 | 	  saisieInvalide.setStyleName("saisie_invalide");
 | 
        
           | 12 | david | 213 |   }
 | 
        
           | 173 | aurelien | 214 |   | 
        
           |  |  | 215 |   | 
        
           | 652 | aurelien | 216 | 	public void cacher() {
 | 
        
           |  |  | 217 | 		saisieInvalide.setText("");
 | 
        
           |  |  | 218 | 		saisieInvalide.setStyleName("saisie_invalide_invisible");
 | 
        
           |  |  | 219 | 		hide();
 | 
        
           |  |  | 220 |   | 
        
           |  |  | 221 | 	}
 | 
        
           | 12 | david | 222 |   | 
        
           |  |  | 223 |   | 
        
           |  |  | 224 | }
 | 
        
           |  |  | 225 |   | 
        
           |  |  | 226 | /* +--Fin du code ---------------------------------------------------------------------------------------+
 | 
        
           |  |  | 227 | * $Log$
 | 
        
           |  |  | 228 | * Revision 1.1  2008-11-13 11:27:05  ddelon
 | 
        
           |  |  | 229 | * Reecriture gwt-ext
 | 
        
           |  |  | 230 | *
 | 
        
           |  |  | 231 | * Revision 1.1  2008-06-09 14:19:37  ddelon
 | 
        
           |  |  | 232 | * Initialisation observation
 | 
        
           |  |  | 233 | *
 | 
        
           |  |  | 234 | * Revision 1.10  2007-09-17 19:25:34  ddelon
 | 
        
           |  |  | 235 | * Documentation
 | 
        
           |  |  | 236 | *
 | 
        
           |  |  | 237 | * Revision 1.9  2007-05-21 21:03:44  ddelon
 | 
        
           |  |  | 238 | * nettoyage de code
 | 
        
           |  |  | 239 | *
 | 
        
           |  |  | 240 | * Revision 1.8  2007-05-21 18:14:06  ddelon
 | 
        
           |  |  | 241 | * Gestion importation releve locaux
 | 
        
           |  |  | 242 | *
 | 
        
           |  |  | 243 | * Revision 1.7  2007-05-21 11:47:30  ddelon
 | 
        
           |  |  | 244 | * meta cvs
 | 
        
           |  |  | 245 | *
 | 
        
           |  |  | 246 | * Revision 1.6  2007-05-21 11:39:48  ddelon
 | 
        
           |  |  | 247 | * meta cvs
 | 
        
           |  |  | 248 | *
 | 
        
           |  |  | 249 | * Revision 1.5  2007-05-21 11:39:12  ddelon
 | 
        
           |  |  | 250 | * meta cvs
 | 
        
           |  |  | 251 | *
 | 
        
           |  |  | 252 | * Revision 1.4  2007-05-21 11:37:35  ddelon
 | 
        
           |  |  | 253 | * meta cvs
 | 
        
           |  |  | 254 | *
 | 
        
           |  |  | 255 | * Revision 1.3  2007-05-21 11:36:51  ddelon
 | 
        
           |  |  | 256 | * meta cvs
 | 
        
           |  |  | 257 | *
 | 
        
           |  |  | 258 | */
 |