Added if dataset open/add incase dataset is null to all pages that require a non null dataset to exist.
This commit is contained in:
@@ -90,20 +90,6 @@ public class App extends Application
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
//testing out dataset
|
||||
try {
|
||||
if (session.getCurrentDataset() != null) {
|
||||
currentDataset = new Dataset(session.getCurrentDataset(), Dataset.getExisting);
|
||||
}else{
|
||||
createPopUpStage(SceneCode.DATASET_CONTROLLER, 600, 400);
|
||||
}
|
||||
}catch (DataException e){
|
||||
createPopUpStage(SceneCode.DATASET_CONTROLLER, 600, 400);
|
||||
}catch (NullPointerException e){
|
||||
createPopUpStage(SceneCode.DATASET_CONTROLLER, 600, 400);
|
||||
}catch (Exception e){
|
||||
createPopUpStage(SceneCode.DATASET_CONTROLLER, 600, 400);
|
||||
}
|
||||
//after all loading then load the previous session
|
||||
if (session.getSceneDisplayed() != null) {
|
||||
menuController.replaceSceneContent(session.getSceneDisplayed());
|
||||
@@ -255,36 +241,4 @@ public class App extends Application
|
||||
}
|
||||
}
|
||||
|
||||
public Stage createPopUpStage(SceneCode scene, int width, int height) {
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
InputStream in = getClass().getClassLoader().getResourceAsStream(scene.getFilePath());
|
||||
Parent page = null;
|
||||
try {
|
||||
page = loader.load(in);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//set contorller and call default calls
|
||||
Controller controller = (Controller) loader.getController();
|
||||
controller.setApp(this);
|
||||
controller.load();
|
||||
controller.loadOnce();
|
||||
//create a new stage to popup
|
||||
Stage popupStage = new Stage();
|
||||
popupStage.initModality(Modality.WINDOW_MODAL);
|
||||
//inner layout constraints
|
||||
VBox container = new VBox();
|
||||
container.getChildren().add(page);
|
||||
Scene popupScene = new Scene(container, width, height);
|
||||
//show
|
||||
popupStage.setScene(popupScene);
|
||||
popupStage.showAndWait();
|
||||
return popupStage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@ public class AirlineRDController extends Controller {
|
||||
* Also sets up the dropdown menu options.
|
||||
*/
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
//Sets up the table columns to be ready for use for Airline data
|
||||
airlIDCol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ID"));
|
||||
airlNameCol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Name"));
|
||||
|
||||
@@ -48,6 +48,9 @@ public class AirlineSummaryController extends Controller{
|
||||
* Loads initial state of the scene.
|
||||
*/
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
//Fills the table.
|
||||
columnName.setCellValueFactory(new PropertyValueFactory<Airline, String>("Name"));
|
||||
columnAlias.setCellValueFactory(new PropertyValueFactory<Airline, String>("Alias"));
|
||||
|
||||
@@ -71,6 +71,9 @@ public class AirportAnalyser extends Controller {
|
||||
* Takes the current dataset then loads the data to the graph using build graph.
|
||||
*/
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
currentdata = getParent().getCurrentDataset();
|
||||
build_graph();
|
||||
}
|
||||
|
||||
@@ -72,6 +72,9 @@ public class AirportEditController extends Controller {
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
currentSession = getParent().getSession();
|
||||
|
||||
|
||||
@@ -59,26 +59,31 @@ public class AirportRDController extends Controller{
|
||||
* Also sets up the dropdown menu options.
|
||||
*/
|
||||
public void load() {
|
||||
//Sets up the table columns to be ready for use for Airport data
|
||||
airpIDCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ID"));
|
||||
airpNameCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
|
||||
airpCityCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("CityName"));
|
||||
airpCountryCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("CountryName"));
|
||||
airpIATAFFACol.setCellValueFactory(new PropertyValueFactory<Airport, String>("IATA_FFA"));
|
||||
airpICAOCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ICAO"));
|
||||
airpLatitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Latitude"));
|
||||
airpLongitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Longitude"));
|
||||
airpAltitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String> ("Altitude"));
|
||||
airpTimezoneCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Timezone"));
|
||||
airpDSTCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("DST"));
|
||||
airpTzCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Tz"));
|
||||
|
||||
//Assigning the Dataset to the current Dataset's airports and displaying it in a table
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
currentSession = getParent().getSession();
|
||||
if (theDataSet != null) {
|
||||
//Sets up the table columns to be ready for use for Airport data
|
||||
airpIDCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ID"));
|
||||
airpNameCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
|
||||
airpCityCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("CityName"));
|
||||
airpCountryCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("CountryName"));
|
||||
airpIATAFFACol.setCellValueFactory(new PropertyValueFactory<Airport, String>("IATA_FFA"));
|
||||
airpICAOCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ICAO"));
|
||||
airpLatitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Latitude"));
|
||||
airpLongitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Longitude"));
|
||||
airpAltitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Altitude"));
|
||||
airpTimezoneCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Timezone"));
|
||||
airpDSTCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("DST"));
|
||||
airpTzCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Tz"));
|
||||
|
||||
tableViewAirportRD.setItems(observableArrayList(theDataSet.getAirports()));
|
||||
tableViewAirportRD.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||
//Assigning the Dataset to the current Dataset's airports and displaying it in a table
|
||||
currentSession = getParent().getSession();
|
||||
|
||||
tableViewAirportRD.setItems(observableArrayList(theDataSet.getAirports()));
|
||||
tableViewAirportRD.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void openAdd() {
|
||||
|
||||
@@ -72,6 +72,9 @@ public class AirportSummaryController extends Controller{
|
||||
* Loads initial state of the scene.
|
||||
*/
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
currentData = getParent().getCurrentDataset();
|
||||
columnName.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
|
||||
columnCity.setCellValueFactory(new PropertyValueFactory<Airport, String>("CityName"));
|
||||
|
||||
@@ -4,6 +4,7 @@ import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
@@ -58,6 +59,23 @@ public abstract class Controller implements Initializable{
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkDataset(){
|
||||
//if the dataset is null then we want to change to the initial and give a warning.
|
||||
//Also then let them selecthe data set
|
||||
if (getParent().getCurrentDataset() == null) {
|
||||
replaceSceneContent(SceneCode.INITIAL);
|
||||
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||
alert.setTitle("Missing Dataset");
|
||||
alert.setHeaderText("No Dataset is currently selected.");
|
||||
alert.setContentText("Please Create a Dataset to store your Information in.");
|
||||
alert.showAndWait();
|
||||
createPopUpStage(SceneCode.DATASET_CONTROLLER, 600, 400);
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a popup window with a specific fxml scene
|
||||
* @param scene
|
||||
|
||||
@@ -67,6 +67,9 @@ public class DistCalcController extends Controller {
|
||||
* Sets the initial state of the scene.
|
||||
*/
|
||||
public void load(){
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
currentData = getParent().getCurrentDataset();
|
||||
answerBox.textProperty().bind(bound);
|
||||
fill_boxes();
|
||||
|
||||
@@ -32,6 +32,9 @@ public class FlightAddController extends Controller {
|
||||
private Session currentSession = null;
|
||||
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
currentSession = getParent().getSession();
|
||||
}
|
||||
|
||||
@@ -81,6 +81,9 @@ public class FlightEditorController extends Controller{
|
||||
* Loader which is used to load the selected information into the text fields for editing.
|
||||
*/
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
|
||||
Session session = getParent().getSession();
|
||||
|
||||
@@ -102,6 +102,9 @@ public class FlightRDController extends Controller {
|
||||
* Used to load the table for the Flight points initially from the MenuController
|
||||
*/
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
if (theDataSet != null) {
|
||||
try {
|
||||
@@ -127,25 +130,25 @@ public class FlightRDController extends Controller {
|
||||
}catch(IndexOutOfBoundsException e){
|
||||
System.out.println("There is no Paths to show");
|
||||
}
|
||||
}
|
||||
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>(){
|
||||
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
||||
String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem();
|
||||
if (flightPathDisplayNameClicked!=null) {
|
||||
String[] segments = flightPathDisplayNameClicked.split("_");
|
||||
String pathIdClicked = segments[0];
|
||||
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>(){
|
||||
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
||||
String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem();
|
||||
if (flightPathDisplayNameClicked!=null) {
|
||||
String[] segments = flightPathDisplayNameClicked.split("_");
|
||||
String pathIdClicked = segments[0];
|
||||
|
||||
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
|
||||
.get(Integer.parseInt(pathIdClicked)));
|
||||
currentPathId = Integer.parseInt(pathIdClicked);
|
||||
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
|
||||
.get(Integer.parseInt(pathIdClicked)));
|
||||
currentPathId = Integer.parseInt(pathIdClicked);
|
||||
|
||||
ArrayList<FlightPath> flightPaths;
|
||||
flightPaths = theDataSet.getFlightPaths();
|
||||
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
|
||||
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
||||
ArrayList<FlightPath> flightPaths;
|
||||
flightPaths = theDataSet.getFlightPaths();
|
||||
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
|
||||
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -175,6 +175,9 @@ public class FlightSummaryController extends Controller {
|
||||
* Used to load the page from the MenuController.
|
||||
*/
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
if (theDataSet != null) {
|
||||
try {
|
||||
|
||||
@@ -74,6 +74,9 @@ public class RouteAddController extends Controller {
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,9 @@ public class RouteAnalyser extends Controller {
|
||||
* Takes the current dataset then loads the data to the graph using build graph.
|
||||
*/
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
currentdata = getParent().getCurrentDataset();
|
||||
build_graph();
|
||||
}
|
||||
|
||||
@@ -58,6 +58,9 @@ public class RouteEditController extends Controller {
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
currentSession = getParent().getSession();
|
||||
|
||||
|
||||
@@ -86,6 +86,9 @@ public class RouteFilterController extends Controller {
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
currentSession = getParent().getSession();
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ public class RouteRDController extends Controller {
|
||||
* Also sets up the dropdown menu options.
|
||||
*/
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
//Sets up the table columns to be ready for use for Route data
|
||||
rAirlineCol.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineName"));
|
||||
rAirlineIDCol.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineID"));
|
||||
|
||||
@@ -43,6 +43,9 @@ public class RouteSummaryController extends Controller{
|
||||
* Loads initial state of the scene.
|
||||
*/
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
columnAirline.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineName"));
|
||||
columnDepart.setCellValueFactory(new PropertyValueFactory<Route, String>("DepartureAirport"));
|
||||
columnArrive.setCellValueFactory(new PropertyValueFactory<Route, String>("ArrivalAirport"));
|
||||
|
||||
Reference in New Issue
Block a user