Remodelled GUI and testing out flight adding.
This commit is contained in:
@@ -12,7 +12,8 @@ public enum SceneCode {
|
||||
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"),
|
||||
ROUTE_FILTER("route_filter_form.fxml"), AIRLINE_EDIT("airline_edit_form.fxml"), AIRPORT_EDIT("airport_edit_form.fxml"),
|
||||
ROUTE_EDIT("route_edit_form.fxml"), FLIGHT_EDITOR("flight_editor_form.fxml"), DATASET_CONTROLLER("dataset_editor.fxml"), HELP("help.fxml");
|
||||
ROUTE_EDIT("route_edit_form.fxml"), FLIGHT_EDITOR("flight_editor_form.fxml"), DATASET_CONTROLLER("dataset_editor.fxml"), HELP("help.fxml"),
|
||||
FLIGHT_ADD("flight_add_form.fxml");
|
||||
|
||||
|
||||
private String filePath;
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Created by Sunguin on 2016/10/01.
|
||||
*/
|
||||
public class FlightAddController extends Controller {
|
||||
//Set up text fields for adding data
|
||||
@FXML
|
||||
private TextField fNameAdd;
|
||||
@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
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
private Session currentSession = null;
|
||||
|
||||
public void load() {
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
currentSession = getParent().getSession();
|
||||
//System.out.println(theDataSet);
|
||||
System.out.println(currentSession.getCurrentFlightPathID());
|
||||
}
|
||||
|
||||
public void addFlight() {
|
||||
|
||||
try {
|
||||
theDataSet.addFlightPointToPath(currentSession.getCurrentFlightPathID(),
|
||||
fNameAdd.getText(),
|
||||
fTypeAdd.getText(),
|
||||
fViaAdd.getText(),
|
||||
fAltitudeAdd.getText(),
|
||||
fLatitudeAdd.getText(),
|
||||
fLongitudeAdd.getText(),
|
||||
fHeadingAdd.getText(),
|
||||
fLegDistAdd.getText(),
|
||||
fTotDistAdd.getText());
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Flight Point Add Successful");
|
||||
alert.setHeaderText("New Flight Point added!");
|
||||
alert.setContentText("Your new flight point has been successfully added into the database.");
|
||||
alert.showAndWait();
|
||||
|
||||
Stage stage = (Stage) flightAddButton.getScene().getWindow();
|
||||
stage.close();
|
||||
} catch ( Exception e ) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Flight Point Data Error");
|
||||
alert.setHeaderText("Error adding a custom flight point entry.");
|
||||
alert.setContentText(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,24 +55,24 @@ public class FlightRDController extends Controller {
|
||||
ListView<String> flightPathListView;
|
||||
private ObservableList<String> flightList = FXCollections.observableArrayList();
|
||||
|
||||
@FXML
|
||||
private TextField flightNameBox;
|
||||
@FXML
|
||||
private TextField flightTypeBox;
|
||||
@FXML
|
||||
private TextField flightViaBox;
|
||||
@FXML
|
||||
private TextField flightAltitudeBox;
|
||||
@FXML
|
||||
private TextField flightLatitudeBox;
|
||||
@FXML
|
||||
private TextField flightLongitudeBox;
|
||||
@FXML
|
||||
private TextField flightHeadingBox;
|
||||
@FXML
|
||||
private TextField flightLegDistBox;
|
||||
@FXML
|
||||
private TextField flightTotDistBox;
|
||||
// @FXML
|
||||
// private TextField flightNameBox;
|
||||
// @FXML
|
||||
// private TextField flightTypeBox;
|
||||
// @FXML
|
||||
// private TextField flightViaBox;
|
||||
// @FXML
|
||||
// private TextField flightAltitudeBox;
|
||||
// @FXML
|
||||
// private TextField flightLatitudeBox;
|
||||
// @FXML
|
||||
// private TextField flightLongitudeBox;
|
||||
// @FXML
|
||||
// private TextField flightHeadingBox;
|
||||
// @FXML
|
||||
// private TextField flightLegDistBox;
|
||||
// @FXML
|
||||
// private TextField flightTotDistBox;
|
||||
|
||||
/**
|
||||
* Loads the Flight paths into the List View and waits for a mouse clicked event for which it will update the table
|
||||
@@ -143,36 +143,44 @@ public class FlightRDController extends Controller {
|
||||
/**
|
||||
* Will take the inputs from the text fields and adds the point to the current flight path.
|
||||
*/
|
||||
public void addFlightPoint() {
|
||||
// public void addFlightPoint() {
|
||||
//
|
||||
// try {
|
||||
// theDataSet.addFlightPointToPath(currentPathId,
|
||||
// flightNameBox.getText(),
|
||||
// flightTypeBox.getText(),
|
||||
// flightViaBox.getText(),
|
||||
// flightAltitudeBox.getText(),
|
||||
// flightLatitudeBox.getText(),
|
||||
// flightLongitudeBox.getText(),
|
||||
// flightHeadingBox.getText(),
|
||||
// flightLegDistBox.getText(),
|
||||
// flightTotDistBox.getText());
|
||||
// flightNameBox.clear();
|
||||
// flightTypeBox.clear();
|
||||
// flightViaBox.clear();
|
||||
// flightAltitudeBox.clear();
|
||||
// flightLatitudeBox.clear();
|
||||
// flightLongitudeBox.clear();
|
||||
// flightHeadingBox.clear();
|
||||
// flightLegDistBox.clear();
|
||||
// flightTotDistBox.clear();
|
||||
//
|
||||
// updateTable(currentPathIndex);
|
||||
// } catch ( Exception e ) {
|
||||
// Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
// alert.setTitle("Flight Point Data Error");
|
||||
// alert.setHeaderText("Error adding a custom flight point entry.");
|
||||
// alert.setContentText(e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
try {
|
||||
theDataSet.addFlightPointToPath(currentPathId,
|
||||
flightNameBox.getText(),
|
||||
flightTypeBox.getText(),
|
||||
flightViaBox.getText(),
|
||||
flightAltitudeBox.getText(),
|
||||
flightLatitudeBox.getText(),
|
||||
flightLongitudeBox.getText(),
|
||||
flightHeadingBox.getText(),
|
||||
flightLegDistBox.getText(),
|
||||
flightTotDistBox.getText());
|
||||
flightNameBox.clear();
|
||||
flightTypeBox.clear();
|
||||
flightViaBox.clear();
|
||||
flightAltitudeBox.clear();
|
||||
flightLatitudeBox.clear();
|
||||
flightLongitudeBox.clear();
|
||||
flightHeadingBox.clear();
|
||||
flightLegDistBox.clear();
|
||||
flightTotDistBox.clear();
|
||||
|
||||
updateTable(currentPathIndex);
|
||||
} catch ( Exception e ) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Flight Point Data Error");
|
||||
alert.setHeaderText("Error adding a custom flight point entry.");
|
||||
alert.setContentText(e.getMessage());
|
||||
}
|
||||
public void openAdd() {
|
||||
Session session = getParent().getSession();
|
||||
session.setCurrentFlightPathtID(currentPathId);
|
||||
createPopUpStage(SceneCode.FLIGHT_ADD, 600, 400);
|
||||
//flightTableView.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
|
||||
updateTable(currentPathIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,4 +278,8 @@ public class FlightRDController extends Controller {
|
||||
flightPathListView();
|
||||
}
|
||||
|
||||
public void flightSummaryButton() {
|
||||
replaceSceneContent(SceneCode.FLIGHT_SUMMARY);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user