Fixed Liam's silly, not setting dataset. And Sunguin's merge deleting Liam's Move up and Down buttons
This commit is contained in:
Binary file not shown.
@@ -17,6 +17,7 @@ import seng202.group9.Core.FlightPoint;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for the Flights Raw Data Scene.
|
* 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
|
* Used to load the table for the Flight points initially from the MenuController
|
||||||
*/
|
*/
|
||||||
public void load() {
|
public void load() {
|
||||||
|
theDataSet = getParent().getCurrentDataset();
|
||||||
if (theDataSet != null) {
|
if (theDataSet != null) {
|
||||||
theDataSet = getParent().getCurrentDataset();
|
|
||||||
try {
|
try {
|
||||||
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
|
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
@@ -172,21 +173,29 @@ public class FlightRDController extends Controller {
|
|||||||
*/
|
*/
|
||||||
public void deletePoint() {
|
public void deletePoint() {
|
||||||
FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem();
|
FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem();
|
||||||
int pathID;
|
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||||
try {
|
alert.setTitle("Flight Point Delete Confirmation");
|
||||||
pathID = toDelete.getIndex();
|
alert.setHeaderText("You are about to delete some data.");
|
||||||
} catch (DataException e) {
|
alert.setContentText("Are you sure you want to delete the selected flight point?");
|
||||||
e.printStackTrace();
|
//alert.showAndWait();
|
||||||
System.err.println("Point is Undeletable as the Index ID is not set.");
|
Optional<ButtonType> result = alert.showAndWait();
|
||||||
return;
|
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));
|
||||||
|
|
||||||
|
updateTable(currentPathIndex);
|
||||||
}
|
}
|
||||||
LinkedHashMap<Integer, FlightPath> flightPathDict = theDataSet.getFlightPathDictionary();
|
|
||||||
FlightPath toDeletesPath = flightPathDict.get(pathID);
|
|
||||||
theDataSet.deleteFlightPoint(toDelete, toDeletesPath);
|
|
||||||
|
|
||||||
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary().get(pathID));
|
|
||||||
|
|
||||||
updateTable(currentPathIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -175,9 +175,9 @@ public class FlightSummaryController extends Controller {
|
|||||||
* Used to load the page from the MenuController.
|
* Used to load the page from the MenuController.
|
||||||
*/
|
*/
|
||||||
public void load() {
|
public void load() {
|
||||||
|
theDataSet = getParent().getCurrentDataset();
|
||||||
if (theDataSet != null) {
|
if (theDataSet != null) {
|
||||||
try {
|
try {
|
||||||
theDataSet = getParent().getCurrentDataset();
|
|
||||||
ArrayList<FlightPath> flightPaths;
|
ArrayList<FlightPath> flightPaths;
|
||||||
flightPaths = theDataSet.getFlightPaths();
|
flightPaths = theDataSet.getFlightPaths();
|
||||||
for (int i = 0; i < flightPaths.size(); i++) {
|
for (int i = 0; i < flightPaths.size(); i++) {
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.control.ContextMenu?>
|
<?import javafx.scene.control.ContextMenu?>
|
||||||
@@ -15,7 +20,7 @@
|
|||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<?import javafx.scene.text.Text?>
|
<?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>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="142.0" minWidth="10.0" prefWidth="142.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="142.0" minWidth="10.0" prefWidth="142.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="686.0" minWidth="10.0" prefWidth="658.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="686.0" minWidth="10.0" prefWidth="658.0" />
|
||||||
@@ -94,6 +99,8 @@
|
|||||||
<contextMenu>
|
<contextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<items>
|
<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="#editPoint" text="Edit" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#deletePoint" text="Delete" />
|
<MenuItem mnemonicParsing="false" onAction="#deletePoint" text="Delete" />
|
||||||
</items>
|
</items>
|
||||||
|
|||||||
Reference in New Issue
Block a user