Subversion Repositories eFlore/Applications.coel

Compare Revisions

Ignore whitespace Rev 65 → Rev 66

/trunk/src/org/tela_botanica/client/composants/IdentificationFenetre.java
9,7 → 9,6
*/
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.modeles.Utilisateur;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.ButtonEvent;
16,7 → 15,6
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.KeyListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.fx.FxConfig;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.button.StatusButtonBar;
26,11 → 24,11
 
public class IdentificationFenetre extends Dialog {
 
protected StatusButtonBar buttonBar;
protected TextField<String> userName;
protected TextField<String> password;
protected Button reset;
protected Button login;
protected StatusButtonBar barreDeBoutons;
protected TextField<String> login;
protected TextField<String> motDePasse;
protected Button reinitialiserBouton;
protected Button validerBouton;
 
public IdentificationFenetre() {
FormLayout layout = new FormLayout();
55,60 → 53,60
 
};
 
userName = new TextField<String>();
userName.setMinLength(4);
userName.setFieldLabel("Courriel");
userName.addKeyListener(keyListener);
add(userName);
login = new TextField<String>();
login.setMinLength(4);
login.setFieldLabel("Courriel");
login.addKeyListener(keyListener);
add(login);
 
password = new TextField<String>();
password.setMinLength(4);
password.setPassword(true);
password.setFieldLabel("Mot de passe");
password.addKeyListener(keyListener);
add(password);
motDePasse = new TextField<String>();
motDePasse.setMinLength(4);
motDePasse.setPassword(true);
motDePasse.setFieldLabel("Mot de passe");
motDePasse.addKeyListener(keyListener);
add(motDePasse);
 
setFocusWidget(userName);
setFocusWidget(login);
 
buttonBar = new StatusButtonBar();
setButtonBar(buttonBar);
barreDeBoutons = new StatusButtonBar();
setButtonBar(barreDeBoutons);
}
 
@Override
protected void createButtons() {
reset = new Button("Réinitialiser");
reset.addSelectionListener(new SelectionListener<ButtonEvent>() {
reinitialiserBouton = new Button("Réinitialiser");
reinitialiserBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
userName.reset();
password.reset();
login.reset();
motDePasse.reset();
validate();
userName.focus();
login.focus();
}
 
});
 
login = new Button("Valider");
validerBouton = new Button("Valider");
//login.disable(); // Par défaut : dois être en mode disable
login.addSelectionListener(new SelectionListener<ButtonEvent>() {
validerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
onSubmit();
}
});
 
buttonBar.add(reset);
buttonBar.add(login);
barreDeBoutons.add(reinitialiserBouton);
barreDeBoutons.add(validerBouton);
}
 
protected void onSubmit() {
buttonBar.getStatusBar().showBusy("Chargement en cours ...");
buttonBar.disable();
barreDeBoutons.getStatusBar().showBusy("Chargement en cours ...");
barreDeBoutons.disable();
Timer t = new Timer() {
 
@Override
public void run() {
IdentificationFenetre.this.hide();
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).connecterUtilisateur(userName.getValue(), password.getValue());
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).connecterUtilisateur(login.getValue(), motDePasse.getValue());
}
 
};
120,7 → 118,7
}
 
protected void validate() {
login.setEnabled(hasValue(userName) && hasValue(password) && password.getValue().length() > 3);
validerBouton.setEnabled(hasValue(login) && hasValue(motDePasse) && motDePasse.getValue().length() > 3);
}
}