DB Fonctionnelle , il ne manque plus qu'a l'ajouter au code
This commit is contained in:
parent
a4df947767
commit
114e9fd8bf
5 changed files with 56 additions and 69 deletions
|
@ -51,25 +51,31 @@
|
||||||
<Button fx:id="EnvoyerButton" mnemonicParsing="false" onAction="#envoyerMessage" prefHeight="27.0" prefWidth="73.0" text="Envoyer" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
<Button fx:id="EnvoyerButton" mnemonicParsing="false" onAction="#envoyerMessage" prefHeight="27.0" prefWidth="73.0" text="Envoyer" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
<GridPane>
|
<GridPane prefHeight="34.0" prefWidth="345.0">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Text fill="#b0c926" strokeType="OUTSIDE" strokeWidth="0.0" text="Moi ">
|
<Text fill="#b0c926" strokeType="OUTSIDE" strokeWidth="0.0" text="Chat avec : ">
|
||||||
<font>
|
<font>
|
||||||
<Font size="19.0" />
|
<Font size="19.0" />
|
||||||
</font>
|
</font>
|
||||||
</Text>
|
</Text>
|
||||||
<Text fx:id="pseudonyme1" fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="Pseudo" textAlignment="RIGHT" wrappingWidth="201.16357421875" GridPane.columnIndex="1">
|
<Text fx:id="pseudonyme1" fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="Pseudo" textAlignment="CENTER" wrappingWidth="133.16357421875" GridPane.columnIndex="1">
|
||||||
<font>
|
<font>
|
||||||
<Font size="19.0" />
|
<Font size="19.0" />
|
||||||
</font>
|
</font>
|
||||||
</Text>
|
</Text>
|
||||||
|
<Button fx:id="plusButton" mnemonicParsing="false" onAction="#ajouterMessagesHistorique" style="-fx-background-color: #b0c926;" text="+" textAlignment="RIGHT" textFill="WHITE" GridPane.columnIndex="2">
|
||||||
|
<font>
|
||||||
|
<Font name="OCR A Extended" size="16.0" />
|
||||||
|
</font>
|
||||||
|
</Button>
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
<TextArea fx:id="ChatText" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1" />
|
<TextArea fx:id="ChatText" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1" />
|
||||||
|
@ -77,15 +83,7 @@
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<HBox alignment="BOTTOM_RIGHT" prefHeight="63.0" prefWidth="600.0" style="-fx-background-color: #3299a8;">
|
<HBox alignment="BOTTOM_RIGHT" prefHeight="63.0" prefWidth="600.0" style="-fx-background-color: #3299a8;" />
|
||||||
<children>
|
|
||||||
<Button fx:id="MenuButton" alignment="CENTER" mnemonicParsing="false" onAction="#retourMenu" style="-fx-background-color: #b0c926;" text="Retour au menu" textFill="WHITE">
|
|
||||||
<font>
|
|
||||||
<Font name="OCR A Extended" size="18.0" />
|
|
||||||
</font>
|
|
||||||
</Button>
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
</children>
|
</children>
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
chatapp/View/DemarrerSession.java
|
chatapp/Model/ListUtilisateurs.java
|
||||||
chatapp.View.DemarrerSession
|
chatapp.Model.ListUtilisateurs
|
||||||
|
chatapp/Model/MessageHorodate.java
|
||||||
|
chatapp.Model.MessageHorodate
|
||||||
|
chatapp/Model/Utilisateur.java
|
||||||
|
chatapp.Model.Utilisateur
|
||||||
|
chatapp/Launcher.java
|
||||||
|
chatapp.Launcher
|
||||||
|
chatapp/Model/DataBase.java
|
||||||
|
chatapp.Model.DataBase
|
||||||
|
chatapp/Protocol/RunnerEcouteTCP.java
|
||||||
|
chatapp.Protocol.RunnerEcouteTCP
|
||||||
chatapp/View/FenetreSession.java
|
chatapp/View/FenetreSession.java
|
||||||
chatapp.View.FenetreSession
|
chatapp.View.FenetreSession
|
||||||
chatapp.View.FenetreSession$1
|
chatapp.View.FenetreSession$1
|
||||||
chatapp/Model/Utilisateur.java
|
chatapp/Controller/ChatApp.java
|
||||||
chatapp.Model.Utilisateur
|
chatapp.Controller.ChatApp
|
||||||
chatapp/View/ConnexionScreen.java
|
|
||||||
chatapp.View.ConnexionScreen
|
|
||||||
chatapp/View/ChangementPseudo.java
|
chatapp/View/ChangementPseudo.java
|
||||||
chatapp.View.ChangementPseudo
|
chatapp.View.ChangementPseudo
|
||||||
chatapp/View/Clavardage.java
|
chatapp/Protocol/RunnerEcouteUDP.java
|
||||||
chatapp.View.Clavardage
|
chatapp.Protocol.RunnerEcouteUDP
|
||||||
chatapp.View.Clavardage$1
|
|
||||||
chatapp/Launcher.java
|
|
||||||
chatapp.Launcher
|
|
||||||
chatapp/Model/ListUtilisateurs.java
|
|
||||||
chatapp.Model.ListUtilisateurs
|
|
||||||
chatapp/View/View_Menu.java
|
|
||||||
chatapp.View.View_Menu
|
|
||||||
chatapp/Model/MessageHorodate.java
|
|
||||||
chatapp.Model.MessageHorodate
|
|
||||||
chatapp/View/View_Utilisateurs.java
|
|
||||||
chatapp.View.View_Utilisateurs
|
|
||||||
chatapp/Protocol/RunnerEcouteTCP.java
|
|
||||||
chatapp.Protocol.RunnerEcouteTCP
|
|
||||||
chatapp/Protocol/UDPEchange.java
|
chatapp/Protocol/UDPEchange.java
|
||||||
chatapp.Protocol.RunnerUDP
|
chatapp.Protocol.RunnerUDP
|
||||||
chatapp.Protocol.UDPEchange
|
chatapp.Protocol.UDPEchange
|
||||||
chatapp/Controller/ChatApp.java
|
|
||||||
chatapp.Controller.ChatApp
|
|
||||||
chatapp/Main.java
|
chatapp/Main.java
|
||||||
chatapp.Main
|
chatapp.Main
|
||||||
|
chatapp/View/Clavardage.java
|
||||||
|
chatapp.View.Clavardage
|
||||||
|
chatapp.View.Clavardage$1
|
||||||
chatapp/Protocol/SessionClavardage.java
|
chatapp/Protocol/SessionClavardage.java
|
||||||
chatapp.Protocol.SessionClavardage
|
chatapp.Protocol.SessionClavardage
|
||||||
chatapp/Model/DataBase.java
|
chatapp/View/ConnexionScreen.java
|
||||||
chatapp.Model.DataBase
|
chatapp.View.ConnexionScreen
|
||||||
chatapp/Protocol/RunnerEcouteUDP.java
|
chatapp/View/View_Utilisateurs.java
|
||||||
chatapp.Protocol.RunnerEcouteUDP
|
chatapp.View.View_Utilisateurs
|
||||||
|
chatapp/View/View_Menu.java
|
||||||
|
chatapp.View.View_Menu
|
||||||
|
chatapp/View/DemarrerSession.java
|
||||||
|
chatapp.View.DemarrerSession
|
||||||
|
|
|
@ -19,13 +19,10 @@ public class ChatApp implements PropertyChangeListener {
|
||||||
/* Liste des utilisateurs actifs */
|
/* Liste des utilisateurs actifs */
|
||||||
private ListUtilisateurs actifUsers ;
|
private ListUtilisateurs actifUsers ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ChatApp est associe a un utilisateur */
|
/* ChatApp est associe a un utilisateur */
|
||||||
private Utilisateur me;
|
private Utilisateur me;
|
||||||
|
|
||||||
/* ChatApp est associe a une application qui le lance et que chatapp doit fermer a la fin */
|
/* ChatApp est associe a une application qui le lance et que chatapp doit fermer a la fin */
|
||||||
|
|
||||||
private Application main;
|
private Application main;
|
||||||
|
|
||||||
private static ChatApp chatapp = null;
|
private static ChatApp chatapp = null;
|
||||||
|
@ -104,7 +101,7 @@ public class ChatApp implements PropertyChangeListener {
|
||||||
//-------Change son propre nom d'utilisateur-------//
|
//-------Change son propre nom d'utilisateur-------//
|
||||||
this.getActifUsers().modifierList(this.getMe().getPseudo(), nouveau);
|
this.getActifUsers().modifierList(this.getMe().getPseudo(), nouveau);
|
||||||
this.getMe().setPseudo(nouveau);
|
this.getMe().setPseudo(nouveau);
|
||||||
db.majPseudo("MacYAYA",nouveau);
|
db.majPseudo(this.me.getId(),nouveau);
|
||||||
System.out.println("Changement pseudo accepte, nouvelle liste des utilisateurs actifs:");
|
System.out.println("Changement pseudo accepte, nouvelle liste des utilisateurs actifs:");
|
||||||
this.getActifUsers().afficherListeUtilisateurs();
|
this.getActifUsers().afficherListeUtilisateurs();
|
||||||
return true;
|
return true;
|
||||||
|
@ -156,12 +153,8 @@ public class ChatApp implements PropertyChangeListener {
|
||||||
if (UDPEchange.getConnecte()) {
|
if (UDPEchange.getConnecte()) {
|
||||||
System.out.println("Connexion reussie");
|
System.out.println("Connexion reussie");
|
||||||
this.connecte=true;
|
this.connecte=true;
|
||||||
//db.ajoutUtilisateurs(this.me.getId(),this.me.getPseudo());
|
this.db.ajoutUtilisateurs(this.me.getId(),pseudo);
|
||||||
db.majPseudo("MacYAYA",this.me.getPseudo());
|
this.db.majUtilisateursActifs(true,this.me.getId());
|
||||||
db.majUtilisateursActifs(true,"MACYAYA");
|
|
||||||
//db.ajoutUtilisateurs(this.me.getId(),this.me.getPseudo());
|
|
||||||
//db.CreationTableHistorique("MACE","MACF");
|
|
||||||
//db.ajoutHistorique("MACE","MACF","Prout");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -195,7 +188,7 @@ public class ChatApp implements PropertyChangeListener {
|
||||||
// Message que l'on envoie à tous les utilisateurs actifs
|
// Message que l'on envoie à tous les utilisateurs actifs
|
||||||
String broadcastMessage = "Deconnexion\n" + this.getMe().toString() ;
|
String broadcastMessage = "Deconnexion\n" + this.getMe().toString() ;
|
||||||
UDPEchange.EnvoiBroadcast(broadcastMessage);
|
UDPEchange.EnvoiBroadcast(broadcastMessage);
|
||||||
db.majUtilisateursActifs(false,"MACYAYA");
|
db.majUtilisateursActifs(false,this.me.getId());
|
||||||
this.connecte=false;
|
this.connecte=false;
|
||||||
try {
|
try {
|
||||||
main.stop();
|
main.stop();
|
||||||
|
|
|
@ -2,6 +2,6 @@ package chatapp;
|
||||||
|
|
||||||
public class Launcher {
|
public class Launcher {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Main.main(args);
|
Main.main(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ public class DataBase {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String PseudoSource = getPseudo(IDSource) ;
|
String PseudoSource = getPseudo(IDSource) ;
|
||||||
Msg += ( PseudoSource + "(" + Envoi + ") : " + Message );
|
Msg += ( PseudoSource + " (" + Envoi + ") : " + Message );
|
||||||
}
|
}
|
||||||
Msg += '\n';
|
Msg += '\n';
|
||||||
}
|
}
|
||||||
|
@ -395,21 +395,25 @@ public class DataBase {
|
||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Integer Taille = tailleBDD(nomTable);
|
||||||
|
if(Taille < fin ){
|
||||||
|
fin = Taille ;
|
||||||
|
}
|
||||||
for(int i = 0 ; i < fin; i++){
|
for(int i = 0 ; i < fin; i++){
|
||||||
try {
|
try {
|
||||||
if( rs.next()){
|
if( rs.next()){
|
||||||
String IDSource = rs.getString("Source");
|
String IDSource = rs.getString("Source");
|
||||||
String Envoi = rs.getTimestamp("Envoi").toString();
|
String Envoi = rs.getTimestamp("Envoi").toString();
|
||||||
String Message = rs.getString("Message");
|
String Message = rs.getString("Message");
|
||||||
if (IDSource.equals(ID)){
|
if (i >= deb) {
|
||||||
//Msg += ( "Moi (" + Envoi + ") : " + Message ) ;
|
if (IDSource.equals(ID)) {
|
||||||
|
Msg += ( "Moi (" + Envoi + ") : " + Message ) ;
|
||||||
|
} else {
|
||||||
|
String PseudoSource = getPseudo(IDSource);
|
||||||
|
Msg += (PseudoSource + " (" + Envoi + ") : " + Message);
|
||||||
|
}
|
||||||
|
Msg += '\n';
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
String PseudoSource = getPseudo(IDSource) ;
|
|
||||||
Msg += ( PseudoSource + "(" + Envoi + ") : " + Message );
|
|
||||||
}
|
|
||||||
Msg += '\n';
|
|
||||||
}
|
}
|
||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
|
@ -445,16 +449,8 @@ public class DataBase {
|
||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
}
|
}
|
||||||
Taille++;
|
Taille++; // on incremente Taille pour chaque solution trouvée
|
||||||
}
|
}
|
||||||
return Taille;
|
return Taille;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
DataBase db = DataBase.getInstance();
|
|
||||||
String Msg = db.recupNMsg("MacYAYA", "MacBibil", 5);
|
|
||||||
System.out.println(Msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue