Browse Source

Reformat whole project

Arnaud Vergnet 3 years ago
parent
commit
b281b4b530
37 changed files with 157 additions and 159 deletions
  1. 11
    16
      client/src/main/java/fr/insa/clavardator/client/config/Config.java
  2. 8
    9
      client/src/main/java/fr/insa/clavardator/client/network/NetDiscoverer.java
  3. 1
    1
      client/src/main/java/fr/insa/clavardator/client/server/presence/InsaPresence.java
  4. 1
    1
      client/src/main/java/fr/insa/clavardator/client/server/presence/Presence.java
  5. 3
    0
      client/src/main/java/fr/insa/clavardator/client/ui/LoadingScreenController.java
  6. 8
    11
      client/src/main/java/fr/insa/clavardator/client/ui/MainController.java
  7. 2
    0
      client/src/main/java/fr/insa/clavardator/client/ui/ToolbarController.java
  8. 7
    6
      client/src/main/java/fr/insa/clavardator/client/ui/chat/ChatController.java
  9. 2
    5
      client/src/main/java/fr/insa/clavardator/client/ui/chat/ChatFooterController.java
  10. 2
    1
      client/src/main/java/fr/insa/clavardator/client/ui/chat/ChatHeaderController.java
  11. 4
    2
      client/src/main/java/fr/insa/clavardator/client/ui/chat/MessageListItemController.java
  12. 4
    6
      client/src/main/java/fr/insa/clavardator/client/ui/dialogs/EditUsernameDialogController.java
  13. 2
    1
      client/src/main/java/fr/insa/clavardator/client/ui/users/UserActiveIndicatorController.java
  14. 7
    2
      client/src/main/java/fr/insa/clavardator/client/ui/users/UserListController.java
  15. 2
    1
      client/src/main/java/fr/insa/clavardator/client/ui/users/UserListItemController.java
  16. 5
    6
      client/src/main/resources/fr/insa/clavardator/client/ui/chat/chat.fxml
  17. 2
    2
      client/src/main/resources/fr/insa/clavardator/client/ui/chat/chatFooter.fxml
  18. 18
    18
      client/src/main/resources/fr/insa/clavardator/client/ui/chat/messageListItem.fxml
  19. 1
    2
      client/src/main/resources/fr/insa/clavardator/client/ui/dialogs/aboutDialog.fxml
  20. 2
    3
      client/src/main/resources/fr/insa/clavardator/client/ui/dialogs/snackbar.fxml
  21. 5
    5
      client/src/main/resources/fr/insa/clavardator/client/ui/errorScreen.fxml
  22. 0
    1
      client/src/main/resources/fr/insa/clavardator/client/ui/scene.fxml
  23. 0
    2
      client/src/main/resources/fr/insa/clavardator/client/ui/styles.css
  24. 5
    3
      client/src/main/resources/fr/insa/clavardator/client/ui/toolbar.fxml
  25. 3
    4
      client/src/main/resources/fr/insa/clavardator/client/ui/users/userActiveIndicator.fxml
  26. 4
    3
      client/src/main/resources/fr/insa/clavardator/client/ui/users/userList.fxml
  27. 3
    2
      client/src/main/resources/fr/insa/clavardator/client/ui/users/userListItem.fxml
  28. 6
    6
      client/src/test/java/fr/insa/clavardator/DatabaseTest.java
  29. 1
    1
      lib/src/main/java/fr/insa/clavardator/lib/message/FileMessage.java
  30. 1
    1
      lib/src/main/java/fr/insa/clavardator/lib/message/Message.java
  31. 11
    12
      lib/src/main/java/fr/insa/clavardator/lib/network/TcpConnection.java
  32. 6
    7
      lib/src/main/java/fr/insa/clavardator/lib/network/TcpListener.java
  33. 10
    9
      lib/src/main/java/fr/insa/clavardator/lib/users/User.java
  34. 7
    7
      lib/src/main/java/fr/insa/clavardator/lib/util/Log.java
  35. 1
    1
      server/build.gradle
  36. 1
    1
      server/src/main/java/fr/insa/clavardator/server/Main.java
  37. 1
    1
      server/src/main/java/fr/insa/clavardator/server/Presence.java

+ 11
- 16
client/src/main/java/fr/insa/clavardator/client/config/Config.java View File

@@ -7,10 +7,10 @@ import org.json.JSONObject;
7 7
 @SuppressWarnings("FieldCanBeLocal")
