Revised merge conflict changes

This commit is contained in:
DieGurke 2019-11-09 17:47:18 +01:00
parent c28f3e2e26
commit acb744a34d
2 changed files with 31 additions and 39 deletions

View File

@ -367,5 +367,5 @@ public class LocalDB {
* @return the User who initialised the local Database
* @since Envoy v0.1-alpha
*/
public User getUser() { return client; }
public User getUser() { return sender; }
}

View File

@ -125,8 +125,8 @@ public class ChatWindow extends JFrame {
if (e.getKeyCode() == KeyEvent.VK_ENTER && ((SettingsScreen.enterToSend && e.getModifiersEx() == 0)
|| (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK))) {
postMessage(client, messageList);
postMessage(messageList);
}
}
@ -164,42 +164,9 @@ public class ChatWindow extends JFrame {
gbc_moveSelectionPostButton.insets = new Insets(10, 10, 10, 10);
postButton.addActionListener((evt) -> {
if (!client.hasRecipient()) {
JOptionPane.showMessageDialog(this,
"Please select a recipient!",
"Cannot send message",
JOptionPane.INFORMATION_MESSAGE);
}
// Create and send message object
final Message message = localDB.createMessage(messageEnterTextArea.getText(),
currentChat.getRecipient());
localDB.addWaitingMessageToLocalDB(message, currentChat);
messageList.setModel(currentChat.getModel());
postButton.addActionListener((evt) -> { postMessage(messageList); });
contentPane.add(postButton, gbc_moveSelectionPostButton);
if (!messageEnterTextArea.getText().isEmpty()) try {
// Create and send message object
final Message message = localDB.createMessage(messageEnterTextArea.getText(), currentChat.getRecipient());
localDB.addWaitingMessageToLocalDB(message, currentChat);
messageList.setModel(currentChat.getModel());
// Clear text field
messageEnterTextArea.setText("");
contentPane.revalidate();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,
"An exception occured while sending a message. See the log for more details.",
"Exception occured",
JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
});
// Settings Button
JButton settingsButton = new JButton("Settings");
settingsButton.setForeground(new Color(255, 255, 255));
@ -208,7 +175,6 @@ public class ChatWindow extends JFrame {
GridBagConstraints gbc_moveSelectionSettingsButton = new GridBagConstraints();
gbc_moveSelectionSettingsButton.fill = GridBagConstraints.BOTH;
gbc_moveSelectionSettingsButton.gridx = 2;
gbc_moveSelectionSettingsButton.gridy = 0;
@ -291,6 +257,32 @@ public class ChatWindow extends JFrame {
contentPane.revalidate();
}
private void postMessage(JList<Message> messageList) {
if (!client.hasRecipient()) {
JOptionPane.showMessageDialog(this,
"Please select a recipient!",
"Cannot send message",
JOptionPane.INFORMATION_MESSAGE);
}
if (!messageEnterTextArea.getText().isEmpty()) try {
// Create and send message object
final Message message = localDB.createMessage(messageEnterTextArea.getText(), currentChat.getRecipient());
localDB.addWaitingMessageToLocalDB(message, currentChat);
messageList.setModel(currentChat.getModel());
// Clear text field
messageEnterTextArea.setText("");
contentPane.revalidate();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,
"An exception occured while sending a message. See the log for more details.",
"Exception occured",
JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
}
/**
* Initializes the elements of the user list by downloading them from the