javadoc connexion en cours
This commit is contained in:
parent
df7fb8c542
commit
fca17bbe08
1 changed files with 43 additions and 25 deletions
|
@ -6,11 +6,13 @@ import javax.swing.*;
|
||||||
|
|
||||||
import database.SQLiteManager;
|
import database.SQLiteManager;
|
||||||
import main.Vue;
|
import main.Vue;
|
||||||
|
import messages.MauvaisTypeMessageException;
|
||||||
|
|
||||||
public class VueConnexion extends Vue {
|
public class VueConnexion extends Vue {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
//Elements vue
|
|
||||||
|
//Graphical elements
|
||||||
private JButton boutonValider;
|
private JButton boutonValider;
|
||||||
private JTextField inputUsername;
|
private JTextField inputUsername;
|
||||||
private JPasswordField inputPassword;
|
private JPasswordField inputPassword;
|
||||||
|
@ -20,40 +22,53 @@ public class VueConnexion extends Vue {
|
||||||
private JPanel main;
|
private JPanel main;
|
||||||
private JPanel panelPassword;
|
private JPanel panelPassword;
|
||||||
|
|
||||||
//Controleur
|
//Controller
|
||||||
private ControleurConnexion controle;
|
private ControleurConnexion controle;
|
||||||
|
|
||||||
//penser à enlever le numtest
|
/**
|
||||||
|
* Create and initialize the view SWING window that will be used during the connection phase.
|
||||||
|
* Doing so, it also creates the controller that will monitor all changes during the connection phase.
|
||||||
|
*
|
||||||
|
* @param numtest : to be passed down to the controller
|
||||||
|
*
|
||||||
|
*/
|
||||||
public VueConnexion(int numtest) {
|
public VueConnexion(int numtest) {
|
||||||
super("Connexion");
|
super("Connexion");
|
||||||
controle = new ControleurConnexion(this, numtest);
|
controle = new ControleurConnexion(this, numtest);
|
||||||
|
|
||||||
//Creation fenetre
|
//Window creation
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
this.setSize(400, 300);
|
this.setSize(400, 300);
|
||||||
this.setLocationRelativeTo(null);
|
this.setLocationRelativeTo(null);
|
||||||
|
|
||||||
//Ajout elements
|
//Adding graphical elements
|
||||||
ajouterElements();
|
ajouterElements();
|
||||||
|
|
||||||
//Regle le bouton par défaut
|
//Setting default button
|
||||||
this.getRootPane().setDefaultButton(boutonValider);
|
this.getRootPane().setDefaultButton(boutonValider);
|
||||||
|
|
||||||
this.inputUsername.setText(SQLiteManager.hardcodedNames[numtest]+numtest);
|
this.inputUsername.setText(SQLiteManager.hardcodedNames[numtest]+numtest);
|
||||||
this.inputPassword.setText("aze1$"+SQLiteManager.hardcodedNames[numtest].charAt(0)+numtest);
|
this.inputPassword.setText("aze1$"+SQLiteManager.hardcodedNames[numtest].charAt(0)+numtest);
|
||||||
|
|
||||||
//Affiche la fenetre
|
//Display window
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ----- ADDING ELEMENTS TO AND REMOVING ELEMENTS FROM THE MAIN WINDOW ----- //
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add various graphical elements to the main window : used when initializing the window
|
||||||
|
*/
|
||||||
private void ajouterElements() {
|
private void ajouterElements() {
|
||||||
|
|
||||||
//Creation panel
|
//Create a panel
|
||||||
main = new JPanel(new GridLayout(4,1));
|
main = new JPanel(new GridLayout(4,1));
|
||||||
JPanel panelUsername = new JPanel(new GridLayout(1, 2));
|
JPanel panelUsername = new JPanel(new GridLayout(1, 2));
|
||||||
this.panelPassword = new JPanel(new GridLayout(1, 2));
|
this.panelPassword = new JPanel(new GridLayout(1, 2));
|
||||||
|
|
||||||
//Cree les elements
|
//Create various elements
|
||||||
this.connexionInfo = new JLabel("");
|
this.connexionInfo = new JLabel("");
|
||||||
|
|
||||||
this.inputUsername = new JTextField();
|
this.inputUsername = new JTextField();
|
||||||
|
@ -70,10 +85,10 @@ public class VueConnexion extends Vue {
|
||||||
|
|
||||||
boutonValider = new JButton("Valider");
|
boutonValider = new JButton("Valider");
|
||||||
|
|
||||||
//Le controleur guette les evenements du bouton
|
//Make it so the controller is monitoring the button
|
||||||
boutonValider.addActionListener(controle);
|
boutonValider.addActionListener(controle);
|
||||||
|
|
||||||
//Ajoute les elements
|
|
||||||
panelUsername.add(this.labelUsername);
|
panelUsername.add(this.labelUsername);
|
||||||
panelUsername.add(this.inputUsername);
|
panelUsername.add(this.inputUsername);
|
||||||
|
|
||||||
|
@ -82,7 +97,6 @@ public class VueConnexion extends Vue {
|
||||||
this.panelPassword.add(this.inputPassword);
|
this.panelPassword.add(this.inputPassword);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
main.add(connexionInfo);
|
main.add(connexionInfo);
|
||||||
main.add(panelUsername);
|
main.add(panelUsername);
|
||||||
main.add(this.panelPassword);
|
main.add(this.panelPassword);
|
||||||
|
@ -91,15 +105,16 @@ public class VueConnexion extends Vue {
|
||||||
this.add(main);
|
this.add(main);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void removePasswordPanel() {
|
||||||
//Getters et setters
|
this.main.remove(2);
|
||||||
protected void setConnexionInfo(String text) {
|
|
||||||
this.connexionInfo.setText(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setTextUsernameField(String text) {
|
protected void addPasswordPanel() {
|
||||||
this.labelUsername.setText(text);
|
this.main.add(this.panelPassword, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//----- GETTERS -----//
|
||||||
|
|
||||||
protected String getUsernameValue() {
|
protected String getUsernameValue() {
|
||||||
return this.inputUsername.getText();
|
return this.inputUsername.getText();
|
||||||
|
@ -110,17 +125,20 @@ public class VueConnexion extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//----- SETTERS -----//
|
||||||
|
|
||||||
|
protected void setConnexionInfo(String text) {
|
||||||
|
this.connexionInfo.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setTextUsernameField(String text) {
|
||||||
|
this.labelUsername.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
protected void resetUsernameField() {
|
protected void resetUsernameField() {
|
||||||
this.inputUsername.setText("");
|
this.inputUsername.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removePasswordPanel() {
|
|
||||||
this.main.remove(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addPasswordPanel() {
|
|
||||||
this.main.add(this.panelPassword, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void resetPasswordField() {
|
protected void resetPasswordField() {
|
||||||
this.inputPassword.setText("");
|
this.inputPassword.setText("");
|
||||||
|
|
Loading…
Reference in a new issue