Renamed every identifier according to new convention
This commit is contained in:
		@@ -25,7 +25,7 @@ public class Cache<T> implements Consumer<T>, Serializable {
 | 
			
		||||
	private transient Consumer<T>	processor;
 | 
			
		||||
 | 
			
		||||
	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.
 | 
			
		||||
 
 | 
			
		||||
@@ -25,9 +25,9 @@ import envoy.event.MessageStatusChangeEvent;
 | 
			
		||||
 */
 | 
			
		||||
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<>();
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -61,7 +61,7 @@ public class Chat implements Serializable {
 | 
			
		||||
	public void read(WriteProxy writeProxy) throws IOException {
 | 
			
		||||
		for (int i = model.size() - 1; i >= 0; --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 {
 | 
			
		||||
				m.setStatus(MessageStatus.READ);
 | 
			
		||||
				writeProxy.writeMessageStatusChangeEvent(new MessageStatusChangeEvent(m));
 | 
			
		||||
 
 | 
			
		||||
@@ -2,14 +2,14 @@ package envoy.client.data;
 | 
			
		||||
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
import envoy.data.IdGenerator;
 | 
			
		||||
import envoy.data.IDGenerator;
 | 
			
		||||
import envoy.data.Message;
 | 
			
		||||
import envoy.data.User;
 | 
			
		||||
import envoy.event.MessageStatusChangeEvent;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 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>
 | 
			
		||||
 * Project: <strong>envoy-client</strong><br>
 | 
			
		||||
 * File: <strong>LocalDB.java</strong><br>
 | 
			
		||||
@@ -23,7 +23,7 @@ public abstract class LocalDB {
 | 
			
		||||
	protected User								user;
 | 
			
		||||
	protected Map<String, User>					users			= new HashMap<>();
 | 
			
		||||
	protected List<Chat>						chats			= new ArrayList<>();
 | 
			
		||||
	protected IdGenerator						idGenerator;
 | 
			
		||||
	protected IDGenerator						idGenerator;
 | 
			
		||||
	protected Cache<Message>					messageCache	= new Cache<>();
 | 
			
		||||
	protected Cache<MessageStatusChangeEvent>	statusCache		= new Cache<>();
 | 
			
		||||
 | 
			
		||||
@@ -64,7 +64,7 @@ public abstract class LocalDB {
 | 
			
		||||
	 *
 | 
			
		||||
	 * @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
 | 
			
		||||
@@ -106,19 +106,19 @@ public abstract class LocalDB {
 | 
			
		||||
	 * @return the message ID generator
 | 
			
		||||
	 * @since Envoy Client v0.3-alpha
 | 
			
		||||
	 */
 | 
			
		||||
	public IdGenerator getIdGenerator() { return idGenerator; }
 | 
			
		||||
	public IDGenerator getIDGenerator() { return idGenerator; }
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * @param idGenerator the message ID generator to set
 | 
			
		||||
	 * @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
 | 
			
		||||
	 */
 | 
			
		||||
	public boolean hasIdGenerator() { return idGenerator != null; }
 | 
			
		||||
	public boolean hasIDGenerator() { return idGenerator != null; }
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * @return the offline message cache
 | 
			
		||||
@@ -146,7 +146,7 @@ public abstract class LocalDB {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Searches for a message by ID.
 | 
			
		||||
	 * 
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param id the ID of the message to search for
 | 
			
		||||
	 * @return the message with the corresponding ID, or {@code null} if no message
 | 
			
		||||
	 *         has been found
 | 
			
		||||
@@ -155,7 +155,7 @@ public abstract class LocalDB {
 | 
			
		||||
	public Message getMessage(long id) {
 | 
			
		||||
		for (Chat c : chats)
 | 
			
		||||
			for (Message m : c.getModel())
 | 
			
		||||
				if (m.getId() == id) return m;
 | 
			
		||||
				if (m.getID() == id) return m;
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ import java.util.ArrayList;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
 | 
			
		||||
import envoy.data.ConfigItem;
 | 
			
		||||
import envoy.data.IdGenerator;
 | 
			
		||||
import envoy.data.IDGenerator;
 | 
			
		||||
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
 | 
			
		||||
	 * @since Envoy Client v0.1-alpha
 | 
			
		||||
@@ -63,11 +64,14 @@ public class PersistentLocalDB extends LocalDB {
 | 
			
		||||
	@Override
 | 
			
		||||
	public void initializeUserStorage() {
 | 
			
		||||
		if (user == null) throw new NullPointerException("Client user is null");
 | 
			
		||||
		localDBFile			= new File(localDBDir, user.getId() + ".db");
 | 
			
		||||
		messageCacheFile	= new File(localDBDir, user.getId() + "_message_cache.db");
 | 
			
		||||
		statusCacheFile		= new File(localDBDir, user.getId() + "_status_cache.db");
 | 
			
		||||
		localDBFile			= new File(localDBDir, user.getID() + ".db");
 | 
			
		||||
		messageCacheFile	= new File(localDBDir, user.getID() + "_message_cache.db");
 | 
			
		||||
		statusCacheFile		= new File(localDBDir, user.getID() + "_status_cache.db");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void save() throws IOException {
 | 
			
		||||
		// Save users
 | 
			
		||||
@@ -81,12 +85,18 @@ public class PersistentLocalDB extends LocalDB {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Save id generator
 | 
			
		||||
		if (hasIdGenerator()) SerializationUtils.write(idGeneratorFile, idGenerator);
 | 
			
		||||
		if (hasIDGenerator()) SerializationUtils.write(idGeneratorFile, idGenerator);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void loadUsers() throws ClassNotFoundException, IOException { users = SerializationUtils.read(usersFile, HashMap.class); }
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void loadUserData() throws ClassNotFoundException, IOException {
 | 
			
		||||
		chats			= SerializationUtils.read(localDBFile, ArrayList.class);
 | 
			
		||||
@@ -94,10 +104,13 @@ public class PersistentLocalDB extends LocalDB {
 | 
			
		||||
		statusCache		= SerializationUtils.read(statusCacheFile, Cache.class);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void loadIdGenerator() {
 | 
			
		||||
	public void loadIDGenerator() {
 | 
			
		||||
		try {
 | 
			
		||||
			idGenerator = SerializationUtils.read(idGeneratorFile, IdGenerator.class);
 | 
			
		||||
			idGenerator = SerializationUtils.read(idGeneratorFile, IDGenerator.class);
 | 
			
		||||
		} catch (ClassNotFoundException | IOException e) {}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ import envoy.client.ui.primary.PrimaryToggleSwitch;
 | 
			
		||||
 * Project: <strong>envoy-clientChess</strong><br>
 | 
			
		||||
 * File: <strong>SettingsItem.java</strong><br>
 | 
			
		||||
 * Created: <strong>23.12.2019</strong><br>
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * @param <T> the type of this {@link SettingsItem}'s value
 | 
			
		||||
 * @author Kai S. K. Engelbart
 | 
			
		||||
 * @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 long serialVersionUID = 2146837835556852218L;
 | 
			
		||||
	private static final long serialVersionUID = 0L;
 | 
			
		||||
 | 
			
		||||
	static {
 | 
			
		||||
		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
 | 
			
		||||
	 * to a {@link JComponent} that can be used to display this {@link SettingsItem}
 | 
			
		||||
	 * to the user.
 | 
			
		||||
	 * 
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param value            the default value
 | 
			
		||||
	 * @param userFriendlyName the user friendly name (short)
 | 
			
		||||
	 * @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
 | 
			
		||||
	 * parameter is {@code null}. In that case a {@link NullPointerException} will
 | 
			
		||||
	 * be thrown if the method {@link SettingsItem#getComponent()} is called.
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param value the default value
 | 
			
		||||
	 * @param componentClass the class of the {@link JComponent} to represent this {@link SettingsItem} with
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param value          the default value
 | 
			
		||||
	 * @param componentClass the class of the {@link JComponent} to represent this
 | 
			
		||||
	 *                       {@link SettingsItem} with
 | 
			
		||||
	 * @since Envoy Client v0.3-alpha
 | 
			
		||||
	 */
 | 
			
		||||
	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 SecurityException if the component initialization failed
 | 
			
		||||
	 * @throws SecurityException            if the component initialization failed
 | 
			
		||||
	 * @since Envoy Client v0.3-alpha
 | 
			
		||||
	 */
 | 
			
		||||
	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
 | 
			
		||||
	 * defined, it will be invoked with this value.
 | 
			
		||||
	 * 
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param value the value to set
 | 
			
		||||
	 * @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
 | 
			
		||||
	 * invoked with the current value once during the registration and every time
 | 
			
		||||
	 * when the value changes.
 | 
			
		||||
	 * 
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param changeHandler the changeHandler to set
 | 
			
		||||
	 * @since Envoy Client v0.3-alpha
 | 
			
		||||
	 */
 | 
			
		||||
 
 | 
			
		||||
@@ -14,5 +14,5 @@ import envoy.event.Event;
 | 
			
		||||
 */
 | 
			
		||||
public class HandshakeSuccessfulEvent extends Event.Valueless {
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = -157972384126278855L;
 | 
			
		||||
	private static final long serialVersionUID = 0L;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ import envoy.event.Event;
 | 
			
		||||
 */
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ import envoy.event.Event;
 | 
			
		||||
 */
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
@@ -6,14 +6,14 @@ import envoy.event.Event;
 | 
			
		||||
 * Project: <strong>envoy-client</strong><br>
 | 
			
		||||
 * File: <strong>SendEvent.java</strong><br>
 | 
			
		||||
 * Created: <strong>11.02.2020</strong><br>
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * @author: Maximilian Käfer
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * @since Envoy Client v0.3-alpha
 | 
			
		||||
 */
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ import envoy.event.Event;
 | 
			
		||||
 */
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
@@ -118,11 +118,11 @@ public class Client implements Closeable {
 | 
			
		||||
	 * this client.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param localDB              the local database used to persist the current
 | 
			
		||||
	 *                             {@link IdGenerator}
 | 
			
		||||
	 *                             {@link IDGenerator}
 | 
			
		||||
	 * @param receivedMessageCache a message cache containing all unread messages
 | 
			
		||||
	 *                             from the server that can be relayed after
 | 
			
		||||
	 *                             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
 | 
			
		||||
	 * @since Envoy Client v0.2-alpha
 | 
			
		||||
	 */
 | 
			
		||||
@@ -143,7 +143,7 @@ public class Client implements Closeable {
 | 
			
		||||
		receiver.registerProcessor(UserStatusChangeEvent.class, new UserStatusChangeProcessor(localDB));
 | 
			
		||||
 | 
			
		||||
		// Process message ID generation
 | 
			
		||||
		receiver.registerProcessor(IdGenerator.class, localDB::setIdGenerator);
 | 
			
		||||
		receiver.registerProcessor(IDGenerator.class, localDB::setIDGenerator);
 | 
			
		||||
 | 
			
		||||
		// Process contact searches
 | 
			
		||||
		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
 | 
			
		||||
		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); }
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 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
 | 
			
		||||
	 * @since Envoy Client v0.3-alpha
 | 
			
		||||
	 */
 | 
			
		||||
	public void requestIdGenerator() throws IOException {
 | 
			
		||||
		logger.info("Requesting new id generator...");
 | 
			
		||||
		writeObject(new IdGeneratorRequest());
 | 
			
		||||
		writeObject(new IDGeneratorRequest());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ public class UserStatusChangeProcessor implements Consumer<UserStatusChangeEvent
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	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);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -48,8 +48,8 @@ public class WriteProxy {
 | 
			
		||||
				logger.finer("Sending cached " + msg);
 | 
			
		||||
				client.sendMessage(msg);
 | 
			
		||||
 | 
			
		||||
				// Update message state to SENT in local db
 | 
			
		||||
				localDB.getMessage(msg.getId()).nextStatus();
 | 
			
		||||
				// Update message state to SENT in localDB
 | 
			
		||||
				localDB.getMessage(msg.getID()).nextStatus();
 | 
			
		||||
			} catch (IOException e) {
 | 
			
		||||
				logger.log(Level.SEVERE, "Could not send cached message", e);
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ import javax.swing.*;
 | 
			
		||||
 */
 | 
			
		||||
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
 | 
			
		||||
@@ -137,11 +137,9 @@ public class ContextMenu extends JPopupMenu {
 | 
			
		||||
 | 
			
		||||
			private void action(MouseEvent e) {
 | 
			
		||||
				if (!built) build();
 | 
			
		||||
				if (e.isPopupTrigger()) {
 | 
			
		||||
					// hides the menu if already visible
 | 
			
		||||
				if (e.isPopupTrigger()) // hides the menu if already visible
 | 
			
		||||
					if (!isVisible()) show(e.getComponent(), e.getX(), e.getY());
 | 
			
		||||
					else setVisible(false);
 | 
			
		||||
				}
 | 
			
		||||
				else setVisible(false);
 | 
			
		||||
			}
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ import java.util.Map;
 | 
			
		||||
 */
 | 
			
		||||
public class Theme implements Serializable {
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = 141727847527060352L;
 | 
			
		||||
	private static final long serialVersionUID = 0L;
 | 
			
		||||
 | 
			
		||||
	private String				themeName;
 | 
			
		||||
	private Map<String, Color>	colors	= new HashMap<>();
 | 
			
		||||
 
 | 
			
		||||
@@ -97,7 +97,7 @@ public class ChatWindow extends JFrame {
 | 
			
		||||
	private final static int	space	= 4;
 | 
			
		||||
	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
 | 
			
		||||
@@ -250,7 +250,7 @@ public class ChatWindow extends JFrame {
 | 
			
		||||
					if (contentPane.getComponent(i).equals(searchPane)) drawChatBox(gbc_scrollPane);
 | 
			
		||||
				if (user != null) {
 | 
			
		||||
					// 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
 | 
			
		||||
					readCurrentChat();
 | 
			
		||||
@@ -412,7 +412,7 @@ public class ChatWindow extends JFrame {
 | 
			
		||||
		// Listen to received messages
 | 
			
		||||
		EventBus.getInstance().register(MessageCreationEvent.class, evt -> {
 | 
			
		||||
			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);
 | 
			
		||||
 | 
			
		||||
			// Read message and update UI if in current chat
 | 
			
		||||
@@ -424,12 +424,12 @@ public class ChatWindow extends JFrame {
 | 
			
		||||
 | 
			
		||||
		// Listen to message status changes
 | 
			
		||||
		EventBus.getInstance().register(MessageStatusChangeEvent.class, evt -> {
 | 
			
		||||
			final long			id		= evt.getId();
 | 
			
		||||
			final long			id		= evt.getID();
 | 
			
		||||
			final MessageStatus	status	= evt.get();
 | 
			
		||||
 | 
			
		||||
			for (Chat c : localDB.getChats())
 | 
			
		||||
				for (Message m : c.getModel())
 | 
			
		||||
					if (m.getId() == id) {
 | 
			
		||||
					if (m.getID() == id) {
 | 
			
		||||
 | 
			
		||||
						// Update message status
 | 
			
		||||
						m.setStatus(status);
 | 
			
		||||
@@ -543,7 +543,7 @@ public class ChatWindow extends JFrame {
 | 
			
		||||
		if (!text.isEmpty()) checkMessageTextLength();
 | 
			
		||||
 | 
			
		||||
		// 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)
 | 
			
		||||
			.build();
 | 
			
		||||
		sendMessage(message);
 | 
			
		||||
@@ -561,7 +561,7 @@ public class ChatWindow extends JFrame {
 | 
			
		||||
	 */
 | 
			
		||||
	private void forwardMessage(Message message, User... recipients) {
 | 
			
		||||
		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");
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
@@ -591,7 +591,7 @@ public class ChatWindow extends JFrame {
 | 
			
		||||
			repaint();
 | 
			
		||||
 | 
			
		||||
			// 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) {
 | 
			
		||||
			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.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
 | 
			
		||||
		new Thread(() -> {
 | 
			
		||||
@@ -654,7 +654,7 @@ public class ChatWindow extends JFrame {
 | 
			
		||||
				userListModel.addElement(user);
 | 
			
		||||
 | 
			
		||||
				// 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));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@ import envoy.data.User;
 | 
			
		||||
 */
 | 
			
		||||
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>())
 | 
			
		||||
		.setRenderer((list, user) -> new UserComponent(user));
 | 
			
		||||
@@ -73,10 +73,7 @@ public class ContactsChooserDialog extends JDialog {
 | 
			
		||||
		dialog.addCancelButtonActionListener(e -> dialog.dispose());
 | 
			
		||||
 | 
			
		||||
		List<User> results = new ArrayList<>();
 | 
			
		||||
		dialog.addOkButtonActionListener(e -> { 
 | 
			
		||||
			results.addAll(dialog.getContactList().getSelectedElements());
 | 
			
		||||
			dialog.dispose();
 | 
			
		||||
		});
 | 
			
		||||
		dialog.addOkButtonActionListener(e -> { results.addAll(dialog.getContactList().getSelectedElements()); dialog.dispose(); });
 | 
			
		||||
		Model<User> contactListModel = dialog.getContactList().getModel();
 | 
			
		||||
		users.forEach(contactListModel::add);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ import envoy.client.ui.Theme;
 | 
			
		||||
 */
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
@@ -65,7 +65,7 @@ public class LoginDialog extends JDialog {
 | 
			
		||||
 | 
			
		||||
	private static final ClientConfig	config				= ClientConfig.getInstance();
 | 
			
		||||
	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.
 | 
			
		||||
@@ -82,7 +82,7 @@ public class LoginDialog extends JDialog {
 | 
			
		||||
		this.receivedMessageCache	= receivedMessageCache;
 | 
			
		||||
 | 
			
		||||
		// Prepare handshake
 | 
			
		||||
		localDB.loadIdGenerator();
 | 
			
		||||
		localDB.loadIDGenerator();
 | 
			
		||||
 | 
			
		||||
		addWindowListener(new WindowAdapter() {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ public class ComponentList<E> extends JPanel {
 | 
			
		||||
	private SelectionMode		selectionMode	= SelectionMode.NONE;
 | 
			
		||||
	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
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ import envoy.event.EventBus;
 | 
			
		||||
 */
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ import envoy.data.User;
 | 
			
		||||
 */
 | 
			
		||||
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 ImageIcon							forwardIcon;
 | 
			
		||||
@@ -114,7 +114,7 @@ public class MessageComponent extends JPanel {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// 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),
 | 
			
		||||
				BorderFactory.createEtchedBorder()));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ import envoy.data.User.UserStatus;
 | 
			
		||||
 */
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ import javax.swing.JButton;
 | 
			
		||||
 */
 | 
			
		||||
public class PrimaryButton extends JButton {
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = 3662266120667728364L;
 | 
			
		||||
	private static final long serialVersionUID = 0L;
 | 
			
		||||
 | 
			
		||||
	private int arcSize;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -60,6 +60,9 @@ public class PrimaryScrollBar extends BasicScrollBarUI {
 | 
			
		||||
				new Color(theme.getInteractableBackgroundColor().getRGB() + 170), isVertical);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	protected JButton createDecreaseButton(int orientation) {
 | 
			
		||||
		JButton button = new JButton();
 | 
			
		||||
@@ -67,6 +70,9 @@ public class PrimaryScrollBar extends BasicScrollBarUI {
 | 
			
		||||
		return button;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	protected JButton createIncreaseButton(int orientation) {
 | 
			
		||||
		JButton button = new JButton();
 | 
			
		||||
@@ -74,9 +80,15 @@ public class PrimaryScrollBar extends BasicScrollBarUI {
 | 
			
		||||
		return button;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void paintTrack(Graphics g, JComponent c, Rectangle r) {}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void paintThumb(Graphics g, JComponent c, Rectangle r) {
 | 
			
		||||
		Graphics2D g2 = (Graphics2D) g.create();
 | 
			
		||||
@@ -103,6 +115,9 @@ public class PrimaryScrollBar extends BasicScrollBarUI {
 | 
			
		||||
		g2.dispose();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void setThumbBounds(int x, int y, int width, int height) {
 | 
			
		||||
		super.setThumbBounds(x, y, width, height);
 | 
			
		||||
 
 | 
			
		||||
@@ -10,18 +10,18 @@ import javax.swing.border.EmptyBorder;
 | 
			
		||||
 * Project: <strong>envoy-client</strong><br>
 | 
			
		||||
 * File: <strong>PrimaryTextArea.javaEvent.java</strong><br>
 | 
			
		||||
 * Created: <strong>07.12.2019</strong><br>
 | 
			
		||||
 * 
 | 
			
		||||
 *
 | 
			
		||||
 * @author Maximilian Käfer
 | 
			
		||||
 * @since Envoy Client v0.2-alpha
 | 
			
		||||
 */
 | 
			
		||||
public class PrimaryTextArea extends JTextArea {
 | 
			
		||||
 | 
			
		||||
	private static final long	serialVersionUID	= -5829028696155434913L;
 | 
			
		||||
	private static final long	serialVersionUID	= 0L;
 | 
			
		||||
	private int					arcSize;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Creates the text area
 | 
			
		||||
	 * 
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param borderSpace the space between components
 | 
			
		||||
	 * @since Envoy 0.2-alpha
 | 
			
		||||
	 */
 | 
			
		||||
@@ -29,7 +29,7 @@ public class PrimaryTextArea extends JTextArea {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Creates the text area
 | 
			
		||||
	 * 
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param arcSize     is the diameter of the arc at the four corners.
 | 
			
		||||
	 * @param borderSpace is the insets of the border on all four sides.
 | 
			
		||||
	 * @since Envoy 0.2-alpha
 | 
			
		||||
@@ -46,6 +46,9 @@ public class PrimaryTextArea extends JTextArea {
 | 
			
		||||
		this.arcSize = arcSize;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void paintComponent(Graphics g) {
 | 
			
		||||
		g.setColor(getBackground());
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ public class PrimaryToggleSwitch extends JButton {
 | 
			
		||||
 | 
			
		||||
	private boolean state;
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = -721155303106833184L;
 | 
			
		||||
	private static final long serialVersionUID = 0L;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Initializes a {@link PrimaryToggleSwitch}.
 | 
			
		||||
@@ -47,6 +47,9 @@ public class PrimaryToggleSwitch extends JButton {
 | 
			
		||||
		addActionListener((evt) -> { state = !state; settingsItem.set(state); revalidate(); repaint(); });
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public void paintComponent(Graphics g) {
 | 
			
		||||
		g.setColor(state ? Color.GREEN : Color.LIGHT_GRAY);
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,9 @@ public class UserListRenderer extends JLabel implements ListCellRenderer<User> {
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = 5164417379767181198L;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * {@inheritDoc}
 | 
			
		||||
	 */
 | 
			
		||||
	@Override
 | 
			
		||||
	public Component getListCellRendererComponent(JList<? extends User> list, User value, int index, boolean isSelected, boolean cellHasFocus) {
 | 
			
		||||
		if (isSelected) {
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ public class GeneralSettingsPanel extends SettingsPanel {
 | 
			
		||||
 | 
			
		||||
	private static final String[]	items				= { "onCloseMode", "enterToSend" };
 | 
			
		||||
	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
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ public class NewThemeScreen extends JDialog {
 | 
			
		||||
 | 
			
		||||
	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>
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ public abstract class SettingsPanel extends JPanel {
 | 
			
		||||
 | 
			
		||||
	protected final SettingsScreen parent;
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = -3069212622468626050L;
 | 
			
		||||
	private static final long serialVersionUID = 0L;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Initializes a {@link SettingsPanel}.
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ import envoy.util.EnvoyLog;
 | 
			
		||||
 */
 | 
			
		||||
public class SettingsScreen extends JDialog {
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = -4476913491263077107L;
 | 
			
		||||
	private static final long serialVersionUID = 0L;
 | 
			
		||||
 | 
			
		||||
	private final JPanel contentPanel = new JPanel();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ public class ThemeCustomizationPanel extends SettingsPanel {
 | 
			
		||||
	private final Insets	insets	= new Insets(5, 5, 5, 5);
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
@@ -135,7 +135,7 @@ public class ThemeCustomizationPanel extends SettingsPanel {
 | 
			
		||||
		gbc_createThemeButton.anchor	= GridBagConstraints.CENTER;
 | 
			
		||||
		gbc_createThemeButton.insets	= insets;
 | 
			
		||||
		add(createThemeButton, gbc_createThemeButton);
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		colorsPanel.setBackground(theme.getCellColor());
 | 
			
		||||
 | 
			
		||||
		// Apply theme upon selection
 | 
			
		||||
@@ -169,7 +169,7 @@ public class ThemeCustomizationPanel extends SettingsPanel {
 | 
			
		||||
		// createThemeButton
 | 
			
		||||
		createThemeButton.setForeground(theme.getInteractableForegroundColor());
 | 
			
		||||
		createThemeButton.setBackground(theme.getInteractableBackgroundColor());
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		// themes
 | 
			
		||||
		themes.setBackground(theme.getInteractableBackgroundColor());
 | 
			
		||||
		themes.setForeground(theme.getInteractableForegroundColor());
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user