From 418a60c0748979c7a6fb1a8965cd08188d608d50 Mon Sep 17 00:00:00 2001
From: DieGurke <55625494+DieGurke@users.noreply.github.com>
Date: Sat, 7 Dec 2019 22:48:12 +0100
Subject: [PATCH 1/4] Primary Button
Took primaryButton class from corresponding branch.
Implemented constructors in ChatWindow.
---
src/main/java/envoy/client/ui/ChatWindow.java | 9 ++-
.../java/envoy/client/ui/PrimaryButton.java | 61 +++++++++++++++++++
2 files changed, 65 insertions(+), 5 deletions(-)
create mode 100644 src/main/java/envoy/client/ui/PrimaryButton.java
diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java
index 6867f5e..7b38a3e 100644
--- a/src/main/java/envoy/client/ui/ChatWindow.java
+++ b/src/main/java/envoy/client/ui/ChatWindow.java
@@ -15,7 +15,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
-import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JOptionPane;
@@ -63,8 +62,8 @@ public class ChatWindow extends JFrame {
private JScrollPane scrollPane = new JScrollPane();
private JTextPane textPane = new JTextPane();
// private JCheckBox jCbChangeMode;
- private JButton postButton = new JButton("Post");
- private JButton settingsButton = new JButton("Settings");
+ private PrimaryButton postButton;
+ private PrimaryButton settingsButton;
private static int space = 4;
@@ -155,7 +154,7 @@ public class ChatWindow extends JFrame {
contentPane.add(messageEnterTextArea, gbc_messageEnterTextfield);
// Post Button
- postButton.setBorderPainted(false);
+ postButton = new PrimaryButton("Post");
GridBagConstraints gbc_moveSelectionPostButton = new GridBagConstraints();
gbc_moveSelectionPostButton.fill = GridBagConstraints.BOTH;
@@ -168,7 +167,7 @@ public class ChatWindow extends JFrame {
contentPane.add(postButton, gbc_moveSelectionPostButton);
// Settings Button
- settingsButton.setBorderPainted(false);
+ settingsButton = new PrimaryButton("Settings");
GridBagConstraints gbc_moveSelectionSettingsButton = new GridBagConstraints();
diff --git a/src/main/java/envoy/client/ui/PrimaryButton.java b/src/main/java/envoy/client/ui/PrimaryButton.java
new file mode 100644
index 0000000..06df82f
--- /dev/null
+++ b/src/main/java/envoy/client/ui/PrimaryButton.java
@@ -0,0 +1,61 @@
+package envoy.client.ui;
+
+import java.awt.Graphics;
+
+import javax.swing.JButton;
+
+/**
+ * Project: envoy-clientChess
+ * File: PrimaryButton.javaEvent.java
+ * Created: 07.12.2019
+ *
+ * @author Kai S. K. Engelbart
+ */
+public class PrimaryButton extends JButton {
+
+ private static final long serialVersionUID = 3662266120667728364L;
+
+ private int arcSize;
+
+ /**
+ * Creates a primary button with a white text color and a purple background
+ * color.
+ *
+ * @param title the title of the button
+ */
+ public PrimaryButton(String title) { this(title, 6); }
+
+ /**
+ * Creates a primary button with a white text color and a purple background
+ * color.
+ *
+ * @param title the title of the button
+ * @param the size of the arc used to draw the round button edges
+ */
+ public PrimaryButton(String title, int arcSize) {
+ super(title);
+ // setForeground(new Color(255, 255, 255));
+ // setBackground(new Color(102, 51, 153));
+ setBorderPainted(false);
+ setFocusPainted(false);
+ setContentAreaFilled(false);
+ this.arcSize = arcSize;
+ }
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ g.setColor(getBackground());
+ g.fillRoundRect(0, 0, getWidth(), getHeight(), arcSize, arcSize);
+ super.paintComponent(g);
+ }
+
+ /**
+ * @return the arcSize
+ */
+ public int getArcSize() { return arcSize; }
+
+ /**
+ * @param arcSize the arcSize to set
+ */
+ public void setArcSize(int arcSize) { this.arcSize = arcSize; }
+}
\ No newline at end of file
From ecf25664312dd5e552198119d4a16974240cf930 Mon Sep 17 00:00:00 2001
From: DieGurke <55625494+DieGurke@users.noreply.github.com>
Date: Sat, 7 Dec 2019 23:23:25 +0100
Subject: [PATCH 2/4] Primary TextArea
* Added PrimaryTextArea Class
* Implemented PrimaryTextArea in ChatWindow (messageEnterArea)
* Made some slight adjustments to the PrimaryButton Class
---
src/main/java/envoy/client/ui/ChatWindow.java | 13 ++--
.../java/envoy/client/ui/PrimaryButton.java | 13 ++--
.../java/envoy/client/ui/PrimaryTextArea.java | 67 +++++++++++++++++++
3 files changed, 80 insertions(+), 13 deletions(-)
create mode 100644 src/main/java/envoy/client/ui/PrimaryTextArea.java
diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java
index 7b38a3e..14065b0 100644
--- a/src/main/java/envoy/client/ui/ChatWindow.java
+++ b/src/main/java/envoy/client/ui/ChatWindow.java
@@ -20,7 +20,6 @@ import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
@@ -55,7 +54,7 @@ public class ChatWindow extends JFrame {
private LocalDB localDB;
// GUI components
private JPanel contentPane = new JPanel();
- private JTextArea messageEnterTextArea = new JTextArea();
+ private PrimaryTextArea messageEnterTextArea;
private JList userList = new JList<>();
private Chat currentChat;
private JList messageList = new JList<>();
@@ -125,6 +124,9 @@ public class ChatWindow extends JFrame {
gbc_scrollPane.insets = new Insets(space, space, space, space);
contentPane.add(scrollPane, gbc_scrollPane);
+ // Checks for changed Message
+ messageEnterTextArea = new PrimaryTextArea(space);
+
// Message enter field
messageEnterTextArea.addKeyListener(new KeyAdapter() {
@@ -137,12 +139,7 @@ public class ChatWindow extends JFrame {
}
}
});
- // Checks for changed Message
- messageEnterTextArea.setWrapStyleWord(true);
- messageEnterTextArea.setLineWrap(true);
- messageEnterTextArea.setBorder(null);
- messageEnterTextArea.setFont(new Font("Arial", Font.PLAIN, 17));
- messageEnterTextArea.setBorder(new EmptyBorder(space, space, space, space));
+
GridBagConstraints gbc_messageEnterTextfield = new GridBagConstraints();
gbc_messageEnterTextfield.fill = GridBagConstraints.BOTH;
diff --git a/src/main/java/envoy/client/ui/PrimaryButton.java b/src/main/java/envoy/client/ui/PrimaryButton.java
index 06df82f..2e528db 100644
--- a/src/main/java/envoy/client/ui/PrimaryButton.java
+++ b/src/main/java/envoy/client/ui/PrimaryButton.java
@@ -5,11 +5,12 @@ import java.awt.Graphics;
import javax.swing.JButton;
/**
- * Project: envoy-clientChess
+ * Project: envoy-client
* File: PrimaryButton.javaEvent.java
* Created: 07.12.2019
*
* @author Kai S. K. Engelbart
+ * @author Maximilian Käfer
*/
public class PrimaryButton extends JButton {
@@ -18,19 +19,19 @@ public class PrimaryButton extends JButton {
private int arcSize;
/**
- * Creates a primary button with a white text color and a purple background
- * color.
+ * Creates a primary button
*
* @param title the title of the button
+ * @since Envoy 0.2-alpha
*/
public PrimaryButton(String title) { this(title, 6); }
/**
- * Creates a primary button with a white text color and a purple background
- * color.
+ * Creates a primary button
*
* @param title the title of the button
* @param the size of the arc used to draw the round button edges
+ * @since Envoy 0.2-alpha
*/
public PrimaryButton(String title, int arcSize) {
super(title);
@@ -51,11 +52,13 @@ public class PrimaryButton extends JButton {
/**
* @return the arcSize
+ * @since Envoy 0.2-alpha
*/
public int getArcSize() { return arcSize; }
/**
* @param arcSize the arcSize to set
+ * @since Envoy 0.2-alpha
*/
public void setArcSize(int arcSize) { this.arcSize = arcSize; }
}
\ No newline at end of file
diff --git a/src/main/java/envoy/client/ui/PrimaryTextArea.java b/src/main/java/envoy/client/ui/PrimaryTextArea.java
new file mode 100644
index 0000000..3f350ed
--- /dev/null
+++ b/src/main/java/envoy/client/ui/PrimaryTextArea.java
@@ -0,0 +1,67 @@
+package envoy.client.ui;
+
+import java.awt.Font;
+import java.awt.Graphics;
+
+import javax.swing.JTextArea;
+import javax.swing.border.EmptyBorder;
+
+/**
+ * Project: envoy-client
+ * File: PrimaryTextArea.javaEvent.java
+ * Created: 07.12.2019
+ *
+ * @author Maximilian Käfer
+ */
+public class PrimaryTextArea extends JTextArea {
+
+ private static final long serialVersionUID = 1L;
+
+ private int arcSize;
+
+ /**
+ * Creates TextArea
+ *
+ * @param borderSpace
+ * @since Envoy 0.2-alpha
+ */
+ public PrimaryTextArea(int borderSpace) { this(6, borderSpace); }
+
+ /**
+ * Creates TextArea
+ *
+ * @param arcSize
+ * @param borderSpace
+ * @since Envoy 0.2-alpha
+ */
+ public PrimaryTextArea(int arcSize, int borderSpace) {
+ super();
+ setWrapStyleWord(true);
+ setLineWrap(true);
+ setBorder(null);
+ setFont(new Font("Arial", Font.PLAIN, 17));
+ setBorder(new EmptyBorder(borderSpace, borderSpace, borderSpace, borderSpace));
+ setOpaque(false);
+
+ this.arcSize = arcSize;
+ }
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ g.setColor(getBackground());
+ g.fillRoundRect(0, 0, getWidth(), getHeight(), arcSize, arcSize);
+ super.paintComponent(g);
+ }
+
+ /**
+ * @return the arcSize
+ * @since Envoy 0.2-alpha
+ */
+ public int getArcSize() { return arcSize; }
+
+ /**
+ * @param arcSize the arcSize to set
+ * @since Envoy 0.2-alpha
+ */
+ public void setArcSize(int arcSize) { this.arcSize = arcSize; }
+}
From 4ba1f6360ce9244b98f5b05eb5aa7e44fbb3816f Mon Sep 17 00:00:00 2001
From: DieGurke <55625494+DieGurke@users.noreply.github.com>
Date: Sat, 14 Dec 2019 13:46:19 +0100
Subject: [PATCH 3/4] Revised code according to reviews by @delvh and
@CyB3RC0nN0R
---
src/main/java/envoy/client/ui/ChatWindow.java | 40 +++++++++----------
.../java/envoy/client/ui/PrimaryButton.java | 3 +-
.../java/envoy/client/ui/PrimaryTextArea.java | 9 +++--
3 files changed, 24 insertions(+), 28 deletions(-)
diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java
index 14065b0..1434148 100644
--- a/src/main/java/envoy/client/ui/ChatWindow.java
+++ b/src/main/java/envoy/client/ui/ChatWindow.java
@@ -53,16 +53,16 @@ public class ChatWindow extends JFrame {
private Client client;
private LocalDB localDB;
// GUI components
- private JPanel contentPane = new JPanel();
- private PrimaryTextArea messageEnterTextArea;
- private JList userList = new JList<>();
+ private JPanel contentPane = new JPanel();
+ private PrimaryTextArea messageEnterTextArea = new PrimaryTextArea(space);
+ private JList userList = new JList<>();
private Chat currentChat;
- private JList messageList = new JList<>();
- private JScrollPane scrollPane = new JScrollPane();
- private JTextPane textPane = new JTextPane();
+ private JList messageList = new JList<>();
+ private JScrollPane scrollPane = new JScrollPane();
+ private JTextPane textPane = new JTextPane();
// private JCheckBox jCbChangeMode;
- private PrimaryButton postButton;
- private PrimaryButton settingsButton;
+ private PrimaryButton postButton = new PrimaryButton("Post");
+ private PrimaryButton settingsButton = new PrimaryButton("Settings");
private static int space = 4;
@@ -76,7 +76,8 @@ public class ChatWindow extends JFrame {
setBounds(100, 100, 600, 800);
setTitle("Envoy");
setLocationRelativeTo(null);
- setIconImage(Toolkit.getDefaultToolkit().createImage(getClass().getClassLoader().getResource("envoy_logo.png")));
+ setIconImage(
+ Toolkit.getDefaultToolkit().createImage(getClass().getClassLoader().getResource("envoy_logo.png")));
// Save chats when window closes
addWindowListener(new WindowAdapter() {
@@ -124,9 +125,6 @@ public class ChatWindow extends JFrame {
gbc_scrollPane.insets = new Insets(space, space, space, space);
contentPane.add(scrollPane, gbc_scrollPane);
- // Checks for changed Message
- messageEnterTextArea = new PrimaryTextArea(space);
-
// Message enter field
messageEnterTextArea.addKeyListener(new KeyAdapter() {
@@ -140,7 +138,6 @@ public class ChatWindow extends JFrame {
}
});
-
GridBagConstraints gbc_messageEnterTextfield = new GridBagConstraints();
gbc_messageEnterTextfield.fill = GridBagConstraints.BOTH;
gbc_messageEnterTextfield.gridx = 1;
@@ -151,7 +148,6 @@ public class ChatWindow extends JFrame {
contentPane.add(messageEnterTextArea, gbc_messageEnterTextfield);
// Post Button
- postButton = new PrimaryButton("Post");
GridBagConstraints gbc_moveSelectionPostButton = new GridBagConstraints();
gbc_moveSelectionPostButton.fill = GridBagConstraints.BOTH;
@@ -164,8 +160,6 @@ public class ChatWindow extends JFrame {
contentPane.add(postButton, gbc_moveSelectionPostButton);
// Settings Button
- settingsButton = new PrimaryButton("Settings");
-
GridBagConstraints gbc_moveSelectionSettingsButton = new GridBagConstraints();
gbc_moveSelectionSettingsButton.fill = GridBagConstraints.BOTH;
@@ -177,8 +171,8 @@ public class ChatWindow extends JFrame {
settingsButton.addActionListener((evt) -> {
try {
SettingsScreen.open();
- changeChatWindowColors(Settings.getInstance().getCurrentTheme());
- } catch (Exception e) {
+ changeChatWindowColors(Settings.getInstance().getCurrentTheme());
+ } catch (Exception e) {
SettingsScreen.open();
logger.log(Level.WARNING, "An error occured while opening the settings screen", e);
e.printStackTrace();
@@ -207,7 +201,11 @@ public class ChatWindow extends JFrame {
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();
// Set all unread messages in the chat to read
readCurrentChat();
@@ -231,7 +229,7 @@ public class ChatWindow extends JFrame {
gbc_userList.insets = new Insets(space, space, space, space);
changeChatWindowColors(Settings.getInstance().getCurrentTheme());
-
+
contentPane.add(userList, gbc_userList);
contentPane.revalidate();
@@ -240,7 +238,6 @@ public class ChatWindow extends JFrame {
contentPane.revalidate();
}
-
/**
* Used to immediately reload the ChatWindow when settings were changed.
@@ -373,4 +370,3 @@ public class ChatWindow extends JFrame {
*/
private void readCurrentChat() { if (currentChat != null) { localDB.setMessagesToRead(currentChat); } }
}
-
diff --git a/src/main/java/envoy/client/ui/PrimaryButton.java b/src/main/java/envoy/client/ui/PrimaryButton.java
index 2e528db..fe93571 100644
--- a/src/main/java/envoy/client/ui/PrimaryButton.java
+++ b/src/main/java/envoy/client/ui/PrimaryButton.java
@@ -11,6 +11,7 @@ import javax.swing.JButton;
*
* @author Kai S. K. Engelbart
* @author Maximilian Käfer
+ * @since Envoy v0.2-alpha
*/
public class PrimaryButton extends JButton {
@@ -35,8 +36,6 @@ public class PrimaryButton extends JButton {
*/
public PrimaryButton(String title, int arcSize) {
super(title);
- // setForeground(new Color(255, 255, 255));
- // setBackground(new Color(102, 51, 153));
setBorderPainted(false);
setFocusPainted(false);
setContentAreaFilled(false);
diff --git a/src/main/java/envoy/client/ui/PrimaryTextArea.java b/src/main/java/envoy/client/ui/PrimaryTextArea.java
index 3f350ed..e4d6fa1 100644
--- a/src/main/java/envoy/client/ui/PrimaryTextArea.java
+++ b/src/main/java/envoy/client/ui/PrimaryTextArea.java
@@ -12,6 +12,7 @@ import javax.swing.border.EmptyBorder;
* Created: 07.12.2019
*
* @author Maximilian Käfer
+ * @since Envoy v0.2-alpha
*/
public class PrimaryTextArea extends JTextArea {
@@ -20,7 +21,7 @@ public class PrimaryTextArea extends JTextArea {
private int arcSize;
/**
- * Creates TextArea
+ * Creates the text area
*
* @param borderSpace
* @since Envoy 0.2-alpha
@@ -28,10 +29,10 @@ public class PrimaryTextArea extends JTextArea {
public PrimaryTextArea(int borderSpace) { this(6, borderSpace); }
/**
- * Creates TextArea
+ * Creates the text area
*
* @param arcSize
- * @param borderSpace
+ * @param borderSpace - the insets of the border on all four sides
* @since Envoy 0.2-alpha
*/
public PrimaryTextArea(int arcSize, int borderSpace) {
@@ -54,7 +55,7 @@ public class PrimaryTextArea extends JTextArea {
}
/**
- * @return the arcSize
+ * @return the arcSize - the diameter of the arc at the four corners.
* @since Envoy 0.2-alpha
*/
public int getArcSize() { return arcSize; }
From 4d35129a67001e24f805da078924a313ffc27555 Mon Sep 17 00:00:00 2001
From: DieGurke <55625494+DieGurke@users.noreply.github.com>
Date: Sat, 14 Dec 2019 13:52:47 +0100
Subject: [PATCH 4/4] Formatted
---
src/main/java/envoy/client/LocalDB.java | 8 +-
src/main/java/envoy/client/Settings.java | 10 +--
src/main/java/envoy/client/ui/ChatWindow.java | 40 +++------
.../envoy/client/ui/MessageListRenderer.java | 12 +--
.../java/envoy/client/ui/PrimaryTextArea.java | 9 +-
.../java/envoy/client/ui/SettingsScreen.java | 87 ++++---------------
src/main/java/envoy/client/ui/Theme.java | 12 ++-
.../envoy/client/ui/UserListRenderer.java | 19 ++--
8 files changed, 58 insertions(+), 139 deletions(-)
diff --git a/src/main/java/envoy/client/LocalDB.java b/src/main/java/envoy/client/LocalDB.java
index f061b28..5ca7a04 100644
--- a/src/main/java/envoy/client/LocalDB.java
+++ b/src/main/java/envoy/client/LocalDB.java
@@ -44,7 +44,7 @@ public class LocalDB {
private Sync sync = objectFactory.createSync();
private Sync readMessages = objectFactory.createSync();
- private static final Logger logger = Logger.getLogger(LocalDB.class.getSimpleName());
+ private static final Logger logger = Logger.getLogger(LocalDB.class.getSimpleName());
/**
* Constructs an empty local database.
@@ -134,13 +134,13 @@ public class LocalDB {
return message;
}
- /**
+ /**
* Creates a {@link Sync} object filled with the changes that occurred to the
* local database since the last synchronization.
*
* @param userId the ID of the user that is synchronized by this client
* @return {@link Sync} object filled with the current changes
- * @since Envoy v0.1-alpha
+ * @since Envoy v0.1-alpha
*/
public Sync fillSync(long userId) {
addWaitingMessagesToSync();
@@ -156,7 +156,7 @@ public class LocalDB {
* Applies the changes carried by a {@link Sync} object to the local database
*
* @param returnSync the {@link Sync} object to apply
- * @since Envoy v0.1-alpha
+ * @since Envoy v0.1-alpha
*/
public void applySync(Sync returnSync) {
for (int i = 0; i < returnSync.getMessages().size(); i++) {
diff --git a/src/main/java/envoy/client/Settings.java b/src/main/java/envoy/client/Settings.java
index 91f696f..fe5d769 100644
--- a/src/main/java/envoy/client/Settings.java
+++ b/src/main/java/envoy/client/Settings.java
@@ -73,9 +73,9 @@ public class Settings {
// Load themes from theme file
try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(themeFile))) {
Object obj = in.readObject();
- if(obj instanceof HashMap) themes = (Map) obj;
+ if (obj instanceof HashMap) themes = (Map) obj;
} catch (IOException | ClassNotFoundException e) {
- themes = new HashMap<>();
+ themes = new HashMap<>();
currentTheme = "dark";
e.printStackTrace();
}
@@ -95,15 +95,15 @@ public class Settings {
* @throws IOException
* @since Envoy v0.2-alpha
*/
- public void save() throws IOException{
+ public void save() throws IOException {
prefs.put("username", getUsername());
prefs.put("email", getEmail());
prefs.put("theme", currentTheme);
prefs.putBoolean("enterToSend", isEnterToSend());
-
+
// Save themes to theme file
themeFile.createNewFile();
- try(ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(themeFile))) {
+ try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(themeFile))) {
out.writeObject(themes);
}
}
diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java
index 1434148..ade7bcd 100644
--- a/src/main/java/envoy/client/ui/ChatWindow.java
+++ b/src/main/java/envoy/client/ui/ChatWindow.java
@@ -53,15 +53,15 @@ public class ChatWindow extends JFrame {
private Client client;
private LocalDB localDB;
// GUI components
- private JPanel contentPane = new JPanel();
- private PrimaryTextArea messageEnterTextArea = new PrimaryTextArea(space);
- private JList userList = new JList<>();
+ private JPanel contentPane = new JPanel();
+ private PrimaryTextArea messageEnterTextArea = new PrimaryTextArea(space);
+ private JList userList = new JList<>();
private Chat currentChat;
- private JList messageList = new JList<>();
- private JScrollPane scrollPane = new JScrollPane();
- private JTextPane textPane = new JTextPane();
+ private JList messageList = new JList<>();
+ private JScrollPane scrollPane = new JScrollPane();
+ private JTextPane textPane = new JTextPane();
// private JCheckBox jCbChangeMode;
- private PrimaryButton postButton = new PrimaryButton("Post");
+ private PrimaryButton postButton = new PrimaryButton("Post");
private PrimaryButton settingsButton = new PrimaryButton("Settings");
private static int space = 4;
@@ -76,8 +76,7 @@ public class ChatWindow extends JFrame {
setBounds(100, 100, 600, 800);
setTitle("Envoy");
setLocationRelativeTo(null);
- setIconImage(
- Toolkit.getDefaultToolkit().createImage(getClass().getClassLoader().getResource("envoy_logo.png")));
+ setIconImage(Toolkit.getDefaultToolkit().createImage(getClass().getClassLoader().getResource("envoy_logo.png")));
// Save chats when window closes
addWindowListener(new WindowAdapter() {
@@ -131,8 +130,7 @@ public class ChatWindow extends JFrame {
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER
- && ((Settings.getInstance().isEnterToSend() && e.getModifiersEx() == 0)
- || (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK))) {
+ && ((Settings.getInstance().isEnterToSend() && e.getModifiersEx() == 0) || (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK))) {
postMessage(messageList);
}
}
@@ -201,11 +199,7 @@ public class ChatWindow extends JFrame {
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();
// Set all unread messages in the chat to read
readCurrentChat();
@@ -280,18 +274,14 @@ public class ChatWindow extends JFrame {
private void postMessage(JList messageList) {
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;
}
if (!messageEnterTextArea.getText().isEmpty()) try {
// Create and send message object
- final Message message = localDB.createMessage(messageEnterTextArea.getText(),
- currentChat.getRecipient().getID());
+ final Message message = localDB.createMessage(messageEnterTextArea.getText(), currentChat.getRecipient().getID());
currentChat.appendMessage(message);
messageList.setModel(currentChat.getModel());
@@ -341,8 +331,7 @@ public class ChatWindow extends JFrame {
new Thread(() -> {
// Synchronize
- localDB.applySync(
- client.sendSync(client.getSender().getID(), localDB.fillSync(client.getSender().getID())));
+ localDB.applySync(client.sendSync(client.getSender().getID(), localDB.fillSync(client.getSender().getID())));
// Process unread messages
localDB.addUnreadMessagesToLocalDB();
@@ -352,8 +341,7 @@ public class ChatWindow extends JFrame {
readCurrentChat();
// Update UI
- SwingUtilities
- .invokeLater(() -> { updateUserStates(); contentPane.revalidate(); contentPane.repaint(); });
+ SwingUtilities.invokeLater(() -> { updateUserStates(); contentPane.revalidate(); contentPane.repaint(); });
}).start();
}).start();
}
diff --git a/src/main/java/envoy/client/ui/MessageListRenderer.java b/src/main/java/envoy/client/ui/MessageListRenderer.java
index 2e6b65f..9be79c5 100644
--- a/src/main/java/envoy/client/ui/MessageListRenderer.java
+++ b/src/main/java/envoy/client/ui/MessageListRenderer.java
@@ -42,22 +42,18 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer%s
%s :%s