Renamed database package to data, moved Chat to data package

This commit is contained in:
Kai S. K. Engelbart 2020-02-05 20:58:30 +01:00
parent 19fafc4c38
commit f80fd5069c
7 changed files with 23 additions and 27 deletions

View File

@ -1,4 +1,4 @@
package envoy.client; package envoy.client.data;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;

View File

@ -1,8 +1,7 @@
package envoy.client.database; package envoy.client.data;
import java.util.*; import java.util.*;
import envoy.client.Chat;
import envoy.data.IdGenerator; import envoy.data.IdGenerator;
import envoy.data.User; import envoy.data.User;

View File

@ -1,4 +1,4 @@
package envoy.client.database; package envoy.client.data;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;

View File

@ -1,4 +1,4 @@
package envoy.client.database; package envoy.client.data;
/** /**
* Implements a {@link LocalDb} in a way that does not persist any information * Implements a {@link LocalDb} in a way that does not persist any information

View File

@ -10,7 +10,7 @@ import java.util.logging.Logger;
import javax.naming.TimeLimitExceededException; import javax.naming.TimeLimitExceededException;
import envoy.client.Config; import envoy.client.Config;
import envoy.client.database.LocalDb; import envoy.client.data.LocalDb;
import envoy.client.util.EnvoyLog; import envoy.client.util.EnvoyLog;
import envoy.data.*; import envoy.data.*;
import envoy.event.Event; import envoy.event.Event;

View File

@ -10,9 +10,9 @@ import java.util.logging.Logger;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import envoy.client.Chat;
import envoy.client.Settings; import envoy.client.Settings;
import envoy.client.database.LocalDb; import envoy.client.data.Chat;
import envoy.client.data.LocalDb;
import envoy.client.event.MessageCreationEvent; import envoy.client.event.MessageCreationEvent;
import envoy.client.event.ThemeChangeEvent; import envoy.client.event.ThemeChangeEvent;
import envoy.client.net.Client; import envoy.client.net.Client;
@ -175,13 +175,8 @@ public class ChatWindow extends JFrame {
// Select current chat // Select current chat
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();
// Read current Chat // Read current chat
try { readCurrentChat();
currentChat.read(client);
} catch (IOException e) {
e.printStackTrace();
logger.log(Level.WARNING, "Could notify server about message status change", e);
}
// Set chat title // Set chat title
textPane.setText(currentChat.getRecipient().getName()); textPane.setText(currentChat.getRecipient().getName());
@ -221,15 +216,7 @@ public class ChatWindow extends JFrame {
chat.appendMessage(message); chat.appendMessage(message);
// Read message and update UI if in current chat // Read message and update UI if in current chat
if (chat == currentChat) { if (chat == currentChat) readCurrentChat();
try {
currentChat.read(client);
} catch (IOException e) {
e.printStackTrace();
logger.log(Level.WARNING, "Could notify server about message status change", e);
}
messageList.synchronizeModel();
}
revalidate(); revalidate();
repaint(); repaint();
@ -356,6 +343,16 @@ public class ChatWindow extends JFrame {
}).start(); }).start();
} }
private void readCurrentChat() {
try {
currentChat.read(client);
messageList.synchronizeModel();
} catch (IOException e) {
e.printStackTrace();
logger.log(Level.WARNING, "Couldn't notify server about message status change", e);
}
}
/** /**
* Sets the {@link Client} used by this {@link ChatWindow}. * Sets the {@link Client} used by this {@link ChatWindow}.
* *

View File

@ -13,9 +13,9 @@ import javax.swing.SwingUtilities;
import envoy.client.Config; import envoy.client.Config;
import envoy.client.Settings; import envoy.client.Settings;
import envoy.client.database.LocalDb; import envoy.client.data.LocalDb;
import envoy.client.database.PersistentLocalDb; import envoy.client.data.PersistentLocalDb;
import envoy.client.database.TransientLocalDb; import envoy.client.data.TransientLocalDb;
import envoy.client.net.Client; import envoy.client.net.Client;
import envoy.client.net.MessageCache; import envoy.client.net.MessageCache;
import envoy.client.util.EnvoyLog; import envoy.client.util.EnvoyLog;