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