From 232439a564d6a554dcfe566d730d6363372de5d2 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Mon, 8 Jun 2020 10:36:30 +0200 Subject: [PATCH] Move scene controllers to separate package --- src/main/java/envoy/client/ui/SceneContext.java | 2 +- src/main/java/envoy/client/ui/Startup.java | 3 ++- .../ChatScene.java} | 16 +++++++++------- .../ContactSearchScene.java} | 8 +++++--- .../SettingsScene.java} | 6 ++++-- .../envoy/client/ui/controller/package-info.java | 11 +++++++++++ src/main/java/module-info.java | 2 +- src/main/resources/fxml/ChatScene.fxml | 2 +- src/main/resources/fxml/ContactSearchScene.fxml | 2 +- src/main/resources/fxml/SettingsScene.fxml | 2 +- 10 files changed, 36 insertions(+), 18 deletions(-) rename src/main/java/envoy/client/ui/{ChatSceneController.java => controller/ChatScene.java} (94%) rename src/main/java/envoy/client/ui/{ContactSearchSceneController.java => controller/ContactSearchScene.java} (95%) rename src/main/java/envoy/client/ui/{settings/SettingsSceneController.java => controller/SettingsScene.java} (88%) create mode 100644 src/main/java/envoy/client/ui/controller/package-info.java diff --git a/src/main/java/envoy/client/ui/SceneContext.java b/src/main/java/envoy/client/ui/SceneContext.java index a8986f4..42dbc59 100644 --- a/src/main/java/envoy/client/ui/SceneContext.java +++ b/src/main/java/envoy/client/ui/SceneContext.java @@ -29,7 +29,7 @@ import envoy.event.EventBus; */ public final class SceneContext { - static enum SceneInfo { + public static enum SceneInfo { CHAT_SCENE("/fxml/ChatScene.fxml"), SETTINGS_SCENE("/fxml/SettingsScene.fxml"), CONTACT_SEARCH_SCENE("/fxml/ContactSearchScene.fxml"); diff --git a/src/main/java/envoy/client/ui/Startup.java b/src/main/java/envoy/client/ui/Startup.java index 55afb40..8464ae6 100644 --- a/src/main/java/envoy/client/ui/Startup.java +++ b/src/main/java/envoy/client/ui/Startup.java @@ -15,6 +15,7 @@ import javafx.stage.Stage; import envoy.client.data.*; import envoy.client.net.Client; import envoy.client.net.WriteProxy; +import envoy.client.ui.controller.ChatScene; import envoy.data.Message; import envoy.data.User; import envoy.data.User.UserStatus; @@ -122,7 +123,7 @@ public final class Startup extends Application { // Prepare stage and load ChatScene final var sceneContext = new SceneContext(stage); sceneContext.load(SceneContext.SceneInfo.CHAT_SCENE); - sceneContext.getController().initializeData(sceneContext, localDB, client, writeProxy); + sceneContext.getController().initializeData(sceneContext, localDB, client, writeProxy); stage.setTitle("Envoy"); stage.setMinHeight(400); diff --git a/src/main/java/envoy/client/ui/ChatSceneController.java b/src/main/java/envoy/client/ui/controller/ChatScene.java similarity index 94% rename from src/main/java/envoy/client/ui/ChatSceneController.java rename to src/main/java/envoy/client/ui/controller/ChatScene.java index 14b1a7e..ea59c90 100644 --- a/src/main/java/envoy/client/ui/ChatSceneController.java +++ b/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -1,4 +1,4 @@ -package envoy.client.ui; +package envoy.client.ui.controller; import java.io.IOException; import java.util.logging.Level; @@ -19,7 +19,9 @@ import envoy.client.data.Settings; import envoy.client.event.MessageCreationEvent; import envoy.client.net.Client; import envoy.client.net.WriteProxy; -import envoy.client.ui.settings.SettingsSceneController; +import envoy.client.ui.MessageListCell; +import envoy.client.ui.SceneContext; +import envoy.client.ui.UserListCell; import envoy.data.Contact; import envoy.data.Message; import envoy.data.MessageBuilder; @@ -37,7 +39,7 @@ import envoy.util.EnvoyLog; * @author Kai S. K. Engelbart * @since Envoy Client v0.1-beta */ -public final class ChatSceneController { +public final class ChatScene { @FXML private Label contactLabel; @@ -69,7 +71,7 @@ public final class ChatSceneController { private static final Settings settings = Settings.getInstance(); private static final EventBus eventBus = EventBus.getInstance(); - private static final Logger logger = EnvoyLog.getLogger(ChatSceneController.class); + private static final Logger logger = EnvoyLog.getLogger(ChatScene.class); private static final int MAX_MESSAGE_LENGTH = 255; @FXML @@ -117,7 +119,7 @@ public final class ChatSceneController { }); } - void initializeData(SceneContext sceneContext, LocalDB localDB, Client client, WriteProxy writeProxy) { + public void initializeData(SceneContext sceneContext, LocalDB localDB, Client client, WriteProxy writeProxy) { this.sceneContext = sceneContext; this.localDB = localDB; this.client = client; @@ -158,7 +160,7 @@ public final class ChatSceneController { private void settingsButtonClicked() { try { sceneContext.load(SceneContext.SceneInfo.SETTINGS_SCENE); - sceneContext.getController().initializeData(sceneContext); + sceneContext.getController().initializeData(sceneContext); } catch (final IOException e) { e.printStackTrace(); } @@ -168,7 +170,7 @@ public final class ChatSceneController { private void addContactButtonClicked() { try { sceneContext.load(SceneContext.SceneInfo.CONTACT_SEARCH_SCENE); - sceneContext.getController().initializeData(sceneContext); + sceneContext.getController().initializeData(sceneContext); } catch (final IOException e) { e.printStackTrace(); } diff --git a/src/main/java/envoy/client/ui/ContactSearchSceneController.java b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java similarity index 95% rename from src/main/java/envoy/client/ui/ContactSearchSceneController.java rename to src/main/java/envoy/client/ui/controller/ContactSearchScene.java index da4e2c0..d6c34b6 100644 --- a/src/main/java/envoy/client/ui/ContactSearchSceneController.java +++ b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java @@ -1,4 +1,4 @@ -package envoy.client.ui; +package envoy.client.ui.controller; import java.util.Optional; import java.util.logging.Level; @@ -10,6 +10,8 @@ import javafx.scene.control.ListView; import javafx.scene.control.TextField; import envoy.client.event.SendEvent; +import envoy.client.ui.SceneContext; +import envoy.client.ui.UserListCell; import envoy.data.Contact; import envoy.event.ElementOperation; import envoy.event.EventBus; @@ -26,7 +28,7 @@ import envoy.util.EnvoyLog; * @author Leon Hofmeister * @since Envoy Client v0.1-beta */ -public class ContactSearchSceneController { +public class ContactSearchScene { @FXML private Button backButton; @@ -46,7 +48,7 @@ public class ContactSearchSceneController { private SceneContext sceneContext; private static EventBus eventBus = EventBus.getInstance(); - private static final Logger logger = EnvoyLog.getLogger(ChatSceneController.class); + private static final Logger logger = EnvoyLog.getLogger(ChatScene.class); /** * @param sceneContext enables the user to return to the chat scene diff --git a/src/main/java/envoy/client/ui/settings/SettingsSceneController.java b/src/main/java/envoy/client/ui/controller/SettingsScene.java similarity index 88% rename from src/main/java/envoy/client/ui/settings/SettingsSceneController.java rename to src/main/java/envoy/client/ui/controller/SettingsScene.java index 795a57f..b7cc49d 100644 --- a/src/main/java/envoy/client/ui/settings/SettingsSceneController.java +++ b/src/main/java/envoy/client/ui/controller/SettingsScene.java @@ -1,9 +1,11 @@ -package envoy.client.ui.settings; +package envoy.client.ui.controller; import javafx.fxml.FXML; import javafx.scene.control.*; import envoy.client.ui.SceneContext; +import envoy.client.ui.settings.GeneralSettingsPane; +import envoy.client.ui.settings.SettingsPane; /** * Project: envoy-client
@@ -13,7 +15,7 @@ import envoy.client.ui.SceneContext; * @author Kai S. K. Engelbart * @since Envoy Client v0.1-beta */ -public class SettingsSceneController { +public class SettingsScene { @FXML private ListView settingsList; diff --git a/src/main/java/envoy/client/ui/controller/package-info.java b/src/main/java/envoy/client/ui/controller/package-info.java new file mode 100644 index 0000000..51d18e8 --- /dev/null +++ b/src/main/java/envoy/client/ui/controller/package-info.java @@ -0,0 +1,11 @@ +/** + * Contains JavaFX scene controllers. + *

+ * Project: envoy-client
+ * File: package-info.java
+ * Created: 08.06.2020
+ * + * @author Kai S. K. Engelbart + * @since Envoy Client v0.1-beta + */ +package envoy.client.ui.controller; \ No newline at end of file diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 905a52a..1f0d0b1 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -18,6 +18,6 @@ module envoy { requires javafx.base; requires javafx.graphics; - opens envoy.client.ui.settings to javafx.graphics, javafx.fxml; opens envoy.client.ui to javafx.graphics, javafx.fxml; + opens envoy.client.ui.controller to javafx.graphics, javafx.fxml; } diff --git a/src/main/resources/fxml/ChatScene.fxml b/src/main/resources/fxml/ChatScene.fxml index 6f2b0b8..d56a195 100644 --- a/src/main/resources/fxml/ChatScene.fxml +++ b/src/main/resources/fxml/ChatScene.fxml @@ -9,7 +9,7 @@ - + diff --git a/src/main/resources/fxml/ContactSearchScene.fxml b/src/main/resources/fxml/ContactSearchScene.fxml index a50d6be..c1fe70b 100644 --- a/src/main/resources/fxml/ContactSearchScene.fxml +++ b/src/main/resources/fxml/ContactSearchScene.fxml @@ -10,7 +10,7 @@ - + diff --git a/src/main/resources/fxml/SettingsScene.fxml b/src/main/resources/fxml/SettingsScene.fxml index 0620305..865bb9b 100644 --- a/src/main/resources/fxml/SettingsScene.fxml +++ b/src/main/resources/fxml/SettingsScene.fxml @@ -7,7 +7,7 @@ - +