8 8
 public class Config {
9 9
 
10
-	private ServerConfig serverConfig;
11
-	private LocalConfig localConfig;
12 10
 	private final String SERVER_KEY = "serveur";
13 11
 	private final String LOCAL_KEY = "local";
12
+	private ServerConfig serverConfig;
13
+	private LocalConfig localConfig;
14 14
 
15 15
 	public Config() {
16 16
 		serverConfig = new ServerConfig();
@@ -30,6 +30,7 @@ public class Config {
30 30
 	public ServerConfig getServerConfig() {
31 31
 		return serverConfig;
32 32
 	}
33
+
33 34
 	public LocalConfig getLocalConfig() {
34 35
 		return localConfig;
35 36
 	}
@@ -38,21 +39,18 @@ public class Config {
38 39
 	public static class ServerConfig {
39 40
 		public static final int DEFAULT_PRESENCE_PORT = 35650;
40 41
 		public static final int DEFAULT_PROXY_PORT = 35750;
41
-
42
-		private JSONObject obj;
43
-
44
-		private boolean enabled;
45
-		private String uri;
46
-		private ServerType type;
47
-		private int presencePort;
48
-		private int proxyPort;
49
-
50 42
 		private final String ENABLED_KEY = "actif";
51 43
 		private final String URI_KEY = "uri";
52 44
 		private final String TYPE_KEY = "type";
53 45
 		private final String PORTS_KEY = "ports";
54 46
 		private final String PORT_PRESENCE_KEY = "presence";
55 47
 		private final String PORT_PROXY_KEY = "proxy";
48
+		private JSONObject obj;
49
+		private boolean enabled;
50
+		private String uri;
51
+		private ServerType type;
52
+		private int presencePort;
53
+		private int proxyPort;
56 54
 
57 55
 		/**
58 56
 		 * Basic constructor setting the default server configuration
@@ -160,15 +158,12 @@ public class Config {
160 158
 	@SuppressWarnings("FieldCanBeLocal")
161 159
 	public static class LocalConfig {
162 160
 		public static final int DEFAULT_TCP_PORT = 31598;
163
-
161
+		private final String ENABLED_KEY = "actif";
162
+		private final String PORT_KEY = "port";
164 163
 		private JSONObject obj;
165
-
166 164
 		private boolean enabled;
167 165
 		private int port;
168 166
 
169
-		private final String ENABLED_KEY = "actif";
170
-		private final String PORT_KEY = "port";
171
-
172 167
 		/**
173 168
 		 * Basic constructor setting the default local configuration
174 169
 		 */

+ 8
- 9
client/src/main/java/fr/insa/clavardator/client/network/NetDiscoverer.java View File

@@ -89,6 +89,14 @@ public class NetDiscoverer {
89 89
 	}
90 90
 
91 91
 
92
+	private interface BroadcastReceivedCallback {
93
+		void onBroadcastReceived(InetAddress ipAddr, String data);
94
+	}
95
+
96
+	public interface ResponseReceivedCallback {
97
+		void onResponseReceived(InetAddress ipAddr, String data);
98
+	}
99
+
92 100
 	private static class BroadcastSender extends Thread {
93 101
 		private final String broadcastMessage;
94 102
 		private final ErrorCallback errorCallback;
@@ -246,13 +254,4 @@ public class NetDiscoverer {
246 254
 		}
247 255
 
248 256
 	}
249
-
250
-
251
-	private interface BroadcastReceivedCallback {
252
-		void onBroadcastReceived(InetAddress ipAddr, String data);
253
-	}
254
-
255
-	public interface ResponseReceivedCallback {
256
-		void onResponseReceived(InetAddress ipAddr, String data);
257
-	}
258 257
 }

+ 1
- 1
client/src/main/java/fr/insa/clavardator/client/server/presence/InsaPresence.java View File

@@ -35,8 +35,8 @@ public class InsaPresence implements Presence {
35 35
 
36 36
 	private final String path;
37 37
 	private final int presencePort;
38
-	private TcpConnection presenceConnection;
39 38
 	private final Proxy proxy;
39
+	private TcpConnection presenceConnection;
40 40
 
41 41
 	public InsaPresence(String path, int presencePort, int proxyPort) {
42 42
 		this.path = path;

+ 1
- 1
client/src/main/java/fr/insa/clavardator/client/server/presence/Presence.java View File

@@ -39,7 +39,7 @@ public interface Presence {
39 39
 	 * Notifies the presence server of any changes to the current user
40 40
 	 *
41 41
 	 * @param newInformation The new information to send
42
-	 * @param callback Called when notify completes
42
+	 * @param callback       Called when notify completes
43 43
 	 */
44 44
 	void notify(UserInformation newInformation, @Nullable SimpleCallback callback, @Nullable ErrorCallback errorCallback);
45 45
 

+ 3
- 0
client/src/main/java/fr/insa/clavardator/client/ui/LoadingScreenController.java View File

@@ -35,6 +35,7 @@ public class LoadingScreenController implements Initializable {
35 35
 
36 36
 	/**
37 37
 	 * Instantly shows the loading screen
38
+	 *
38 39
 	 * @param label The text to display bellow the loading indicator
39 40
 	 */
40 41
 	public void show(String label) {
@@ -51,6 +52,7 @@ public class LoadingScreenController implements Initializable {
51 52
 
52 53
 	/**
53 54
 	 * Sets the text to display bellow the loading indicator
55
+	 *
54 56
 	 * @param label The text to use
55 57
 	 */
56 58
 	public void setLabel(@Nullable String label) {
@@ -62,6 +64,7 @@ public class LoadingScreenController implements Initializable {
62 64
 
63 65
 	/**
64 66
 	 * Gets the main container styles to apply custom styling
67
+	 *
65 68
 	 * @return The style list
66 69
 	 */
67 70
 	public ObservableList<String> getRootStyle() {

+ 8
- 11
client/src/main/java/fr/insa/clavardator/client/ui/MainController.java View File

@@ -4,9 +4,9 @@ import com.jfoenix.controls.JFXSnackbar;
4 4
 import fr.insa.clavardator.client.config.Config;
5 5
 import fr.insa.clavardator.client.config.ConfigLoader;
6 6
 import fr.insa.clavardator.client.db.DatabaseController;
7
+import fr.insa.clavardator.client.server.ServerType;
7 8
 import fr.insa.clavardator.client.server.presence.Presence;
8 9
 import fr.insa.clavardator.client.server.presence.PresenceFactory;
9
-import fr.insa.clavardator.client.server.ServerType;
10 10
 import fr.insa.clavardator.client.server.presence.UnknownPresenceException;
11 11
 import fr.insa.clavardator.client.ui.chat.ChatController;
12 12
 import fr.insa.clavardator.client.ui.dialogs.AboutDialogController;
@@ -32,6 +32,7 @@ import java.util.TimerTask;
32 32
 public class MainController implements Initializable {
33 33
 
34 34
 	private final CurrentUser currentUser;
35
+	private final int DEFAULT_PORT = 31598;
35 36
 	@FXML
36 37
 	private StackPane root;
37 38
 	@FXML
@@ -50,14 +51,10 @@ public class MainController implements Initializable {
50 51
 	private LoadingScreenController loadingController;
51 52
 	@FXML
52 53
 	private ErrorScreenController errorController;
53
-
54 54
 	private JFXSnackbar snackbar;
55 55
 	private UserList userList;
56 56
 	private Presence presenceServer;
57 57
 	private boolean online;
58
-
59
-	private final int DEFAULT_PORT = 31598;
60
-
61 58
 	private int port = DEFAULT_PORT;
62 59
 	private boolean localEnabled = true;
63 60
 
@@ -177,9 +174,9 @@ public class MainController implements Initializable {
177 174
 			userList.discoverActiveUsers(
178 175
 					port,
179 176
 					(e) -> {
180
-				Log.e(this.getClass().getSimpleName(), "Error discovering users", e);
181
-				CurrentUser.getInstance().setState(CurrentUser.State.INVALID);
182
-			});
177
+						Log.e(this.getClass().getSimpleName(), "Error discovering users", e);
178
+						CurrentUser.getInstance().setState(CurrentUser.State.INVALID);
179
+					});
183 180
 		}
184 181
 	}
185 182
 
@@ -193,9 +190,9 @@ public class MainController implements Initializable {
193 190
 			userList.startUserListening(
194 191
 					port,
195 192
 					(e) -> {
196
-				Log.e(this.getClass().getSimpleName(), "Error listening to users", e);
197
-				CurrentUser.getInstance().setState(CurrentUser.State.INVALID);
198
-			});
193
+						Log.e(this.getClass().getSimpleName(), "Error listening to users", e);
194
+						CurrentUser.getInstance().setState(CurrentUser.State.INVALID);
195
+					});
199 196
 		}
200 197
 	}
201 198
 

+ 2
- 0
client/src/main/java/fr/insa/clavardator/client/ui/ToolbarController.java View File

@@ -23,6 +23,7 @@ public class ToolbarController implements Initializable {
23 23
 	public void setEditListener(ButtonPressEvent listener) {
24 24
 		editListeners = listener;
25 25
 	}
26
+
26 27
 	public void setAboutListener(ButtonPressEvent listener) {
27 28
 		aboutListeners = listener;
28 29
 	}
@@ -32,6 +33,7 @@ public class ToolbarController implements Initializable {
32 33
 			editListeners.onPress();
33 34
 		}
34 35
 	}
36
+
35 37
 	public void onAboutPress() {
36 38
 		if (aboutListeners != null) {
37 39
 			aboutListeners.onPress();

+ 7
- 6
client/src/main/java/fr/insa/clavardator/client/ui/chat/ChatController.java View File

@@ -1,10 +1,10 @@
1 1
 package fr.insa.clavardator.client.ui.chat;
2 2
 
3 3
 import fr.insa.clavardator.client.chat.ChatHistory;
4
-import fr.insa.clavardator.lib.message.Message;
5 4
 import fr.insa.clavardator.client.ui.LoadingScreenController;
6 5
 import fr.insa.clavardator.client.ui.NoSelectionModel;
7 6
 import fr.insa.clavardator.client.users.PeerUser;
7
+import fr.insa.clavardator.lib.message.Message;
8 8
 import fr.insa.clavardator.lib.util.ErrorCallback;
9 9
 import fr.insa.clavardator.lib.util.Log;
10 10
 import javafx.application.Platform;
@@ -36,18 +36,19 @@ public class ChatController implements Initializable {
36 36
 	private VBox emptyContainer;
37 37
 	private PeerUser remoteUser;
38 38
 
39
-//	public void setAttachmentListener(ButtonPressEvent listener) {
39
+	//	public void setAttachmentListener(ButtonPressEvent listener) {
40 40
 //		chatFooterController.setAttachmentListener(listener);
41 41
 //	}
42
-public void setSendErrorListener(ErrorCallback listener) {
43
-	chatFooterController.setSendErrorListener(listener);
44
-}
42
+	public void setSendErrorListener(ErrorCallback listener) {
43
+		chatFooterController.setSendErrorListener(listener);
44
+	}
45 45
 
46 46
 	/**
47 47
 	 * Check the user that finished loading is the right one then set the chat state to done
48
+	 *
48 49
 	 * @param user The user that finished loading
49 50
 	 */
50
-	private void onHistoryLoaded (PeerUser user) {
51
+	private void onHistoryLoaded(PeerUser user) {
51 52
 		if (user.equals(remoteUser)) {
52 53
 			setState(State.DONE);
53 54
 			scrollToEnd();

+ 2
- 5
client/src/main/java/fr/insa/clavardator/client/ui/chat/ChatFooterController.java View File

@@ -24,6 +24,8 @@ import java.util.ResourceBundle;
24 24
  * Controller for the chat input field and associated buttons
25 25
  */
26 26
 public class ChatFooterController implements Initializable {
27
+	FileChooser fileChooser = new FileChooser();
28
+	File attachedFile;
27 29
 	@FXML
28 30
 	private HBox container;
29 31
 	@FXML
@@ -32,15 +34,10 @@ public class ChatFooterController implements Initializable {
32 34
 	private JFXButton sendButton;
33 35
 	@FXML
34 36
 	private JFXButton attachButton;
35
-
36 37
 	private ErrorCallback sendErrorListeners;
37
-
38 38
 	private PeerUser remoteUser;
39 39
 	private HashMap<PeerUser, String> savedText;
40 40
 
41
-	FileChooser fileChooser = new FileChooser();
42
-	File attachedFile;
43
-
44 41
 	public void setSendErrorListener(ErrorCallback listener) {
45 42
 		sendErrorListeners = listener;
46 43
 	}

+ 2
- 1
client/src/main/java/fr/insa/clavardator/client/ui/chat/ChatHeaderController.java View File

@@ -52,5 +52,6 @@ public class ChatHeaderController implements Initializable {
52 52
 	}
53 53
 
54 54
 	@Override
55
-	public void initialize(URL location, ResourceBundle resources) {}
55
+	public void initialize(URL location, ResourceBundle resources) {
56
+	}
56 57
 }

+ 4
- 2
client/src/main/java/fr/insa/clavardator/client/ui/chat/MessageListItemController.java View File

@@ -1,9 +1,9 @@
1 1
 package fr.insa.clavardator.client.ui.chat;
2 2
 
3 3
 import com.jfoenix.controls.JFXButton;
4
+import fr.insa.clavardator.client.users.CurrentUser;
4 5
 import fr.insa.clavardator.lib.message.FileMessage;
5 6
 import fr.insa.clavardator.lib.message.Message;
6
-import fr.insa.clavardator.client.users.CurrentUser;
7 7
 import javafx.fxml.FXML;
8 8
 import javafx.fxml.Initializable;
9 9
 import javafx.geometry.Pos;
@@ -30,6 +30,7 @@ public class MessageListItemController implements Initializable {
30 30
 	private Label timestamp;
31 31
 	@FXML
32 32
 	private FontIcon attachmentIcon;
33
+
33 34
 	/**
34 35
 	 * Sets the message to display
35 36
 	 *
@@ -108,5 +109,6 @@ public class MessageListItemController implements Initializable {
108 109
 	}
109 110
 
110 111
 	@Override
111
-	public void initialize(URL url, ResourceBundle rb) {}
112
+	public void initialize(URL url, ResourceBundle rb) {
113
+	}
112 114
 }

+ 4
- 6
client/src/main/java/fr/insa/clavardator/client/ui/dialogs/EditUsernameDialogController.java View File

@@ -7,8 +7,6 @@ import com.jfoenix.validation.base.ValidatorBase;
7 7
 import fr.insa.clavardator.client.ui.ButtonPressEvent;
8 8
 import fr.insa.clavardator.client.users.CurrentUser;
9 9
 import fr.insa.clavardator.client.users.UserList;
10
-import fr.insa.clavardator.lib.util.ParametrizedCallback;
11
-import fr.insa.clavardator.lib.util.SimpleCallback;
12 10
 import javafx.beans.property.ReadOnlyBooleanWrapper;
13 11
 import javafx.beans.value.ObservableValue;
14 12
 import javafx.fxml.FXML;
@@ -69,6 +67,7 @@ public class EditUsernameDialogController implements Initializable {
69 67
 	public void setOnSuccessListener(ButtonPressEvent listener) {
70 68
 		this.successListener = listener;
71 69
 	}
70
+
72 71
 	public void setOnCancelListener(ButtonPressEvent listener) {
73 72
 		this.cancelListener = listener;
74 73
 	}
@@ -76,12 +75,11 @@ public class EditUsernameDialogController implements Initializable {
76 75
 	/**
77 76
 	 * Plays the dialog show animation
78 77
 	 *
78
+	 * @param root The dialog's root component
79
+	 * @param mode The dialog display mode
79 80
 	 * @implNote WARNING: Do not try to open the dialog instantly after closing it.
80 81
 	 * Due to JFoenix animations, the dialog will not reopen.
81 82
 	 * If you must, wait at least 500ms before reopening.
82
-	 *
83
-	 * @param root The dialog's root component
84
-	 * @param mode The dialog display mode
85 83
 	 */
86 84
 	public void show(StackPane root, Mode mode) {
87 85
 		setLocked(false);
@@ -202,7 +200,7 @@ public class EditUsernameDialogController implements Initializable {
202 200
 		textField.setOnKeyPressed(event -> {
203 201
 			if (event.getCode() == KeyCode.ENTER) {
204 202
 				event.consume();
205
-				if(!textField.getText().isEmpty()){
203
+				if (!textField.getText().isEmpty()) {
206 204
 					onConfirm();
207 205
 				}
208 206
 			}

+ 2
- 1
client/src/main/java/fr/insa/clavardator/client/ui/users/UserActiveIndicatorController.java View File

@@ -72,6 +72,7 @@ public class UserActiveIndicatorController implements Initializable {
72 72
 	}
73 73
 
74 74
 	@Override
75
-	public void initialize(URL location, ResourceBundle resources) {}
75
+	public void initialize(URL location, ResourceBundle resources) {
76
+	}
76 77
 
77 78
 }

+ 7
- 2
client/src/main/java/fr/insa/clavardator/client/ui/users/UserListController.java View File

@@ -4,8 +4,8 @@ import com.jfoenix.controls.JFXButton;
4 4
 import fr.insa.clavardator.client.ui.ButtonPressEvent;
5 5
 import fr.insa.clavardator.client.ui.UserSelectedEvent;
6 6
 import fr.insa.clavardator.client.users.PeerUser;
7
-import fr.insa.clavardator.lib.users.User;
8 7
 import fr.insa.clavardator.client.users.UserList;
8
+import fr.insa.clavardator.lib.users.User;
9 9
 import javafx.fxml.FXML;
10 10
 import javafx.fxml.Initializable;
11 11
 import javafx.scene.control.ListView;
@@ -22,14 +22,17 @@ public class UserListController implements Initializable {
22 22
 	private ButtonPressEvent refreshUserListener;
23 23
 	private UserSelectedEvent userSelectedListener;
24 24
 
25
-	public UserListController() {}
25
+	public UserListController() {
26
+	}
26 27
 
27 28
 	public void setRefreshUserListener(ButtonPressEvent listener) {
28 29
 		refreshUserListener = listener;
29 30
 	}
31
+
30 32
 	public void setUserSelectedListener(UserSelectedEvent listener) {
31 33
 		userSelectedListener = listener;
32 34
 	}
35
+
33 36
 	public void onRefreshUserListPress() {
34 37
 		if (refreshUserListener != null) {
35 38
 			refreshUserListener.onPress();
@@ -38,6 +41,7 @@ public class UserListController implements Initializable {
38 41
 
39 42
 	/**
40 43
 	 * Enables or disables the refresh button
44
+	 *
41 45
 	 * @param enabled True to enable, false otherwise
42 46
 	 */
43 47
 	public void setRefreshButtonEnabled(boolean enabled) {
@@ -63,6 +67,7 @@ public class UserListController implements Initializable {
63 67
 
64 68
 	/**
65 69
 	 * Sets the user list to subscribe to
70
+	 *
66 71
 	 * @param userList The user list to use
67 72
 	 */
68 73
 	public void setUserList(UserList userList) {

+ 2
- 1
client/src/main/java/fr/insa/clavardator/client/ui/users/UserListItemController.java View File

@@ -111,5 +111,6 @@ public class UserListItemController implements Initializable {
111 111
 	}
112 112
 
113 113
 	@Override
114
-	public void initialize(URL location, ResourceBundle resources) {}
114
+	public void initialize(URL location, ResourceBundle resources) {
115
+	}
115 116
 }

+ 5
- 6
client/src/main/resources/fr/insa/clavardator/client/ui/chat/chat.fxml View File

@@ -1,13 +1,12 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 
3
-<?import javafx.scene.control.ListView?>
4
-<?import javafx.scene.layout.*?>
5 3
 <!--suppress JavaFxUnresolvedFxIdReference -->
6
-<?import javafx.scene.control.Label?>
7
-<?import com.jfoenix.controls.JFXSpinner?>
8 4
 <?import javafx.geometry.Insets?>
9
-<AnchorPane xmlns="http://javafx.com/javafx/11.0.1"
10
-            xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.client.ui.chat.ChatController"
5
+<?import javafx.scene.control.Label?>
6
+<?import javafx.scene.control.ListView?>
7
+<?import javafx.scene.layout.*?>
8
+<AnchorPane xmlns:fx="http://javafx.com/fxml/1"
9
+            xmlns="http://javafx.com/javafx/11.0.1" fx:controller="fr.insa.clavardator.client.ui.chat.ChatController"
11 10
             stylesheets="@../styles.css" styleClass="container">
12 11
   <StackPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
13 12
              AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">

+ 2
- 2
client/src/main/resources/fr/insa/clavardator/client/ui/chat/chatFooter.fxml View File

@@ -5,8 +5,8 @@
5 5
 <?import javafx.geometry.Insets?>
6 6
 <?import javafx.scene.layout.HBox?>
7 7
 <?import org.kordamp.ikonli.javafx.FontIcon?>
8
-<HBox xmlns="http://javafx.com/javafx"
9
-      xmlns:fx="http://javafx.com/fxml"
8
+<HBox xmlns:fx="http://javafx.com/fxml"
9
+      xmlns="http://javafx.com/javafx"
10 10
       fx:controller="fr.insa.clavardator.client.ui.chat.ChatFooterController"
11 11
       stylesheets="@../styles.css" styleClass="container" alignment="CENTER" spacing="10.0" fx:id="container">
12 12
   <padding>

+ 18
- 18
client/src/main/resources/fr/insa/clavardator/client/ui/chat/messageListItem.fxml View File

@@ -1,29 +1,29 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 
3 3
 <?import com.jfoenix.controls.JFXButton?>
4
-<?import javafx.scene.control.Label?>
5
-<?import javafx.scene.layout.*?>
6 4
 <?import javafx.geometry.Insets?>
5
+<?import javafx.scene.control.Label?>
6
+<?import javafx.scene.layout.VBox?>
7 7
 <?import org.kordamp.ikonli.javafx.FontIcon?>
8
-<VBox xmlns="http://javafx.com/javafx/11.0.1"
9
-      xmlns:fx="http://javafx.com/fxml/1"
8
+<VBox xmlns:fx="http://javafx.com/fxml/1"
9
+      xmlns="http://javafx.com/javafx/11.0.1"
10 10
       fx:controller="fr.insa.clavardator.client.ui.chat.MessageListItemController"
11 11
       stylesheets="@../styles.css"
12 12
       styleClass="inner"
13 13
       fx:id="container"
14 14
       spacing="10">
15
-    <padding>
16
-        <Insets left="50" right="50" top="10" bottom="10"/>
17
-    </padding>
18
-    <JFXButton fx:id="button"
19
-               mnemonicParsing="false"
20
-               text="Message"
21
-               textAlignment="CENTER">
22
-        <graphic>
23
-            <FontIcon iconLiteral="fas-paperclip" iconSize="24" fx:id="attachmentIcon"/>
24
-        </graphic>
25
-    </JFXButton>
26
-    <Label fx:id="timestamp"
27
-           text="Timestamp"
28
-           styleClass="timestamp"/>
15
+  <padding>
16
+    <Insets left="50" right="50" top="10" bottom="10"/>
17
+  </padding>
18
+  <JFXButton fx:id="button"
19
+             mnemonicParsing="false"
20
+             text="Message"
21
+             textAlignment="CENTER">
22
+    <graphic>
23
+      <FontIcon iconLiteral="fas-paperclip" iconSize="24" fx:id="attachmentIcon"/>
24
+    </graphic>
25
+  </JFXButton>
26
+  <Label fx:id="timestamp"
27
+         text="Timestamp"
28
+         styleClass="timestamp"/>
29 29
 </VBox>

+ 1
- 2
client/src/main/resources/fr/insa/clavardator/client/ui/dialogs/aboutDialog.fxml View File

@@ -2,7 +2,6 @@
2 2
 
3 3
 <?import com.jfoenix.controls.JFXButton?>
4 4
 <?import com.jfoenix.controls.JFXDialog?>
5
-<?import com.jfoenix.controls.JFXTextField?>
6 5
 <?import javafx.geometry.Insets?>
7 6
 <?import javafx.scene.control.Label?>
8 7
 <?import javafx.scene.layout.*?>
@@ -22,7 +21,7 @@
22 21
         <padding>
23 22
           <Insets bottom="10"/>
24 23
         </padding>
25
-        <Label styleClass="dialog-title" >À Propos</Label>
24
+        <Label styleClass="dialog-title">À Propos</Label>
26 25
         <VBox VBox.vgrow="ALWAYS" alignment="CENTER" spacing="30">
27 26
           <Label VBox.vgrow="ALWAYS">Application réalisée par Yohan SIMARD et Arnaud VERGNET</Label>
28 27
           <Label VBox.vgrow="ALWAYS">INSA Toulouse 2020-2021</Label>

+ 2
- 3
client/src/main/resources/fr/insa/clavardator/client/ui/dialogs/snackbar.fxml View File

@@ -1,10 +1,9 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 
3
+<?import javafx.geometry.Insets?>
3 4
 <?import javafx.scene.control.Label?>
4
-<?import javafx.scene.layout.AnchorPane?>
5
-<?import javafx.scene.layout.HBox?>
5
+<?import javafx.scene.layout.*?>
6 6
 <?import org.kordamp.ikonli.javafx.FontIcon?>
7
-<?import javafx.geometry.Insets?>
8 7
 <AnchorPane xmlns:fx="http://javafx.com/fxml"
9 8
             xmlns="http://javafx.com/javafx"
10 9
             fx:controller="fr.insa.clavardator.client.ui.dialogs.SnackbarController"

+ 5
- 5
client/src/main/resources/fr/insa/clavardator/client/ui/errorScreen.fxml View File

@@ -1,8 +1,8 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 
3
+<?import com.jfoenix.controls.JFXButton?>
3 4
 <?import javafx.scene.control.Label?>
4 5
 <?import javafx.scene.layout.VBox?>
5
-<?import com.jfoenix.controls.JFXButton?>
6 6
 <?import org.kordamp.ikonli.javafx.FontIcon?>
7 7
 <VBox xmlns:fx="http://javafx.com/fxml"
8 8
       xmlns="http://javafx.com/javafx"
@@ -14,9 +14,9 @@
14 14
       fx:id="container">
15 15
   <Label>Une erreur est survenue et Clavardator ne peut pas démarrer</Label>
16 16
   <JFXButton styleClass="background-danger" onAction="#onPress">
17
-      <graphic>
18
-          <FontIcon iconLiteral="fas-times"/>
19
-      </graphic>
20
-      Quitter
17
+    <graphic>
18
+      <FontIcon iconLiteral="fas-times"/>
19
+    </graphic>
20
+    Quitter
21 21
   </JFXButton>
22 22
 </VBox>

+ 0
- 1
client/src/main/resources/fr/insa/clavardator/client/ui/scene.fxml View File

@@ -1,7 +1,6 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 
3 3
 <!--suppress JavaFxUnresolvedFxIdReference -->
4
-<?import javafx.scene.control.Label?>
5 4
 <?import javafx.scene.layout.*?>
6 5
 <StackPane xmlns:fx="http://javafx.com/fxml/1"
7 6
            xmlns="http://javafx.com/javafx/11.0.1"

+ 0
- 2
client/src/main/resources/fr/insa/clavardator/client/ui/styles.css View File

@@ -1,4 +1,3 @@
1
-
2 1
 /********************************************************
3 2
                         THEME
4 3
 *********************************************************/
@@ -17,7 +16,6 @@
17 16
 }
18 17
 
19 18
 
20
-
21 19
 /********************************************************
22 20
                         STYLE
23 21
 *********************************************************/

+ 5
- 3
client/src/main/resources/fr/insa/clavardator/client/ui/toolbar.fxml View File

@@ -3,10 +3,12 @@
3 3
 <?import com.jfoenix.controls.JFXButton?>
4 4
 <?import javafx.geometry.Insets?>
5 5
 <?import javafx.scene.control.Label?>
6
-<?import javafx.scene.layout.*?>
6
+<?import javafx.scene.layout.HBox?>
7
+<?import javafx.scene.layout.Pane?>
8
+<?import javafx.scene.layout.VBox?>
7 9
 <?import org.kordamp.ikonli.javafx.FontIcon?>
8
-<VBox xmlns="http://javafx.com/javafx"
9
-      xmlns:fx="http://javafx.com/fxml"
10
+<VBox xmlns:fx="http://javafx.com/fxml"
11
+      xmlns="http://javafx.com/javafx"
10 12
       fx:controller="fr.insa.clavardator.client.ui.ToolbarController"
11 13
       stylesheets="@styles.css" styleClass="container">
12 14
   <HBox alignment="CENTER_LEFT" prefHeight="64.0" spacing="10">

+ 3
- 4
client/src/main/resources/fr/insa/clavardator/client/ui/users/userActiveIndicator.fxml View File

@@ -1,10 +1,9 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 
3
-<?import javafx.scene.layout.*?>
4
-
3
+<?import javafx.scene.layout.HBox?>
5 4
 <?import javafx.scene.shape.Circle?>
6
-<HBox xmlns="http://javafx.com/javafx"
7
-      xmlns:fx="http://javafx.com/fxml"
5
+<HBox xmlns:fx="http://javafx.com/fxml"
6
+      xmlns="http://javafx.com/javafx"
8 7
       fx:controller="fr.insa.clavardator.client.ui.users.UserActiveIndicatorController"
9 8
       stylesheets="@../styles.css" alignment="CENTER">
10 9
   <Circle fx:id="circle" radius="5.0" styleClass="active-user-dot"/>

+ 4
- 3
client/src/main/resources/fr/insa/clavardator/client/ui/users/userList.fxml View File

@@ -4,13 +4,14 @@
4 4
 <?import javafx.scene.control.ListView?>
5 5
 <?import javafx.scene.layout.*?>
6 6
 <?import org.kordamp.ikonli.javafx.FontIcon?>
7
-<AnchorPane xmlns="http://javafx.com/javafx/11.0.1"
8
-            xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.client.ui.users.UserListController"
7
+<AnchorPane xmlns:fx="http://javafx.com/fxml/1"
8
+            xmlns="http://javafx.com/javafx/11.0.1" fx:controller="fr.insa.clavardator.client.ui.users.UserListController"
9 9
             stylesheets="@../styles.css" styleClass="container">
10 10
   <VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
11 11
         AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
12 12
     <HBox alignment="CENTER" prefHeight="64.0" spacing="10.0">
13
-      <JFXButton mnemonicParsing="false" text="Utilisateurs" onMouseClicked="#onRefreshUserListPress" fx:id="refreshButton">
13
+      <JFXButton mnemonicParsing="false" text="Utilisateurs" onMouseClicked="#onRefreshUserListPress"
14
+                 fx:id="refreshButton">
14 15
         <graphic>
15 16
           <FontIcon iconLiteral="fas-sync-alt" iconSize="24"/>
16 17
         </graphic>

+ 3
- 2
client/src/main/resources/fr/insa/clavardator/client/ui/users/userListItem.fxml View File

@@ -1,11 +1,12 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 
3
+<!--suppress JavaFxUnresolvedFxIdReference -->
3 4
 <?import com.jfoenix.controls.JFXButton?>
4 5
 <?import javafx.scene.layout.*?>
5
-<!--suppress JavaFxUnresolvedFxIdReference -->
6
-<AnchorPane prefHeight="40.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"
6
+<AnchorPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="40.0" xmlns="http://javafx.com/javafx/11.0.1"
7 7
             fx:controller="fr.insa.clavardator.client.ui.users.UserListItemController" stylesheets="@../styles.css"
8 8
             styleClass="inner">
9
+  <!--suppress JavaFxRedundantPropertyValue -->
9 10
   <JFXButton fx:id="button" alignment="CENTER_LEFT" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
10 11
              AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0" onAction="#onPress">
11 12
     <graphic>

+ 6
- 6
client/src/test/java/fr/insa/clavardator/DatabaseTest.java View File

@@ -1,7 +1,7 @@
1 1
 package fr.insa.clavardator;
2 2
 
3
-import fr.insa.clavardator.lib.message.Message;
4 3
 import fr.insa.clavardator.client.db.DatabaseController;
4
+import fr.insa.clavardator.lib.message.Message;
5 5
 import fr.insa.clavardator.lib.users.UserInformation;
6 6
 import org.junit.jupiter.api.Assertions;
7 7
 import org.junit.jupiter.api.Test;
@@ -30,9 +30,9 @@ public class DatabaseTest {
30 30
 
31 31
 			db.getChatHistory(new UserInformation("1", "Yohan"),
32 32
 					new UserInformation("0", "Arnaud"), new Date(0), new Date(), history -> {
33
-				assertEquals(history.size(), 0);
34
-				latch2.countDown();
35
-			}, Assertions::fail);
33
+						assertEquals(history.size(), 0);
34
+						latch2.countDown();
35
+					}, Assertions::fail);
36 36
 			latch2.await();
37 37
 
38 38
 			CountDownLatch latch8 = new CountDownLatch(1);
@@ -67,8 +67,8 @@ public class DatabaseTest {
67 67
 
68 68
 			db.getChatHistory(new UserInformation("1", "Yohan"),
69 69
 					new UserInformation("2", "Arnaud"), new Date(0), new Date(), history -> {
70
-				assertEquals(5, history.size());
71
-				assertEquals("Coucou Arnaud !", history.get(0).getText());
70
+						assertEquals(5, history.size());
71
+						assertEquals("Coucou Arnaud !", history.get(0).getText());
72 72
 						assertEquals("1", history.get(0).getSender().id);
73 73
 						assertEquals("2", history.get(0).getRecipient().id);
74 74
 						assertEquals("Yohan", history.get(0).getSender().getUsername());

+ 1
- 1
lib/src/main/java/fr/insa/clavardator/lib/message/FileMessage.java View File

@@ -14,8 +14,8 @@ public class FileMessage extends Message {
14 14
 	public static final String STORED_FILES_FOLDER = "clavardator_stored_files";
15 15
 
16 16
 	private final String fileName;
17
-	private String path;
18 17
 	byte[] rawFile = null;
18
+	private String path;
19 19
 
20 20
 	/**
21 21
 	 * Constructs a FileMessage

+ 1
- 1
lib/src/main/java/fr/insa/clavardator/lib/message/Message.java View File

@@ -17,7 +17,7 @@ public class Message implements Serializable, SenderInfo, RecipientInfo {
17 17
 	}
18 18
 
19 19
 	public Message(User sender, User recipient, Date date) {
20
-		this(sender, recipient, date,"");
20
+		this(sender, recipient, date, "");
21 21
 	}
22 22
 
23 23
 	public Message(UserInformation sender, UserInformation recipient, Date date, String text) {

+ 11
- 12
lib/src/main/java/fr/insa/clavardator/lib/network/TcpConnection.java View File

@@ -14,12 +14,12 @@ import java.net.Socket;
14 14
 
15 15
 public class TcpConnection {
16 16
 
17
+	private final int port;
18
+	private final Object outputStreamGuard = new Object();
17 19
 	private Socket socket;
18 20
 	private ObjectOutputStream outputStream;
19 21
 	private ObjectInputStream inputStream;
20 22
 	private boolean shouldStop = false;
21
-	private final int port;
22
-	private final Object outputStreamGuard = new Object();
23 23
 
24 24
 	/**
25 25
 	 * Creates a new connection, and connects to the peer
@@ -103,6 +103,15 @@ public class TcpConnection {
103 103
 		return socket != null && socket.isConnected() && !socket.isClosed();
104 104
 	}
105 105
 
106
+	public interface SocketConnectedCallback {
107
+		void onSocketConnected(TcpConnection connection);
108
+	}
109
+
110
+
111
+	public interface MessageReceivedCallback {
112
+		void onMessageReceived(Object msg) throws IOException;
113
+	}
114
+
106 115
 	private class Connector extends Thread {
107 116
 		private final InetAddress ipAddr;
108 117
 		private final SocketConnectedCallback callback;
@@ -129,7 +138,6 @@ public class TcpConnection {
129 138
 		}
130 139
 	}
131 140
 
132
-
133 141
 	private class Sender extends Thread {
134 142
 		private final Serializable message;
135 143
 		private final SimpleCallback callback;
@@ -198,13 +206,4 @@ public class TcpConnection {
198 206
 			}
199 207
 		}
200 208
 	}
201
-
202
-
203
-	public interface SocketConnectedCallback {
204
-		void onSocketConnected(TcpConnection connection);
205
-	}
206
-
207
-	public interface MessageReceivedCallback {
208
-		void onMessageReceived(Object msg) throws IOException;
209
-	}
210 209
 }

+ 6
- 7
lib/src/main/java/fr/insa/clavardator/lib/network/TcpListener.java View File

@@ -30,12 +30,16 @@ public class TcpListener {
30 30
 	}
31 31
 
32 32
 
33
+	public interface NewConnectionCallback {
34
+		void onNewConnection(Socket clientSocket);
35
+	}
36
+
33 37
 	private static class Acceptor extends Thread {
34
-		private boolean shouldStop = false;
35 38
 		private final NewConnectionCallback callback;
36 39
 		private final ErrorCallback errorCallback;
37
-		private ServerSocket server;
38 40
 		private final int port;
41
+		private boolean shouldStop = false;
42
+		private ServerSocket server;
39 43
 
40 44
 		public Acceptor(int port, NewConnectionCallback callback, ErrorCallback errorCallback) {
41 45
 			this.port = port;
@@ -66,9 +70,4 @@ public class TcpListener {
66 70
 			}
67 71
 		}
68 72
 	}
69
-
70
-
71
-	public interface NewConnectionCallback {
72
-		void onNewConnection(Socket clientSocket);
73
-	}
74 73
 }

+ 10
- 9
lib/src/main/java/fr/insa/clavardator/lib/users/User.java View File

@@ -5,17 +5,10 @@ import java.beans.PropertyChangeSupport;
5 5
 import java.io.Serializable;
6 6
 
7 7
 public class User implements Serializable {
8
-	private String username;
9
-	private String id;
10
-
11 8
 	// Make this class observable
12 9
 	private final transient PropertyChangeSupport pcs = new PropertyChangeSupport(this);
13
-	public void addObserver(PropertyChangeListener listener) {
14
-		pcs.addPropertyChangeListener(listener);
15
-	}
16
-	public void removeObserver(PropertyChangeListener listener) {
17
-		pcs.removePropertyChangeListener(listener);
18
-	}
10
+	private String username;
11
+	private String id;
19 12
 
20 13
 	public User() {
21 14
 	}
@@ -29,6 +22,14 @@ public class User implements Serializable {
29 22
 		this.username = username;
30 23
 	}
31 24
 
25
+	public void addObserver(PropertyChangeListener listener) {
26
+		pcs.addPropertyChangeListener(listener);
27
+	}
28
+
29
+	public void removeObserver(PropertyChangeListener listener) {
30
+		pcs.removePropertyChangeListener(listener);
31
+	}
32
+
32 33
 	public PropertyChangeSupport getPcs() {
33 34
 		return pcs;
34 35
 	}

+ 7
- 7
lib/src/main/java/fr/insa/clavardator/lib/util/Log.java View File

@@ -16,13 +16,13 @@ public class Log {
16 16
 	public static int verboseLevel = 4;
17 17
 
18 18
 	private static void print(String prefix, String message, String mode, int requiredLevel, @Nullable Exception e) {
19
-			if (verboseLevel >= requiredLevel) {
20
-					Date date = new Date();
21
-					SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS");
22
-					System.out.println(sdf.format(date) + " | " + mode + " | " + prefix + ": " + message);
23
-					if (e != null)
24
-							e.printStackTrace();
25
-			}
19
+		if (verboseLevel >= requiredLevel) {
20
+			Date date = new Date();
21
+			SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS");
22
+			System.out.println(sdf.format(date) + " | " + mode + " | " + prefix + ": " + message);
23
+			if (e != null)
24
+				e.printStackTrace();
25
+		}
26 26
 	}
27 27
 
28 28
 	public static void v(String prefix, String message) {

+ 1
- 1
server/build.gradle View File

@@ -21,6 +21,6 @@ shadowJar {
21 21
     mergeServiceFiles()
22 22
 }
23 23
 
24
-run{
24
+run {
25 25
     standardInput = System.in
26 26
 }

+ 1
- 1
server/src/main/java/fr/insa/clavardator/server/Main.java View File

@@ -51,7 +51,7 @@ public class Main {
51 51
 				printVersion();
52 52
 				System.exit(0);
53 53
 			}
54
-			for (int i = 0; i < args.length -1; i++) {
54
+			for (int i = 0; i < args.length - 1; i++) {
55 55
 				if (PROXY_ARGS.contains(args[i])) {
56 56
 					proxyPort = getPort(args[i + 1], PROXY_PORT);
57 57
 				}

+ 1
- 1
server/src/main/java/fr/insa/clavardator/server/Presence.java View File

@@ -30,7 +30,7 @@ public class Presence {
30 30
 	public void publish(UserInformation info) {
31 31
 		ArrayList<UserInformation> msg = new ArrayList<>(1);
32 32
 		msg.add(info);
33
-		for (Map.Entry<String,TcpConnection> entry : subscribers.entrySet()) {
33
+		for (Map.Entry<String, TcpConnection> entry : subscribers.entrySet()) {
34 34
 			// Do not send update to self
35 35
 			if (!entry.getKey().equals(info.id)) {
36 36
 				entry.getValue().send(msg, null,

Loading…
Cancel
Save