correctif + getIp (à compléter)
This commit is contained in:
parent
1d6a632017
commit
d564e547ea
3 changed files with 48 additions and 9 deletions
|
@ -12,7 +12,7 @@ public class Main {
|
||||||
GestionnaireListeUtilisateur.instance().ecoute();
|
GestionnaireListeUtilisateur.instance().ecoute();
|
||||||
GestionnaireListeUtilisateur.instance().envoie("add$$$77$$$Moi$$$ip");
|
GestionnaireListeUtilisateur.instance().envoie("add$$$77$$$Moi$$$ip");
|
||||||
|
|
||||||
|
GestionnaireListeUtilisateur.instance().majListe();
|
||||||
|
|
||||||
Thread t = new Thread(new Login_RegisterUI());//gestionnaireListeUtilisateur, gestionnaireNom));
|
Thread t = new Thread(new Login_RegisterUI());//gestionnaireListeUtilisateur, gestionnaireNom));
|
||||||
t.start();
|
t.start();
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class GestionnaireNom{
|
||||||
|
|
||||||
private String idUtilisateur;
|
private String idUtilisateur;
|
||||||
private String nomUtilisateur;
|
private String nomUtilisateur;
|
||||||
|
private String ipUtilisateur;
|
||||||
//public static String ipUtilisateur = InetAddress.getLocalHost().getHostName();
|
//public static String ipUtilisateur = InetAddress.getLocalHost().getHostName();
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,6 +46,12 @@ public class GestionnaireNom{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getIp() {
|
||||||
|
return ipUtilisateur;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// attribue le nom "nom" à l'utilisateur
|
// attribue le nom "nom" à l'utilisateur
|
||||||
private void setNom(String nom) {
|
private void setNom(String nom) {
|
||||||
nomUtilisateur = nom;
|
nomUtilisateur = nom;
|
||||||
|
@ -58,14 +65,18 @@ public class GestionnaireNom{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setIp(String ip) {
|
||||||
|
ipUtilisateur = ip;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// renvoie l'ID d'un utilisateur ou 0 s'il n'existe pas (ou non en ligne)
|
// renvoie l'ID d'un utilisateur ou 0 s'il n'existe pas (ou non en ligne)
|
||||||
public String idFromNom(String nom) {
|
public String idFromNom(String nom) {
|
||||||
GestionnaireListeUtilisateur gestionnaireListeUtilisateur = new GestionnaireListeUtilisateur();
|
for (int i=0; i<GestionnaireListeUtilisateur.instance().getListeUtilisateur().size(); i++) {
|
||||||
for (int i=0; i<gestionnaireListeUtilisateur.getListeUtilisateur().size(); i++) {
|
if (GestionnaireListeUtilisateur.instance().getListeUtilisateur().get(i).nom.toLowerCase().equals(nom.toLowerCase())) {
|
||||||
if (gestionnaireListeUtilisateur.getListeUtilisateur().get(i).nom.toLowerCase().equals(nom.toLowerCase())) {
|
return GestionnaireListeUtilisateur.instance().getListeUtilisateur().get(i).id;
|
||||||
return gestionnaireListeUtilisateur.getListeUtilisateur().get(i).id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +85,17 @@ public class GestionnaireNom{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String ipFromNom(String nom) {
|
||||||
|
for (int i=0; i<GestionnaireListeUtilisateur.instance().getListeUtilisateur().size(); i++) {
|
||||||
|
if (GestionnaireListeUtilisateur.instance().getListeUtilisateur().get(i).nom.toLowerCase().equals(nom.toLowerCase())) {
|
||||||
|
return GestionnaireListeUtilisateur.instance().getListeUtilisateur().get(i).ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// renvoie 1 si le nom est disponible
|
// renvoie 1 si le nom est disponible
|
||||||
private boolean verifierDisponibiliteNom(String nom) {
|
private boolean verifierDisponibiliteNom(String nom) {
|
||||||
|
|
|
@ -10,7 +10,11 @@ import javax.swing.JLabel;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
|
import liste.GestionnaireListeUtilisateur;
|
||||||
import nom.GestionnaireNom;
|
import nom.GestionnaireNom;
|
||||||
|
import liste.TypeListeUtilisateur;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
@ -23,7 +27,10 @@ public class ListUI extends JFrame implements Runnable{
|
||||||
private JTable table;
|
private JTable table;
|
||||||
private DefaultTableModel dtm = new DefaultTableModel(null, new String[] {"Name"});
|
private DefaultTableModel dtm = new DefaultTableModel(null, new String[] {"Name"});
|
||||||
|
|
||||||
private String[] test = new String[] {"1", "2", "3", "4"};
|
|
||||||
|
|
||||||
|
private ArrayList<String> test = new ArrayList<String>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch the application.
|
* Launch the application.
|
||||||
|
@ -41,7 +48,7 @@ public class ListUI extends JFrame implements Runnable{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ajouterNomListe(DefaultTableModel dtm, String[] test) {
|
public void ajouterNomListe(DefaultTableModel dtm, ArrayList<String> test) {
|
||||||
for (String t : test) {
|
for (String t : test) {
|
||||||
dtm.addRow(new Object[] {t});
|
dtm.addRow(new Object[] {t});
|
||||||
}
|
}
|
||||||
|
@ -54,7 +61,7 @@ public class ListUI extends JFrame implements Runnable{
|
||||||
*/
|
*/
|
||||||
public ListUI() {
|
public ListUI() {
|
||||||
setTitle("List");
|
setTitle("List");
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
setBounds(100, 100, 450, 300);
|
setBounds(100, 100, 450, 300);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
@ -69,6 +76,10 @@ public class ListUI extends JFrame implements Runnable{
|
||||||
try{
|
try{
|
||||||
String nom = (String) table.getValueAt(row, col);
|
String nom = (String) table.getValueAt(row, col);
|
||||||
System.out.println(nom);
|
System.out.println(nom);
|
||||||
|
|
||||||
|
test.add("1");
|
||||||
|
test.add("2");
|
||||||
|
test.add("3");
|
||||||
ajouterNomListe(dtm, test);
|
ajouterNomListe(dtm, test);
|
||||||
//String id = GestionnaireNom.idFromNom(nom);
|
//String id = GestionnaireNom.idFromNom(nom);
|
||||||
|
|
||||||
|
@ -80,7 +91,13 @@ public class ListUI extends JFrame implements Runnable{
|
||||||
btnNewButton.setBounds(171, 206, 89, 23);
|
btnNewButton.setBounds(171, 206, 89, 23);
|
||||||
contentPane.add(btnNewButton);
|
contentPane.add(btnNewButton);
|
||||||
|
|
||||||
ajouterNomListe(dtm, test);
|
ArrayList<TypeListeUtilisateur> listeUtilisateur = GestionnaireListeUtilisateur.instance().getListeUtilisateur();
|
||||||
|
ArrayList<String> liste = new ArrayList<String>();
|
||||||
|
for (int i=0; i< listeUtilisateur.size(); i++) {
|
||||||
|
liste.add(listeUtilisateur.get(i).nom);
|
||||||
|
}
|
||||||
|
|
||||||
|
ajouterNomListe(dtm, liste);
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
scrollPane.setBounds(67, 23, 303, 158);
|
scrollPane.setBounds(67, 23, 303, 158);
|
||||||
|
|
Loading…
Reference in a new issue