From ee239d9d6b262b757990adfe13547c81b70da465 Mon Sep 17 00:00:00 2001 From: YaFedImYaEatIm Date: Sat, 1 Oct 2016 18:06:46 +1300 Subject: [PATCH] Added catching for no Paths in Dataset --- .../group9/GUI/FlightRDController.java | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/seng202/group9/GUI/FlightRDController.java b/src/main/java/seng202/group9/GUI/FlightRDController.java index 51fc8b3..620a8b5 100644 --- a/src/main/java/seng202/group9/GUI/FlightRDController.java +++ b/src/main/java/seng202/group9/GUI/FlightRDController.java @@ -121,24 +121,28 @@ public class FlightRDController extends Controller { theDataSet = getParent().getCurrentDataset(); if (theDataSet != null) { try { - currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path - } catch (DataException e) { - e.printStackTrace(); - } - flightIdCol.setCellValueFactory(new PropertyValueFactory("ID")); - flightNameCol.setCellValueFactory(new PropertyValueFactory("Name")); - flightTypeCol.setCellValueFactory(new PropertyValueFactory("Type")); - flightAltitudeCol.setCellValueFactory(new PropertyValueFactory("Altitude")); - flightLatCol.setCellValueFactory(new PropertyValueFactory("Latitude")); - flightLongCol.setCellValueFactory(new PropertyValueFactory("Longitude")); - flightHeadCol.setCellValueFactory(new PropertyValueFactory("Heading")); - flightLegDisCol.setCellValueFactory(new PropertyValueFactory("LegDistance")); - flightTotDisCol.setCellValueFactory(new PropertyValueFactory("totalDistance")); + try { + currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path + } catch (DataException e) { + e.printStackTrace(); + } + flightIdCol.setCellValueFactory(new PropertyValueFactory("ID")); + flightNameCol.setCellValueFactory(new PropertyValueFactory("Name")); + flightTypeCol.setCellValueFactory(new PropertyValueFactory("Type")); + flightAltitudeCol.setCellValueFactory(new PropertyValueFactory("Altitude")); + flightLatCol.setCellValueFactory(new PropertyValueFactory("Latitude")); + flightLongCol.setCellValueFactory(new PropertyValueFactory("Longitude")); + flightHeadCol.setCellValueFactory(new PropertyValueFactory("Heading")); + flightLegDisCol.setCellValueFactory(new PropertyValueFactory("LegDistance")); + flightTotDisCol.setCellValueFactory(new PropertyValueFactory("totalDistance")); - ArrayList flightPaths; - flightPaths = theDataSet.getFlightPaths(); - ArrayList flightPoints = flightPaths.get(0).getFlight(); - flightTableView.setItems(FXCollections.observableArrayList(flightPoints)); + ArrayList flightPaths; + flightPaths = theDataSet.getFlightPaths(); + ArrayList flightPoints = flightPaths.get(0).getFlight(); + flightTableView.setItems(FXCollections.observableArrayList(flightPoints)); + }catch(IndexOutOfBoundsException e){ + System.out.println("There is no Paths to show"); + } } }