Added a controller and a fxml file for getting started.

This commit is contained in:
Sunguin
2016-09-26 14:50:49 +13:00
parent 5d8b3e2656
commit b7308f1920
7 changed files with 165 additions and 18 deletions
@@ -50,6 +50,23 @@ public class App extends Application
@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
//after all loading then load the previous session
try{
FileInputStream fileIn = new FileInputStream("res/session.ser");
ObjectInputStream objectIn = new ObjectInputStream(fileIn);
session = (Session) objectIn.readObject();
objectIn.close();
fileIn.close();
}catch(IOException e){
session = new Session();
System.out.println("New Session File Created");
}catch(ClassNotFoundException e){
System.out.println("Missing Session Class");
System.exit(1);
} catch (Exception e) {
session = new Session();
e.printStackTrace();
}
//load the menu and the first container
try {
FXMLLoader loader = new FXMLLoader();
@@ -61,6 +78,9 @@ public class App extends Application
primaryStage.sizeToScene();
menuController = (MenuController) loader.getController();
menuController.setApp(this);
menuController.replaceSceneContent(SceneCode.INITIAL);
in.close();
} catch (Exception e) {
e.printStackTrace();
@@ -78,25 +98,13 @@ public class App extends Application
}catch (DataException e){
e.printStackTrace();
}
//after all loading then load the previous session
try{
FileInputStream fileIn = new FileInputStream("res/session.ser");
ObjectInputStream objectIn = new ObjectInputStream(fileIn);
session = (Session) objectIn.readObject();
Controller controller = (Controller) replaceSceneContent(session.getSceneDisplayed());
Controller controller = null;
try {
controller = (Controller) replaceSceneContent(session.getSceneDisplayed());
controller.setApp(this);
controller.load();
controller.loadOnce();
objectIn.close();
fileIn.close();
}catch(IOException e){
session = new Session();
System.out.println("New Session File Created");
}catch(ClassNotFoundException e){
System.out.println("Missing Session Class");
System.exit(1);
} catch (Exception e) {
session = new Session();
e.printStackTrace();
}
}
@@ -5,7 +5,7 @@ package seng202.group9.Controller;
* SceneCode enum is used for Serialization of sessions as well as changing the GUI state from one to the other.
*/
public enum SceneCode {
INITIAL(""), AIRLINE_SUMMARY("airline_summary.fxml"), AIRLINE_RAW_DATA("airline_raw_data.fxml"),
INITIAL("getting_started.fxml"), 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"), AIRPORT_ANALYSER("airport_analyser.fxml"), ROUTE_ANALYSER("route_analyser.fxml"),
@@ -0,0 +1,33 @@
package seng202.group9.GUI;
import seng202.group9.Controller.SceneCode;
/**
* Created by spe76 on 26/09/16.
*/
public class GettingStartedController extends Controller {
public void load() {
}
public void importAirlines() {
Importer importer = new Importer(SceneCode.AIRLINE_RAW_DATA, getParent(), getParent().getPrimaryStage());
}
public void importAirports() {
Importer importer = new Importer(SceneCode.AIRPORT_RAW_DATA, getParent(), getParent().getPrimaryStage());
}
public void importRoutes() {
Importer importer = new Importer(SceneCode.ROUTE_RAW_DATA, getParent(), getParent().getPrimaryStage());
}
public void importFlightData() {
Importer importer = new Importer(SceneCode.FLIGHT_RAW_DATA, getParent(), getParent().getPrimaryStage());
}
public void goToAirlineSummary() {
replaceSceneContent(SceneCode.AIRLINE_SUMMARY);
}
}
@@ -74,6 +74,10 @@ public class MenuController extends Controller{
replaceSceneContent(SceneCode.FLIGHT_RAW_DATA);
}
public void goToGettingStarted() {
replaceSceneContent(SceneCode.INITIAL);
}
public void load() {
//nothing to load
}