Applied single entry add methods to GUI for Airports and Airlines. Made error pop ups for them as well.
This commit is contained in:
Binary file not shown.
@@ -2,6 +2,7 @@ package seng202.group9.GUI;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
@@ -47,50 +48,43 @@ public class AirlineRDController extends MenuController {
|
||||
private TextField airlCountryBox;
|
||||
@FXML
|
||||
private TextField airlActiveBox;
|
||||
@FXML
|
||||
private TextField airlIDBox;
|
||||
|
||||
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
App parent;
|
||||
|
||||
public void setApp(App parent){
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
public void loadTables() {
|
||||
airlIDcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ID"));
|
||||
airlNamecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Name"));
|
||||
airlAliascol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Alias"));
|
||||
airlIATAcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("IATA"));
|
||||
airlICAOcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ICAO"));
|
||||
//Need to check IATA and ICAO
|
||||
airlIATAcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ICAO"));
|
||||
airlICAOcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("IATA"));
|
||||
airlCallsigncol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CallSign"));
|
||||
airlCountrycol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Country"));
|
||||
airlActivecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Active"));
|
||||
|
||||
theDataSet = this.parent.getCurrentDataset();
|
||||
// try{
|
||||
// System.out.println(theDataSet.importAirline("res/Samples/Airlines.txt"));
|
||||
// } catch (DataException e){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
tableView.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
|
||||
}
|
||||
|
||||
//Dummy function to test the add button.
|
||||
//Will edit when ID is added automatically.
|
||||
public void addAirlineSingle() {
|
||||
theDataSet.getAirlines().add(new Airline(
|
||||
Integer.parseInt(airlIDBox.getText()),
|
||||
try {
|
||||
theDataSet.addAirline(
|
||||
airlNameBox.getText(),
|
||||
airlAliasBox.getText(),
|
||||
airlIATABox.getText(),
|
||||
airlICAOBox.getText(),
|
||||
airlCallsignBox.getText(),
|
||||
airlCountryBox.getText(),
|
||||
airlActiveBox.getText()));
|
||||
airlIDBox.clear();
|
||||
airlActiveBox.getText());
|
||||
airlNameBox.clear();
|
||||
airlAliasBox.clear();
|
||||
airlIATABox.clear();
|
||||
@@ -98,5 +92,13 @@ public class AirlineRDController extends MenuController {
|
||||
airlCallsignBox.clear();
|
||||
airlCountryBox.clear();
|
||||
airlActiveBox.clear();
|
||||
tableView.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
|
||||
} catch ( Exception e ) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Airline Data Error");
|
||||
alert.setHeaderText("Error adding a custom airline entry.");
|
||||
alert.setContentText(e.getMessage());
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,7 @@ import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.util.Callback;
|
||||
import seng202.group9.Controller.App;
|
||||
@@ -50,6 +47,30 @@ public class AirportRDController extends MenuController{
|
||||
@FXML
|
||||
private TableColumn<Airport, City> airpTzcol;
|
||||
|
||||
@FXML
|
||||
private TextField airpNameBox;
|
||||
@FXML
|
||||
private TextField airpCityBox;
|
||||
@FXML
|
||||
private TextField airpCountryBox;
|
||||
@FXML
|
||||
private TextField airpIATAFFABox;
|
||||
@FXML
|
||||
private TextField airpICAOBox;
|
||||
@FXML
|
||||
private TextField airpLatitudeBox;
|
||||
@FXML
|
||||
private TextField airpLongitudeBox;
|
||||
@FXML
|
||||
private TextField airpAltitudeBox;
|
||||
@FXML
|
||||
private TextField airpTimezoneBox;
|
||||
@FXML
|
||||
private TextField airpDSTBox;
|
||||
@FXML
|
||||
private TextField airpTzBox;
|
||||
|
||||
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
App parent;
|
||||
@@ -59,8 +80,6 @@ public class AirportRDController extends MenuController{
|
||||
}
|
||||
|
||||
public void loadTables() {
|
||||
theDataSet = this.parent.getCurrentDataset();
|
||||
|
||||
airpIDcol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ID"));
|
||||
airpNamecol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
|
||||
airpCitycol.setCellValueFactory(new PropertyValueFactory<Airport, String>("City"));
|
||||
@@ -91,8 +110,42 @@ public class AirportRDController extends MenuController{
|
||||
// return timeZoneCell;
|
||||
// }
|
||||
// });
|
||||
|
||||
theDataSet = this.parent.getCurrentDataset();
|
||||
tableViewAirportRD.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
|
||||
}
|
||||
|
||||
public void addAirportSingle() {
|
||||
try {
|
||||
theDataSet.addAirport(
|
||||
airpNameBox.getText(),
|
||||
airpCityBox.getText(),
|
||||
airpCountryBox.getText(),
|
||||
airpIATAFFABox.getText(),
|
||||
airpICAOBox.getText(),
|
||||
airpLatitudeBox.getText(),
|
||||
airpLongitudeBox.getText(),
|
||||
airpAltitudeBox.getText(),
|
||||
airpTimezoneBox.getText(),
|
||||
airpDSTBox.getText(),
|
||||
airpTzBox.getText());
|
||||
airpCityBox.clear();
|
||||
airpCountryBox.clear();
|
||||
airpIATAFFABox.clear();
|
||||
airpICAOBox.clear();
|
||||
airpLatitudeBox.clear();
|
||||
airpLongitudeBox.clear();
|
||||
airpAltitudeBox.clear();
|
||||
airpTimezoneBox.clear();
|
||||
airpDSTBox.clear();
|
||||
airpTzBox.clear();
|
||||
tableViewAirportRD.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
|
||||
} catch ( Exception e ) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Airline Data Error");
|
||||
alert.setHeaderText("Error adding a custom airport entry.");
|
||||
alert.setContentText(e.getMessage());
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -85,11 +85,7 @@
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airlIDBox" layoutY="2.0" prefHeight="25.0" prefWidth="93.0" promptText="Airline ID">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<Label layoutY="2.0" prefHeight="25.0" prefWidth="93.0" text="Enter Values:" />
|
||||
</children>
|
||||
</Pane>
|
||||
</children>
|
||||
|
||||
@@ -33,74 +33,70 @@
|
||||
</Label>
|
||||
<ScrollPane hbarPolicy="ALWAYS" layoutX="14.0" layoutY="364.0" prefHeight="47.0" prefViewportHeight="29.0" prefViewportWidth="1095.0" prefWidth="770.0" vbarPolicy="NEVER">
|
||||
<content>
|
||||
<Pane prefHeight="29.0" prefWidth="1087.0">
|
||||
<Pane prefHeight="29.0" prefWidth="1219.0">
|
||||
<children>
|
||||
<TextField layoutX="6.0" layoutY="2.0" prefHeight="25.0" prefWidth="83.0" promptText="Airport ID">
|
||||
<TextField fx:id="airpNameBox" layoutX="89.0" layoutY="2.0" prefHeight="25.0" prefWidth="137.0" promptText="Name">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="89.0" layoutY="2.0" prefHeight="25.0" prefWidth="137.0" promptText="Name">
|
||||
<TextField fx:id="airpCityBox" layoutX="226.0" layoutY="2.0" prefHeight="25.0" prefWidth="129.0" promptText="City">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="226.0" layoutY="2.0" prefHeight="25.0" prefWidth="129.0" promptText="City">
|
||||
<TextField fx:id="airpCountryBox" layoutX="355.0" layoutY="2.0" prefHeight="25.0" prefWidth="96.0" promptText="Country">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="355.0" layoutY="2.0" prefHeight="25.0" prefWidth="96.0" promptText="Country">
|
||||
<TextField fx:id="airpIATAFFABox" layoutX="451.0" layoutY="2.0" prefHeight="25.0" prefWidth="87.0" promptText="IATA/FAA">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="451.0" layoutY="2.0" prefHeight="25.0" prefWidth="87.0" promptText="IATA/FAA">
|
||||
<TextField fx:id="airpICAOBox" layoutX="538.0" layoutY="2.0" prefHeight="25.0" prefWidth="48.0" promptText="ICAO">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="538.0" layoutY="2.0" prefHeight="25.0" prefWidth="48.0" promptText="ICAO">
|
||||
<TextField fx:id="airpLatitudeBox" layoutX="586.0" layoutY="2.0" prefHeight="25.0" prefWidth="82.0" promptText="Latitude">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="586.0" layoutY="2.0" prefHeight="25.0" prefWidth="82.0" promptText="Latitude">
|
||||
<TextField fx:id="airpLongitudeBox" layoutX="668.0" layoutY="2.0" prefHeight="25.0" prefWidth="92.0" promptText="Longitude">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="668.0" layoutY="2.0" prefHeight="25.0" prefWidth="92.0" promptText="Longitude">
|
||||
<TextField fx:id="airpAltitudeBox" layoutX="760.0" layoutY="2.0" prefHeight="25.0" prefWidth="78.0" promptText="Altitude">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="760.0" layoutY="2.0" prefHeight="25.0" prefWidth="78.0" promptText="Altitude">
|
||||
<TextField fx:id="airpTimezoneBox" layoutX="838.0" layoutY="2.0" prefHeight="25.0" prefWidth="80.0" promptText="Timezone">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="838.0" layoutY="2.0" prefHeight="25.0" prefWidth="80.0" promptText="Timezone">
|
||||
<TextField fx:id="airpTzBox" layoutX="1023.0" layoutY="3.0" prefHeight="25.0" prefWidth="182.0" promptText="Tz database time zone">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="1020.0" layoutY="2.0" prefHeight="25.0" prefWidth="182.0" promptText="Tz database time zone">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="918.0" layoutY="2.0" prefHeight="25.0" prefWidth="102.0" promptText="DST">
|
||||
<TextField fx:id="airpDSTBox" layoutX="918.0" layoutY="2.0" prefHeight="25.0" prefWidth="102.0" promptText="DST">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<Label layoutY="2.0" prefHeight="25.0" prefWidth="87.0" text="Enter Values:" />
|
||||
</children>
|
||||
</Pane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<Button layoutX="10.0" layoutY="420.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="125.0" text="Analyse" />
|
||||
<Button layoutX="661.0" layoutY="420.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="125.0" text="Add" />
|
||||
<Button layoutX="661.0" layoutY="420.0" mnemonicParsing="false" onAction="#addAirportSingle" prefHeight="25.0" prefWidth="125.0" text="Add" />
|
||||
<Pane layoutX="15.0" layoutY="60.0" prefHeight="295.0" prefWidth="772.0">
|
||||
<children>
|
||||
<TableView fx:id="tableViewAirportRD" prefHeight="293.0" prefWidth="770.0">
|
||||
|
||||
@@ -65,17 +65,17 @@
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="758.0" layoutY="2.0" prefHeight="25.0" prefWidth="99.0" promptText="Codeshare">
|
||||
<TextField fx:id="rCodeshareCol" layoutX="758.0" layoutY="2.0" prefHeight="25.0" prefWidth="99.0" promptText="Codeshare">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="857.0" layoutY="2.0" prefHeight="25.0" prefWidth="65.0" promptText="Stops">
|
||||
<TextField fx:id="rStopsCol" layoutX="857.0" layoutY="2.0" prefHeight="25.0" prefWidth="65.0" promptText="Stops">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField layoutX="922.0" layoutY="2.0" prefHeight="25.0" prefWidth="98.0" promptText="Equipment">
|
||||
<TextField fx:id="rEquipmentCol" layoutX="922.0" layoutY="2.0" prefHeight="25.0" prefWidth="98.0" promptText="Equipment">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
@@ -85,17 +85,17 @@
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<Button layoutX="10.0" layoutY="420.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="125.0" text="Analyse" />
|
||||
<Button layoutX="661.0" layoutY="420.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="125.0" text="Add" />
|
||||
<Button layoutX="661.0" layoutY="420.0" mnemonicParsing="false" onAction="#addRouteSingle" prefHeight="25.0" prefWidth="125.0" text="Add" />
|
||||
<Pane layoutX="8.0" layoutY="53.0" prefHeight="300.0" prefWidth="776.0">
|
||||
<children>
|
||||
<TableView layoutX="-1.0" prefHeight="300.0" prefWidth="784.0">
|
||||
<TableView fx:id="tableViewRouteRD" layoutX="-1.0" prefHeight="300.0" prefWidth="784.0">
|
||||
<columns>
|
||||
<TableColumn prefWidth="67.0" text="Airline" />
|
||||
<TableColumn prefWidth="86.0" text="Airline ID" />
|
||||
<TableColumn minWidth="0.0" prefWidth="124.0" text="Source airport" />
|
||||
<TableColumn minWidth="0.0" prefWidth="141.0" text="Source airport ID" />
|
||||
<TableColumn minWidth="0.0" prefWidth="160.0" text="Destination airport" />
|
||||
<TableColumn minWidth="0.0" prefWidth="184.0" text="Destination airport ID" />
|
||||
<TableColumn fx:id="rAirlineCol" prefWidth="67.0" text="Airline" />
|
||||
<TableColumn fx:id="rAirlineIDCol" prefWidth="86.0" text="Airline ID" />
|
||||
<TableColumn fx:id="rSourceCol" minWidth="0.0" prefWidth="124.0" text="Source airport" />
|
||||
<TableColumn fx:id="rSourceIDCol" minWidth="0.0" prefWidth="141.0" text="Source airport ID" />
|
||||
<TableColumn fx:id="rDestCol" minWidth="0.0" prefWidth="160.0" text="Destination airport" />
|
||||
<TableColumn fx:id="rDestIDCol" minWidth="0.0" prefWidth="184.0" text="Destination airport ID" />
|
||||
<TableColumn minWidth="0.0" prefWidth="95.0" text="Codeshare" />
|
||||
<TableColumn minWidth="0.0" prefWidth="69.0" text="Stops" />
|
||||
<TableColumn prefWidth="98.0" text="Equipment" />
|
||||
|
||||
Reference in New Issue
Block a user