From 3cebdc89971aeb84fd3a8396e75366cdeb723bd1 Mon Sep 17 00:00:00 2001 From: kske Date: Tue, 31 Dec 2019 11:27:52 +0200 Subject: [PATCH] Integrated the new Message class from envoy-common --- src/main/java/envoy/client/ui/ChatWindow.java | 4 ++-- src/main/java/envoy/client/ui/MessageListRenderer.java | 10 ++++------ src/main/java/envoy/client/ui/StatusTrayIcon.java | 8 +++----- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java index 289fdd6..591be9f 100644 --- a/src/main/java/envoy/client/ui/ChatWindow.java +++ b/src/main/java/envoy/client/ui/ChatWindow.java @@ -14,7 +14,7 @@ import envoy.client.event.ThemeChangeEvent; import envoy.client.ui.settings.SettingsScreen; import envoy.client.util.EnvoyLog; import envoy.data.Message; -import envoy.data.TextMessage; +import envoy.data.MessageBuilder; import envoy.data.User; import envoy.event.EventBus; @@ -247,7 +247,7 @@ public class ChatWindow extends JFrame { if (!messageEnterTextArea.getText().isEmpty()) try { // Create and send message object - final Message message = new TextMessage(0, localDB.getUser(), currentChat.getRecipient(), messageEnterTextArea.getText()); + final Message message = new MessageBuilder(localDB.getUser(), currentChat.getRecipient()).setText(messageEnterTextArea.getText()).build(); currentChat.appendMessage(message); messageList.setModel(currentChat.getModel()); diff --git a/src/main/java/envoy/client/ui/MessageListRenderer.java b/src/main/java/envoy/client/ui/MessageListRenderer.java index 967b1cc..33f36f9 100644 --- a/src/main/java/envoy/client/ui/MessageListRenderer.java +++ b/src/main/java/envoy/client/ui/MessageListRenderer.java @@ -9,7 +9,6 @@ import javax.swing.ListCellRenderer; import envoy.client.Settings; import envoy.data.Message; -import envoy.data.TextMessage; /** * Defines how a message is displayed.
@@ -38,12 +37,11 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer { // TODO: Handle other message types - if (displayMessages) trayIcon.displayMessage("New message received", - ((TextMessage) ((MessageCreationEvent) evt).get()).getContent(), - MessageType.INFO); + if (displayMessages) + trayIcon.displayMessage("New message received", ((MessageCreationEvent) evt).get().getText(), MessageType.INFO); }); } @@ -99,4 +97,4 @@ public class StatusTrayIcon { throw new EnvoyException("Could not attach Envoy tray icon to system tray.", e); } } -} +} \ No newline at end of file