package View;
import Controller.OthelloController;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.F2F93D42-E75A-0AA9-0CD3-0D97CE84D638]
// </editor-fold>
public class LoginView extends ViewAbstract implements CommandListener {
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.6505D275-0673-8355-F778-64032B90064B]
// </editor-fold>
private static final Command CANCEL = new Command("Annuler", Command.BACK, 1);
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.D33B3760-A613-E679-8B5B-86E855D1D5DD]
// </editor-fold>
private static final Command VALID = new Command("Valider", Command.SCREEN, 1);
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.664EEB0F-620A-5E1D-E2B0-54EF730317E5]
// </editor-fold>
private String _logText = "Inscription auprès du serveur...";
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.7E3F356B-0008-55A0-D430-C93DB80DF830]
// </editor-fold>
private Alert _logScreen = new Alert("inscription");
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.527D0E4B-A92B-2F16-6FE4-704FB7AB5636]
// </editor-fold>
private TextField _fieldLogin;
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.AA3FB1D3-45AF-21A6-D557-5FD98257D5E8]
// </editor-fold>
private TextField _fieldPass;
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.CD37B848-5A93-F505-1090-D6C1B09D8791]
// </editor-fold>
private Form _form;
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.0F96E763-C08A-FEF9-50FE-43BA1BC87382]
// </editor-fold>
public LoginView (Display disp, OthelloController ctrl){
super(disp,ctrl);
this.set_form(new Form("Saisir le login et le mot de passe :"));
this.set_fieldLogin(new TextField("Login", "", 5, TextField.ANY) );
this.set_fieldPass(new TextField("Pass","", 5,TextField.PASSWORD));
this.get_form().addCommand(CANCEL);
this.get_form().addCommand(VALID);
this.get_form().append( _fieldLogin ) ;
this.get_form().append( _fieldPass ) ;
// prepare wait screen
this.get_logScreen().addCommand(CANCEL);
this.get_logScreen().setString(_logText);
this.get_logScreen().setTimeout(Alert.FOREVER);
this.get_logScreen().setCommandListener(this);
this.get_form().setCommandListener(this);
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.F072CAFF-BDA5-08CC-AC76-4D722C8DB3B7]
// </editor-fold>
public void display (){
super.get_display().setCurrent( _form ) ;
System.out.println("LoginView : display");
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.0BC094F9-5950-DD4F-8A00-E97270EBF2F6]
// </editor-fold>
public void commandAction (Command c, Displayable d){
if( c == VALID ) {
//this.get_othelloController().get_othelloClient().log !!!
boolean logOK=true;
if( logOK ){
super.get_child().display();
}else{
this.display() ;
}
} else if( (c == CANCEL) && (d == _logScreen) ) {
this.display() ;
} else {
super.get_parent().display() ;
}
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.F899A829-BC24-73CC-FD76-2677F1F7A1A5]
// </editor-fold>
public TextField get_fieldLogin () {
return _fieldLogin;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.F1654D48-771C-FDEE-ED6A-EAB2C0B800A4]
// </editor-fold>
public void set_fieldLogin (TextField val) {
this._fieldLogin = val;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.6C0E8C70-F226-80B9-4CD5-5968CD57F81F]
// </editor-fold>
public TextField get_fieldPass () {
return _fieldPass;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.BB79B360-A5BB-F3FA-0D05-848AB9B132CC]
// </editor-fold>
public void set_fieldPass (TextField val) {
this._fieldPass = val;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.C88DCE61-849C-5BF0-5461-624C8EE15C6C]
// </editor-fold>
public Form get_form () {
return _form;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.22A47AC1-2513-EFF1-4F4D-550CD2B728F6]
// </editor-fold>
public void set_form (Form val) {
this._form = val;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.041FC87F-E612-E979-23DB-760B53518BB1]
// </editor-fold>
public Alert get_logScreen () {
return _logScreen;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.83250EBA-138C-095C-7E26-C56C24E15DD3]
// </editor-fold>
public void set_logScreen (Alert val) {
this._logScreen = val;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.B675AA13-2068-A897-0528-14B64DB65F35]
// </editor-fold>
public String get_logText () {
return _logText;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.94BB56D7-5ED9-B535-8C27-58F5728FA7D8]
// </editor-fold>
public void set_logText (String val) {
this._logText = val;
}
}