diff --git a/.classpath b/.classpath index 906bfce..8bcb665 100644 --- a/.classpath +++ b/.classpath @@ -28,5 +28,11 @@ + + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 262bd4f..4d86470 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -8,10 +8,18 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.problem.APILeak=warning org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning @@ -21,6 +29,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod= org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled @@ -33,12 +42,25 @@ org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=info +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=info +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=info +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning @@ -61,8 +83,8 @@ org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore @@ -74,7 +96,7 @@ org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore @@ -95,7 +117,7 @@ org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled diff --git a/src/main/java/envoy/client/Chat.java b/src/main/java/envoy/client/Chat.java index da35bd3..4f13cee 100644 --- a/src/main/java/envoy/client/Chat.java +++ b/src/main/java/envoy/client/Chat.java @@ -7,6 +7,19 @@ import javax.swing.DefaultListModel; import envoy.schema.Message; import envoy.schema.User; +/** + * Represents a chat between two {@link User}s
+ * as a list of {@link Message} objects. + *
+ * Project: envoy-client
+ * File: Chat.java
+ * Created: 19 Oct 2019
+ * + * @author Maximilian Käfer + * @author Leon Hofmeister + * @author Kai S. K. Engelbart + * @since Envoy v0.1-alpha + */ public class Chat implements Serializable { private static final long serialVersionUID = -7751248474547242056L; @@ -17,7 +30,7 @@ public class Chat implements Serializable { /** * Provides the list of messages that the recipient receives.
* Saves the Messages in the corresponding chat at that Point. - * + * * @param recipient the user who receives the messages * @since Envoy v0.1-alpha */ @@ -31,7 +44,7 @@ public class Chat implements Serializable { /** * Adds the received message at the current Point in the current chat - * + * * @param message the message to add in said chat * @since Envoy v0.1-alpha */ diff --git a/src/main/java/envoy/client/Config.java b/src/main/java/envoy/client/Config.java index 0c3a000..ca86a33 100644 --- a/src/main/java/envoy/client/Config.java +++ b/src/main/java/envoy/client/Config.java @@ -6,10 +6,15 @@ import java.util.Properties; import envoy.exception.EnvoyException; /** + * Manages all application settings that are set during application startup by + * either loading them from the {@link Properties} file + * {@code client.properties} or parsing them from the command line arguments of + * the application.
+ *
* Project: envoy-client
* File: Config.java
* Created: 12 Oct 2019
- * + * * @author Kai S. K. Engelbart * @since Envoy v0.1-alpha */ @@ -24,6 +29,10 @@ public class Config { private Config() {} + /** + * @return the singleton instance of the {@link Config} + * @since Envoy v0.1-alpha + */ public static Config getInstance() { if (config == null) config = new Config(); return config; @@ -34,7 +43,7 @@ public class Config { * This file contains information about * the server and port, as well as the path to the local * database and the synchronization timeout - * + * * @throws EnvoyException if the {@code client.properties} file could not be * loaded * @since Envoy v0.1-alpha @@ -56,7 +65,7 @@ public class Config { /** * Sets the server, port and localDB path via command line properties --server / * -s, --port / -p and --localDB / -db. - * + * * @param args the command line arguments to parse * @throws EnvoyException if the command line arguments contain an unknown token * @since Envoy v0.1-alpha @@ -96,7 +105,7 @@ public class Config { /** * Changes the default server host name. * Exclusively intended for development purposes. - * + * * @param server the host name of the Envoy server * @since Envoy v0.1-alpha */ @@ -111,7 +120,7 @@ public class Config { /** * Changes the default port. * Exclusively intended for development purposes. - * + * * @param port the port where an Envoy server is located * @since Envoy v0.1-alpha */ @@ -143,5 +152,4 @@ public class Config { * @since Envoy v0.1-alpha */ public void setSyncTimeout(int syncTimeout) { this.syncTimeout = syncTimeout; } - } diff --git a/src/main/java/envoy/client/LocalDB.java b/src/main/java/envoy/client/LocalDB.java index 61e7461..8c6a40b 100644 --- a/src/main/java/envoy/client/LocalDB.java +++ b/src/main/java/envoy/client/LocalDB.java @@ -56,7 +56,7 @@ public class LocalDB { * system, call {@link LocalDB#initializeDBFile()}. * * @param localDBDir the directory in which to store users and chats - * @throws IOException if the LocalDB could not be initialised + * @throws IOException if the LocalDB could not be initialized * @since Envoy v0.1-alpha */ public LocalDB(File localDBDir) throws IOException { @@ -102,7 +102,7 @@ public class LocalDB { /** * Loads all users that are stored in the local database. - * + * * @throws EnvoyException if the loading process failed * @since Envoy v0.2-alpha */ @@ -170,7 +170,7 @@ public class LocalDB { /** * Creates a {@link Sync} object filled with the changes that occurred to the * local database since the last synchronization. - * + * * @param userId the ID of the user that is synchronized by this client * @return {@link Sync} object filled with the current changes * @since Envoy v0.1-alpha @@ -187,7 +187,7 @@ public class LocalDB { /** * Applies the changes carried by a {@link Sync} object to the local database - * + * * @param returnSync the {@link Sync} object to apply * @since Envoy v0.1-alpha */ diff --git a/src/main/java/envoy/client/Settings.java b/src/main/java/envoy/client/Settings.java index ea789c8..75a4355 100644 --- a/src/main/java/envoy/client/Settings.java +++ b/src/main/java/envoy/client/Settings.java @@ -14,10 +14,14 @@ import java.util.prefs.Preferences; import envoy.client.ui.Theme; /** + * Manages all application settings, which are different objects that can be + * changed during runtime and serialized them by using either the file system or + * the {@link Preferences} API.
+ *
* Project: envoy-client
* File: Settings.java
* Created: 11 Nov 2019
- * + * * @author Leon Hofmeister * @author Maximilian Käfer * @author Kai S. K. Engelbart @@ -48,14 +52,14 @@ public class Settings { /** * The way to instantiate the settings. * Is set to private to deny other instances of that object. - * + * * @since Envoy v0.2-alpha */ private Settings() { load(); } /** * This method is used to ensure that there is only one instance of Settings. - * + * * @return the instance of Settings * @since Envoy v0.2-alpha */ @@ -87,8 +91,9 @@ public class Settings { /** * Updates the preferences when the save button is clicked. - * - * @throws IOException if something went wrong while saving + * + * @throws IOException if an error occurs while saving the themes to the theme + * file * @since Envoy v0.2-alpha */ public void save() throws IOException { @@ -103,56 +108,55 @@ public class Settings { } /** - * adds new theme to the theme map and sets current theme to the new theme. - * - * @param theme the theme to add + * Adds new theme to the theme map. + * + * @param theme the {@link Theme} to add * @since Envoy v0.2-alpha */ - public void addNewThemeToMap(Theme theme) { - settings.getThemes().put(theme.getThemeName(), theme); - // currentTheme = theme.getThemeName(); - } + public void addNewThemeToMap(Theme theme) { settings.getThemes().put(theme.getThemeName(), theme); } /** - * @return the name of the current theme + * @return the name of the currently active {@link Theme} * @since Envoy v0.2-alpha */ public String getCurrentTheme() { return currentTheme; } /** - * Sets the currentTheme - * - * @param themeName the name of the new current theme + * Sets the name of the current {@link Theme}. + * + * @param themeName the name to set * @since Envoy v0.2-alpha */ public void setCurrentTheme(String themeName) { currentTheme = themeName; } /** - * @return true, if "enter" suffices to send a message, else it has to be "ctrl" - * + "enter" + * @return {@code true}, if pressing the {@code Enter} key suffices to send a + * message. Otherwise it has to be pressed in conjunction with the + * {@code Control} key. * @since Envoy v0.2-alpha */ public boolean isEnterToSend() { return enterToSend; } /** - * Change mode of posting a message via Keystroke. - * - * @param enterToSend if true, "enter" suffices to send a message,
- * else it has to be "ctrl" + "enter" + * Changes the keystrokes performed by the user to send a message. + * + * @param enterToSend If set to {@code true} a message can be sent by pressing + * the {@code Enter} key. Otherwise it has to be pressed in + * conjunction with the {@code Control} key. * @since Envoy v0.2-alpha */ public void setEnterToSend(boolean enterToSend) { this.enterToSend = enterToSend; } /** - * @return the map of all themes + * @return a {@code Map} of all themes with their names as keys * @since Envoy v0.2-alpha */ public Map getThemes() { return themes; } /** - * Sets the map of all themes - * - * @param themes a map(String, Theme) of all themes + * Sets the {@code Map} of all themes with their names as keys + * + * @param themes the theme map to set * @since Envoy v0.2-alpha */ public void setThemes(Map themes) { this.themes = themes; } diff --git a/src/main/java/envoy/client/event/MessageEvent.java b/src/main/java/envoy/client/event/MessageEvent.java index 014a7bb..2e818e5 100644 --- a/src/main/java/envoy/client/event/MessageEvent.java +++ b/src/main/java/envoy/client/event/MessageEvent.java @@ -13,6 +13,13 @@ public class MessageEvent implements Event { protected final Message message; + /** + * Initializes a {@link MessageEvent} conveying information about a + * {@link Message} object. + * + * @param message the {@link Message} object to attach to this event + * @since Envoy v0.2-alpha + */ public MessageEvent(Message message) { this.message = message; } @Override diff --git a/src/main/java/envoy/client/event/ThemeChangeEvent.java b/src/main/java/envoy/client/event/ThemeChangeEvent.java index d3ba96b..ac07aa1 100644 --- a/src/main/java/envoy/client/event/ThemeChangeEvent.java +++ b/src/main/java/envoy/client/event/ThemeChangeEvent.java @@ -8,11 +8,19 @@ import envoy.client.ui.Theme; * Created: 15 Dec 2019
* * @author Kai S. K. Engelbart + * @since Envoy v0.2-alpha */ public class ThemeChangeEvent implements Event { private final Theme theme; + /** + * Initializes a {@link ThemeChangeEvent} conveying information about the change + * of the {@link Theme} currently in use + * + * @param theme the new currently used {@link Theme} object + * @since Envoy v0.2-alpha + */ public ThemeChangeEvent(Theme theme) { this.theme = theme; } @Override diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java index e94c32b..b21e2d9 100644 --- a/src/main/java/envoy/client/ui/ChatWindow.java +++ b/src/main/java/envoy/client/ui/ChatWindow.java @@ -66,6 +66,14 @@ public class ChatWindow extends JFrame { private static final Logger logger = EnvoyLog.getLogger(ChatWindow.class.getSimpleName()); + /** + * Initializes a {@link JFrame} with UI elements used to send and read messages + * to different users. + * + * @param client the {@link Client} used to send and receive messages + * @param localDB the {@link LocalDB} used to manage stored messages and users + * @since Envoy v0.1-alpha + */ public ChatWindow(Client client, LocalDB localDB) { this.client = client; this.localDB = localDB; @@ -112,9 +120,8 @@ public class ChatWindow extends JFrame { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER - && ((Settings.getInstance().isEnterToSend() && e.getModifiersEx() == 0) || (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK))) { + && ((Settings.getInstance().isEnterToSend() && e.getModifiersEx() == 0) || (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK))) postMessage(messageList); - } } }); @@ -219,8 +226,8 @@ public class ChatWindow extends JFrame { /** * Used to immediately reload the ChatWindow when settings were changed. - * - * @param theme the theme to change colors into + * + * @param theme the theme to change colors into * @since Envoy v0.1-alpha */ private void changeChatWindowColors(Theme theme) { diff --git a/src/main/java/envoy/client/ui/MessageListRenderer.java b/src/main/java/envoy/client/ui/MessageListRenderer.java index 9be79c5..5623fb6 100644 --- a/src/main/java/envoy/client/ui/MessageListRenderer.java +++ b/src/main/java/envoy/client/ui/MessageListRenderer.java @@ -14,11 +14,10 @@ import envoy.schema.Message; /** * Defines how a message is displayed.
*
- * * Project: envoy-client
* File: UserListRenderer.java
* Created: 19 Oct 2019
- * + * * @author Kai S. K. Engelbart * @author Maximilian Käfer * @since Envoy v0.1-alpha @@ -62,7 +61,7 @@ public class MessageListRenderer extends JLabel implements ListCellRendererenvoy-client
* File: Startup.java
* Created: 12 Oct 2019
- * + * * @author Leon Hofmeister * @author Maximilian Käfer * @author Kai S. K. Engelbart @@ -32,6 +32,17 @@ public class Startup { private static final Logger logger = EnvoyLog.getLogger(Startup.class.getSimpleName()); + /** + * Loads the application by first loading the configuration, then acquiring a + * user name and connecting to the server. If the server cannot be reached, + * offline mode is entered if possible. After that, a {@link ChatWindow} + * instance is initialized and then displayed to the user. Upon application + * exit, settings and the local database are saved. + * + * @param args the command line arguments may contain configuration parameters + * and are parsed by the {@link Config} class + * @since Envoy v0.1-alpha + */ public static void main(String[] args) { Config config = Config.getInstance(); @@ -127,7 +138,7 @@ public class Startup { e.printStackTrace(); } }); - + // Save Settings and LocalDB on shutdown Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { diff --git a/src/main/java/envoy/client/ui/Theme.java b/src/main/java/envoy/client/ui/Theme.java index 66a0a80..bd2ccb3 100644 --- a/src/main/java/envoy/client/ui/Theme.java +++ b/src/main/java/envoy/client/ui/Theme.java @@ -7,7 +7,7 @@ import java.io.Serializable; * Project: envoy-client
* File: Theme.java
* Created: 23 Nov 2019
- * + * * @author Maximilian Käfer * @since Envoy v0.2-alpha */ @@ -26,6 +26,23 @@ public class Theme implements Serializable { private Color selectionColor; private Color typingMessageColor; + /** + * Initializes a {@link Theme} with all colors relevant to the application GUI. + * + * @param themeName the name of the {@link Theme} + * @param backgroundColor the background color + * @param cellColor the cell color + * @param interactableForegroundColor the color of interactable foreground UI + * elements + * @param interactableBackgroundColor the color of interactable background UI + * elements + * @param messageColorChat the color of chat messages + * @param dateColorChat the color of chat message metadata + * @param selectionColor the section color + * @param typingMessageColor the color of currently typed messages + * @param userNameColor the color of user names + * @since Envoy v0.2-alpha + */ public Theme(String themeName, Color backgroundColor, Color cellColor, Color interactableForegroundColor, Color interactableBackgroundColor, Color messageColorChat, Color dateColorChat, Color selectionColor, Color typingMessageColor, Color userNameColor) { @@ -42,6 +59,14 @@ public class Theme implements Serializable { this.userNameColor = userNameColor; } + /** + * Initializes a {@link Theme} by copying all parameters except for the name + * from another {@link Theme} instance. + * + * @param name the name of the {@link Theme} + * @param other the {@link Theme} to copy + * @since Envoy v0.2-alpha + */ public Theme(String name, Theme other) { this(name, other.backgroundColor, other.cellColor, other.interactableForegroundColor, other.interactableBackgroundColor, other.messageColorChat, other.dateColorChat, other.selectionColor, @@ -110,7 +135,7 @@ public class Theme implements Serializable { /** * Sets the a specific {@link Color} in this theme to a new {@link Color} - * + * * @param index - index of the color
* 0 = backgroundColor
* 1 = cellColor
@@ -122,38 +147,38 @@ public class Theme implements Serializable { * 7 = typingMessageColor
* 8 = userNameColor
*
- * + * * @param newColor - new {@link Color} to be set * @since Envoy 0.2-alpha */ public void setColor(int index, Color newColor) { switch (index) { case 0: - this.backgroundColor = newColor; + backgroundColor = newColor; break; case 1: - this.cellColor = newColor; + cellColor = newColor; break; case 2: - this.interactableForegroundColor = newColor; + interactableForegroundColor = newColor; break; case 3: - this.interactableBackgroundColor = newColor; + interactableBackgroundColor = newColor; break; case 4: - this.messageColorChat = newColor; + messageColorChat = newColor; break; case 5: - this.dateColorChat = newColor; + dateColorChat = newColor; break; case 6: - this.selectionColor = newColor; + selectionColor = newColor; break; case 7: - this.typingMessageColor = newColor; + typingMessageColor = newColor; break; case 8: - this.userNameColor = newColor; + userNameColor = newColor; break; } } diff --git a/src/main/java/envoy/client/ui/UserListRenderer.java b/src/main/java/envoy/client/ui/UserListRenderer.java index 1ee3f84..d26aa8b 100644 --- a/src/main/java/envoy/client/ui/UserListRenderer.java +++ b/src/main/java/envoy/client/ui/UserListRenderer.java @@ -17,7 +17,7 @@ import envoy.schema.User.UserStatus; * Project: envoy-client
* File: UserListRenderer.java
* Created: 12 Oct 2019
- * + * * @author Kai S. K. Engelbart * @author Maximilian Käfer * @since Envoy v0.1-alpha @@ -58,7 +58,7 @@ public class UserListRenderer extends JLabel implements ListCellRenderer { return this; } - public String toHex(Color c) { + private String toHex(Color c) { int r = c.getRed(); int g = c.getGreen(); int b = c.getBlue();