Added Enums for each Open View for easier storage for Session.
This commit is contained in:
@@ -28,6 +28,7 @@ public class App extends Application
|
||||
private Dataset currentDataset = null;
|
||||
private Stage primaryStage = null;
|
||||
private VBox mainContainer;
|
||||
private Session session;
|
||||
|
||||
public static void main( String[] args )
|
||||
{
|
||||
@@ -40,6 +41,7 @@ public class App extends Application
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
this.primaryStage = primaryStage;
|
||||
this.session = new Session();
|
||||
//load the menu and the first container
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
@@ -126,9 +128,9 @@ public class App extends Application
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Initializable replaceSceneContent(String fxml) throws Exception {
|
||||
public Initializable replaceSceneContent(SceneCode fxml) throws Exception {
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
InputStream in = getClass().getClassLoader().getResourceAsStream(fxml);
|
||||
InputStream in = getClass().getClassLoader().getResourceAsStream(fxml.getFilePath());
|
||||
Parent page;
|
||||
try {
|
||||
page = (Parent) loader.load(in);
|
||||
@@ -139,6 +141,8 @@ public class App extends Application
|
||||
mainContainer.getChildren().remove(1);
|
||||
}
|
||||
mainContainer.getChildren().add(page);
|
||||
//change session code to fit with the serialisation
|
||||
session.setSceneDisplayed(fxml);
|
||||
return (Initializable) loader.getController();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,18 @@ package seng202.group9.Controller;
|
||||
* Created by fwy13 on 16/09/16.
|
||||
*/
|
||||
public enum SceneCode {
|
||||
INITIAL, AIRLINE_SUMMARY, AIRLINE_RAW_DATA, AIRPORT_SUMMARY, AIRPORT_RAW_DATA,
|
||||
ROUTE_SUMMARY, ROUTE_RAW_DATA, FLIGHT_SUMMARY, FLIGHT_RAW_DATA
|
||||
INITIAL(""), AIRLINE_SUMMARY("airline_summary.fxml"), AIRLINE_RAW_DATA("airline_raw_data.fxml"),
|
||||
AIRPORT_SUMMARY("airport_summary.fxml"), AIRPORT_RAW_DATA("airport_raw_data.fxml"),
|
||||
ROUTE_SUMMARY("routes_summary.fxml"), ROUTE_RAW_DATA("route_raw_data.fxml"), FLIGHT_SUMMARY("flight_data_summary.fxml"),
|
||||
FLIGHT_RAW_DATA("flight_raw_data.fxml");
|
||||
|
||||
private String filePath;
|
||||
|
||||
SceneCode(String filePath){
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public String getFilePath(){
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,16 @@ import java.io.Serializable;
|
||||
* Created by fwy13 on 16/09/16.
|
||||
*/
|
||||
public class Session implements Serializable {
|
||||
private SceneCode sceneDisplayed = SceneCode.INITIAL;
|
||||
private SceneCode sceneDisplayed;
|
||||
|
||||
public Session(){
|
||||
//blank constructor
|
||||
this.sceneDisplayed = SceneCode.INITIAL;
|
||||
}
|
||||
|
||||
public Session(SceneCode scene){
|
||||
this.sceneDisplayed = scene;
|
||||
}
|
||||
|
||||
public void setSceneDisplayed(SceneCode sceneDisplayed) {
|
||||
this.sceneDisplayed = sceneDisplayed;
|
||||
|
||||
Reference in New Issue
Block a user