diff --git a/res/userdb.db b/res/userdb.db index 4f6d70c..4c19f27 100644 Binary files a/res/userdb.db and b/res/userdb.db differ diff --git a/src/main/java/seng202/group9/GUI/FlightRDController.java b/src/main/java/seng202/group9/GUI/FlightRDController.java index 74594a2..a4da096 100644 --- a/src/main/java/seng202/group9/GUI/FlightRDController.java +++ b/src/main/java/seng202/group9/GUI/FlightRDController.java @@ -17,6 +17,7 @@ import seng202.group9.Core.FlightPoint; import javax.swing.*; import java.util.ArrayList; import java.util.LinkedHashMap; +import java.util.Optional; /** * Controller for the Flights Raw Data Scene. @@ -117,8 +118,8 @@ public class FlightRDController extends Controller { * Used to load the table for the Flight points initially from the MenuController */ public void load() { + theDataSet = getParent().getCurrentDataset(); if (theDataSet != null) { - theDataSet = getParent().getCurrentDataset(); try { currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path } catch (DataException e) { @@ -172,21 +173,29 @@ public class FlightRDController extends Controller { */ public void deletePoint() { FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem(); - int pathID; - try { - pathID = toDelete.getIndex(); - } catch (DataException e) { - e.printStackTrace(); - System.err.println("Point is Undeletable as the Index ID is not set."); - return; - } - LinkedHashMap flightPathDict = theDataSet.getFlightPathDictionary(); - FlightPath toDeletesPath = flightPathDict.get(pathID); - theDataSet.deleteFlightPoint(toDelete, toDeletesPath); + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setTitle("Flight Point Delete Confirmation"); + alert.setHeaderText("You are about to delete some data."); + alert.setContentText("Are you sure you want to delete the selected flight point?"); + //alert.showAndWait(); + Optional result = alert.showAndWait(); + if (result.isPresent() && result.get() == ButtonType.OK) { + int pathID; + try { + pathID = toDelete.getIndex(); + } catch (DataException e) { + e.printStackTrace(); + System.err.println("Point is Undeletable as the Index ID is not set."); + return; + } + LinkedHashMap flightPathDict = theDataSet.getFlightPathDictionary(); + FlightPath toDeletesPath = flightPathDict.get(pathID); + theDataSet.deleteFlightPoint(toDelete, toDeletesPath); - currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary().get(pathID)); + currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary().get(pathID)); - updateTable(currentPathIndex); + updateTable(currentPathIndex); + } } /** diff --git a/src/main/java/seng202/group9/GUI/FlightSummaryController.java b/src/main/java/seng202/group9/GUI/FlightSummaryController.java index 62c4281..2843233 100644 --- a/src/main/java/seng202/group9/GUI/FlightSummaryController.java +++ b/src/main/java/seng202/group9/GUI/FlightSummaryController.java @@ -175,9 +175,9 @@ public class FlightSummaryController extends Controller { * Used to load the page from the MenuController. */ public void load() { + theDataSet = getParent().getCurrentDataset(); if (theDataSet != null) { try { - theDataSet = getParent().getCurrentDataset(); ArrayList flightPaths; flightPaths = theDataSet.getFlightPaths(); for (int i = 0; i < flightPaths.size(); i++) { diff --git a/src/main/resources/flight_raw_data.fxml b/src/main/resources/flight_raw_data.fxml index b0bfb26..e192fd6 100644 --- a/src/main/resources/flight_raw_data.fxml +++ b/src/main/resources/flight_raw_data.fxml @@ -1,5 +1,10 @@ + + + + + @@ -15,7 +20,7 @@ - + @@ -94,6 +99,8 @@ + +