Renamed every identifier according to new convention

This commit is contained in:
delvh 2020-03-26 16:06:18 +01:00
parent 5c2abe7c1c
commit 364ec6f04e
33 changed files with 124 additions and 90 deletions

View File

@ -25,7 +25,7 @@ public class Cache<T> implements Consumer<T>, Serializable {
private transient Consumer<T> processor; private transient Consumer<T> processor;
private static final Logger logger = EnvoyLog.getLogger(Cache.class); private static final Logger logger = EnvoyLog.getLogger(Cache.class);
private static final long serialVersionUID = 7343544675545545076L; private static final long serialVersionUID = 0L;
/** /**
* Adds an element to the cache. * Adds an element to the cache.

View File

@ -25,9 +25,9 @@ import envoy.event.MessageStatusChangeEvent;
*/ */
public class Chat implements Serializable { public class Chat implements Serializable {
private static final long serialVersionUID = -7751248474547242056L; private static final long serialVersionUID = 0L;
private final User recipient; private final User recipient;
private final Model<Message> model = new Model<>(); private final Model<Message> model = new Model<>();
/** /**
@ -61,7 +61,7 @@ public class Chat implements Serializable {
public void read(WriteProxy writeProxy) throws IOException { public void read(WriteProxy writeProxy) throws IOException {
for (int i = model.size() - 1; i >= 0; --i) { for (int i = model.size() - 1; i >= 0; --i) {
final Message m = model.get(i); final Message m = model.get(i);
if (m.getSenderId() == recipient.getId()) if (m.getStatus() == MessageStatus.READ) break; if (m.getSenderID() == recipient.getID()) if (m.getStatus() == MessageStatus.READ) break;
else { else {
m.setStatus(MessageStatus.READ); m.setStatus(MessageStatus.READ);
writeProxy.writeMessageStatusChangeEvent(new MessageStatusChangeEvent(m)); writeProxy.writeMessageStatusChangeEvent(new MessageStatusChangeEvent(m));

View File

@ -2,14 +2,14 @@ package envoy.client.data;
import java.util.*; import java.util.*;
import envoy.data.IdGenerator; import envoy.data.IDGenerator;
import envoy.data.Message; import envoy.data.Message;
import envoy.data.User; import envoy.data.User;
import envoy.event.MessageStatusChangeEvent; import envoy.event.MessageStatusChangeEvent;
/** /**
* Stores information about the current {@link User} and their {@link Chat}s. * Stores information about the current {@link User} and their {@link Chat}s.
* For message ID generation a {@link IdGenerator} is stored as well.<br> * For message ID generation a {@link IDGenerator} is stored as well.<br>
* <br> * <br>
* Project: <strong>envoy-client</strong><br> * Project: <strong>envoy-client</strong><br>
* File: <strong>LocalDB.java</strong><br> * File: <strong>LocalDB.java</strong><br>
@ -23,7 +23,7 @@ public abstract class LocalDB {
protected User user; protected User user;
protected Map<String, User> users = new HashMap<>(); protected Map<String, User> users = new HashMap<>();
protected List<Chat> chats = new ArrayList<>(); protected List<Chat> chats = new ArrayList<>();
protected IdGenerator idGenerator; protected IDGenerator idGenerator;
protected Cache<Message> messageCache = new Cache<>(); protected Cache<Message> messageCache = new Cache<>();
protected Cache<MessageStatusChangeEvent> statusCache = new Cache<>(); protected Cache<MessageStatusChangeEvent> statusCache = new Cache<>();
@ -64,7 +64,7 @@ public abstract class LocalDB {
* *
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
*/ */
public void loadIdGenerator() {} public void loadIDGenerator() {}
/** /**
* @return a {@code Map<String, User>} of all users stored locally with their * @return a {@code Map<String, User>} of all users stored locally with their
@ -106,19 +106,19 @@ public abstract class LocalDB {
* @return the message ID generator * @return the message ID generator
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
*/ */
public IdGenerator getIdGenerator() { return idGenerator; } public IDGenerator getIDGenerator() { return idGenerator; }
/** /**
* @param idGenerator the message ID generator to set * @param idGenerator the message ID generator to set
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
*/ */
public void setIdGenerator(IdGenerator idGenerator) { this.idGenerator = idGenerator; } public void setIDGenerator(IDGenerator idGenerator) { this.idGenerator = idGenerator; }
/** /**
* @return {@code true} if an {@link IdGenerator} is present * @return {@code true} if an {@link IDGenerator} is present
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
*/ */
public boolean hasIdGenerator() { return idGenerator != null; } public boolean hasIDGenerator() { return idGenerator != null; }
/** /**
* @return the offline message cache * @return the offline message cache
@ -146,7 +146,7 @@ public abstract class LocalDB {
/** /**
* Searches for a message by ID. * Searches for a message by ID.
* *
* @param id the ID of the message to search for * @param id the ID of the message to search for
* @return the message with the corresponding ID, or {@code null} if no message * @return the message with the corresponding ID, or {@code null} if no message
* has been found * has been found
@ -155,7 +155,7 @@ public abstract class LocalDB {
public Message getMessage(long id) { public Message getMessage(long id) {
for (Chat c : chats) for (Chat c : chats)
for (Message m : c.getModel()) for (Message m : c.getModel())
if (m.getId() == id) return m; if (m.getID() == id) return m;
return null; return null;
} }
} }

View File

@ -6,7 +6,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import envoy.data.ConfigItem; import envoy.data.ConfigItem;
import envoy.data.IdGenerator; import envoy.data.IDGenerator;
import envoy.util.SerializationUtils; import envoy.util.SerializationUtils;
/** /**
@ -55,7 +55,8 @@ public class PersistentLocalDB extends LocalDB {
} }
/** /**
* Creates a database file for a user-specific list of chats. * Creates a database file for a user-specific list of chats.<br>
* {@inheritDoc}
* *
* @throws NullPointerException if the client user is not yet specified * @throws NullPointerException if the client user is not yet specified
* @since Envoy Client v0.1-alpha * @since Envoy Client v0.1-alpha
@ -63,11 +64,14 @@ public class PersistentLocalDB extends LocalDB {
@Override @Override
public void initializeUserStorage() { public void initializeUserStorage() {
if (user == null) throw new NullPointerException("Client user is null"); if (user == null) throw new NullPointerException("Client user is null");
localDBFile = new File(localDBDir, user.getId() + ".db"); localDBFile = new File(localDBDir, user.getID() + ".db");
messageCacheFile = new File(localDBDir, user.getId() + "_message_cache.db"); messageCacheFile = new File(localDBDir, user.getID() + "_message_cache.db");
statusCacheFile = new File(localDBDir, user.getId() + "_status_cache.db"); statusCacheFile = new File(localDBDir, user.getID() + "_status_cache.db");
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void save() throws IOException { public void save() throws IOException {
// Save users // Save users
@ -81,12 +85,18 @@ public class PersistentLocalDB extends LocalDB {
} }
// Save id generator // Save id generator
if (hasIdGenerator()) SerializationUtils.write(idGeneratorFile, idGenerator); if (hasIDGenerator()) SerializationUtils.write(idGeneratorFile, idGenerator);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void loadUsers() throws ClassNotFoundException, IOException { users = SerializationUtils.read(usersFile, HashMap.class); } public void loadUsers() throws ClassNotFoundException, IOException { users = SerializationUtils.read(usersFile, HashMap.class); }
/**
* {@inheritDoc}
*/
@Override @Override
public void loadUserData() throws ClassNotFoundException, IOException { public void loadUserData() throws ClassNotFoundException, IOException {
chats = SerializationUtils.read(localDBFile, ArrayList.class); chats = SerializationUtils.read(localDBFile, ArrayList.class);
@ -94,10 +104,13 @@ public class PersistentLocalDB extends LocalDB {
statusCache = SerializationUtils.read(statusCacheFile, Cache.class); statusCache = SerializationUtils.read(statusCacheFile, Cache.class);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void loadIdGenerator() { public void loadIDGenerator() {
try { try {
idGenerator = SerializationUtils.read(idGeneratorFile, IdGenerator.class); idGenerator = SerializationUtils.read(idGeneratorFile, IDGenerator.class);
} catch (ClassNotFoundException | IOException e) {} } catch (ClassNotFoundException | IOException e) {}
} }
} }

View File

@ -16,7 +16,7 @@ import envoy.client.ui.primary.PrimaryToggleSwitch;
* Project: <strong>envoy-clientChess</strong><br> * Project: <strong>envoy-clientChess</strong><br>
* File: <strong>SettingsItem.java</strong><br> * File: <strong>SettingsItem.java</strong><br>
* Created: <strong>23.12.2019</strong><br> * Created: <strong>23.12.2019</strong><br>
* *
* @param <T> the type of this {@link SettingsItem}'s value * @param <T> the type of this {@link SettingsItem}'s value
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
@ -31,7 +31,7 @@ public class SettingsItem<T> implements Serializable {
private static final Map<Class<?>, Class<? extends JComponent>> componentClasses = new HashMap<>(); private static final Map<Class<?>, Class<? extends JComponent>> componentClasses = new HashMap<>();
private static final long serialVersionUID = 2146837835556852218L; private static final long serialVersionUID = 0L;
static { static {
componentClasses.put(Boolean.class, PrimaryToggleSwitch.class); componentClasses.put(Boolean.class, PrimaryToggleSwitch.class);
@ -41,7 +41,7 @@ public class SettingsItem<T> implements Serializable {
* Initializes a {@link SettingsItem}. The default value's class will be mapped * Initializes a {@link SettingsItem}. The default value's class will be mapped
* to a {@link JComponent} that can be used to display this {@link SettingsItem} * to a {@link JComponent} that can be used to display this {@link SettingsItem}
* to the user. * to the user.
* *
* @param value the default value * @param value the default value
* @param userFriendlyName the user friendly name (short) * @param userFriendlyName the user friendly name (short)
* @param description the description (long) * @param description the description (long)
@ -58,9 +58,10 @@ public class SettingsItem<T> implements Serializable {
* to a specific {@link JComponent}. The mapping can also be disables if this * to a specific {@link JComponent}. The mapping can also be disables if this
* parameter is {@code null}. In that case a {@link NullPointerException} will * parameter is {@code null}. In that case a {@link NullPointerException} will
* be thrown if the method {@link SettingsItem#getComponent()} is called. * be thrown if the method {@link SettingsItem#getComponent()} is called.
* *
* @param value the default value * @param value the default value
* @param componentClass the class of the {@link JComponent} to represent this {@link SettingsItem} with * @param componentClass the class of the {@link JComponent} to represent this
* {@link SettingsItem} with
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
*/ */
public SettingsItem(T value, Class<? extends JComponent> componentClass) { public SettingsItem(T value, Class<? extends JComponent> componentClass) {
@ -69,9 +70,10 @@ public class SettingsItem<T> implements Serializable {
} }
/** /**
* @return an instance of the {@link JComponent} that represents this {@link SettingsItem} * @return an instance of the {@link JComponent} that represents this
* {@link SettingsItem}
* @throws ReflectiveOperationException if the component initialization failed * @throws ReflectiveOperationException if the component initialization failed
* @throws SecurityException if the component initialization failed * @throws SecurityException if the component initialization failed
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
*/ */
public JComponent getComponent() throws ReflectiveOperationException, SecurityException { public JComponent getComponent() throws ReflectiveOperationException, SecurityException {
@ -88,7 +90,7 @@ public class SettingsItem<T> implements Serializable {
/** /**
* Changes the value of this {@link SettingsItem}. If a {@code ChangeHandler} if * Changes the value of this {@link SettingsItem}. If a {@code ChangeHandler} if
* defined, it will be invoked with this value. * defined, it will be invoked with this value.
* *
* @param value the value to set * @param value the value to set
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
*/ */
@ -137,7 +139,7 @@ public class SettingsItem<T> implements Serializable {
* Sets a {@code ChangeHandler} for this {@link SettingsItem}. It will be * Sets a {@code ChangeHandler} for this {@link SettingsItem}. It will be
* invoked with the current value once during the registration and every time * invoked with the current value once during the registration and every time
* when the value changes. * when the value changes.
* *
* @param changeHandler the changeHandler to set * @param changeHandler the changeHandler to set
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
*/ */

View File

@ -14,5 +14,5 @@ import envoy.event.Event;
*/ */
public class HandshakeSuccessfulEvent extends Event.Valueless { public class HandshakeSuccessfulEvent extends Event.Valueless {
private static final long serialVersionUID = -157972384126278855L; private static final long serialVersionUID = 0L;
} }

View File

@ -13,7 +13,7 @@ import envoy.event.Event;
*/ */
public class MessageCreationEvent extends Event<Message> { public class MessageCreationEvent extends Event<Message> {
private static final long serialVersionUID = -6451021678064566774L; private static final long serialVersionUID = 0L;
/** /**
* @param message the {@link Message} that has been created * @param message the {@link Message} that has been created

View File

@ -13,7 +13,7 @@ import envoy.event.Event;
*/ */
public class MessageModificationEvent extends Event<Message> { public class MessageModificationEvent extends Event<Message> {
private static final long serialVersionUID = 4650039506439563116L; private static final long serialVersionUID = 0L;
/** /**
* @param message the {@link Message} that has been modified * @param message the {@link Message} that has been modified

View File

@ -6,14 +6,14 @@ import envoy.event.Event;
* Project: <strong>envoy-client</strong><br> * Project: <strong>envoy-client</strong><br>
* File: <strong>SendEvent.java</strong><br> * File: <strong>SendEvent.java</strong><br>
* Created: <strong>11.02.2020</strong><br> * Created: <strong>11.02.2020</strong><br>
* *
* @author: Maximilian K&aumlfer * @author: Maximilian K&aumlfer
* *
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
*/ */
public class SendEvent extends Event<Event<?>> { public class SendEvent extends Event<Event<?>> {
private static final long serialVersionUID = 8372746924138839060L; private static final long serialVersionUID = 0L;
/** /**
* @param value the event to send to the server * @param value the event to send to the server

View File

@ -13,7 +13,7 @@ import envoy.event.Event;
*/ */
public class ThemeChangeEvent extends Event<Theme> { public class ThemeChangeEvent extends Event<Theme> {
private static final long serialVersionUID = 6756772448803774547L; private static final long serialVersionUID = 0L;
/** /**
* Initializes a {@link ThemeChangeEvent} conveying information about the change * Initializes a {@link ThemeChangeEvent} conveying information about the change

View File

@ -118,11 +118,11 @@ public class Client implements Closeable {
* this client. * this client.
* *
* @param localDB the local database used to persist the current * @param localDB the local database used to persist the current
* {@link IdGenerator} * {@link IDGenerator}
* @param receivedMessageCache a message cache containing all unread messages * @param receivedMessageCache a message cache containing all unread messages
* from the server that can be relayed after * from the server that can be relayed after
* initialization * initialization
* @throws IOException if no {@link IdGenerator} is present and none could be * @throws IOException if no {@link IDGenerator} is present and none could be
* requested from the server * requested from the server
* @since Envoy Client v0.2-alpha * @since Envoy Client v0.2-alpha
*/ */
@ -143,7 +143,7 @@ public class Client implements Closeable {
receiver.registerProcessor(UserStatusChangeEvent.class, new UserStatusChangeProcessor(localDB)); receiver.registerProcessor(UserStatusChangeEvent.class, new UserStatusChangeProcessor(localDB));
// Process message ID generation // Process message ID generation
receiver.registerProcessor(IdGenerator.class, localDB::setIdGenerator); receiver.registerProcessor(IDGenerator.class, localDB::setIDGenerator);
// Process contact searches // Process contact searches
receiver.registerProcessor(ContactSearchResult.class, EventBus.getInstance()::dispatch); receiver.registerProcessor(ContactSearchResult.class, EventBus.getInstance()::dispatch);
@ -161,7 +161,7 @@ public class Client implements Closeable {
}); });
// Request a generator if none is present or the existing one is consumed // Request a generator if none is present or the existing one is consumed
if (!localDB.hasIdGenerator() || !localDB.getIdGenerator().hasNext()) requestIdGenerator(); if (!localDB.hasIDGenerator() || !localDB.getIDGenerator().hasNext()) requestIdGenerator();
} }
/** /**
@ -197,14 +197,14 @@ public class Client implements Closeable {
public void sendEvent(Event<?> evt) throws IOException { writeObject(evt); } public void sendEvent(Event<?> evt) throws IOException { writeObject(evt); }
/** /**
* Requests a new {@link IdGenerator} from the server. * Requests a new {@link IDGenerator} from the server.
* *
* @throws IOException if the request does not reach the server * @throws IOException if the request does not reach the server
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
*/ */
public void requestIdGenerator() throws IOException { public void requestIdGenerator() throws IOException {
logger.info("Requesting new id generator..."); logger.info("Requesting new id generator...");
writeObject(new IdGeneratorRequest()); writeObject(new IDGeneratorRequest());
} }
/** /**

View File

@ -26,7 +26,7 @@ public class UserStatusChangeProcessor implements Consumer<UserStatusChangeEvent
@Override @Override
public void accept(UserStatusChangeEvent evt) { public void accept(UserStatusChangeEvent evt) {
localDB.getUsers().values().stream().filter(u -> u.getId() == evt.getId()).findFirst().get().setStatus(evt.get()); localDB.getUsers().values().stream().filter(u -> u.getID() == evt.getID()).findFirst().get().setStatus(evt.get());
EventBus.getInstance().dispatch(evt); EventBus.getInstance().dispatch(evt);
} }
} }

View File

@ -48,8 +48,8 @@ public class WriteProxy {
logger.finer("Sending cached " + msg); logger.finer("Sending cached " + msg);
client.sendMessage(msg); client.sendMessage(msg);
// Update message state to SENT in local db // Update message state to SENT in localDB
localDB.getMessage(msg.getId()).nextStatus(); localDB.getMessage(msg.getID()).nextStatus();
} catch (IOException e) { } catch (IOException e) {
logger.log(Level.SEVERE, "Could not send cached message", e); logger.log(Level.SEVERE, "Could not send cached message", e);
} }

View File

@ -28,7 +28,7 @@ import javax.swing.*;
*/ */
public class ContextMenu extends JPopupMenu { public class ContextMenu extends JPopupMenu {
private static final long serialVersionUID = 2177146471226992104L; private static final long serialVersionUID = 0L;
/** /**
* If a key starts with this String, a {@link JCheckBoxMenuItem} will be created * If a key starts with this String, a {@link JCheckBoxMenuItem} will be created
@ -137,11 +137,9 @@ public class ContextMenu extends JPopupMenu {
private void action(MouseEvent e) { private void action(MouseEvent e) {
if (!built) build(); if (!built) build();
if (e.isPopupTrigger()) { if (e.isPopupTrigger()) // hides the menu if already visible
// hides the menu if already visible
if (!isVisible()) show(e.getComponent(), e.getX(), e.getY()); if (!isVisible()) show(e.getComponent(), e.getX(), e.getY());
else setVisible(false); else setVisible(false);
}
} }
}; };
} }

View File

@ -14,7 +14,7 @@ import java.util.Map;
*/ */
public class Theme implements Serializable { public class Theme implements Serializable {
private static final long serialVersionUID = 141727847527060352L; private static final long serialVersionUID = 0L;
private String themeName; private String themeName;
private Map<String, Color> colors = new HashMap<>(); private Map<String, Color> colors = new HashMap<>();

View File

@ -97,7 +97,7 @@ public class ChatWindow extends JFrame {
private final static int space = 4; private final static int space = 4;
private static final Insets insets = new Insets(space, space, space, space); private static final Insets insets = new Insets(space, space, space, space);
private static final long serialVersionUID = 6865098428255463649L; private static final long serialVersionUID = 0L;
/** /**
* Initializes a {@link JFrame} with UI elements used to send and read messages * Initializes a {@link JFrame} with UI elements used to send and read messages
@ -250,7 +250,7 @@ public class ChatWindow extends JFrame {
if (contentPane.getComponent(i).equals(searchPane)) drawChatBox(gbc_scrollPane); if (contentPane.getComponent(i).equals(searchPane)) drawChatBox(gbc_scrollPane);
if (user != null) { if (user != null) {
// 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
readCurrentChat(); readCurrentChat();
@ -412,7 +412,7 @@ public class ChatWindow extends JFrame {
// Listen to received messages // Listen to received messages
EventBus.getInstance().register(MessageCreationEvent.class, evt -> { EventBus.getInstance().register(MessageCreationEvent.class, evt -> {
Message message = evt.get(); Message message = evt.get();
Chat chat = localDB.getChats().stream().filter(c -> c.getRecipient().getId() == message.getSenderId()).findFirst().get(); Chat chat = localDB.getChats().stream().filter(c -> c.getRecipient().getID() == message.getSenderID()).findFirst().get();
chat.appendMessage(message); chat.appendMessage(message);
// Read message and update UI if in current chat // Read message and update UI if in current chat
@ -424,12 +424,12 @@ public class ChatWindow extends JFrame {
// Listen to message status changes // Listen to message status changes
EventBus.getInstance().register(MessageStatusChangeEvent.class, evt -> { EventBus.getInstance().register(MessageStatusChangeEvent.class, evt -> {
final long id = evt.getId(); final long id = evt.getID();
final MessageStatus status = evt.get(); final MessageStatus status = evt.get();
for (Chat c : localDB.getChats()) for (Chat c : localDB.getChats())
for (Message m : c.getModel()) for (Message m : c.getModel())
if (m.getId() == id) { if (m.getID() == id) {
// Update message status // Update message status
m.setStatus(status); m.setStatus(status);
@ -543,7 +543,7 @@ public class ChatWindow extends JFrame {
if (!text.isEmpty()) checkMessageTextLength(); if (!text.isEmpty()) checkMessageTextLength();
// Create message // Create message
final Message message = new MessageBuilder(localDB.getUser().getId(), currentChat.getRecipient().getId(), localDB.getIdGenerator()) final Message message = new MessageBuilder(localDB.getUser().getID(), currentChat.getRecipient().getID(), localDB.getIDGenerator())
.setText(text) .setText(text)
.build(); .build();
sendMessage(message); sendMessage(message);
@ -561,7 +561,7 @@ public class ChatWindow extends JFrame {
*/ */
private void forwardMessage(Message message, User... recipients) { private void forwardMessage(Message message, User... recipients) {
Arrays.stream(recipients).forEach(recipient -> { Arrays.stream(recipients).forEach(recipient -> {
if (message != null && recipients != null) sendMessage(new MessageBuilder(message, recipient.getId(), localDB.getIdGenerator()).build()); if (message != null && recipients != null) sendMessage(new MessageBuilder(message, recipient.getID(), localDB.getIDGenerator()).build());
else throw new NullPointerException("No recipient or no message selected"); else throw new NullPointerException("No recipient or no message selected");
}); });
@ -591,7 +591,7 @@ public class ChatWindow extends JFrame {
repaint(); repaint();
// Request a new id generator if all IDs were used // Request a new id generator if all IDs were used
if (!localDB.getIdGenerator().hasNext()) client.requestIdGenerator(); if (!localDB.getIDGenerator().hasNext()) client.requestIdGenerator();
} catch (Exception e) { } catch (Exception e) {
JOptionPane.showMessageDialog(this, "Error sending message:\n" + e.toString(), "Message sending error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(this, "Error sending message:\n" + e.toString(), "Message sending error", JOptionPane.ERROR_MESSAGE);
@ -646,7 +646,7 @@ public class ChatWindow extends JFrame {
this.localDB = localDB; this.localDB = localDB;
this.writeProxy = writeProxy; this.writeProxy = writeProxy;
messageList.setRenderer((list, message) -> new MessageComponent(list, message, client.getSender().getId())); messageList.setRenderer((list, message) -> new MessageComponent(list, message, client.getSender().getID()));
// Load users and chats // Load users and chats
new Thread(() -> { new Thread(() -> {
@ -654,7 +654,7 @@ public class ChatWindow extends JFrame {
userListModel.addElement(user); userListModel.addElement(user);
// Check if user exists in local DB // Check if user exists in local DB
if (localDB.getChats().stream().noneMatch(c -> c.getRecipient().getId() == user.getId())) localDB.getChats().add(new Chat(user)); if (localDB.getChats().stream().noneMatch(c -> c.getRecipient().getID() == user.getID())) localDB.getChats().add(new Chat(user));
}); });
SwingUtilities.invokeLater(() -> userList.setModel(userListModel)); SwingUtilities.invokeLater(() -> userList.setModel(userListModel));

View File

@ -34,7 +34,7 @@ import envoy.data.User;
*/ */
public class ContactsChooserDialog extends JDialog { public class ContactsChooserDialog extends JDialog {
private static final long serialVersionUID = -5774558118579032256L; private static final long serialVersionUID = 0L;
private ComponentList<User> contactList = new ComponentList<User>().setModel(new Model<User>()) private ComponentList<User> contactList = new ComponentList<User>().setModel(new Model<User>())
.setRenderer((list, user) -> new UserComponent(user)); .setRenderer((list, user) -> new UserComponent(user));
@ -73,10 +73,7 @@ public class ContactsChooserDialog extends JDialog {
dialog.addCancelButtonActionListener(e -> dialog.dispose()); dialog.addCancelButtonActionListener(e -> dialog.dispose());
List<User> results = new ArrayList<>(); List<User> results = new ArrayList<>();
dialog.addOkButtonActionListener(e -> { dialog.addOkButtonActionListener(e -> { results.addAll(dialog.getContactList().getSelectedElements()); dialog.dispose(); });
results.addAll(dialog.getContactList().getSelectedElements());
dialog.dispose();
});
Model<User> contactListModel = dialog.getContactList().getModel(); Model<User> contactListModel = dialog.getContactList().getModel();
users.forEach(contactListModel::add); users.forEach(contactListModel::add);

View File

@ -32,7 +32,7 @@ import envoy.client.ui.Theme;
*/ */
public class ContextMenu extends JPopupMenu { public class ContextMenu extends JPopupMenu {
private static final long serialVersionUID = 2177146471226992104L; private static final long serialVersionUID = 0L;
/** /**
* If a key starts with this String, a {@link JCheckBoxMenuItem} will be created * If a key starts with this String, a {@link JCheckBoxMenuItem} will be created

View File

@ -65,7 +65,7 @@ public class LoginDialog extends JDialog {
private static final ClientConfig config = ClientConfig.getInstance(); private static final ClientConfig config = ClientConfig.getInstance();
private static final Logger logger = EnvoyLog.getLogger(LoginDialog.class); private static final Logger logger = EnvoyLog.getLogger(LoginDialog.class);
private static final long serialVersionUID = 352021600833907468L; private static final long serialVersionUID = 0L;
/** /**
* Displays a dialog enabling the user to enter their user name and password. * Displays a dialog enabling the user to enter their user name and password.
@ -82,7 +82,7 @@ public class LoginDialog extends JDialog {
this.receivedMessageCache = receivedMessageCache; this.receivedMessageCache = receivedMessageCache;
// Prepare handshake // Prepare handshake
localDB.loadIdGenerator(); localDB.loadIDGenerator();
addWindowListener(new WindowAdapter() { addWindowListener(new WindowAdapter() {

View File

@ -29,7 +29,7 @@ public class ComponentList<E> extends JPanel {
private SelectionMode selectionMode = SelectionMode.NONE; private SelectionMode selectionMode = SelectionMode.NONE;
private Set<Integer> selection = new HashSet<>(); private Set<Integer> selection = new HashSet<>();
private static final long serialVersionUID = 1759644503942876737L; private static final long serialVersionUID = 0L;
/** /**
* Defines the possible modes of selection that can be performed by the user * Defines the possible modes of selection that can be performed by the user

View File

@ -24,7 +24,7 @@ import envoy.event.EventBus;
*/ */
public class ContactSearchComponent extends JComponent { public class ContactSearchComponent extends JComponent {
private static final long serialVersionUID = 3166795412575239455L; private static final long serialVersionUID = 0L;
/** /**
* @param list the {@link ComponentList} that is used to display search results * @param list the {@link ComponentList} that is used to display search results

View File

@ -26,7 +26,7 @@ import envoy.data.User;
*/ */
public class MessageComponent extends JPanel { public class MessageComponent extends JPanel {
private static final long serialVersionUID = 103920706139926996L; private static final long serialVersionUID = 0L;
private static EnumMap<MessageStatus, ImageIcon> statusIcons; private static EnumMap<MessageStatus, ImageIcon> statusIcons;
private static ImageIcon forwardIcon; private static ImageIcon forwardIcon;
@ -114,7 +114,7 @@ public class MessageComponent extends JPanel {
} }
// Define an etched border and some space to the messages below // Define an etched border and some space to the messages below
var ours = senderId == message.getSenderId(); var ours = senderId == message.getSenderID();
setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, ours ? padding : 10, 10, ours ? 0 : padding), setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, ours ? padding : 10, 10, ours ? 0 : padding),
BorderFactory.createEtchedBorder())); BorderFactory.createEtchedBorder()));

View File

@ -24,7 +24,7 @@ import envoy.data.User.UserStatus;
*/ */
public class UserComponent extends JPanel { public class UserComponent extends JPanel {
private static final long serialVersionUID = 8450602172939729585L; private static final long serialVersionUID = 0L;
/** /**
* @param user the {@link User} whose information is displayed * @param user the {@link User} whose information is displayed

View File

@ -15,7 +15,7 @@ import javax.swing.JButton;
*/ */
public class PrimaryButton extends JButton { public class PrimaryButton extends JButton {
private static final long serialVersionUID = 3662266120667728364L; private static final long serialVersionUID = 0L;
private int arcSize; private int arcSize;

View File

@ -60,6 +60,9 @@ public class PrimaryScrollBar extends BasicScrollBarUI {
new Color(theme.getInteractableBackgroundColor().getRGB() + 170), isVertical); new Color(theme.getInteractableBackgroundColor().getRGB() + 170), isVertical);
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected JButton createDecreaseButton(int orientation) { protected JButton createDecreaseButton(int orientation) {
JButton button = new JButton(); JButton button = new JButton();
@ -67,6 +70,9 @@ public class PrimaryScrollBar extends BasicScrollBarUI {
return button; return button;
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected JButton createIncreaseButton(int orientation) { protected JButton createIncreaseButton(int orientation) {
JButton button = new JButton(); JButton button = new JButton();
@ -74,9 +80,15 @@ public class PrimaryScrollBar extends BasicScrollBarUI {
return button; return button;
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected void paintTrack(Graphics g, JComponent c, Rectangle r) {} protected void paintTrack(Graphics g, JComponent c, Rectangle r) {}
/**
* {@inheritDoc}
*/
@Override @Override
protected void paintThumb(Graphics g, JComponent c, Rectangle r) { protected void paintThumb(Graphics g, JComponent c, Rectangle r) {
Graphics2D g2 = (Graphics2D) g.create(); Graphics2D g2 = (Graphics2D) g.create();
@ -103,6 +115,9 @@ public class PrimaryScrollBar extends BasicScrollBarUI {
g2.dispose(); g2.dispose();
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected void setThumbBounds(int x, int y, int width, int height) { protected void setThumbBounds(int x, int y, int width, int height) {
super.setThumbBounds(x, y, width, height); super.setThumbBounds(x, y, width, height);

View File

@ -10,18 +10,18 @@ import javax.swing.border.EmptyBorder;
* Project: <strong>envoy-client</strong><br> * Project: <strong>envoy-client</strong><br>
* File: <strong>PrimaryTextArea.javaEvent.java</strong><br> * File: <strong>PrimaryTextArea.javaEvent.java</strong><br>
* Created: <strong>07.12.2019</strong><br> * Created: <strong>07.12.2019</strong><br>
* *
* @author Maximilian K&auml;fer * @author Maximilian K&auml;fer
* @since Envoy Client v0.2-alpha * @since Envoy Client v0.2-alpha
*/ */
public class PrimaryTextArea extends JTextArea { public class PrimaryTextArea extends JTextArea {
private static final long serialVersionUID = -5829028696155434913L; private static final long serialVersionUID = 0L;
private int arcSize; private int arcSize;
/** /**
* Creates the text area * Creates the text area
* *
* @param borderSpace the space between components * @param borderSpace the space between components
* @since Envoy 0.2-alpha * @since Envoy 0.2-alpha
*/ */
@ -29,7 +29,7 @@ public class PrimaryTextArea extends JTextArea {
/** /**
* Creates the text area * Creates the text area
* *
* @param arcSize is the diameter of the arc at the four corners. * @param arcSize is the diameter of the arc at the four corners.
* @param borderSpace is the insets of the border on all four sides. * @param borderSpace is the insets of the border on all four sides.
* @since Envoy 0.2-alpha * @since Envoy 0.2-alpha
@ -46,6 +46,9 @@ public class PrimaryTextArea extends JTextArea {
this.arcSize = arcSize; this.arcSize = arcSize;
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
g.setColor(getBackground()); g.setColor(getBackground());

View File

@ -25,7 +25,7 @@ public class PrimaryToggleSwitch extends JButton {
private boolean state; private boolean state;
private static final long serialVersionUID = -721155303106833184L; private static final long serialVersionUID = 0L;
/** /**
* Initializes a {@link PrimaryToggleSwitch}. * Initializes a {@link PrimaryToggleSwitch}.
@ -47,6 +47,9 @@ public class PrimaryToggleSwitch extends JButton {
addActionListener((evt) -> { state = !state; settingsItem.set(state); revalidate(); repaint(); }); addActionListener((evt) -> { state = !state; settingsItem.set(state); revalidate(); repaint(); });
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
g.setColor(state ? Color.GREEN : Color.LIGHT_GRAY); g.setColor(state ? Color.GREEN : Color.LIGHT_GRAY);

View File

@ -26,6 +26,9 @@ public class UserListRenderer extends JLabel implements ListCellRenderer<User> {
private static final long serialVersionUID = 5164417379767181198L; private static final long serialVersionUID = 5164417379767181198L;
/**
* {@inheritDoc}
*/
@Override @Override
public Component getListCellRendererComponent(JList<? extends User> list, User value, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList<? extends User> list, User value, int index, boolean isSelected, boolean cellHasFocus) {
if (isSelected) { if (isSelected) {

View File

@ -30,7 +30,7 @@ public class GeneralSettingsPanel extends SettingsPanel {
private static final String[] items = { "onCloseMode", "enterToSend" }; private static final String[] items = { "onCloseMode", "enterToSend" };
private static final Logger logger = EnvoyLog.getLogger(GeneralSettingsPanel.class); private static final Logger logger = EnvoyLog.getLogger(GeneralSettingsPanel.class);
private static final long serialVersionUID = -7470848775130754239L; private static final long serialVersionUID = 0L;
/** /**
* This is the constructor for the General class. Here the user can set general * This is the constructor for the General class. Here the user can set general

View File

@ -36,7 +36,7 @@ public class NewThemeScreen extends JDialog {
private final Consumer<String> newThemeAction, modifyThemeAction; private final Consumer<String> newThemeAction, modifyThemeAction;
private static final long serialVersionUID = 2369985550946300976L; private static final long serialVersionUID = 0L;
/** /**
* Creates a window, where you can choose a name for a new {@link Theme}. <br> * Creates a window, where you can choose a name for a new {@link Theme}. <br>

View File

@ -18,7 +18,7 @@ public abstract class SettingsPanel extends JPanel {
protected final SettingsScreen parent; protected final SettingsScreen parent;
private static final long serialVersionUID = -3069212622468626050L; private static final long serialVersionUID = 0L;
/** /**
* Initializes a {@link SettingsPanel}. * Initializes a {@link SettingsPanel}.

View File

@ -30,7 +30,7 @@ import envoy.util.EnvoyLog;
*/ */
public class SettingsScreen extends JDialog { public class SettingsScreen extends JDialog {
private static final long serialVersionUID = -4476913491263077107L; private static final long serialVersionUID = 0L;
private final JPanel contentPanel = new JPanel(); private final JPanel contentPanel = new JPanel();

View File

@ -39,7 +39,7 @@ public class ThemeCustomizationPanel extends SettingsPanel {
private final Insets insets = new Insets(5, 5, 5, 5); private final Insets insets = new Insets(5, 5, 5, 5);
private static final Logger logger = EnvoyLog.getLogger(ThemeCustomizationPanel.class); private static final Logger logger = EnvoyLog.getLogger(ThemeCustomizationPanel.class);
private static final long serialVersionUID = -8697897390666456624L; private static final long serialVersionUID = 0L;
/** /**
* Initializes a {@link ThemeCustomizationPanel} that enables the user to change * Initializes a {@link ThemeCustomizationPanel} that enables the user to change
@ -135,7 +135,7 @@ public class ThemeCustomizationPanel extends SettingsPanel {
gbc_createThemeButton.anchor = GridBagConstraints.CENTER; gbc_createThemeButton.anchor = GridBagConstraints.CENTER;
gbc_createThemeButton.insets = insets; gbc_createThemeButton.insets = insets;
add(createThemeButton, gbc_createThemeButton); add(createThemeButton, gbc_createThemeButton);
colorsPanel.setBackground(theme.getCellColor()); colorsPanel.setBackground(theme.getCellColor());
// Apply theme upon selection // Apply theme upon selection
@ -169,7 +169,7 @@ public class ThemeCustomizationPanel extends SettingsPanel {
// createThemeButton // createThemeButton
createThemeButton.setForeground(theme.getInteractableForegroundColor()); createThemeButton.setForeground(theme.getInteractableForegroundColor());
createThemeButton.setBackground(theme.getInteractableBackgroundColor()); createThemeButton.setBackground(theme.getInteractableBackgroundColor());
// themes // themes
themes.setBackground(theme.getInteractableBackgroundColor()); themes.setBackground(theme.getInteractableBackgroundColor());
themes.setForeground(theme.getInteractableForegroundColor()); themes.setForeground(theme.getInteractableForegroundColor());