diff --git a/res/userdb.db b/res/userdb.db index e70283a..6476a05 100644 Binary files a/res/userdb.db and b/res/userdb.db differ diff --git a/src/main/java/seng202/group9/Core/FlightPath.java b/src/main/java/seng202/group9/Core/FlightPath.java index 0f29d90..70539e4 100644 --- a/src/main/java/seng202/group9/Core/FlightPath.java +++ b/src/main/java/seng202/group9/Core/FlightPath.java @@ -28,7 +28,7 @@ public class FlightPath { } /** - * COnstructor for FlightPath from dataset add later the ID needs to be set from database. + * Constructor for FlightPath from dataset add later the ID needs to be set from database. * @param departureAirport * @param arrivalAirport */ diff --git a/src/main/java/seng202/group9/GUI/FlightRDController.java b/src/main/java/seng202/group9/GUI/FlightRDController.java index d3a42c0..25ab2dd 100644 --- a/src/main/java/seng202/group9/GUI/FlightRDController.java +++ b/src/main/java/seng202/group9/GUI/FlightRDController.java @@ -92,17 +92,19 @@ public class FlightRDController extends Controller { flightPathListView.setOnMouseClicked(new EventHandler() { public void handle(MouseEvent event) { String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem(); - String[] segments = flightPathDisplayNameClicked.split("_"); - String pathIdClicked = segments[0]; + 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 flightPaths; - flightPaths = theDataSet.getFlightPaths(); - ArrayList flightPoints = flightPaths.get(currentPathIndex).getFlight(); - flightTableView.setItems(FXCollections.observableArrayList(flightPoints)); + ArrayList flightPaths; + flightPaths = theDataSet.getFlightPaths(); + ArrayList flightPoints = flightPaths.get(currentPathIndex).getFlight(); + flightTableView.setItems(FXCollections.observableArrayList(flightPoints)); + } } }); @@ -246,6 +248,9 @@ public class FlightRDController extends Controller { flightPathListView(); } + /** + * Function for the 'Move Up' right click option on the points in the flight table. + */ public void movePointUp(){ FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem(); int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex(); @@ -258,9 +263,11 @@ public class FlightRDController extends Controller { } updateTable(currentPathIndex); updatePaths(); - } + /** + * Function for the 'Move Down' right click option on the points in the flight table. + */ public void movePointDown(){ FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem(); int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex(); @@ -287,6 +294,9 @@ public class FlightRDController extends Controller { flightTableView.refresh(); } + /** + * Updates the flight path list view so that it displays the correct names for the paths + */ private void updatePaths(){ try { flightPathListView.getItems().clear(); diff --git a/src/main/java/seng202/group9/GUI/FlightSummaryController.java b/src/main/java/seng202/group9/GUI/FlightSummaryController.java index c5a99f4..12f8c86 100644 --- a/src/main/java/seng202/group9/GUI/FlightSummaryController.java +++ b/src/main/java/seng202/group9/GUI/FlightSummaryController.java @@ -158,12 +158,14 @@ public class FlightSummaryController extends Controller { flightPathListView.setOnMouseClicked(new EventHandler() { public void handle(MouseEvent event) { String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem(); - String[] segments = flightPathDisplayNameClicked.split("_"); - String pathIdClicked = segments[0]; - - currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary() - .get(Integer.parseInt(pathIdClicked))); - currentPathId = Integer.parseInt(pathIdClicked); + 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); + } } }); flightPathListView.setItems(flightList);