Move SceneInfo to separate file

This commit is contained in:
Kai S. K. Engelbart 2020-11-06 08:58:13 +01:00
parent cd7793a589
commit 0ce8b0c89d
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13
8 changed files with 51 additions and 49 deletions

View File

@ -6,7 +6,7 @@ import envoy.data.User.UserStatus;
import envoy.client.data.Context; import envoy.client.data.Context;
import envoy.client.helper.ShutdownHelper; import envoy.client.helper.ShutdownHelper;
import envoy.client.ui.SceneContext.SceneInfo; import envoy.client.ui.SceneInfo;
import envoy.client.util.UserUtil; import envoy.client.util.UserUtil;
/** /**

View File

@ -4,7 +4,7 @@ import java.util.*;
import javafx.scene.input.KeyCombination; import javafx.scene.input.KeyCombination;
import envoy.client.ui.SceneContext.SceneInfo; import envoy.client.ui.SceneInfo;
/** /**
* Contains all keyboard shortcuts used throughout the application. * Contains all keyboard shortcuts used throughout the application.

View File

@ -28,45 +28,6 @@ import envoy.client.event.*;
*/ */
public final class SceneContext implements EventListener { public final class SceneContext implements EventListener {
/**
* Contains information about different scenes and their FXML resource files.
*
* @author Kai S. K. Engelbart
* @since Envoy Client v0.1-beta
*/
public enum SceneInfo {
/**
* The main scene in which the chat screen is displayed.
*
* @since Envoy Client v0.1-beta
*/
CHAT_SCENE("/fxml/ChatScene.fxml"),
/**
* The scene in which the settings screen is displayed.
*
* @since Envoy Client v0.1-beta
*/
SETTINGS_SCENE("/fxml/SettingsScene.fxml"),
/**
* The scene in which the login screen is displayed.
*
* @since Envoy Client v0.1-beta
*/
LOGIN_SCENE("/fxml/LoginScene.fxml");
/**
* The path to the FXML resource.
*/
public final String path;
SceneInfo(String path) {
this.path = path;
}
}
private final Stage stage; private final Stage stage;
private final FXMLLoader loader = new FXMLLoader(); private final FXMLLoader loader = new FXMLLoader();
private final Stack<Scene> sceneStack = new Stack<>(); private final Stack<Scene> sceneStack = new Stack<>();

View File

@ -0,0 +1,40 @@
package envoy.client.ui;
/**
* Contains information about different scenes and their FXML resource files.
*
* @author Kai S. K. Engelbart
* @since Envoy Client v0.1-beta
*/
public enum SceneInfo {
/**
* The main scene in which the chat screen is displayed.
*
* @since Envoy Client v0.1-beta
*/
CHAT_SCENE("/fxml/ChatScene.fxml"),
/**
* The scene in which the settings screen is displayed.
*
* @since Envoy Client v0.1-beta
*/
SETTINGS_SCENE("/fxml/SettingsScene.fxml"),
/**
* The scene in which the login screen is displayed.
*
* @since Envoy Client v0.1-beta
*/
LOGIN_SCENE("/fxml/LoginScene.fxml");
/**
* The path to the FXML resource.
*/
public final String path;
SceneInfo(String path) {
this.path = path;
}
}

View File

@ -20,7 +20,6 @@ import envoy.client.data.*;
import envoy.client.data.shortcuts.EnvoyShortcutConfig; import envoy.client.data.shortcuts.EnvoyShortcutConfig;
import envoy.client.helper.ShutdownHelper; import envoy.client.helper.ShutdownHelper;
import envoy.client.net.Client; import envoy.client.net.Client;
import envoy.client.ui.SceneContext.SceneInfo;
import envoy.client.ui.controller.LoginScene; import envoy.client.ui.controller.LoginScene;
import envoy.client.util.IconUtil; import envoy.client.util.IconUtil;
@ -226,7 +225,7 @@ public final class Startup extends Application {
// Load ChatScene // Load ChatScene
stage.setMinHeight(400); stage.setMinHeight(400);
stage.setMinWidth(843); stage.setMinWidth(843);
context.getSceneContext().load(SceneContext.SceneInfo.CHAT_SCENE); context.getSceneContext().load(SceneInfo.CHAT_SCENE);
stage.centerOnScreen(); stage.centerOnScreen();
// Exit or minimize the stage when a close request occurs // Exit or minimize the stage when a close request occurs

View File

@ -15,7 +15,7 @@ import envoy.util.EnvoyLog;
import envoy.client.data.Context; import envoy.client.data.Context;
import envoy.client.data.commands.*; import envoy.client.data.commands.*;
import envoy.client.helper.ShutdownHelper; import envoy.client.helper.ShutdownHelper;
import envoy.client.ui.SceneContext.SceneInfo; import envoy.client.ui.SceneInfo;
import envoy.client.ui.controller.ChatScene; import envoy.client.ui.controller.ChatScene;
import envoy.client.util.*; import envoy.client.util.*;
@ -32,7 +32,7 @@ public final class ChatSceneCommands {
private final SystemCommandBuilder builder = private final SystemCommandBuilder builder =
new SystemCommandBuilder(messageTextAreaCommands); new SystemCommandBuilder(messageTextAreaCommands);
private static final String messageDependantCommandDescription = private static final String messageDependentCommandDescription =
" the given message. Use s/S to use the selected message. Otherwise expects a number relative to the uppermost completely visible message."; " the given message. Use s/S to use the selected message. Otherwise expects a number relative to the uppermost completely visible message.";
/** /**
@ -141,7 +141,7 @@ public final class ChatSceneCommands {
else else
useRelativeMessage(command, action, additionalCheck, positionalArgument, false); useRelativeMessage(command, action, additionalCheck, positionalArgument, false);
}).setDefaults("s").setNumberOfArguments(1) }).setDefaults("s").setNumberOfArguments(1)
.setDescription(description.concat(messageDependantCommandDescription)).build(command); .setDescription(description.concat(messageDependentCommandDescription)).build(command);
} }
private void selectionNeighbor(Consumer<Message> action, Predicate<Message> additionalCheck, private void selectionNeighbor(Consumer<Message> action, Predicate<Message> additionalCheck,

View File

@ -1,5 +1,7 @@
package envoy.client.ui.controller; package envoy.client.ui.controller;
import static envoy.client.ui.SceneInfo.SETTINGS_SCENE;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.StringSelection;
import java.io.*; import java.io.*;
@ -32,7 +34,7 @@ import envoy.data.*;
import envoy.data.Attachment.AttachmentType; import envoy.data.Attachment.AttachmentType;
import envoy.data.Message.MessageStatus; import envoy.data.Message.MessageStatus;
import envoy.event.*; import envoy.event.*;
import envoy.event.contact.*; import envoy.event.contact.UserOperation;
import envoy.exception.EnvoyException; import envoy.exception.EnvoyException;
import envoy.util.EnvoyLog; import envoy.util.EnvoyLog;
@ -445,7 +447,7 @@ public final class ChatScene implements EventListener, Restorable, KeyboardMappi
*/ */
@FXML @FXML
private void settingsButtonClicked() { private void settingsButtonClicked() {
sceneContext.load(SceneContext.SceneInfo.SETTINGS_SCENE); sceneContext.load(SETTINGS_SCENE);
} }
/** /**

View File

@ -16,7 +16,7 @@ import envoy.util.EnvoyLog;
import envoy.client.data.Context; import envoy.client.data.Context;
import envoy.client.event.*; import envoy.client.event.*;
import envoy.client.helper.*; import envoy.client.helper.*;
import envoy.client.ui.SceneContext.SceneInfo; import envoy.client.ui.SceneInfo;
import envoy.client.ui.controller.ChatScene; import envoy.client.ui.controller.ChatScene;
/** /**