From 910896152268c7f968162042f974df63347f1c2e Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Wed, 30 Oct 2019 06:19:50 +0100 Subject: [PATCH] Fixed formatting --- src/main/java/envoy/client/ui/ChatWindow.java | 36 +++++++------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java index 8feb3ac..5f79b13 100644 --- a/src/main/java/envoy/client/ui/ChatWindow.java +++ b/src/main/java/envoy/client/ui/ChatWindow.java @@ -47,14 +47,14 @@ public class ChatWindow extends JFrame { private JPanel contentPane = new JPanel(); - private Client client; + private Client client; private LocalDB localDB; private JList userList = new JList<>(); private Chat currentChat; public ChatWindow(Client client, LocalDB localDB) { - this.client = client; + this.client = client; this.localDB = localDB; setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -66,11 +66,9 @@ public class ChatWindow extends JFrame { addWindowListener(new WindowAdapter() { @Override - public void windowClosing(WindowEvent e) { - localDB.saveToLocalDB(); - } + public void windowClosing(WindowEvent e) { localDB.saveToLocalDB(); } }); - + contentPane.setBackground(new Color(0, 0, 0)); contentPane.setForeground(Color.white); contentPane.setBorder(new EmptyBorder(0, 5, 0, 0)); @@ -149,8 +147,7 @@ public class ChatWindow extends JFrame { postButton.addActionListener((evt) -> { if (!client.hasRecipient()) { - JOptionPane.showMessageDialog(this, "Please select a recipient!", "Cannot send message", - JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(this, "Please select a recipient!", "Cannot send message", JOptionPane.INFORMATION_MESSAGE); return; } @@ -170,7 +167,8 @@ public class ChatWindow extends JFrame { } catch (Exception e) { JOptionPane.showMessageDialog(this, "An exception occured while sending a message. See the log for more details.", - "Exception occured", JOptionPane.ERROR_MESSAGE); + "Exception occured", + JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } }); @@ -197,18 +195,12 @@ public class ChatWindow extends JFrame { userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); userList.addListSelectionListener((listSelectionEvent) -> { if (!listSelectionEvent.getValueIsAdjusting()) { - @SuppressWarnings( - "unchecked" - ) + @SuppressWarnings("unchecked") final JList selectedUserList = (JList) listSelectionEvent.getSource(); final User user = selectedUserList.getSelectedValue(); client.setRecipient(user); - currentChat = localDB.getChats() - .stream() - .filter(chat -> chat.getRecipient().getID() == user.getID()) - .findFirst() - .get(); + currentChat = localDB.getChats().stream().filter(chat -> chat.getRecipient().getID() == user.getID()).findFirst().get(); client.setRecipient(user); @@ -253,10 +245,8 @@ public class ChatWindow extends JFrame { userListModel.addElement(user); // Check if user exists in local DB - if (localDB.getChats() - .stream() - .filter(c -> c.getRecipient().getID() == user.getID()) - .count() == 0) localDB.getChats().add(new Chat(user)); + if (localDB.getChats().stream().filter(c -> c.getRecipient().getID() == user.getID()).count() == 0) + localDB.getChats().add(new Chat(user)); }); SwingUtilities.invokeLater(() -> userList.setModel(userListModel)); }).start(); @@ -273,9 +263,7 @@ public class ChatWindow extends JFrame { Messages unreadMessages = client.getUnreadMessages(client.getSender().getID()); for (int i = 0; i < unreadMessages.getMessage().size(); i++) for (int j = 0; j < localDB.getChats().size(); j++) - if (localDB.getChats().get(j) - .getRecipient() - .getID() == unreadMessages.getMessage().get(i).getMetaData().getSender()) + if (localDB.getChats().get(j).getRecipient().getID() == unreadMessages.getMessage().get(i).getMetaData().getSender()) localDB.getChats().get(j).appendMessage(unreadMessages.getMessage().get(i)); }).start(); }