Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 65 Rev 66
Line 7... Line 7...
7
 * 
7
 * 
8
 * http://extjs.com/license
8
 * http://extjs.com/license
9
 */
9
 */
10
import org.tela_botanica.client.Mediateur;
10
import org.tela_botanica.client.Mediateur;
11
import org.tela_botanica.client.RegistreId;
11
import org.tela_botanica.client.RegistreId;
12
import org.tela_botanica.client.modeles.Utilisateur;
-
 
Line 13... Line 12...
13
 
12
 
14
import com.extjs.gxt.ui.client.Registry;
13
import com.extjs.gxt.ui.client.Registry;
15
import com.extjs.gxt.ui.client.event.ButtonEvent;
14
import com.extjs.gxt.ui.client.event.ButtonEvent;
16
import com.extjs.gxt.ui.client.event.ComponentEvent;
15
import com.extjs.gxt.ui.client.event.ComponentEvent;
17
import com.extjs.gxt.ui.client.event.KeyListener;
16
import com.extjs.gxt.ui.client.event.KeyListener;
18
import com.extjs.gxt.ui.client.event.SelectionListener;
-
 
19
import com.extjs.gxt.ui.client.fx.FxConfig;
17
import com.extjs.gxt.ui.client.event.SelectionListener;
20
import com.extjs.gxt.ui.client.widget.Dialog;
18
import com.extjs.gxt.ui.client.widget.Dialog;
21
import com.extjs.gxt.ui.client.widget.button.Button;
19
import com.extjs.gxt.ui.client.widget.button.Button;
22
import com.extjs.gxt.ui.client.widget.button.StatusButtonBar;
20
import com.extjs.gxt.ui.client.widget.button.StatusButtonBar;
23
import com.extjs.gxt.ui.client.widget.form.TextField;
21
import com.extjs.gxt.ui.client.widget.form.TextField;
24
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
22
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
Line 25... Line 23...
25
import com.google.gwt.user.client.Timer;
23
import com.google.gwt.user.client.Timer;
Line 26... Line 24...
26
 
24
 
27
public class IdentificationFenetre extends Dialog {
25
public class IdentificationFenetre extends Dialog {
28
 
26
 
29
	protected StatusButtonBar buttonBar;
27
	protected StatusButtonBar barreDeBoutons;
30
	protected TextField<String> userName;
28
	protected TextField<String> login;
Line 31... Line 29...
31
	protected TextField<String> password;
29
	protected TextField<String> motDePasse;
32
	protected Button reset;
30
	protected Button reinitialiserBouton;
33
	protected Button login;
31
	protected Button validerBouton;
34
 
32
 
Line 53... Line 51...
53
				validate();
51
				validate();
54
			}
52
			}
Line 55... Line 53...
55
 
53
 
Line 56... Line 54...
56
		};
54
		};
57
 
55
 
58
		userName = new TextField<String>();
56
		login = new TextField<String>();
59
		userName.setMinLength(4);
57
		login.setMinLength(4);
60
		userName.setFieldLabel("Courriel");
58
		login.setFieldLabel("Courriel");
61
		userName.addKeyListener(keyListener);
59
		login.addKeyListener(keyListener);
62
		add(userName);
60
		add(login);
63
 
61
 
64
		password = new TextField<String>();
62
		motDePasse = new TextField<String>();
65
		password.setMinLength(4);
63
		motDePasse.setMinLength(4);
66
		password.setPassword(true);
64
		motDePasse.setPassword(true);
67
		password.setFieldLabel("Mot de passe");
65
		motDePasse.setFieldLabel("Mot de passe");
Line 68... Line 66...
68
		password.addKeyListener(keyListener);
66
		motDePasse.addKeyListener(keyListener);
Line 69... Line 67...
69
		add(password);
67
		add(motDePasse);
70
 
68
 
Line 71... Line 69...
71
		setFocusWidget(userName);
69
		setFocusWidget(login);
Line 72... Line 70...
72
 
70
 
73
		buttonBar = new StatusButtonBar();
71
		barreDeBoutons = new StatusButtonBar();
74
		setButtonBar(buttonBar);
72
		setButtonBar(barreDeBoutons);
75
		
73
		
76
	}
74
	}
77
 
75
 
78
	@Override
76
	@Override
79
	protected void createButtons() {
77
	protected void createButtons() {
80
		reset = new Button("Réinitialiser");
78
		reinitialiserBouton = new Button("Réinitialiser");
81
		reset.addSelectionListener(new SelectionListener<ButtonEvent>() {
79
		reinitialiserBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
Line 82... Line 80...
82
			public void componentSelected(ButtonEvent ce) {
80
			public void componentSelected(ButtonEvent ce) {
Line 83... Line 81...
83
				userName.reset();
81
				login.reset();
84
				password.reset();
82
				motDePasse.reset();
85
				validate();
83
				validate();
86
				userName.focus();
84
				login.focus();
87
			}
85
			}
88
 
86
 
89
		});
87
		});
Line 90... Line 88...
90
 
88
 
91
		login = new Button("Valider");
89
		validerBouton = new Button("Valider");
92
		//login.disable(); // Par défaut : dois être en mode disable
90
		//login.disable(); // Par défaut : dois être en mode disable
Line 93... Line 91...
93
		login.addSelectionListener(new SelectionListener<ButtonEvent>() {
91
		validerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
94
			public void componentSelected(ButtonEvent ce) {
92
			public void componentSelected(ButtonEvent ce) {
95
				onSubmit();
93
				onSubmit();
96
			}
94
			}
Line 97... Line 95...
97
		});
95
		});
98
 
96
 
99
		buttonBar.add(reset);
97
		barreDeBoutons.add(reinitialiserBouton);
100
		buttonBar.add(login);
98
		barreDeBoutons.add(validerBouton);
101
	}
99
	}
Line 102... Line 100...
102
 
100
 
103
	protected void onSubmit() {
101
	protected void onSubmit() {
104
		buttonBar.getStatusBar().showBusy("Chargement en cours ...");
102
		barreDeBoutons.getStatusBar().showBusy("Chargement en cours ...");
Line 118... Line 116...
118
	protected boolean hasValue(TextField<String> field) {
116
	protected boolean hasValue(TextField<String> field) {
119
		return field.getValue() != null && field.getValue().length() > 0;
117
		return field.getValue() != null && field.getValue().length() > 0;
120
	}
118
	}
Line 121... Line 119...
121
 
119
 
122
	protected void validate() {
120
	protected void validate() {
123
		login.setEnabled(hasValue(userName) && hasValue(password) && password.getValue().length() > 3);
121
		validerBouton.setEnabled(hasValue(login) && hasValue(motDePasse) && motDePasse.getValue().length() > 3);
Line 124... Line 122...
124
	}
122
	}