Implemented the same error messages that are used in other areas of the application

main
Liam Beckett 9 years ago
parent c1df5bd066
commit 753247b004

@ -1150,6 +1150,15 @@ public class Dataset {
newPath.setID(pathID); newPath.setID(pathID);
flightPathDictionary.put(pathID, newPath); flightPathDictionary.put(pathID, newPath);
flightPaths.add(newPath); flightPaths.add(newPath);
FlightPoint sourcePoint = new FlightPoint(sourceAirport, pathID);
FlightPoint destinationPoint = new FlightPoint(sourceAirport, pathID);
try{
addFlightPointToPath(sourcePoint);
addFlightPointToPath(destinationPoint);
} catch (DataException e){
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
} }
/** /**

@ -16,7 +16,26 @@ public class FlightPoint {
private double longitude; private double longitude;
/** /**
* Constructor for FLight POint before set by the database. * Constructor for Flight Point when creating a new path
* @param name
* @param indexID
*/
public FlightPoint(String name, int indexID) {
this.name = name;
this.ID = -1;
this.indexID = indexID;
this.type = "";
this.via = "";
this.heading = 0;
this.altitude = 0.0;
this.legDistance = 0;
this.totalDistance = 0;
this.latitude = 0.0;
this.longitude = 0.0;
}
/**
* Constructor for Flight Point before set by the database.
* @param type * @param type
* @param name * @param name
* @param altitude * @param altitude

@ -4,22 +4,17 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import seng202.group9.Controller.App;
import seng202.group9.Controller.DataException; import seng202.group9.Controller.DataException;
import seng202.group9.Controller.Dataset; import seng202.group9.Controller.Dataset;
import seng202.group9.Core.FlightPath; import seng202.group9.Core.FlightPath;
import seng202.group9.Core.FlightPoint; import seng202.group9.Core.FlightPoint;
import javax.swing.*; import javax.swing.*;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.ResourceBundle;
/** /**
* Controller for the Flights Raw Data Scene. * Controller for the Flights Raw Data Scene.
@ -57,7 +52,7 @@ public class FlightRDController extends Controller {
@FXML @FXML
ListView<String> flightPathListView; ListView<String> flightPathListView;
final ObservableList<String> flightList = FXCollections.observableArrayList(); private ObservableList<String> flightList = FXCollections.observableArrayList();
@FXML @FXML
private TextField flightNameBox; private TextField flightNameBox;
@ -82,7 +77,7 @@ public class FlightRDController extends Controller {
* Loads the Flight paths into the List View and waits for a mouse clicked event for which it will update the table * Loads the Flight paths into the List View and waits for a mouse clicked event for which it will update the table
* to display the selected Flight paths points. Called from the MenuController. * to display the selected Flight paths points. Called from the MenuController.
*/ */
public void flightPathListView() { private void flightPathListView() {
try { try {
ArrayList<FlightPath> flightPaths; ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths(); flightPaths = theDataSet.getFlightPaths();
@ -135,8 +130,8 @@ public class FlightRDController extends Controller {
flightLatCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Latitude")); flightLatCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Latitude"));
flightLongCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Longitude")); flightLongCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Longitude"));
flightHeadCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Heading")); flightHeadCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Heading"));
flightLegDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Leg_Dist")); flightLegDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("LegDistance"));
flightTotDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Tot_Dist")); flightTotDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("totalDistance"));
ArrayList<FlightPath> flightPaths; ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths(); flightPaths = theDataSet.getFlightPaths();
@ -175,7 +170,6 @@ public class FlightRDController extends Controller {
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight(); ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints)); flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
} catch ( Exception e ) { } catch ( Exception e ) {
//e.printStackTrace();
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.");
@ -204,7 +198,7 @@ public class FlightRDController extends Controller {
*/ */
public void deletePoint() { public void deletePoint() {
FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem(); FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem();
int pathID = 0; int pathID;
try { try {
pathID = toDelete.getIndex(); pathID = toDelete.getIndex();
} catch (DataException e) { } catch (DataException e) {

@ -124,7 +124,6 @@ public class FlightSummaryController extends Controller {
} }
}); });
} }
/** /**
* 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.
*/ */

@ -1,7 +1,9 @@
package seng202.group9.GUI; package seng202.group9.GUI;
import javafx.scene.control.Alert;
import seng202.group9.Controller.DataException; import seng202.group9.Controller.DataException;
import seng202.group9.Controller.EntryParser; import seng202.group9.Controller.EntryParser;
import seng202.group9.Core.FlightPoint;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -17,7 +19,6 @@ public class NewPathPopUp {
private String sourceAirport = null; private String sourceAirport = null;
private String destinationAirport = null; private String destinationAirport = null;
// Creates and displays the pop up box for the user to input data. // Creates and displays the pop up box for the user to input data.
public void display() { public void display() {
JTextField field1 = new JTextField(); JTextField field1 = new JTextField();
@ -38,8 +39,11 @@ public class NewPathPopUp {
}catch (DataException e){ }catch (DataException e){
sourceAirport = null; sourceAirport = null;
destinationAirport = null; destinationAirport = null;
JOptionPane.showMessageDialog(null, "Source " + e.getMessage()); Alert alert = new Alert(Alert.AlertType.ERROR);
return; alert.setTitle("Flight Path Name Error");
alert.setHeaderText("Error adding the Source airport ICAO code.");
alert.setContentText(e.getMessage());
alert.showAndWait();
} }
try{ try{
EntryParser parser = new EntryParser(); EntryParser parser = new EntryParser();
@ -47,8 +51,11 @@ public class NewPathPopUp {
}catch (DataException e){ }catch (DataException e){
sourceAirport = null; sourceAirport = null;
destinationAirport = null; destinationAirport = null;
JOptionPane.showMessageDialog(null, "Destination " + e.getMessage()); Alert alert = new Alert(Alert.AlertType.ERROR);
return; alert.setTitle("Flight Path Name Error");
alert.setHeaderText("Error adding the Destination airport ICAO code.");
alert.setContentText(e.getMessage());
alert.showAndWait();
} }
} else { } else {
sourceAirport = null; sourceAirport = null;

Loading…
Cancel
Save