Merge branch 'WIP_Flight_Editor' into 'master'
flight editor See merge request !17
This commit is contained in:
Binary file not shown.
@@ -27,6 +27,7 @@ public class Dataset {
|
|||||||
private LinkedHashMap<String, Airport> airportDictionary;
|
private LinkedHashMap<String, Airport> airportDictionary;
|
||||||
private LinkedHashMap<String, Route> routeDictionary;
|
private LinkedHashMap<String, Route> routeDictionary;
|
||||||
private LinkedHashMap<Integer, FlightPath> flightPathDictionary;
|
private LinkedHashMap<Integer, FlightPath> flightPathDictionary;
|
||||||
|
private LinkedHashMap<Integer, FlightPoint> flightPointDictionary;
|
||||||
private LinkedHashMap<String, Country> countryDictionary;
|
private LinkedHashMap<String, Country> countryDictionary;
|
||||||
private LinkedHashMap<String, City> cityDictionary;
|
private LinkedHashMap<String, City> cityDictionary;
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ public class Dataset {
|
|||||||
this.countryDictionary = new LinkedHashMap<String, Country>();;
|
this.countryDictionary = new LinkedHashMap<String, Country>();;
|
||||||
this.cityDictionary = new LinkedHashMap<String, City>();;
|
this.cityDictionary = new LinkedHashMap<String, City>();;
|
||||||
this.flightPathDictionary = new LinkedHashMap<Integer, FlightPath>();
|
this.flightPathDictionary = new LinkedHashMap<Integer, FlightPath>();
|
||||||
|
this.flightPointDictionary = new LinkedHashMap<Integer, FlightPoint>();
|
||||||
if (action == getExisting){
|
if (action == getExisting){
|
||||||
updateDataset();
|
updateDataset();
|
||||||
//after this make connections. ie filling in the country.cities airports.routes etc
|
//after this make connections. ie filling in the country.cities airports.routes etc
|
||||||
@@ -670,7 +672,7 @@ public class Dataset {
|
|||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = c.createStatement();
|
stmt = c.createStatement();
|
||||||
//ADDED
|
|
||||||
String firstPt = flightPointsToImport.get(0).getName();
|
String firstPt = flightPointsToImport.get(0).getName();
|
||||||
String lastPt = flightPointsToImport.get(flightPointsToImport.size() - 1).getName();
|
String lastPt = flightPointsToImport.get(flightPointsToImport.size() - 1).getName();
|
||||||
FlightPath flightPathToAdd = new FlightPath(firstPt, lastPt);
|
FlightPath flightPathToAdd = new FlightPath(firstPt, lastPt);
|
||||||
@@ -680,7 +682,7 @@ public class Dataset {
|
|||||||
stmt.execute(insertFlightPathQuery);
|
stmt.execute(insertFlightPathQuery);
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = c.createStatement();
|
stmt = c.createStatement();
|
||||||
int flightPathId = 0;
|
int flightPathId = 1;
|
||||||
String getLastestIndex = "SELECT * FROM `sqlite_sequence` WHERE `name` = \"" + this.name.replace("\"", "\"\"") +
|
String getLastestIndex = "SELECT * FROM `sqlite_sequence` WHERE `name` = \"" + this.name.replace("\"", "\"\"") +
|
||||||
"_Flight_Path\" LIMIT 1;";
|
"_Flight_Path\" LIMIT 1;";
|
||||||
ResultSet lastestIdResult = stmt.executeQuery(getLastestIndex);
|
ResultSet lastestIdResult = stmt.executeQuery(getLastestIndex);
|
||||||
@@ -691,9 +693,9 @@ public class Dataset {
|
|||||||
lastestIdResult.close();
|
lastestIdResult.close();
|
||||||
stmt = c.createStatement();
|
stmt = c.createStatement();
|
||||||
flightPathToAdd.setID(flightPathId);
|
flightPathToAdd.setID(flightPathId);
|
||||||
//ADDED
|
|
||||||
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
|
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
|
||||||
" `Altitude`, `Latitude`, `Longitude`, `Order`) VALUES ";
|
" `Altitude`, `Latitude`, `Longitude`) VALUES ";
|
||||||
int numOfFlights = 0;
|
int numOfFlights = 0;
|
||||||
for (int i = 0; i < flightPointsToImport.size(); i ++){
|
for (int i = 0; i < flightPointsToImport.size(); i ++){
|
||||||
String flightPointIdentifier = flightPointsToImport.get(i).getType() + flightPointsToImport.get(i).getName() +
|
String flightPointIdentifier = flightPointsToImport.get(i).getType() + flightPointsToImport.get(i).getName() +
|
||||||
@@ -706,17 +708,18 @@ public class Dataset {
|
|||||||
double flightLatitude = flightPointsToImport.get(i).getLatitude();
|
double flightLatitude = flightPointsToImport.get(i).getLatitude();
|
||||||
double flightLongitude = flightPointsToImport.get(i).getLongitude();
|
double flightLongitude = flightPointsToImport.get(i).getLongitude();
|
||||||
//insert import into database
|
//insert import into database
|
||||||
if (numOfFlights > 0){
|
if (numOfFlights > 0) {
|
||||||
insertFlightPointQuery += ",";
|
insertFlightPointQuery += ",";
|
||||||
}
|
}
|
||||||
insertFlightPointQuery += "(" + flightPathId +", \""+ flightName +"\", \"" + flightType + "\", "+ flightAltitude + ", " +
|
insertFlightPointQuery += "(" + flightPathId +", \""+ flightName +"\", \"" + flightType + "\", "+ flightAltitude + ", " +
|
||||||
"" + flightLatitude + ", " + flightLongitude + ", "+numOfFlights+")";
|
"" + flightLatitude + ", " + flightLongitude + ")";
|
||||||
flightPointsToImport.get(i).setID(nextID);
|
flightPointsToImport.get(i).setID(nextID);
|
||||||
flightPointsToImport.get(i).setIndexID(flightPathId);
|
flightPointsToImport.get(i).setIndexID(flightPathId);
|
||||||
//add data to dataset array.
|
//add data to dataset array.
|
||||||
//this is placed after incase the database messes up
|
//this is placed after incase the database messes up
|
||||||
flightPathToAdd.addFlightPoint(flightPointsToImport.get(i));
|
flightPathToAdd.addFlightPoint(flightPointsToImport.get(i));
|
||||||
//routeDictionary.put(routeIdentifier, flightsToImport.get(i));
|
//routeDictionary.put(routeIdentifier, flightsToImport.get(i));
|
||||||
|
flightPointDictionary.put(nextID, flightPointsToImport.get(i));
|
||||||
nextID++;
|
nextID++;
|
||||||
numOfFlights++;
|
numOfFlights++;
|
||||||
//}
|
//}
|
||||||
@@ -756,7 +759,6 @@ public class Dataset {
|
|||||||
//create Airline country link
|
//create Airline country link
|
||||||
for (Airline airline: airlines){
|
for (Airline airline: airlines){
|
||||||
airlineByIATA.put(airline.getIATA(), airline);
|
airlineByIATA.put(airline.getIATA(), airline);
|
||||||
//System.out.println(airline.getAlias());
|
|
||||||
airline.setRoutes(new ArrayList<Route>());
|
airline.setRoutes(new ArrayList<Route>());
|
||||||
airline.setCountry(countryDictionary.get(airline.getCountryName()));
|
airline.setCountry(countryDictionary.get(airline.getCountryName()));
|
||||||
Country country = countryDictionary.get(airline.getCountryName());
|
Country country = countryDictionary.get(airline.getCountryName());
|
||||||
@@ -1226,21 +1228,21 @@ public class Dataset {
|
|||||||
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
|
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
|
||||||
|
|
||||||
stmt = c.createStatement();
|
stmt = c.createStatement();
|
||||||
String flightPointIDQuery = "SELECT * FROM `sqlite_sequence` WHERE `name` = \""+this.name.replace("\"", "\"\"")+"_Flight_Points\" LIMIT 1;";
|
String flightPointIDQuery = "SELECT * FROM `sqlite_sequence` WHERE `name` = \"" + this.name + "_Flight_Points\" LIMIT 1;";
|
||||||
ResultSet pointIDRes= stmt.executeQuery(flightPointIDQuery);
|
ResultSet pointIDRes = stmt.executeQuery(flightPointIDQuery);
|
||||||
while (pointIDRes.next()){
|
while (pointIDRes.next()) {
|
||||||
pointID = Integer.parseInt(pointIDRes.getString("seq"));
|
pointID = Integer.parseInt(pointIDRes.getString("seq"));
|
||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
|
||||||
stmt = c.createStatement();
|
stmt = c.createStatement();
|
||||||
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
|
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`, `Heading`, `Tot_Dist`, `Leg_Dist`, `Via`) VALUES ";
|
||||||
String flightType = type.replace("\"", "\"\"");
|
String flightType = type.replace("\"", "\"\"");
|
||||||
String flightName = name.replace("\"", "\"\"");
|
String flightName = name.replace("\"", "\"\"");
|
||||||
insertFlightPointQuery += "(" + id +", \""+ flightName +"\", \"" + flightType + "\", "+ altitudeVal + ", " +
|
insertFlightPointQuery += "(" + id +", \""+ flightName +"\", \"" + flightType + "\", "+ altitudeVal + ", " +
|
||||||
"" + latitudeVal + ", " + longitudeVal + ", " + headingVal + ", " + totalDistVal + ", " + legDistVal +
|
"" + latitudeVal + ", " + longitudeVal + ", " + headingVal + ", " + totalDistVal + ", " + legDistVal +
|
||||||
", \"" + via + "\", "+index+")";
|
", \"" + via + "\")";
|
||||||
stmt.execute(insertFlightPointQuery);
|
stmt.execute(insertFlightPointQuery);
|
||||||
stmt.close();
|
stmt.close();
|
||||||
//move all the points after this forward
|
//move all the points after this forward
|
||||||
@@ -1368,14 +1370,10 @@ public class Dataset {
|
|||||||
try {
|
try {
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
|
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
|
||||||
//System.out.println(airline.getID());
|
String deleteQuery = "DELETE FROM `" + this.name + "_Airline` WHERE `Airline_ID` = " + airline.getID() + ";";
|
||||||
String deleteQuery = "DELETE FROM `"+this.name+"_Airline` WHERE `Airline_ID` = " + airline.getID() + ";";
|
|
||||||
stmt = c.createStatement();
|
stmt = c.createStatement();
|
||||||
//System.out.println("Airline deleted");
|
|
||||||
stmt.execute(deleteQuery);
|
stmt.execute(deleteQuery);
|
||||||
//System.out.println("Airline deleted");
|
|
||||||
stmt.close();
|
stmt.close();
|
||||||
//System.out.println("Airline deleted");
|
|
||||||
stmt = c.createStatement();
|
stmt = c.createStatement();
|
||||||
//check if number of countries that contain airlines > 0 else delete the country
|
//check if number of countries that contain airlines > 0 else delete the country
|
||||||
String countCountry = "SELECT COUNT(*) FROM `"+this.name+"_Airline` JOIN `"+this.name+"_Country` ON" +
|
String countCountry = "SELECT COUNT(*) FROM `"+this.name+"_Airline` JOIN `"+this.name+"_Country` ON" +
|
||||||
@@ -1603,6 +1601,11 @@ public class Dataset {
|
|||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
flightPath.getFlightPoints().remove(flightPoint);
|
flightPath.getFlightPoints().remove(flightPoint);
|
||||||
|
try {
|
||||||
|
flightPointDictionary.remove(flightPoint.getID());
|
||||||
|
} catch (DataException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1694,6 +1697,15 @@ public class Dataset {
|
|||||||
return flightPathDictionary;
|
return flightPathDictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a flightpoint dictionary with the flights that are associated with this dataset.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public LinkedHashMap<Integer, FlightPoint> getFlightPointDictionary() {
|
||||||
|
return flightPointDictionary;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a Country Dictionary with the COuntries that are associated with this dataset.
|
* returns a Country Dictionary with the COuntries that are associated with this dataset.
|
||||||
* @return
|
* @return
|
||||||
@@ -1806,10 +1818,17 @@ public class Dataset {
|
|||||||
EntryParser parser = new EntryParser();
|
EntryParser parser = new EntryParser();
|
||||||
Airport newAirport = parser.parseAirport(name, city, country, IATA_FFA, ICAO, lat, lng, alt, timezone, DST, olson);
|
Airport newAirport = parser.parseAirport(name, city, country, IATA_FFA, ICAO, lat, lng, alt, timezone, DST, olson);
|
||||||
airport.setName(name);
|
airport.setName(name);
|
||||||
|
airport.setCityName(city);
|
||||||
|
airport.getCity().setName(city);
|
||||||
|
airport.setCountryName(country);
|
||||||
|
airport.getCountry().setName(country);
|
||||||
airport.setIATA_FFA(IATA_FFA);
|
airport.setIATA_FFA(IATA_FFA);
|
||||||
airport.setICAO(ICAO);
|
airport.setICAO(ICAO);
|
||||||
airport.setLatitude(newAirport.getLatitude());
|
airport.setLatitude(newAirport.getLatitude());
|
||||||
airport.setLongitude(newAirport.getLongitude());
|
airport.setLongitude(newAirport.getLongitude());
|
||||||
|
airport.getCity().setTimezone(Double.parseDouble(timezone));
|
||||||
|
airport.getCountry().setDST(DST);
|
||||||
|
airport.getCity().setTimeOlson(olson);
|
||||||
|
|
||||||
Connection c = null;
|
Connection c = null;
|
||||||
Statement stmt = null;
|
Statement stmt = null;
|
||||||
@@ -1921,10 +1940,10 @@ public class Dataset {
|
|||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
|
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
|
||||||
stmt = c.createStatement();
|
stmt = c.createStatement();
|
||||||
String query = "UPDATE `"+this.name+"_Routes` SET `Airline` = \""+route.getAirlineName().replace("\"", "\"\"")+"\", " +
|
String query = "UPDATE `" + this.name + "_Routes` SET `Airline` = \"" + route.getAirlineName().replace("\"", "\"\"") + "\", " +
|
||||||
"`Source_Airport` = \""+route.getDepartureAirport().replace("\"", "\"\"")+"\", `Destination_Airport` = \""+route.getArrivalAirport().replace("\"", "\"\"")+"\", " +
|
"`Source_Airport` = \"" + route.getDepartureAirport().replace("\"", "\"\"") + "\", `Destination_Airport` = \"" + route.getArrivalAirport().replace("\"", "\"\"") + "\", " +
|
||||||
"`Codeshare` = \""+route.getCode().replace("\"", "\"\"")+"\", `Stops` = "+route.getStops()+", `Equipment` = \""+route.getEquipment().replace("\"", "\"\"")+"\" " +
|
"`Codeshare` = \"" + route.getCode().replace("\"", "\"\"") + "\", `Stops` = " + route.getStops() + ", `Equipment` = \"" + route.getEquipment().replace("\"", "\"\"") + "\" " +
|
||||||
"WHERE `Route_ID` = "+route.getID();
|
"WHERE `Route_ID` = " + route.getID();
|
||||||
stmt.execute(query);
|
stmt.execute(query);
|
||||||
stmt.close();
|
stmt.close();
|
||||||
c.close();
|
c.close();
|
||||||
@@ -1959,14 +1978,14 @@ 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 editFlight(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 parsedFlightPoint = entryParser.parsePoint(name, type, altitude, latitude, longitude);
|
||||||
flightPoint.setName(flightPoint1.getName());
|
flightPoint.setName(parsedFlightPoint.getName());
|
||||||
flightPoint.setType(flightPoint1.getType());
|
flightPoint.setType(parsedFlightPoint.getType());
|
||||||
flightPoint.setAltitude(flightPoint1.getAltitude());
|
flightPoint.setAltitude(parsedFlightPoint.getAltitude());
|
||||||
flightPoint.setLatitude(flightPoint1.getLatitude());
|
flightPoint.setLatitude(parsedFlightPoint.getLatitude());
|
||||||
flightPoint.setLongitude(flightPoint1.getLongitude());
|
flightPoint.setLongitude(parsedFlightPoint.getLongitude());
|
||||||
|
|
||||||
|
|
||||||
Connection c = null;
|
Connection c = null;
|
||||||
@@ -2000,7 +2019,7 @@ public class Dataset {
|
|||||||
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
||||||
}
|
}
|
||||||
flightPath.setDepartureAirport(flightPoint.getName());
|
flightPath.setDepartureAirport(flightPoint.getName());
|
||||||
}else if (indexOf == flightPath.getFlightPoints().size() - 1){
|
} else if (indexOf == flightPath.getFlightPoints().size() - 1) {
|
||||||
try {
|
try {
|
||||||
stmt = c.createStatement();
|
stmt = c.createStatement();
|
||||||
String query = "UPDATE `"+this.name+"_Flight_Path` SET `Destination_Airport` = \""+flightPoint.getName().replace("\"", "\"\"")+"\" " +
|
String query = "UPDATE `"+this.name+"_Flight_Path` SET `Destination_Airport` = \""+flightPoint.getName().replace("\"", "\"\"")+"\" " +
|
||||||
@@ -2012,7 +2031,7 @@ public class Dataset {
|
|||||||
}
|
}
|
||||||
flightPath.setArrivalAirport(flightPoint.getName());
|
flightPath.setArrivalAirport(flightPoint.getName());
|
||||||
}
|
}
|
||||||
updateFlightPointInfo(flightPath);
|
|
||||||
createDataLinks();
|
createDataLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,18 +132,26 @@ 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
|
||||||
|
name = name.toUpperCase();
|
||||||
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 +172,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public enum SceneCode {
|
|||||||
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"), AIRLINE_ADD("airline_add_form.fxml"), AIRLINE_FILTER("airline_filter_form.fxml"),
|
AIRPORT_DIST_CALC("airport_dist_calc.fxml"), AIRLINE_ADD("airline_add_form.fxml"), AIRLINE_FILTER("airline_filter_form.fxml"),
|
||||||
AIRPORT_ADD("airport_add_form.fxml"), AIRPORT_FILTER("airport_filter_form.fxml"), ROUTE_ADD("route_add_form.fxml"),
|
AIRPORT_ADD("airport_add_form.fxml"), AIRPORT_FILTER("airport_filter_form.fxml"), ROUTE_ADD("route_add_form.fxml"),
|
||||||
ROUTE_FILTER("route_filter_form.fxml");
|
ROUTE_FILTER("route_filter_form.fxml"), FLIGHT_EDITOR("flight_editor_form.fxml");
|
||||||
|
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package seng202.group9.Controller;
|
|||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import seng202.group9.Core.Airline;
|
import seng202.group9.Core.Airline;
|
||||||
|
|
||||||
|
import seng202.group9.Core.FlightPoint;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@@ -12,6 +14,8 @@ import java.util.HashMap;
|
|||||||
*/
|
*/
|
||||||
public class Session implements Serializable {
|
public class Session implements Serializable {
|
||||||
private SceneCode sceneDisplayed;
|
private SceneCode sceneDisplayed;
|
||||||
|
private int currentFlightPointID;
|
||||||
|
private int currentFlightPathID;
|
||||||
private HashMap<Integer, String> filteredAirlines;
|
private HashMap<Integer, String> filteredAirlines;
|
||||||
private HashMap<Integer, String> filteredAirports;
|
private HashMap<Integer, String> filteredAirports;
|
||||||
private HashMap<Integer, String> filteredRoutes;
|
private HashMap<Integer, String> filteredRoutes;
|
||||||
@@ -71,4 +75,36 @@ public class Session implements Serializable {
|
|||||||
public HashMap<Integer, String> getFilteredRoutes() {
|
public HashMap<Integer, String> getFilteredRoutes() {
|
||||||
return filteredRoutes;
|
return filteredRoutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the current flight point
|
||||||
|
* @param currentFlightPointID
|
||||||
|
*/
|
||||||
|
public void setCurrentFlightPointID(int currentFlightPointID) {
|
||||||
|
this.currentFlightPointID = currentFlightPointID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the current flight point
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getCurrentFlightPointID() {
|
||||||
|
return currentFlightPointID;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* sets the current flight point
|
||||||
|
* @param currentFlightPathID
|
||||||
|
*/
|
||||||
|
public void setCurrentFlightPathtID(int currentFlightPathID) {
|
||||||
|
this.currentFlightPathID = currentFlightPathID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the current flight point
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getCurrentFlightPathID() {
|
||||||
|
return currentFlightPathID;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package seng202.group9.GUI;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import seng202.group9.Controller.Dataset;
|
||||||
|
import seng202.group9.Controller.Session;
|
||||||
|
import seng202.group9.Core.FlightPoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller for the Flights Edit Point Pop up Scene.
|
||||||
|
* 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;
|
||||||
|
@FXML
|
||||||
|
private Button flightEditButton;
|
||||||
|
|
||||||
|
//Set an empty Dataset to be assigned later
|
||||||
|
private Dataset theDataSet = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edits a single flight entry in the database.
|
||||||
|
* Takes in values from the field the user right clicked.
|
||||||
|
* @see Dataset
|
||||||
|
*/
|
||||||
|
public void editFlight() {
|
||||||
|
//Data is pre-loaded into the text fields and any accepted changes will be implemented.
|
||||||
|
//Otherwise an error message will pop up with what is wrong with edit
|
||||||
|
try {
|
||||||
|
Session session = getParent().getSession();
|
||||||
|
int flightPointID = session.getCurrentFlightPointID();
|
||||||
|
|
||||||
|
theDataSet.editFlight(
|
||||||
|
theDataSet.getFlightPointDictionary().get(flightPointID),
|
||||||
|
fNameEdit.getText(),
|
||||||
|
fTypeEdit.getText(),
|
||||||
|
fAltitudeEdit.getText(),
|
||||||
|
fLatitudeEdit.getText(),
|
||||||
|
fLongitudeEdit.getText()
|
||||||
|
);
|
||||||
|
session.setCurrentFlightPointID(flightPointID);
|
||||||
|
|
||||||
|
fNameEdit.clear();
|
||||||
|
fTypeEdit.clear();
|
||||||
|
fAltitudeEdit.clear();
|
||||||
|
fLatitudeEdit.clear();
|
||||||
|
fLongitudeEdit.clear();
|
||||||
|
|
||||||
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||||
|
alert.setTitle("Flight Path Edit Successful");
|
||||||
|
alert.setHeaderText("Flight Point Edited!");
|
||||||
|
alert.setContentText("Your flight point has been updated in the database.");
|
||||||
|
alert.showAndWait();
|
||||||
|
|
||||||
|
Stage stage = (Stage) flightEditButton.getScene().getWindow();
|
||||||
|
stage.close();
|
||||||
|
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
e.printStackTrace();
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loader which is used to load the selected information into the text fields for editing.
|
||||||
|
*/
|
||||||
|
public void load() {
|
||||||
|
theDataSet = getParent().getCurrentDataset();
|
||||||
|
|
||||||
|
Session session = getParent().getSession();
|
||||||
|
int flightPointID = session.getCurrentFlightPointID();
|
||||||
|
FlightPoint flightPoint = theDataSet.getFlightPointDictionary().get(flightPointID);
|
||||||
|
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -9,6 +9,8 @@ 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.Controller.Session;
|
||||||
import seng202.group9.Core.FlightPath;
|
import seng202.group9.Core.FlightPath;
|
||||||
import seng202.group9.Core.FlightPoint;
|
import seng202.group9.Core.FlightPoint;
|
||||||
|
|
||||||
@@ -20,7 +22,6 @@ import java.util.LinkedHashMap;
|
|||||||
* Controller for the Flights Raw Data Scene.
|
* Controller for the Flights Raw Data Scene.
|
||||||
* Created by Liam Beckett on 13/09/2016.
|
* Created by Liam Beckett on 13/09/2016.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class FlightRDController extends Controller {
|
public class FlightRDController extends Controller {
|
||||||
|
|
||||||
private Dataset theDataSet = null;
|
private Dataset theDataSet = null;
|
||||||
@@ -143,8 +144,6 @@ public class FlightRDController extends Controller {
|
|||||||
* Will take the inputs from the text fields and adds the point to the current flight path.
|
* Will take the inputs from the text fields and adds the point to the current flight path.
|
||||||
*/
|
*/
|
||||||
public void addFlightPoint() {
|
public void addFlightPoint() {
|
||||||
ArrayList<FlightPath> flightPaths;
|
|
||||||
flightPaths = theDataSet.getFlightPaths();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
theDataSet.addFlightPointToPath(currentPathId,
|
theDataSet.addFlightPointToPath(currentPathId,
|
||||||
@@ -167,14 +166,12 @@ public class FlightRDController extends Controller {
|
|||||||
flightLegDistBox.clear();
|
flightLegDistBox.clear();
|
||||||
flightTotDistBox.clear();
|
flightTotDistBox.clear();
|
||||||
|
|
||||||
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
|
updateTable(currentPathIndex);
|
||||||
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception e ) {
|
||||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||||
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());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +200,7 @@ public class FlightRDController extends Controller {
|
|||||||
pathID = toDelete.getIndex();
|
pathID = toDelete.getIndex();
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("Point is Undeletable as the Index ID is not set.");
|
System.err.println("Point is Undeletable as the Index ID is not set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LinkedHashMap<Integer, FlightPath> flightPathDict = theDataSet.getFlightPathDictionary();
|
LinkedHashMap<Integer, FlightPath> flightPathDict = theDataSet.getFlightPathDictionary();
|
||||||
@@ -212,12 +209,27 @@ public class FlightRDController extends Controller {
|
|||||||
|
|
||||||
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary().get(pathID));
|
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary().get(pathID));
|
||||||
|
|
||||||
ArrayList<FlightPath> flightPaths;
|
updateTable(currentPathIndex);
|
||||||
flightPaths = theDataSet.getFlightPaths();
|
|
||||||
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
|
|
||||||
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the pop up for the edit data scene and updates the table when the window is closed.
|
||||||
|
*/
|
||||||
|
public void editPoint() {
|
||||||
|
FlightPoint toEdit = flightTableView.getSelectionModel().getSelectedItem();
|
||||||
|
try {
|
||||||
|
Session session = getParent().getSession();
|
||||||
|
session.setCurrentFlightPointID(toEdit.getID());
|
||||||
|
session.setCurrentFlightPathtID(currentPathId);
|
||||||
|
} catch (DataException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.err.println("Point is Uneditable as the Index ID is not set.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
createPopUpStage(SceneCode.FLIGHT_EDITOR, 600, 289);
|
||||||
|
updateTable(currentPathIndex);
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
@@ -234,10 +246,22 @@ public class FlightRDController extends Controller {
|
|||||||
flightPathListView();
|
flightPathListView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the table so that when the database is changed (deleted or edited) it still shows the correct data values.
|
||||||
|
* @param currentPathIndex The index of the current path in the Path array list.
|
||||||
|
*/
|
||||||
|
private void updateTable(int currentPathIndex) {
|
||||||
|
ArrayList<FlightPath> flightPaths;
|
||||||
|
flightPaths = theDataSet.getFlightPaths();
|
||||||
|
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
|
||||||
|
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
||||||
|
flightTableView.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will link to the flight analyser when implemented.
|
* Will link to the flight analyser when implemented.
|
||||||
*/
|
*/
|
||||||
public void flightAnalyser(){
|
private void flightAnalyser(){
|
||||||
JOptionPane.showMessageDialog(null, "This is not Implemented yet");
|
JOptionPane.showMessageDialog(null, "This is not Implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.FlightEditorController">
|
||||||
|
<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="flightEditButton" 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>
|
||||||
@@ -153,6 +153,7 @@
|
|||||||
<contextMenu>
|
<contextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<items>
|
<items>
|
||||||
|
<MenuItem mnemonicParsing="false" onAction="#editPoint" text="Edit" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#deletePoint" text="Delete" />
|
<MenuItem mnemonicParsing="false" onAction="#deletePoint" text="Delete" />
|
||||||
</items>
|
</items>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
|
|||||||
Reference in New Issue
Block a user