Changed JSwing component in new flight path.
This commit is contained in:
Binary file not shown.
@@ -13,7 +13,8 @@ public enum SceneCode {
|
|||||||
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"), AIRLINE_EDIT("airline_edit_form.fxml"), AIRPORT_EDIT("airport_edit_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"), ROUTE_BY_AIRPORT("airport_map_routes.fxml"), ROUTE_BY_EQUIP("route_by_equip.fxml");
|
FLIGHT_ADD("flight_add_form.fxml"), ROUTE_BY_AIRPORT("airport_map_routes.fxml"), ROUTE_BY_EQUIP("route_by_equip.fxml"),
|
||||||
|
FLIGHT_PATH_ADD("new_flight_path.fxml");
|
||||||
|
|
||||||
|
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
|||||||
@@ -56,25 +56,6 @@ public class FlightRDController extends Controller {
|
|||||||
ListView<String> flightPathListView;
|
ListView<String> flightPathListView;
|
||||||
private ObservableList<String> flightList = FXCollections.observableArrayList();
|
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
@@ -166,16 +147,9 @@ public class FlightRDController extends Controller {
|
|||||||
* Creates a pop up dialog which prompts the user for two ICAO airport codes which will use when creating a new path.
|
* 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() {
|
public void newPath() {
|
||||||
NewPathPopUp dialogBox = new NewPathPopUp();
|
createPopUpStage(SceneCode.FLIGHT_PATH_ADD, 500, 240);
|
||||||
dialogBox.display();
|
flightPathListView.getItems().clear();
|
||||||
String destAirport = dialogBox.getDestinationAirport();
|
flightPathListView();
|
||||||
String sourceAirport = dialogBox.getSourceAirport();
|
|
||||||
|
|
||||||
if (destAirport != null && sourceAirport != null){
|
|
||||||
theDataSet.addFlightPath(sourceAirport, destAirport);
|
|
||||||
flightPathListView.getItems().clear();
|
|
||||||
flightPathListView();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Removes the selected point from the table and database.
|
* Removes the selected point from the table and database.
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
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.EntryParser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The controller class for new_flight_path.fxml.
|
||||||
|
* Created by Sunguin.
|
||||||
|
*/
|
||||||
|
public class NewPathController extends Controller {
|
||||||
|
@FXML
|
||||||
|
private TextField sourceAirport;
|
||||||
|
@FXML
|
||||||
|
private TextField destinationAirport;
|
||||||
|
@FXML
|
||||||
|
private Button addButton;
|
||||||
|
|
||||||
|
private Dataset theDataSet = null;
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
theDataSet = getParent().getCurrentDataset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to add a new flight path. First uses the entry parser to check for valid ICAO codes.
|
||||||
|
*/
|
||||||
|
public void addPath() {
|
||||||
|
EntryParser airportCheck = new EntryParser();
|
||||||
|
try {
|
||||||
|
airportCheck.parsePointName(sourceAirport.getText());
|
||||||
|
airportCheck.parsePointName(destinationAirport.getText());
|
||||||
|
theDataSet.addFlightPath(sourceAirport.getText(), destinationAirport.getText());
|
||||||
|
|
||||||
|
//Saying to the user that the flight path has successfully added.
|
||||||
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||||
|
alert.setTitle("Flight Path Add Successful");
|
||||||
|
alert.setHeaderText("New Flight Path added!");
|
||||||
|
alert.setContentText("Your new flight path has been successfully added into the database.");
|
||||||
|
alert.showAndWait();
|
||||||
|
|
||||||
|
//Closes the add form.
|
||||||
|
Stage stage = (Stage) addButton.getScene().getWindow();
|
||||||
|
stage.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
//Tells the user what and where the error is.
|
||||||
|
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||||
|
alert.setTitle("Flight Path Data Error");
|
||||||
|
alert.setHeaderText("Error adding a custom flight path entry.");
|
||||||
|
alert.setContentText(e.getMessage());
|
||||||
|
alert.showAndWait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
package seng202.group9.GUI;
|
|
||||||
|
|
||||||
import javafx.scene.control.Alert;
|
|
||||||
import seng202.group9.Controller.DataException;
|
|
||||||
import seng202.group9.Controller.EntryParser;
|
|
||||||
import seng202.group9.Core.FlightPoint;
|
|
||||||
|
|
||||||
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();
|
|
||||||
try{
|
|
||||||
EntryParser parser = new EntryParser();
|
|
||||||
parser.parsePointName(sourceAirport);
|
|
||||||
}catch (DataException e){
|
|
||||||
sourceAirport = null;
|
|
||||||
destinationAirport = null;
|
|
||||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
|
||||||
alert.setTitle("Flight Path Name Error");
|
|
||||||
alert.setHeaderText("Error adding the Source airport ICAO code.");
|
|
||||||
alert.setContentText(e.getMessage());
|
|
||||||
alert.showAndWait();
|
|
||||||
}
|
|
||||||
try{
|
|
||||||
EntryParser parser = new EntryParser();
|
|
||||||
parser.parsePointName(destinationAirport);
|
|
||||||
}catch (DataException e){
|
|
||||||
sourceAirport = null;
|
|
||||||
destinationAirport = null;
|
|
||||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
|
||||||
alert.setTitle("Flight Path Name Error");
|
|
||||||
alert.setHeaderText("Error adding the Destination airport ICAO code.");
|
|
||||||
alert.setContentText(e.getMessage());
|
|
||||||
alert.showAndWait();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sourceAirport = null;
|
|
||||||
destinationAirport = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSourceAirport() {
|
|
||||||
return sourceAirport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDestinationAirport() {
|
|
||||||
return destinationAirport;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?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?>
|
||||||
|
<?import javafx.scene.text.Text?>
|
||||||
|
|
||||||
|
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="240.0" prefWidth="500.0" vgap="10.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.60" fx:controller="seng202.group9.GUI.NewPathController">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="250.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="250.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="60.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="60.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="60.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="60.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Add New Flight Path" textAlignment="CENTER" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
|
||||||
|
<font>
|
||||||
|
<Font size="18.0" />
|
||||||
|
</font>
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Text>
|
||||||
|
<Label text="Source Airport ICAO Code" GridPane.rowIndex="1">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Label>
|
||||||
|
<Label text="Desination Airport ICAO Code" GridPane.rowIndex="2">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Label>
|
||||||
|
<TextField fx:id="sourceAirport" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||||
|
<TextField fx:id="destinationAirport" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||||
|
<Button fx:id="addButton" mnemonicParsing="false" onAction="#addPath" text="Add New Flight Path" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="3" />
|
||||||
|
</children>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
</padding>
|
||||||
|
</GridPane>
|
||||||
Reference in New Issue
Block a user