Cleaned up unnecessary entries for the flight point adder
This commit is contained in:
Binary file not shown.
@@ -1189,22 +1189,14 @@ public class Dataset {
|
||||
* @param id
|
||||
* @param name
|
||||
* @param type
|
||||
* @param via
|
||||
* @param altitude
|
||||
* @param latitude
|
||||
* @param longitude
|
||||
* @param heading
|
||||
* @param legDist
|
||||
* @param totDist
|
||||
*/
|
||||
public void addFlightPointToPath(int id, String name, String type, String via, String altitude, String latitude, String longitude,
|
||||
String heading, String legDist, String totDist , int index) throws DataException{
|
||||
public void addFlightPointToPath(int id, String name, String type, String altitude, String latitude, String longitude, int index) throws DataException{
|
||||
double altitudeVal = 0.0;
|
||||
double latitudeVal = 0.0;
|
||||
double longitudeVal = 0.0;
|
||||
int headingVal = 0;
|
||||
double legDistVal = 0.0;
|
||||
double totalDistVal = 0.0;
|
||||
|
||||
try{
|
||||
altitudeVal = Double.parseDouble(altitude);
|
||||
@@ -1221,20 +1213,8 @@ public class Dataset {
|
||||
}catch (NumberFormatException e){
|
||||
throw new DataException("Longitude must be a double value");
|
||||
}
|
||||
try{
|
||||
headingVal = Integer.parseInt(heading);
|
||||
}catch (NumberFormatException e){
|
||||
throw new DataException("Heading must be a integer value");
|
||||
}
|
||||
try{
|
||||
legDistVal = Double.parseDouble(legDist);
|
||||
}catch (NumberFormatException e){
|
||||
throw new DataException("Leg DIstance must be a double value");
|
||||
}
|
||||
try{
|
||||
totalDistVal = Double.parseDouble(totDist);
|
||||
}catch (NumberFormatException e){
|
||||
throw new DataException("Total Distance must be a double value");
|
||||
if (index == -1){
|
||||
index = flightPathDictionary.get(id).getFlightPoints().size();
|
||||
}
|
||||
Connection c = null;
|
||||
Statement stmt;
|
||||
@@ -1252,12 +1232,11 @@ public class Dataset {
|
||||
|
||||
stmt = c.createStatement();
|
||||
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
|
||||
" `Altitude`, `Latitude`, `Longitude`, `Heading`, `Tot_Dist`, `Leg_Dist`, `Via`, `Order`) VALUES ";
|
||||
" `Altitude`, `Latitude`, `Longitude`, `Order`) VALUES ";
|
||||
String flightType = type.replace("\"", "\"\"");
|
||||
String flightName = name.replace("\"", "\"\"");
|
||||
insertFlightPointQuery += "(" + id +", \""+ flightName +"\", \"" + flightType + "\", "+ altitudeVal + ", " +
|
||||
"" + latitudeVal + ", " + longitudeVal + ", " + headingVal + ", " + totalDistVal + ", " + legDistVal +
|
||||
", \"" + via + "\", "+index+")";
|
||||
"" + latitudeVal + ", " + longitudeVal + ", "+index+")";
|
||||
stmt.execute(insertFlightPointQuery);
|
||||
stmt.close();
|
||||
//move all the points after this forward
|
||||
@@ -1297,11 +1276,10 @@ public class Dataset {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
FlightPoint pointToAdd = new FlightPoint(name, pointID+1, id, type, via, headingVal, altitudeVal, legDistVal,
|
||||
totalDistVal,latitudeVal, longitudeVal);
|
||||
updateFlightPointInfo(flightPathDictionary.get(Integer.valueOf(id)));
|
||||
FlightPoint pointToAdd = new FlightPoint(type, pointID+1, id, name, altitudeVal, latitudeVal, longitudeVal);
|
||||
flightPathDictionary.get(Integer.valueOf(id)).addFlightPoint(pointToAdd, index);
|
||||
flightPointDictionary.put(pointID + 1, pointToAdd);
|
||||
updateFlightPointInfo(flightPathDictionary.get(Integer.valueOf(id)));
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -1311,9 +1289,8 @@ public class Dataset {
|
||||
* @throws DataException
|
||||
*/
|
||||
public void addFlightPointToPath(FlightPoint point, int index) throws DataException{
|
||||
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
|
||||
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
|
||||
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), index);
|
||||
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), String.valueOf(point.getAltitude()),
|
||||
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()), index);
|
||||
}
|
||||
/***
|
||||
* Adds a single flight Point to an Existing FLight Path appended on the end of the list.
|
||||
@@ -1321,9 +1298,8 @@ public class Dataset {
|
||||
* @throws DataException
|
||||
*/
|
||||
public void addFlightPointToPath(FlightPoint point) throws DataException{
|
||||
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
|
||||
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
|
||||
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), -1);
|
||||
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), String.valueOf(point.getAltitude()),
|
||||
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()), -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1331,19 +1307,14 @@ public class Dataset {
|
||||
* @param id
|
||||
* @param name
|
||||
* @param type
|
||||
* @param via
|
||||
* @param altitude
|
||||
* @param latitude
|
||||
* @param longitude
|
||||
* @param heading
|
||||
* @param legDist
|
||||
* @param totDist
|
||||
* @throws DataException
|
||||
*/
|
||||
|
||||
public void addFlightPointToPath(int id, String name, String type, String via, String altitude, String latitude, String longitude,
|
||||
String heading, String legDist, String totDist) throws DataException{
|
||||
addFlightPointToPath(id, name, type, via, altitude, latitude, longitude, heading, legDist, totDist, -1);
|
||||
public void addFlightPointToPath(int id, String name, String type, String altitude, String latitude, String longitude) throws DataException{
|
||||
addFlightPointToPath(id, name, type, altitude, latitude, longitude, -1);
|
||||
}
|
||||
/**
|
||||
* This is called in conjunction to the App deleteDataset DO NOT CALL UNLESS THROUGH APP.DELETEDATASET
|
||||
|
||||
@@ -60,6 +60,24 @@ public class FlightPoint {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public FlightPoint(String type, int id, int index, String name, double altitude, double latitude, double longitude){
|
||||
//extra calculations will have to be used to find heading, legdistance and total distance. If necessary
|
||||
//Type 1 file the file the lecturers gave us
|
||||
//indexID = flight path ID
|
||||
//ID = unique Auto Increment value
|
||||
this.name = name;
|
||||
this.ID = id;
|
||||
this.indexID = index;
|
||||
this.type = type;
|
||||
this.via = "";
|
||||
this.heading = 0;
|
||||
this.altitude = altitude;
|
||||
this.legDistance = 0.0;
|
||||
this.totalDistance = 0.0;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor when getting points from the database.
|
||||
* @param name Name for the point.
|
||||
|
||||
@@ -18,20 +18,12 @@ public class FlightAddController extends Controller {
|
||||
@FXML
|
||||
private TextField fTypeAdd;
|
||||
@FXML
|
||||
private TextField fViaAdd;
|
||||
@FXML
|
||||
private TextField fAltitudeAdd;
|
||||
@FXML
|
||||
private TextField fLatitudeAdd;
|
||||
@FXML
|
||||
private TextField fLongitudeAdd;
|
||||
@FXML
|
||||
private TextField fHeadingAdd;
|
||||
@FXML
|
||||
private TextField fLegDistAdd;
|
||||
@FXML
|
||||
private TextField fTotDistAdd;
|
||||
@FXML
|
||||
private Button flightAddButton;
|
||||
|
||||
//Set an empty Dataset to be assigned later
|
||||
@@ -49,13 +41,9 @@ public class FlightAddController extends Controller {
|
||||
theDataSet.addFlightPointToPath(currentSession.getCurrentFlightPathID(),
|
||||
fNameAdd.getText(),
|
||||
fTypeAdd.getText(),
|
||||
fViaAdd.getText(),
|
||||
fAltitudeAdd.getText(),
|
||||
fLatitudeAdd.getText(),
|
||||
fLongitudeAdd.getText(),
|
||||
fHeadingAdd.getText(),
|
||||
fLegDistAdd.getText(),
|
||||
fTotDistAdd.getText());
|
||||
fLongitudeAdd.getText());
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Flight Point Add Successful");
|
||||
alert.setHeaderText("New Flight Point added!");
|
||||
|
||||
@@ -154,7 +154,7 @@ public class FlightRDController extends Controller {
|
||||
public void openAdd() {
|
||||
Session session = getParent().getSession();
|
||||
session.setCurrentFlightPathtID(currentPathId);
|
||||
createPopUpStage(SceneCode.FLIGHT_ADD, 600, 400);
|
||||
createPopUpStage(SceneCode.FLIGHT_ADD, 600, 280);
|
||||
//flightTableView.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
|
||||
updateTable(currentPathIndex);
|
||||
}
|
||||
|
||||
@@ -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.Label?>
|
||||
@@ -9,7 +14,7 @@
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" vgap="10.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightAddController">
|
||||
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="280.0" prefWidth="600.0" vgap="10.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightAddController">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="280.0" minWidth="10.0" prefWidth="125.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="515.0" minWidth="10.0" prefWidth="402.0" />
|
||||
@@ -22,10 +27,6 @@
|
||||
<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 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" />
|
||||
@@ -46,50 +47,26 @@
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label text="Altitude" GridPane.halignment="LEFT" GridPane.rowIndex="4">
|
||||
<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="5">
|
||||
<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="6">
|
||||
<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="flightAddButton" mnemonicParsing="false" onAction="#addFlight" text="Add Flight" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="10" />
|
||||
<Button fx:id="flightAddButton" mnemonicParsing="false" onAction="#addFlight" text="Add Flight Point" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="6" />
|
||||
<TextField fx:id="fNameAdd" prefHeight="31.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="fTypeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
|
||||
<TextField fx:id="fAltitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="4" />
|
||||
<TextField fx:id="fLatitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="5" />
|
||||
<TextField fx:id="fLongitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="6" />
|
||||
<Label text="Via" GridPane.rowIndex="3">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label text="Heading" GridPane.rowIndex="7">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label text="Leg Distance" GridPane.rowIndex="8">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label text="Total Distance" GridPane.rowIndex="9">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<TextField fx:id="fViaAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="3" />
|
||||
<TextField fx:id="fHeadingAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="7" />
|
||||
<TextField fx:id="fLegDistAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="8" />
|
||||
<TextField fx:id="fTotDistAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="9" />
|
||||
<TextField fx:id="fAltitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="3" />
|
||||
<TextField fx:id="fLatitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="4" />
|
||||
<TextField fx:id="fLongitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="5" />
|
||||
</children>
|
||||
</GridPane>
|
||||
|
||||
Reference in New Issue
Block a user