mirror of
https://github.com/Akomry/sae302_applicom.git
synced 2025-12-06 08:43:54 +00:00
feat(message): Création message quand bouton send cliqué
This commit is contained in:
parent
63c165f024
commit
c2ef4108cb
2 changed files with 30 additions and 6 deletions
|
|
@ -25,6 +25,7 @@ import net.synedra.validatorfx.Validator;
|
|||
import rtgre.chat.graphisme.ContactListViewCell;
|
||||
import rtgre.modeles.Contact;
|
||||
import rtgre.modeles.ContactMap;
|
||||
import rtgre.modeles.Message;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
|
|
@ -89,6 +90,7 @@ public class ChatController implements Initializable {
|
|||
|
||||
avatarMenuItem.setOnAction(this::handleAvatarChange);
|
||||
avatarImageView.setOnMouseClicked(this::handleAvatarChange);
|
||||
sendButton.setOnAction(this::onActionSend);
|
||||
|
||||
initContactListView();
|
||||
|
||||
|
|
@ -103,6 +105,15 @@ public class ChatController implements Initializable {
|
|||
/* -------------------------------------- */
|
||||
loginTextField.setText("riri");
|
||||
connectionButton.setSelected(true);
|
||||
/* -------------------------------------- */
|
||||
}
|
||||
|
||||
private void onActionSend(ActionEvent actionEvent) {
|
||||
String login = getSelectedContactLogin();
|
||||
if (login != null) {
|
||||
Message message = new Message(login, messageTextField.getText());
|
||||
LOGGER.info(message.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAvatarChange(Event event) {
|
||||
|
|
@ -131,8 +142,8 @@ public class ChatController implements Initializable {
|
|||
java.awt.Image img = SwingFXUtils.fromFXImage(this.avatarImageView.getImage(), null);
|
||||
this.contact = new Contact(loginTextField.getText(), img);
|
||||
contactMap.put(this.contact.getLogin(), this.contact);
|
||||
System.out.println("Nouveau contact : " + contact);
|
||||
System.out.println(contactMap);
|
||||
LOGGER.info("Nouveau contact : " + contact);
|
||||
LOGGER.info(contactMap.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +171,7 @@ public class ChatController implements Initializable {
|
|||
Platform.runLater(() -> dateTimeLabel.setText(datetime));
|
||||
Thread.sleep(60000);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
LOGGER.severe(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -181,4 +192,15 @@ public class ChatController implements Initializable {
|
|||
LOGGER.severe(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String getSelectedContactLogin() {
|
||||
String login;
|
||||
try {
|
||||
login = contactsListView.getSelectionModel().getSelectedItem().toString();
|
||||
} catch (java.lang.NullPointerException e) {
|
||||
login = null;
|
||||
}
|
||||
LOGGER.info("Selected login: " + login);
|
||||
return login;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static rtgre.chat.ChatApplication.LOGGER;
|
||||
|
||||
public class Contact {
|
||||
protected String login;
|
||||
protected java.awt.Image avatar;
|
||||
|
|
@ -52,9 +54,9 @@ public class Contact {
|
|||
try {
|
||||
this.avatar = avatarFromLogin(banques_avatars, login);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Impossible de créer l'utilisateur " + login);
|
||||
System.out.println(e.getMessage());
|
||||
System.out.println(banques_avatars);
|
||||
LOGGER.severe("Impossible de créer l'utilisateur " + login);
|
||||
LOGGER.severe(e.getMessage());
|
||||
LOGGER.severe(banques_avatars.getAbsolutePath());
|
||||
}
|
||||
this.connected = connected;
|
||||
this.currentRoom = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue