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" />
|
||||
</children>
|
||||
</GridPane>
|
||||
<GridPane>
|
||||
<GridPane prefHeight="34.0" prefWidth="345.0">
|
||||
<columnConstraints>
|
||||
<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>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Text fill="#b0c926" strokeType="OUTSIDE" strokeWidth="0.0" text="Moi ">
|
||||
<Text fill="#b0c926" strokeType="OUTSIDE" strokeWidth="0.0" text="Chat avec : ">
|
||||
<font>
|
||||
<Font size="19.0" />
|
||||
</font>
|
||||
</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 size="19.0" />
|
||||
</font>
|
||||
</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>
|
||||
</GridPane>
|
||||
<TextArea fx:id="ChatText" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1" />
|
||||
|
@ -77,15 +83,7 @@
|
|||
</GridPane>
|
||||
</children>
|
||||
</HBox>
|
||||
<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>
|
||||
<HBox alignment="BOTTOM_RIGHT" prefHeight="63.0" prefWidth="600.0" style="-fx-background-color: #3299a8;" />
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
chatapp/View/DemarrerSession.java
|
||||
chatapp.View.DemarrerSession
|
||||
chatapp/Model/ListUtilisateurs.java
|
||||
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
|
||||
chatapp.View.FenetreSession$1
|
||||
chatapp/Model/Utilisateur.java
|
||||
chatapp.Model.Utilisateur
|
||||
chatapp/View/ConnexionScreen.java
|
||||
chatapp.View.ConnexionScreen
|
||||
chatapp/Controller/ChatApp.java
|
||||
chatapp.Controller.ChatApp
|
||||
chatapp/View/ChangementPseudo.java
|
||||
chatapp.View.ChangementPseudo
|
||||
chatapp/View/Clavardage.java
|
||||
chatapp.View.Clavardage
|
||||
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/RunnerEcouteUDP.java
|
||||
chatapp.Protocol.RunnerEcouteUDP
|
||||
chatapp/Protocol/UDPEchange.java
|
||||
chatapp.Protocol.RunnerUDP
|
||||
chatapp.Protocol.UDPEchange
|
||||
chatapp/Controller/ChatApp.java
|
||||
chatapp.Controller.ChatApp
|
||||
chatapp/Main.java
|
||||
chatapp.Main
|
||||
chatapp/View/Clavardage.java
|
||||
chatapp.View.Clavardage
|
||||
chatapp.View.Clavardage$1
|
||||
chatapp/Protocol/SessionClavardage.java
|
||||
chatapp.Protocol.SessionClavardage
|
||||
chatapp/Model/DataBase.java
|
||||
chatapp.Model.DataBase
|
||||
chatapp/Protocol/RunnerEcouteUDP.java
|
||||
chatapp.Protocol.RunnerEcouteUDP
|
||||
chatapp/View/ConnexionScreen.java
|
||||
chatapp.View.ConnexionScreen
|
||||
chatapp/View/View_Utilisateurs.java
|
||||
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 */
|
||||
private ListUtilisateurs actifUsers ;
|
||||
|
||||
|
||||
|
||||
/* ChatApp est associe a un utilisateur */
|
||||
private Utilisateur me;
|
||||
|
||||
/* ChatApp est associe a une application qui le lance et que chatapp doit fermer a la fin */
|
||||
|
||||
private Application main;
|
||||
|
||||
private static ChatApp chatapp = null;
|
||||
|
@ -104,7 +101,7 @@ public class ChatApp implements PropertyChangeListener {
|
|||
//-------Change son propre nom d'utilisateur-------//
|
||||
this.getActifUsers().modifierList(this.getMe().getPseudo(), 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:");
|
||||
this.getActifUsers().afficherListeUtilisateurs();
|
||||
return true;
|
||||
|
@ -156,12 +153,8 @@ public class ChatApp implements PropertyChangeListener {
|
|||
if (UDPEchange.getConnecte()) {
|
||||
System.out.println("Connexion reussie");
|
||||
this.connecte=true;
|
||||
//db.ajoutUtilisateurs(this.me.getId(),this.me.getPseudo());
|
||||
db.majPseudo("MacYAYA",this.me.getPseudo());
|
||||
db.majUtilisateursActifs(true,"MACYAYA");
|
||||
//db.ajoutUtilisateurs(this.me.getId(),this.me.getPseudo());
|
||||
//db.CreationTableHistorique("MACE","MACF");
|
||||
//db.ajoutHistorique("MACE","MACF","Prout");
|
||||
this.db.ajoutUtilisateurs(this.me.getId(),pseudo);
|
||||
this.db.majUtilisateursActifs(true,this.me.getId());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -195,7 +188,7 @@ public class ChatApp implements PropertyChangeListener {
|
|||
// Message que l'on envoie à tous les utilisateurs actifs
|
||||
String broadcastMessage = "Deconnexion\n" + this.getMe().toString() ;
|
||||
UDPEchange.EnvoiBroadcast(broadcastMessage);
|
||||
db.majUtilisateursActifs(false,"MACYAYA");
|
||||
db.majUtilisateursActifs(false,this.me.getId());
|
||||
this.connecte=false;
|
||||
try {
|
||||
main.stop();
|
||||
|
|
|
@ -2,6 +2,6 @@ package chatapp;
|
|||
|
||||
public class Launcher {
|
||||
public static void main(String[] args) {
|
||||
// Main.main(args);
|
||||
Main.main(args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -395,22 +395,26 @@ public class DataBase {
|
|||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
|
||||
Integer Taille = tailleBDD(nomTable);
|
||||
if(Taille < fin ){
|
||||
fin = Taille ;
|
||||
}
|
||||
for(int i = 0 ; i < fin; i++){
|
||||
try {
|
||||
if( rs.next()){
|
||||
String IDSource = rs.getString("Source");
|
||||
String Envoi = rs.getTimestamp("Envoi").toString();
|
||||
String Message = rs.getString("Message");
|
||||
if (i >= deb) {
|
||||
if (IDSource.equals(ID)) {
|
||||
//Msg += ( "Moi (" + Envoi + ") : " + Message ) ;
|
||||
}
|
||||
else {
|
||||
Msg += ( "Moi (" + Envoi + ") : " + Message ) ;
|
||||
} else {
|
||||
String PseudoSource = getPseudo(IDSource);
|
||||
Msg += (PseudoSource + " (" + Envoi + ") : " + Message);
|
||||
}
|
||||
Msg += '\n';
|
||||
}
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
|
@ -445,16 +449,8 @@ public class DataBase {
|
|||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
Taille++;
|
||||
Taille++; // on incremente Taille pour chaque solution trouvée
|
||||
}
|
||||
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