parent
262547e590
commit
b7a3d416ca
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
<?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?>
|
||||
|
||||
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" vgap="10.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightAddController">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="280.0" minWidth="10.0" prefWidth="125.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="515.0" minWidth="10.0" prefWidth="402.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="30.0" minHeight="0.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="30.0" minHeight="4.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
<children>
|
||||
<Label text="Add Flight Point" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.valignment="TOP">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Name" GridPane.halignment="LEFT" GridPane.rowIndex="1">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label text="Type" GridPane.halignment="LEFT" GridPane.rowIndex="2">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label text="Altitude" GridPane.halignment="LEFT" GridPane.rowIndex="4">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label text="Latitude" GridPane.halignment="LEFT" GridPane.rowIndex="5">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label text="Longitude" GridPane.halignment="LEFT" GridPane.rowIndex="6">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Button fx:id="flightAddButton" mnemonicParsing="false" onAction="#addFlight" text="Add Flight" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="10" />
|
||||
<TextField fx:id="fNameAdd" prefHeight="31.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="fTypeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
|
||||
<TextField fx:id="fAltitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="4" />
|
||||
<TextField fx:id="fLatitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="5" />
|
||||
<TextField fx:id="fLongitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="6" />
|
||||
<Label text="Via" GridPane.rowIndex="3">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label text="Heading" GridPane.rowIndex="7">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label text="Leg Distance" GridPane.rowIndex="8">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Label text="Total Distance" GridPane.rowIndex="9">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<TextField fx:id="fViaAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="3" />
|
||||
<TextField fx:id="fHeadingAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="7" />
|
||||
<TextField fx:id="fLegDistAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="8" />
|
||||
<TextField fx:id="fTotDistAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="9" />
|
||||
</children>
|
||||
</GridPane>
|
||||
Loading…
Reference in new issue