Compare commits
No commits in common. "9412bb899d561829fd457987e2f13c3fae7d5a9d" and "a6097ca49a19f8c81e32fcb1cc94d3ba6209d631" have entirely different histories.
9412bb899d
...
a6097ca49a
5 changed files with 23 additions and 91 deletions
|
@ -13,7 +13,6 @@ import standard.VueStandard;
|
||||||
|
|
||||||
public class ControleurConnexion implements ActionListener{
|
public class ControleurConnexion implements ActionListener{
|
||||||
|
|
||||||
//Controller state : either DEBUT at initialization or ID_OK if the user has signed in
|
|
||||||
private enum Etat {DEBUT, ID_OK};
|
private enum Etat {DEBUT, ID_OK};
|
||||||
|
|
||||||
private VueConnexion vue;
|
private VueConnexion vue;
|
||||||
|
@ -24,14 +23,6 @@ public class ControleurConnexion implements ActionListener{
|
||||||
private SQLiteManager sqlManager;
|
private SQLiteManager sqlManager;
|
||||||
private VueStandard vueStd;
|
private VueStandard vueStd;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create and initialize the object in charge of monitoring all actions depending on what the user do.
|
|
||||||
*
|
|
||||||
* @param vue : associated instance of VueConnexion
|
|
||||||
* @param numtest : on local mode, allows you to choose which port to use. Integer between 0 and 3
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public ControleurConnexion(VueConnexion vue, int numtest) {
|
public ControleurConnexion(VueConnexion vue, int numtest) {
|
||||||
this.vue = vue;
|
this.vue = vue;
|
||||||
this.etat = Etat.DEBUT;
|
this.etat = Etat.DEBUT;
|
||||||
|
@ -64,10 +55,10 @@ public class ControleurConnexion implements ActionListener{
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
String pseudo;
|
String pseudo;
|
||||||
|
@ -82,6 +73,7 @@ public class ControleurConnexion implements ActionListener{
|
||||||
inputOK = (res == 1);
|
inputOK = (res == 1);
|
||||||
|
|
||||||
} catch (SQLException e2) {
|
} catch (SQLException e2) {
|
||||||
|
e2.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,13 +117,17 @@ public class ControleurConnexion implements ActionListener{
|
||||||
try {
|
try {
|
||||||
Utilisateur.setSelf(this.username, pseudo, "localhost", this.portTCP);
|
Utilisateur.setSelf(this.username, pseudo, "localhost", this.portTCP);
|
||||||
} catch (UnknownHostException e2) {
|
} catch (UnknownHostException e2) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e2.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
//broadcast new pseudo
|
//broadcast new pseudo
|
||||||
try {
|
try {
|
||||||
this.comUDP.sendMessageInfoPseudo();
|
this.comUDP.sendMessageInfoPseudo();
|
||||||
} catch (UnknownHostException e1) {
|
} catch (UnknownHostException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -139,6 +135,7 @@ public class ControleurConnexion implements ActionListener{
|
||||||
this.vue.setVisible(false);
|
this.vue.setVisible(false);
|
||||||
this.setVueStandard();
|
this.setVueStandard();
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else this.vue.setConnexionInfo("Ce nom est déjà utilisé, veuillez en choisir un autre");
|
else this.vue.setConnexionInfo("Ce nom est déjà utilisé, veuillez en choisir un autre");
|
||||||
|
@ -146,12 +143,6 @@ public class ControleurConnexion implements ActionListener{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----- SETTING & RESETTING VIEW ----- //
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new VueStandard instance and give it the hand.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private void setVueStandard() throws IOException {
|
private void setVueStandard() throws IOException {
|
||||||
if(this.vueStd == null) {
|
if(this.vueStd == null) {
|
||||||
this.vueStd = new VueStandard("Standard", this.comUDP, this.portTCP, this.sqlManager, this.vue);
|
this.vueStd = new VueStandard("Standard", this.comUDP, this.portTCP, this.sqlManager, this.vue);
|
||||||
|
@ -162,11 +153,7 @@ public class ControleurConnexion implements ActionListener{
|
||||||
this.vueStd.setVisible(true);
|
this.vueStd.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Restore the associated instance of VueConnexion to its initial state
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private void resetView() {
|
private void resetView() {
|
||||||
this.etat = Etat.DEBUT;
|
this.etat = Etat.DEBUT;
|
||||||
this.vue.addPasswordPanel();
|
this.vue.addPasswordPanel();
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package connexion;
|
package connexion;
|
||||||
|
|
||||||
//Import librairies
|
//Importe les librairies
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import javax.swing.*;
|
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 {
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@ import java.net.*;
|
||||||
|
|
||||||
public class Utilisateur implements Serializable{
|
public class Utilisateur implements Serializable{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
@ -12,103 +14,48 @@ public class Utilisateur implements Serializable{
|
||||||
private InetAddress ip;
|
private InetAddress ip;
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
//Represents the user that is currently using the application
|
|
||||||
private static Utilisateur self;
|
private static Utilisateur self;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create and initialize an object representing an user
|
|
||||||
*
|
|
||||||
* @param id : user id as String
|
|
||||||
* @param pseudo : name under which other users can see this user as String
|
|
||||||
* @param ip : ip of the device this user is currently using as InetAddress
|
|
||||||
* @param port : on local mode, port used for the TCP listen socket as int
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public Utilisateur(String id, String pseudo, InetAddress ip, int port) throws UnknownHostException {
|
public Utilisateur(String id, String pseudo, InetAddress ip, int port) throws UnknownHostException {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.pseudo = pseudo;
|
this.pseudo = pseudo;
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
|
|
||||||
this.port = port;
|
this.port = port;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- GETTERS ----- //
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns user id as String
|
|
||||||
*
|
|
||||||
* @return user id as String
|
|
||||||
*/
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns user pseudo as String
|
|
||||||
*
|
|
||||||
* @return user pseudo as String
|
|
||||||
*/
|
|
||||||
public String getPseudo() {
|
public String getPseudo() {
|
||||||
return pseudo;
|
return pseudo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setPseudo(String pseudo) {
|
||||||
* Returns user device's ip as String
|
this.pseudo = pseudo;
|
||||||
*
|
}
|
||||||
* @return user device's ip as String
|
|
||||||
*/
|
|
||||||
public InetAddress getIp() {
|
public InetAddress getIp() {
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the port the user uses for their TCP listen socket as int
|
|
||||||
*
|
|
||||||
* @return TCP listen socket port as int
|
|
||||||
*/
|
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the user currently using this instance of the application as Utilisateur
|
|
||||||
*
|
|
||||||
* @return current user as Utilisateur
|
|
||||||
*/
|
|
||||||
public static Utilisateur getSelf() {
|
|
||||||
return Utilisateur.self;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ----- SETTERS ----- //
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change the pseudo used by an user
|
|
||||||
*
|
|
||||||
* @param pseudo : new pseudo as String
|
|
||||||
*/
|
|
||||||
public void setPseudo(String pseudo) {
|
|
||||||
this.pseudo = pseudo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the self static attribute with a new Utilisateur
|
|
||||||
*
|
|
||||||
* @param id : user id as String
|
|
||||||
* @param pseudo : name under which other users can see this user as String
|
|
||||||
* @param ip : ip of the device this user is currently using as InetAddress
|
|
||||||
* @param port : on local mode, port used for the TCP listen socket as int
|
|
||||||
*/
|
|
||||||
public static void setSelf(String id, String pseudo, String host, int port) throws UnknownHostException {
|
public static void setSelf(String id, String pseudo, String host, int port) throws UnknownHostException {
|
||||||
if(Utilisateur.self == null) {
|
if(Utilisateur.self == null) {
|
||||||
Utilisateur.self = new Utilisateur(id, pseudo, InetAddress.getByName(host), port);
|
Utilisateur.self = new Utilisateur(id, pseudo, InetAddress.getByName(host), port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static Utilisateur getSelf() {
|
||||||
* Sets the self static attribute with null
|
return Utilisateur.self;
|
||||||
*/
|
}
|
||||||
|
|
||||||
public static void resetSelf() {
|
public static void resetSelf() {
|
||||||
Utilisateur.self = null;
|
Utilisateur.self = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,6 @@ package main;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
|
||||||
// General class from which all VueX class derivate
|
|
||||||
|
|
||||||
public class Vue extends JFrame{
|
public class Vue extends JFrame{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
0
modelisation/dossmod.txt
Normal file
0
modelisation/dossmod.txt
Normal file
Loading…
Reference in a new issue