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
*/
public void load() {
theDataSet = getParent().getCurrentDataset();
try {
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
} catch (DataException e) {
e.printStackTrace();
}
flightIdCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("ID"));
flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name"));
flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type"));
flightAltitudeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Altitude"));
flightLatCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Latitude"));
flightLongCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Longitude"));
flightHeadCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Heading"));
flightLegDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("LegDistance"));
flightTotDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("totalDistance"));
if (theDataSet != null) {
theDataSet = getParent().getCurrentDataset();
try {
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
} catch (DataException e) {
e.printStackTrace();
}
flightIdCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("ID"));
flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name"));
flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type"));
flightAltitudeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Altitude"));
flightLatCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Latitude"));
flightLongCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Longitude"));
flightHeadCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Heading"));
flightLegDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("LegDistance"));
flightTotDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("totalDistance"));
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
}
}
/**
@ -318,7 +320,9 @@ public class FlightRDController extends Controller {
@Override
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.
*/
public void load() {
try {
theDataSet = getParent().getCurrentDataset();
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
for(int i = 0; i<flightPaths.size(); i++ ){
int pathID = flightPaths.get(i).getID();
String pathSource = flightPaths.get(i).departsFrom();
String pathDestin = flightPaths.get(i).arrivesAt();
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());
if (theDataSet != null) {
try {
theDataSet = getParent().getCurrentDataset();
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
for (int i = 0; i < flightPaths.size(); i++) {
int pathID = flightPaths.get(i).getID();
String pathSource = flightPaths.get(i).departsFrom();
String pathDestin = flightPaths.get(i).arrivesAt();
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());
}
}
});
}
}
/**
* Removes the selected path from the list view of paths and from the database.

Loading…
Cancel
Save