Move scene controllers to separate package
This commit is contained in:
parent
0372c1393e
commit
232439a564
@ -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");
|
||||
|
||||
|
@ -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.<ChatSceneController>getController().initializeData(sceneContext, localDB, client, writeProxy);
|
||||
sceneContext.<ChatScene>getController().initializeData(sceneContext, localDB, client, writeProxy);
|
||||
|
||||
stage.setTitle("Envoy");
|
||||
stage.setMinHeight(400);
|
||||
|
@ -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.<SettingsSceneController>getController().initializeData(sceneContext);
|
||||
sceneContext.<SettingsScene>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.<ContactSearchSceneController>getController().initializeData(sceneContext);
|
||||
sceneContext.<ContactSearchScene>getController().initializeData(sceneContext);
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
@ -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
|
@ -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: <strong>envoy-client</strong><br>
|
||||
@ -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<SettingsPane> settingsList;
|
11
src/main/java/envoy/client/ui/controller/package-info.java
Normal file
11
src/main/java/envoy/client/ui/controller/package-info.java
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Contains JavaFX scene controllers.
|
||||
* <p>
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>package-info.java</strong><br>
|
||||
* Created: <strong>08.06.2020</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
package envoy.client.ui.controller;
|
@ -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;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
|
||||
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="400.0" minWidth="350.0" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.ChatSceneController">
|
||||
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="400.0" minWidth="350.0" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.controller.ChatScene">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" percentWidth="20.0" prefWidth="161.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" percentWidth="65.0" prefWidth="357.0" />
|
||||
|
@ -10,7 +10,7 @@
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
|
||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.ContactSearchSceneController">
|
||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.controller.ContactSearchScene">
|
||||
<children>
|
||||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<VBox alignment="TOP_RIGHT" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.settings.SettingsSceneController">
|
||||
<VBox alignment="TOP_RIGHT" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.controller.SettingsScene">
|
||||
<children>
|
||||
<HBox prefHeight="100.0" prefWidth="200.0">
|
||||
<children>
|
||||
|
Reference in New Issue
Block a user