Fixed bug with flight pages and an empty dataset

main
Liam Beckett 9 years ago
parent 04481661c4
commit e51aaaa7f2

Binary file not shown.

@ -115,26 +115,28 @@ public class FlightRDController extends Controller {
* Used to load the table for the Flight points initially from the MenuController * Used to load the table for the Flight points initially from the MenuController
*/ */
public void load() { public void load() {
theDataSet = getParent().getCurrentDataset(); if (theDataSet != null) {
try { theDataSet = getParent().getCurrentDataset();
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path try {
} catch (DataException e) { currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
e.printStackTrace(); } catch (DataException e) {
} e.printStackTrace();
flightIdCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("ID")); }
flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name")); flightIdCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("ID"));
flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type")); flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name"));
flightAltitudeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Altitude")); flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type"));
flightLatCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Latitude")); flightAltitudeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Altitude"));
flightLongCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Longitude")); flightLatCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Latitude"));
flightHeadCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Heading")); flightLongCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Longitude"));
flightLegDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("LegDistance")); flightHeadCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Heading"));
flightTotDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("totalDistance")); flightLegDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("LegDistance"));
flightTotDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("totalDistance"));
ArrayList<FlightPath> flightPaths; ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths(); flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight(); ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints)); flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
}
} }
/** /**
@ -318,7 +320,9 @@ public class FlightRDController extends Controller {
@Override @Override
public void loadOnce(){ public void loadOnce(){
flightPathListView(); if (theDataSet != null) {
flightPathListView();
}
} }
} }

@ -177,36 +177,37 @@ public class FlightSummaryController extends Controller {
* Used to load the page from the MenuController. * Used to load the page from the MenuController.
*/ */
public void load() { public void load() {
try { if (theDataSet != null) {
theDataSet = getParent().getCurrentDataset(); try {
ArrayList<FlightPath> flightPaths; theDataSet = getParent().getCurrentDataset();
flightPaths = theDataSet.getFlightPaths(); ArrayList<FlightPath> flightPaths;
for(int i = 0; i<flightPaths.size(); i++ ){ flightPaths = theDataSet.getFlightPaths();
int pathID = flightPaths.get(i).getID(); for (int i = 0; i < flightPaths.size(); i++) {
String pathSource = flightPaths.get(i).departsFrom(); int pathID = flightPaths.get(i).getID();
String pathDestin = flightPaths.get(i).arrivesAt(); String pathSource = flightPaths.get(i).departsFrom();
String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin; String pathDestin = flightPaths.get(i).arrivesAt();
flightList.add(flightPathDisplayName); String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin;
} flightList.add(flightPathDisplayName);
flightPathListView.setItems(flightList);
flightSummaryListView();
} catch (Exception e) {
e.printStackTrace();
}
if (theDataSet.getFlightPaths().size() > 0){
map = new Map(mapView, theDataSet.getFlightPaths().get(0).getRoutePath());
}else{
map = new Map(mapView, new RoutePath());
}
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
int index = flightPathListView.getSelectionModel().getSelectedIndices().get(0);
if (index != -1) {
map.displayRoute(theDataSet.getFlightPaths().get(index).getRoutePath());
} }
flightPathListView.setItems(flightList);
flightSummaryListView();
} catch (Exception e) {
e.printStackTrace();
} }
}); if (theDataSet.getFlightPaths().size() > 0) {
map = new Map(mapView, theDataSet.getFlightPaths().get(0).getRoutePath());
} else {
map = new Map(mapView, new RoutePath());
}
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
int index = flightPathListView.getSelectionModel().getSelectedIndices().get(0);
if (index != -1) {
map.displayRoute(theDataSet.getFlightPaths().get(index).getRoutePath());
}
}
});
}
} }
/** /**
* Removes the selected path from the list view of paths and from the database. * Removes the selected path from the list view of paths and from the database.

Loading…
Cancel
Save