Fixed the error when the user clicks on empty path fields in the flight path list view

main
Liam Beckett 9 years ago
parent e17bf9b055
commit 6ec38bcb87

Binary file not shown.

@ -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 departureAirport
* @param arrivalAirport * @param arrivalAirport
*/ */

@ -92,17 +92,19 @@ public class FlightRDController extends Controller {
flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() { flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) { public void handle(MouseEvent event) {
String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem(); String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem();
String[] segments = flightPathDisplayNameClicked.split("_"); if (flightPathDisplayNameClicked!=null) {
String pathIdClicked = segments[0]; String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0];
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary() currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
.get(Integer.parseInt(pathIdClicked))); .get(Integer.parseInt(pathIdClicked)));
currentPathId = Integer.parseInt(pathIdClicked); currentPathId = Integer.parseInt(pathIdClicked);
ArrayList<FlightPath> flightPaths; ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths(); flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight(); ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints)); flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
}
} }
}); });
@ -246,6 +248,9 @@ public class FlightRDController extends Controller {
flightPathListView(); flightPathListView();
} }
/**
* Function for the 'Move Up' right click option on the points in the flight table.
*/
public void movePointUp(){ public void movePointUp(){
FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem(); FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem();
int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex(); int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex();
@ -258,9 +263,11 @@ public class FlightRDController extends Controller {
} }
updateTable(currentPathIndex); updateTable(currentPathIndex);
updatePaths(); updatePaths();
} }
/**
* Function for the 'Move Down' right click option on the points in the flight table.
*/
public void movePointDown(){ public void movePointDown(){
FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem(); FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem();
int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex(); int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex();
@ -287,6 +294,9 @@ public class FlightRDController extends Controller {
flightTableView.refresh(); flightTableView.refresh();
} }
/**
* Updates the flight path list view so that it displays the correct names for the paths
*/
private void updatePaths(){ private void updatePaths(){
try { try {
flightPathListView.getItems().clear(); flightPathListView.getItems().clear();

@ -158,12 +158,14 @@ public class FlightSummaryController extends Controller {
flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() { flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) { public void handle(MouseEvent event) {
String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem(); String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem();
String[] segments = flightPathDisplayNameClicked.split("_"); if (flightPathDisplayNameClicked!=null) {
String pathIdClicked = segments[0]; String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0];
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
.get(Integer.parseInt(pathIdClicked))); currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
currentPathId = Integer.parseInt(pathIdClicked); .get(Integer.parseInt(pathIdClicked)));
currentPathId = Integer.parseInt(pathIdClicked);
}
} }
}); });
flightPathListView.setItems(flightList); flightPathListView.setItems(flightList);

Loading…
Cancel
Save