Implemented the ablitity to manually enter flight points into the database.

This commit is contained in:
Liam Beckett
2016-09-16 12:50:58 +12:00
parent de9cee785c
commit ff20c6435e
6 changed files with 264 additions and 40 deletions
@@ -5,9 +5,7 @@ import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import seng202.group9.Controller.App;
@@ -24,13 +22,17 @@ import java.util.ResourceBundle;
* Controller for the Flights Raw Data Scene.
* Created by Liam Beckett on 13/09/2016.
*/
public class FlightRawDataController implements Initializable {
public class FlightRDController implements Initializable {
private Dataset theDataSet = null;
private int currentPathId = 0;
private int currentPathIndex = 0;
App parent;
public void setApp(App parent){
this.parent = parent;
theDataSet = parent.getCurrentDataset();
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
}
@FXML
@@ -60,6 +62,24 @@ public class FlightRawDataController implements Initializable {
ListView<String> flightPathListView;
final ObservableList<String> flightList = FXCollections.observableArrayList();
@FXML
private TextField flightNameBox;
@FXML
private TextField flightTypeBox;
@FXML
private TextField flightViaBox;
@FXML
private TextField flightAltitudeBox;
@FXML
private TextField flightLatitudeBox;
@FXML
private TextField flightLongitudeBox;
@FXML
private TextField flightHeadingBox;
@FXML
private TextField flightLegDistBox;
@FXML
private TextField flightTotDistBox;
/**
* Loads the Flight paths into the List View and waits for a mouse clicked event for which it will update the table
@@ -67,7 +87,7 @@ public class FlightRawDataController implements Initializable {
*/
public void flightPathListView() {
try {
ArrayList<FlightPath> flightPaths = new ArrayList();
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
for(int i = 0; i<flightPaths.size(); i++ ) {
int pathID = flightPaths.get(i).getID();
@@ -82,9 +102,13 @@ public class FlightRawDataController implements Initializable {
String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0];
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(Integer.parseInt(pathIdClicked)-1).getFlight();
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
}
@@ -115,11 +139,48 @@ public class FlightRawDataController implements Initializable {
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
int firstID = flightPaths.get(0).getID();
//int firstID = flightPaths.get(0).getID();
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
}
public void addFlightPoint() {
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
try {
theDataSet.addFlightPointToPath(currentPathId,
flightNameBox.getText(),
flightTypeBox.getText(),
flightViaBox.getText(),
flightAltitudeBox.getText(),
flightLatitudeBox.getText(),
flightLongitudeBox.getText(),
flightHeadingBox.getText(),
flightLegDistBox.getText(),
flightTotDistBox.getText());
flightNameBox.clear();
flightTypeBox.clear();
flightViaBox.clear();
flightAltitudeBox.clear();
flightLatitudeBox.clear();
flightLongitudeBox.clear();
flightHeadingBox.clear();
flightLegDistBox.clear();
flightTotDistBox.clear();
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
} catch ( Exception e ) {
//e.printStackTrace();
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Flight Point Data Error");
alert.setHeaderText("Error adding a custom flight point entry.");
alert.setContentText(e.getMessage());
alert.showAndWait();
}
}
public void initialize(URL arg0, ResourceBundle arg1) {
// TODO Auto-generated method stub
@@ -2,17 +2,13 @@ package seng202.group9.GUI;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.control.TableView;
import seng202.group9.Controller.App;
import seng202.group9.Controller.Dataset;
import seng202.group9.Core.FlightPath;
import seng202.group9.Core.FlightPoint;
import java.net.URL;
import java.util.ArrayList;
@@ -65,7 +61,7 @@ public class FlightSummaryController implements Initializable {
*/
public void handleRawDataButton() {
try {
FlightRawDataController rawDataController = (FlightRawDataController)
FlightRDController rawDataController = (FlightRDController)
parent.replaceSceneContent("flight_raw_data.fxml");
rawDataController.setApp(parent);
rawDataController.loadTables();
@@ -6,10 +6,7 @@ import java.util.ResourceBundle;
import javax.swing.JOptionPane;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import seng202.group9.Controller.App;
public class MenuController implements Initializable{
@@ -117,7 +114,7 @@ public class MenuController implements Initializable{
*/
public void viewFlightRawData() {
try {
FlightRawDataController rawDataController = (FlightRawDataController)
FlightRDController rawDataController = (FlightRDController)
parent.replaceSceneContent("flight_raw_data.fxml");
rawDataController.setApp(parent);
rawDataController.loadTables();