Revised merge conflict changes
This commit is contained in:
parent
c28f3e2e26
commit
acb744a34d
@ -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; }
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
|
Reference in New Issue
Block a user