Revised merge conflict changes

This commit is contained in:
DieGurke 2019-11-09 17:47:18 +01:00
parent 29d1fc784b
commit a76f1aa743
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 * @return the User who initialised the local Database
* @since Envoy v0.1-alpha * @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) if (e.getKeyCode() == KeyEvent.VK_ENTER && ((SettingsScreen.enterToSend && e.getModifiersEx() == 0)
|| (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK))) { || (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); gbc_moveSelectionPostButton.insets = new Insets(10, 10, 10, 10);
postButton.addActionListener((evt) -> { postMessage(messageList); });
contentPane.add(postButton, gbc_moveSelectionPostButton);
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());
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 // Settings Button
JButton settingsButton = new JButton("Settings"); JButton settingsButton = new JButton("Settings");
settingsButton.setForeground(new Color(255, 255, 255)); settingsButton.setForeground(new Color(255, 255, 255));
@ -208,7 +175,6 @@ public class ChatWindow extends JFrame {
GridBagConstraints gbc_moveSelectionSettingsButton = new GridBagConstraints(); GridBagConstraints gbc_moveSelectionSettingsButton = new GridBagConstraints();
gbc_moveSelectionSettingsButton.fill = GridBagConstraints.BOTH; gbc_moveSelectionSettingsButton.fill = GridBagConstraints.BOTH;
gbc_moveSelectionSettingsButton.gridx = 2; gbc_moveSelectionSettingsButton.gridx = 2;
gbc_moveSelectionSettingsButton.gridy = 0; gbc_moveSelectionSettingsButton.gridy = 0;
@ -291,7 +257,33 @@ public class ChatWindow extends JFrame {
contentPane.revalidate(); 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 * Initializes the elements of the user list by downloading them from the
* server. * server.