Atempting to get the editor to work for the flight raw data points (Currently broken)
This commit is contained in:
@@ -1863,8 +1863,9 @@ public class Dataset {
|
|||||||
* @param longitude
|
* @param longitude
|
||||||
* @throws DataException
|
* @throws DataException
|
||||||
*/
|
*/
|
||||||
public void editFlight(FlightPath flightPath, int index, String name, String type, String altitude, String latitude, String longitude) throws DataException{
|
public void editFlightPath(FlightPath flightPath, int index, String name, String type, String altitude, String latitude,
|
||||||
editFlight(flightPath.getFlightPoints().get(index), name, type, altitude, latitude, longitude);
|
String longitude) throws DataException{
|
||||||
|
editFlightPoint(flightPath.getFlightPoints().get(index), name, type, altitude, latitude, longitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1877,7 +1878,8 @@ public class Dataset {
|
|||||||
* @param longitude
|
* @param longitude
|
||||||
* @throws DataException
|
* @throws DataException
|
||||||
*/
|
*/
|
||||||
public void editFlight(FlightPoint flightPoint, String name, String type, String altitude, String latitude, String longitude) throws DataException{
|
public void editFlightPoint(FlightPoint flightPoint, String name, String type, String altitude, String latitude,
|
||||||
|
String longitude) throws DataException{
|
||||||
EntryParser entryParser = new EntryParser();
|
EntryParser entryParser = new EntryParser();
|
||||||
FlightPoint flightPoint1 = entryParser.parsePoint(name, type, altitude, latitude, longitude);
|
FlightPoint flightPoint1 = entryParser.parsePoint(name, type, altitude, latitude, longitude);
|
||||||
flightPoint.setName(flightPoint1.getName());
|
flightPoint.setName(flightPoint1.getName());
|
||||||
|
|||||||
@@ -132,18 +132,25 @@ public class EntryParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FlightPoint parsePoint(String name, String type, String altitude, String latitude, String longitude) throws DataException{
|
public FlightPoint parsePoint(String name, String type, String altitude, String latitude, String longitude) throws DataException{
|
||||||
//(airport) name (first and last point)
|
//name
|
||||||
if (!isLetter(name)) {
|
if (!isLetter(name)) {
|
||||||
throw new DataException("Airport ICAO code must contain only letters");
|
throw new DataException("ICAO code must contain only letters");
|
||||||
}
|
|
||||||
if (name.length() != 4) {
|
|
||||||
throw new DataException("Aiport ICAO code must be of length four");
|
|
||||||
}
|
}
|
||||||
//type
|
//type
|
||||||
type = type.toUpperCase();
|
type = type.toUpperCase();
|
||||||
if (!type.equals("APT") && !type.equals("VOR") && !type.equals("FIX") && !type.equals("NDB") && !type.equals("LATLON")){
|
if (!type.equals("APT") && !type.equals("VOR") && !type.equals("FIX") && !type.equals("NDB") && !type.equals("LATLON")){
|
||||||
throw new DataException("Type of flight must be either APT, VOR, FIX, NDB or LATLON");
|
throw new DataException("Type of flight must be either APT, VOR, FIX, NDB or LATLON");
|
||||||
}
|
}
|
||||||
|
//altitude
|
||||||
|
double alt;
|
||||||
|
try{
|
||||||
|
alt = Double.parseDouble(altitude);
|
||||||
|
}catch (NumberFormatException e){
|
||||||
|
throw new DataException ("Altitude must be a number");
|
||||||
|
}
|
||||||
|
if (alt < 0 || alt > 50000){
|
||||||
|
throw new DataException("Altitude must be between 0 and 50000ft inclusive.");
|
||||||
|
}
|
||||||
//latitude
|
//latitude
|
||||||
double lat;
|
double lat;
|
||||||
try{
|
try{
|
||||||
@@ -164,13 +171,7 @@ public class EntryParser {
|
|||||||
if (lng > 180 || lng < -180){
|
if (lng > 180 || lng < -180){
|
||||||
throw new DataException("Longitude must be between -180 and 180 inclusive.");
|
throw new DataException("Longitude must be between -180 and 180 inclusive.");
|
||||||
}
|
}
|
||||||
//altitude
|
|
||||||
double alt;
|
|
||||||
try{
|
|
||||||
alt = Double.parseDouble(altitude);
|
|
||||||
}catch (NumberFormatException e){
|
|
||||||
throw new DataException ("Altitude must be a number");
|
|
||||||
}
|
|
||||||
FlightPoint parseSuccess = new FlightPoint(type, name, alt, lat, lng);
|
FlightPoint parseSuccess = new FlightPoint(type, name, alt, lat, lng);
|
||||||
return parseSuccess;
|
return parseSuccess;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public enum SceneCode {
|
|||||||
AIRPORT_SUMMARY("airport_summary.fxml"), AIRPORT_RAW_DATA("airport_raw_data.fxml"),
|
AIRPORT_SUMMARY("airport_summary.fxml"), AIRPORT_RAW_DATA("airport_raw_data.fxml"),
|
||||||
ROUTE_SUMMARY("routes_summary.fxml"), ROUTE_RAW_DATA("route_raw_data.fxml"), FLIGHT_SUMMARY("flight_data_summary.fxml"),
|
ROUTE_SUMMARY("routes_summary.fxml"), ROUTE_RAW_DATA("route_raw_data.fxml"), FLIGHT_SUMMARY("flight_data_summary.fxml"),
|
||||||
FLIGHT_RAW_DATA("flight_raw_data.fxml"), AIRPORT_ANALYSER("airport_analyser.fxml"), ROUTE_ANALYSER("route_analyser.fxml"),
|
FLIGHT_RAW_DATA("flight_raw_data.fxml"), AIRPORT_ANALYSER("airport_analyser.fxml"), ROUTE_ANALYSER("route_analyser.fxml"),
|
||||||
AIRPORT_DIST_CALC("airport_dist_calc.fxml");
|
AIRPORT_DIST_CALC("airport_dist_calc.fxml"), FLIGHT_EDITOR("flight_editor_form.fxml");
|
||||||
|
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
package seng202.group9.GUI;
|
package seng202.group9.GUI;
|
||||||
|
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.Modality;
|
||||||
|
import javafx.stage.Stage;
|
||||||
import seng202.group9.Controller.App;
|
import seng202.group9.Controller.App;
|
||||||
import seng202.group9.Controller.SceneCode;
|
import seng202.group9.Controller.SceneCode;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
@@ -50,6 +58,45 @@ public abstract class Controller implements Initializable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a popup window with a specific fxml scene
|
||||||
|
* @param scene
|
||||||
|
* @param width
|
||||||
|
* @param height
|
||||||
|
*/
|
||||||
|
public Stage createPopUpStage(SceneCode scene, int width, int height) {
|
||||||
|
FXMLLoader loader = new FXMLLoader();
|
||||||
|
InputStream in = getClass().getClassLoader().getResourceAsStream(scene.getFilePath());
|
||||||
|
Parent page = null;
|
||||||
|
try {
|
||||||
|
page = loader.load(in);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//set contorller and call default calls
|
||||||
|
Controller controller = (Controller) loader.getController();
|
||||||
|
controller.setApp(parent);
|
||||||
|
controller.load();
|
||||||
|
controller.loadOnce();
|
||||||
|
//create a new stage to popup
|
||||||
|
Stage popupStage = new Stage();
|
||||||
|
popupStage.initModality(Modality.APPLICATION_MODAL);
|
||||||
|
//inner layout constraints
|
||||||
|
VBox container = new VBox();
|
||||||
|
container.getChildren().add(page);
|
||||||
|
Scene popupScene = new Scene(container, width, height);
|
||||||
|
//show
|
||||||
|
popupStage.setScene(popupScene);
|
||||||
|
popupStage.showAndWait();
|
||||||
|
return popupStage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functions here will only load once and after the load function.
|
* Functions here will only load once and after the load function.
|
||||||
*/
|
*/
|
||||||
@@ -66,4 +113,4 @@ public abstract class Controller implements Initializable{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package seng202.group9.GUI;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import seng202.group9.Controller.Dataset;
|
||||||
|
import seng202.group9.Core.FlightPoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Liam Beckett on 23/09/2016.
|
||||||
|
*/
|
||||||
|
public class FlightEditorController extends Controller{
|
||||||
|
//Setting up text fields for adding data
|
||||||
|
@FXML
|
||||||
|
TextField fNameEdit;
|
||||||
|
@FXML
|
||||||
|
TextField fTypeEdit;
|
||||||
|
@FXML
|
||||||
|
TextField fAltitudeEdit;
|
||||||
|
@FXML
|
||||||
|
TextField fLatitudeEdit;
|
||||||
|
@FXML
|
||||||
|
TextField fLongitudeEdit;
|
||||||
|
|
||||||
|
|
||||||
|
//Set an empty Dataset to be assigned later
|
||||||
|
private Dataset theDataSet = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a single airport entry in the database.
|
||||||
|
* Takes in values from the GUI the user has typed in.
|
||||||
|
* @see Dataset
|
||||||
|
*/
|
||||||
|
public void editFlight(FlightPoint flightPoint) {
|
||||||
|
//Tries to add a new airport and clears the fields to their initial state if successful.
|
||||||
|
//Otherwise an error message will pop up with what is wrong with the manual data.
|
||||||
|
try {
|
||||||
|
fNameEdit.setText(flightPoint.getName());
|
||||||
|
fTypeEdit.setText(flightPoint.getType());
|
||||||
|
fAltitudeEdit.setText(Double.toString(flightPoint.getAltitude()));
|
||||||
|
fLatitudeEdit.setText(Double.toString(flightPoint.getLatitude()));
|
||||||
|
fLongitudeEdit.setText(Double.toString(flightPoint.getLongitude()));
|
||||||
|
|
||||||
|
theDataSet.editFlightPoint(
|
||||||
|
flightPoint,
|
||||||
|
fNameEdit.getText(),
|
||||||
|
fTypeEdit.getText(),
|
||||||
|
fAltitudeEdit.getText(),
|
||||||
|
fLatitudeEdit.getText(),
|
||||||
|
fLongitudeEdit.getText()
|
||||||
|
);
|
||||||
|
fNameEdit.clear();
|
||||||
|
fTypeEdit.clear();
|
||||||
|
fAltitudeEdit.clear();
|
||||||
|
fLatitudeEdit.clear();
|
||||||
|
fLongitudeEdit.clear();
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||||
|
alert.setTitle("Flight Data Error");
|
||||||
|
alert.setHeaderText("Error editing a flight point.");
|
||||||
|
alert.setContentText(e.getMessage());
|
||||||
|
alert.showAndWait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
theDataSet = getParent().getCurrentDataset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@ import javafx.scene.control.cell.PropertyValueFactory;
|
|||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import seng202.group9.Controller.DataException;
|
import seng202.group9.Controller.DataException;
|
||||||
import seng202.group9.Controller.Dataset;
|
import seng202.group9.Controller.Dataset;
|
||||||
|
import seng202.group9.Controller.SceneCode;
|
||||||
import seng202.group9.Core.FlightPath;
|
import seng202.group9.Core.FlightPath;
|
||||||
import seng202.group9.Core.FlightPoint;
|
import seng202.group9.Core.FlightPoint;
|
||||||
|
|
||||||
@@ -174,7 +175,6 @@ public class FlightRDController extends Controller {
|
|||||||
alert.setTitle("Flight Point Data Error");
|
alert.setTitle("Flight Point Data Error");
|
||||||
alert.setHeaderText("Error adding a custom flight point entry.");
|
alert.setHeaderText("Error adding a custom flight point entry.");
|
||||||
alert.setContentText(e.getMessage());
|
alert.setContentText(e.getMessage());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,6 +218,21 @@ public class FlightRDController extends Controller {
|
|||||||
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void editPoint() {
|
||||||
|
FlightPoint toEdit = flightTableView.getSelectionModel().getSelectedItem();
|
||||||
|
int pathID;
|
||||||
|
try {
|
||||||
|
pathID = toEdit.getIndex();
|
||||||
|
} catch (DataException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println("Point is Uneditable as the Index ID is not set.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ArrayList<FlightPath> flightPaths = theDataSet.getFlightPaths();
|
||||||
|
createPopUpStage(SceneCode.FLIGHT_EDITOR, 600, 289);
|
||||||
|
flightTableView.setItems(FXCollections.observableArrayList(flightPaths.get(currentPathIndex).getFlight()));
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Removes the selected path from the list view of paths and from the database.
|
* Removes the selected path from the list view of paths and from the database.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
|
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="289.0" prefWidth="600.0" vgap="10.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.RouteAddController">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="280.0" minWidth="10.0" prefWidth="168.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="515.0" minWidth="10.0" prefWidth="402.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints maxHeight="30.0" minHeight="0.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="30.0" minHeight="4.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
</padding>
|
||||||
|
<children>
|
||||||
|
<Label text="Edit Flight Point" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.valignment="TOP">
|
||||||
|
<font>
|
||||||
|
<Font size="18.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label text="Name" GridPane.halignment="LEFT" GridPane.rowIndex="1">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Label>
|
||||||
|
<Label text="Type" GridPane.halignment="LEFT" GridPane.rowIndex="2">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Label>
|
||||||
|
<Label text="Altitude" GridPane.halignment="LEFT" GridPane.rowIndex="3">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Label>
|
||||||
|
<Label text="Latitude" GridPane.halignment="LEFT" GridPane.rowIndex="4">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Label>
|
||||||
|
<Label text="Longitude" GridPane.halignment="LEFT" GridPane.rowIndex="5">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Label>
|
||||||
|
<Button fx:id="editButton" mnemonicParsing="false" onAction="#editFlight" text="Edit Flight" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="6" />
|
||||||
|
<TextField fx:id="fNameEdit" prefHeight="31.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="1" />
|
||||||
|
<TextField fx:id="fTypeEdit" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
|
||||||
|
<TextField fx:id="fAltitudeEdit" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="3" />
|
||||||
|
<TextField fx:id="fLatitudeEdit" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="4" />
|
||||||
|
<TextField fx:id="fLongitudeEdit" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="5" />
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
@@ -154,6 +154,7 @@
|
|||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#deletePoint" text="Delete" />
|
<MenuItem mnemonicParsing="false" onAction="#deletePoint" text="Delete" />
|
||||||
|
<MenuItem mnemonicParsing="false" onAction="#editPoint" text="Edit" />
|
||||||
</items>
|
</items>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</contextMenu>
|
</contextMenu>
|
||||||
|
|||||||
Reference in New Issue
Block a user