Merge remote-tracking branch 'origin/master'

main
Michael Wilson 9 years ago
commit 8c49ce4455

3
.gitignore vendored

@ -4,4 +4,5 @@ SENG202.iml
.classpath
.project
.settings/
doc/
doc/
res/session.ser

Binary file not shown.

@ -130,7 +130,7 @@ public class App extends Application
fileIn.close();
}catch(IOException e){
session = new Session();
e.printStackTrace();
System.out.println("New Session File Created");
}catch(ClassNotFoundException e){
System.out.println("Missing Session Class");
System.exit(1);

@ -731,9 +731,6 @@ public class Dataset {
return message;
}
/**
* This function updates the connections between airports citys countries etc.
*/
@ -1020,7 +1017,53 @@ public class Dataset {
}
}
/**
* Adds a path to the database and to the path dictionary
* @param sourceAirport
* @param destAirport
*/
public void addFlightPath(String sourceAirport, String destAirport){
FlightPath newPath = new FlightPath(sourceAirport, destAirport);
Connection c;
Statement stmt;
int pathID = 0;
try {
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
stmt = c.createStatement();
String flightPathIDQuery = "SELECT * FROM `sqlite_sequence` WHERE `name` = \""+this.name+"_Flight_Path\" LIMIT 1;";
ResultSet pathIDRes= stmt.executeQuery(flightPathIDQuery);
while (pathIDRes.next()){
pathID = Integer.parseInt(pathIDRes.getString("seq"));
}
pathID +=1;
stmt.close();
stmt = c.createStatement();
String insertPathQuery = "INSERT INTO `" + this.name + "_Flight_Path` (`Path_ID`, `Source_Airport`, " +
"`Destination_Airport`) VALUES ("+pathID+", \""+sourceAirport+"\", \""+destAirport+"\" )";
stmt.execute(insertPathQuery);
} catch (Exception e){
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
newPath.setID(pathID);
flightPathDictionary.put(pathID, newPath);
}
/**
* Adds a flight point to a given path woth the given id
* @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) throws DataException{
double altitudeVal = 0.0;

@ -13,6 +13,7 @@ import seng202.group9.Controller.Dataset;
import seng202.group9.Core.FlightPath;
import seng202.group9.Core.FlightPoint;
import javax.swing.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@ -115,7 +116,7 @@ public class FlightRDController extends Controller {
}
/**
* Function 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() {
theDataSet = getParent().getCurrentDataset();
@ -133,11 +134,13 @@ public class FlightRDController extends Controller {
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
//int firstID = flightPaths.get(0).getID();
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
}
/**
* Will take the inputs from the text fields and adds the point to the current flight path.
*/
public void addFlightPoint() {
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
@ -171,10 +174,28 @@ public class FlightRDController extends Controller {
alert.setTitle("Flight Point Data Error");
alert.setHeaderText("Error adding a custom flight point entry.");
alert.setContentText(e.getMessage());
alert.showAndWait();
}
}
/**
* Creates a pop up dialog which prompts the user for two ICAO airport codes which will use when creating a new path
*/
public void newPath() {
NewPathPopUp dialogBox = new NewPathPopUp();
dialogBox.display();
String destAirport = dialogBox.getDestinationAirport();
String sourceAirport = dialogBox.getSourceAirport();
if (destAirport != null && sourceAirport != null){
theDataSet.addFlightPath(sourceAirport, destAirport);
}
}
public void flightAnalyser(){
JOptionPane.showMessageDialog(null, "This is not Implemented yet");
}
@Override
public void loadOnce(){
flightPathListView();

@ -26,32 +26,33 @@ public class Importer{
"Text & .csv", "*.txt", "*.csv");
chooser.getExtensionFilters().add(filter);
File file = chooser.showOpenDialog(primaryStage);
if (scene == SceneCode.AIRLINE_RAW_DATA){
try {
showSuccessAlert(parent.getCurrentDataset().importAirline(file.getPath()));
} catch (DataException e) {
e.printStackTrace();
}
}else if (scene == SceneCode.AIRPORT_RAW_DATA){
try {
showSuccessAlert(parent.getCurrentDataset().importAirport(file.getPath()));
} catch (DataException e) {
e.printStackTrace();
}
}else if (scene == SceneCode.ROUTE_RAW_DATA){
try {
showSuccessAlert(parent.getCurrentDataset().importRoute(file.getPath()));
} catch (DataException e) {
e.printStackTrace();
}
}else if (scene == SceneCode.FLIGHT_RAW_DATA){
try {
showSuccessAlert(parent.getCurrentDataset().importFlight(file.getPath()));
} catch (DataException e) {
e.printStackTrace();
if (file != null) {
if (scene == SceneCode.AIRLINE_RAW_DATA) {
try {
showSuccessAlert(parent.getCurrentDataset().importAirline(file.getPath()));
} catch (DataException e) {
e.printStackTrace();
}
} else if (scene == SceneCode.AIRPORT_RAW_DATA) {
try {
showSuccessAlert(parent.getCurrentDataset().importAirport(file.getPath()));
} catch (DataException e) {
e.printStackTrace();
}
} else if (scene == SceneCode.ROUTE_RAW_DATA) {
try {
showSuccessAlert(parent.getCurrentDataset().importRoute(file.getPath()));
} catch (DataException e) {
e.printStackTrace();
}
} else if (scene == SceneCode.FLIGHT_RAW_DATA) {
try {
showSuccessAlert(parent.getCurrentDataset().importFlight(file.getPath()));
} catch (DataException e) {
e.printStackTrace();
}
}
}
}
public void showSuccessAlert(String message){

@ -0,0 +1,77 @@
package seng202.group9.GUI;
import javax.swing.*;
import java.awt.*;
import static java.awt.Color.red;
/**
* Creates the pop up box where the user will enter the Source and Destination airports for the path name, will reject
* empty strings, strings of length 4 and characters that are not A-Z. Will convert lowercase to uppercase.
* Created by Liam Beckett on 17/09/2016.
*/
public class NewPathPopUp {
private String sourceAirport = null;
private String destinationAirport = null;
// Creates and displays the pop up box for the user to input data.
public void display() {
JTextField field1 = new JTextField();
JTextField field2 = new JTextField();
JPanel panel = new JPanel(new GridLayout(0, 1));
panel.add(new JLabel("Source Airport ICAO Code" ));
panel.add(field1);
panel.add(new JLabel("Destination Airport ICAO Code: "));
panel.add(field2);
int result = JOptionPane.showConfirmDialog(null, panel, "Test",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
sourceAirport = field1.getText().toUpperCase();
destinationAirport = field2.getText().toUpperCase();
if (validate(sourceAirport) != true && validate(destinationAirport) != true){
sourceAirport = null;
destinationAirport = null;
JOptionPane.showMessageDialog(null, "Enter a vaild ICAO Code!");
return;
}
} else {
sourceAirport = null;
destinationAirport = null;
}
}
// Checks the users entered string to make sure it is a 4 letter valid code.
private static boolean validate(String airportCode){
if(airportCode == ""){
return false;
} else if(airportCode.length() != 4){
return false;
} else if(!isLetter(airportCode)){
return false;
}
return true;
}
// Used by the validate() method to cycle through the string looking for non letter characters.
private static boolean isLetter(String airportCode){
char[] chars = airportCode.toCharArray();
for (char element : chars) {
if(!Character.isLetter(element)) {
return false;
}
}
return true;
}
public String getSourceAirport() {
return sourceAirport;
}
public String getDestinationAirport() {
return destinationAirport;
}
}

@ -84,22 +84,22 @@
<children>
<Pane prefHeight="160.0" prefWidth="295.0" GridPane.rowIndex="1">
<children>
<Button layoutX="20.0" layoutY="14.0" mnemonicParsing="false" onAction="#airportSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Airports">
<Button layoutX="26.0" layoutY="82.0" mnemonicParsing="false" onAction="#airportSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Airports">
<font>
<Font size="12.0" />
</font>
</Button>
<Button layoutX="94.0" layoutY="14.0" mnemonicParsing="false" onAction="#airlineSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Airlines">
<Button layoutX="127.0" layoutY="82.0" mnemonicParsing="false" onAction="#airlineSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Airlines">
<font>
<Font size="12.0" />
</font>
</Button>
<Button layoutX="169.0" layoutY="14.0" mnemonicParsing="false" onAction="#routeSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Routes">
<Button layoutX="227.0" layoutY="82.0" mnemonicParsing="false" onAction="#routeSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Routes">
<font>
<Font size="12.0" />
</font>
</Button>
<Button layoutX="20.0" layoutY="61.0" mnemonicParsing="false" onAction="#handleRawDataButton" prefHeight="25.0" prefWidth="214.0" text="Flights Raw Data" />
<Button layoutX="26.0" layoutY="132.0" mnemonicParsing="false" onAction="#handleRawDataButton" prefHeight="25.0" prefWidth="266.0" text="Flights Raw Data" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />

@ -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?>
@ -17,7 +22,7 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightRDController">
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightRDController">
<children>
<ScrollPane hbarPolicy="NEVER" prefHeight="603.0" prefWidth="751.0" vbarPolicy="NEVER">
<content>
@ -44,6 +49,7 @@
<children>
<Pane prefHeight="434.0" prefWidth="158.0">
<children>
<Button layoutX="32.0" layoutY="486.0" mnemonicParsing="false" onAction="#newPath" prefHeight="25.0" prefWidth="99.0" text="New" />
<ListView fx:id="flightPathListView" layoutX="19.0" layoutY="25.0" prefHeight="450.0" prefWidth="125.0" />
<Label layoutX="16.0" text="Flight Path File(s)">
<font>
@ -124,7 +130,7 @@
<Pane prefHeight="44.0" prefWidth="601.0" GridPane.rowIndex="3">
<children>
<Button layoutX="476.0" layoutY="11.0" mnemonicParsing="false" onAction="#addFlightPoint" prefHeight="25.0" prefWidth="125.0" text="Add" />
<Button layoutY="11.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="125.0" text="Analyse" />
<Button layoutY="11.0" mnemonicParsing="false" onAction="#flightAnalyser" prefHeight="25.0" prefWidth="125.0" text="Analyse" />
</children>
</Pane>
<TableView fx:id="flightTableView" prefHeight="377.0" prefWidth="601.0">

Loading…
Cancel
Save