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

main
Liam Beckett 10 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,6 +92,7 @@ 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();
if (flightPathDisplayNameClicked!=null) {
String[] segments = flightPathDisplayNameClicked.split("_"); String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0]; String pathIdClicked = segments[0];
@ -103,6 +104,7 @@ public class FlightRDController extends Controller {
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,6 +158,7 @@ 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();
if (flightPathDisplayNameClicked!=null) {
String[] segments = flightPathDisplayNameClicked.split("_"); String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0]; String pathIdClicked = segments[0];
@ -165,6 +166,7 @@ public class FlightSummaryController extends Controller {
.get(Integer.parseInt(pathIdClicked))); .get(Integer.parseInt(pathIdClicked)));
currentPathId = Integer.parseInt(pathIdClicked); currentPathId = Integer.parseInt(pathIdClicked);
} }
}
}); });
flightPathListView.setItems(flightList); flightPathListView.setItems(flightList);
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save