Revised requested changes besides 2 (please change by yourself)
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
package envoy.client.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.ComponentOrientation;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
@ -136,6 +135,7 @@ public class ChatWindow extends JFrame {
|
||||
&& ((Settings.getInstance().isEnterToSend() && e.getModifiersEx() == 0)
|
||||
|| (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK))) {
|
||||
postMessage(messageList);
|
||||
}
|
||||
}
|
||||
});
|
||||
// Checks for changed Message
|
||||
@ -244,6 +244,7 @@ public class ChatWindow extends JFrame {
|
||||
|
||||
contentPane.revalidate();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to immediately reload the ChatWindow when settings were changed.
|
||||
@ -282,19 +283,22 @@ public class ChatWindow extends JFrame {
|
||||
userList.setSelectionBackground(theme.getSelectionColor());
|
||||
userList.setForeground(theme.getUserNameColor());
|
||||
userList.setBackground(theme.getCellColor());
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void postMessage(JList<Message> 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());
|
||||
final Message message = localDB.createMessage(messageEnterTextArea.getText(),
|
||||
currentChat.getRecipient().getID());
|
||||
currentChat.appendMessage(message);
|
||||
messageList.setModel(currentChat.getModel());
|
||||
|
||||
@ -344,7 +348,8 @@ 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();
|
||||
@ -354,7 +359,8 @@ public class ChatWindow extends JFrame {
|
||||
readCurrentChat();
|
||||
|
||||
// Update UI
|
||||
SwingUtilities.invokeLater(() -> { updateUserStates(); contentPane.revalidate(); contentPane.repaint(); });
|
||||
SwingUtilities
|
||||
.invokeLater(() -> { updateUserStates(); contentPane.revalidate(); contentPane.repaint(); });
|
||||
}).start();
|
||||
}).start();
|
||||
}
|
||||
@ -371,3 +377,4 @@ public class ChatWindow extends JFrame {
|
||||
*/
|
||||
private void readCurrentChat() { if (currentChat != null) { localDB.setMessagesToRead(currentChat); } }
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user