parent
725900f80a
commit
2404c18d51
Binary file not shown.
@ -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>
|
||||
Loading…
Reference in new issue