Fixed Liam's silly, not setting dataset. And Sunguin's merge deleting Liam's Move up and Down buttons

main
YaFedImYaEatIm 9 years ago
parent 12c396a263
commit 3f54e0998b

Binary file not shown.

@ -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<Integer, FlightPath> 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<ButtonType> 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<Integer, FlightPath> 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);
}
}
/**

@ -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<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
for (int i = 0; i < flightPaths.size(); i++) {

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ContextMenu?>
@ -15,7 +20,7 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<GridPane alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="568.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightRDController">
<GridPane alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="568.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightRDController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="142.0" minWidth="10.0" prefWidth="142.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="686.0" minWidth="10.0" prefWidth="658.0" />
@ -94,6 +99,8 @@
<contextMenu>
<ContextMenu>
<items>
<MenuItem mnemonicParsing="false" onAction="#movePointUp" text="Move Up" />
<MenuItem mnemonicParsing="false" onAction="#movePointDown" text="Move Down" />
<MenuItem mnemonicParsing="false" onAction="#editPoint" text="Edit" />
<MenuItem mnemonicParsing="false" onAction="#deletePoint" text="Delete" />
</items>

Loading…
Cancel
Save