Seperated Controllers
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.TextField;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
|
||||
/**
|
||||
* Created by Sunguin on 2016/09/22.
|
||||
*/
|
||||
public class AirlineAddController extends AirlineRDController{
|
||||
//Setting up text fields for adding data
|
||||
@FXML
|
||||
private TextField airlNameAdd;
|
||||
@FXML
|
||||
private TextField airlAliasAdd;
|
||||
@FXML
|
||||
private TextField airlIATAAdd;
|
||||
@FXML
|
||||
private TextField airlICAOAdd;
|
||||
@FXML
|
||||
private TextField airlCallsignAdd;
|
||||
@FXML
|
||||
private TextField airlCountryAdd;
|
||||
@FXML
|
||||
private TextField airlActiveAdd;
|
||||
|
||||
Dataset theDataSet = null;
|
||||
|
||||
/**
|
||||
* Adds a single airline entry to the database.
|
||||
* Takes in values from the GUI the user has typed in.
|
||||
* @see Dataset
|
||||
*/
|
||||
public void addAirlineSingle() {
|
||||
//Tries to add a new airline and clears the fields to their initial state if successful.
|
||||
//Otherwise an error message will pop up with what is wrong with the manual data.
|
||||
|
||||
try {
|
||||
theDataSet.addAirline(
|
||||
airlNameAdd.getText(),
|
||||
airlAliasAdd.getText(),
|
||||
airlIATAAdd.getText(),
|
||||
airlICAOAdd.getText(),
|
||||
airlCallsignAdd.getText(),
|
||||
airlCountryAdd.getText(),
|
||||
airlActiveAdd.getText());
|
||||
airlNameAdd.clear();
|
||||
airlAliasAdd.clear();
|
||||
airlIATAAdd.clear();
|
||||
airlICAOAdd.clear();
|
||||
airlCallsignAdd.clear();
|
||||
airlCountryAdd.clear();
|
||||
airlActiveAdd.getText();
|
||||
//setData(theDataSet);
|
||||
} catch (Exception e) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Airline Data Error");
|
||||
alert.setHeaderText("Error adding a custom airline entry.");
|
||||
System.out.println(e);
|
||||
alert.setContentText(e.getMessage());
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
import seng202.group9.Controller.AirlineFilter;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Core.Airline;
|
||||
|
||||
/**
|
||||
* Created by Sunguin on 2016/09/22.
|
||||
*/
|
||||
public class AirlineFilterController extends AirlineRDController{
|
||||
|
||||
//Setting up text fields for filtering data
|
||||
@FXML
|
||||
private TextField airlNameFilter;
|
||||
@FXML
|
||||
private TextField airlAliasFilter;
|
||||
@FXML
|
||||
private TextField airlIATAFilter;
|
||||
@FXML
|
||||
private TextField airlICAOFilter;
|
||||
@FXML
|
||||
private TextField airlCallsignFilter;
|
||||
@FXML
|
||||
private TextField airlCountryFilter;
|
||||
@FXML
|
||||
private TextField airlActiveFilter;
|
||||
|
||||
Dataset theDataSet = null;
|
||||
|
||||
|
||||
/**
|
||||
* Filters airlines by any field.
|
||||
* These are specified by what the user has typed in the filter boxes.
|
||||
* Updates the GUI accordingly.
|
||||
* @see AirlineFilter
|
||||
*/
|
||||
public void filterAirlines() {
|
||||
//System.out.println(getData());
|
||||
//The filter function also operates like a search function
|
||||
//theDataSet = getParent().getCurrentDataset();
|
||||
AirlineFilter filter = new AirlineFilter(theDataSet.getAirlines());
|
||||
if (airlNameFilter.getText() != null) {
|
||||
filter.filterName(airlNameFilter.getText());
|
||||
}
|
||||
if (airlAliasFilter.getText() != null) {
|
||||
filter.filterAlias(airlAliasFilter.getText());
|
||||
}
|
||||
if (airlIATAFilter.getText() != null) {
|
||||
filter.filterIATA(airlIATAFilter.getText());
|
||||
}
|
||||
if (airlICAOFilter.getText() != null) {
|
||||
filter.filterICAO(airlICAOFilter.getText());
|
||||
}
|
||||
if (airlCallsignFilter.getText() != null) {
|
||||
filter.filterCallsign(airlCallsignFilter.getText());
|
||||
}
|
||||
if (airlCountryFilter.getText() != null) {
|
||||
filter.filterCountry(airlCountryFilter.getText());
|
||||
}
|
||||
if (airlActiveFilter.getText() != null) {
|
||||
filter.filterActive(airlActiveFilter.getText());
|
||||
}
|
||||
//Sets the data according to the criteria specified by the user.
|
||||
//setDataL(FXCollections.<Airline>observableArrayList(filter.getFilteredData()));
|
||||
}
|
||||
}
|
||||
@@ -47,41 +47,12 @@ public class AirlineRDController extends Controller {
|
||||
@FXML
|
||||
private TableColumn<Airline, String> airlActiveCol;
|
||||
|
||||
//Setting up text fields for adding data
|
||||
@FXML
|
||||
private TextField airlNameAdd;
|
||||
@FXML
|
||||
private TextField airlAliasAdd;
|
||||
@FXML
|
||||
private TextField airlIATAAdd;
|
||||
@FXML
|
||||
private TextField airlICAOAdd;
|
||||
@FXML
|
||||
private TextField airlCallsignAdd;
|
||||
@FXML
|
||||
private TextField airlCountryAdd;
|
||||
@FXML
|
||||
private TextField airlActiveAdd;
|
||||
|
||||
//Setting up text fields for filtering data
|
||||
@FXML
|
||||
private TextField airlNameFilter;
|
||||
@FXML
|
||||
private TextField airlAliasFilter;
|
||||
@FXML
|
||||
private TextField airlIATAFilter;
|
||||
@FXML
|
||||
private TextField airlICAOFilter;
|
||||
@FXML
|
||||
private TextField airlCallsignFilter;
|
||||
@FXML
|
||||
private TextField airlCountryFilter;
|
||||
@FXML
|
||||
private TextField airlActiveFilter;
|
||||
|
||||
//Set an empty Dataset to be assigned later.
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
private ObservableList dataL = null;
|
||||
|
||||
/**
|
||||
* Loads the initial airline data to the GUI table.
|
||||
* Also sets up the dropdown menu options.
|
||||
@@ -102,6 +73,7 @@ public class AirlineRDController extends Controller {
|
||||
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Opens the Airline add form.
|
||||
*/
|
||||
@@ -118,93 +90,10 @@ public class AirlineRDController extends Controller {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a single airline entry to the database.
|
||||
* Takes in values from the GUI the user has typed in.
|
||||
* @see Dataset
|
||||
*/
|
||||
public void addAirlineSingle() {
|
||||
//Tries to add a new airline and clears the fields to their initial state if successful.
|
||||
//Otherwise an error message will pop up with what is wrong with the manual data.
|
||||
|
||||
//How to get this dataset into here to show data?
|
||||
try {
|
||||
theDataSet.addAirline(
|
||||
airlNameAdd.getText(),
|
||||
airlAliasAdd.getText(),
|
||||
airlIATAAdd.getText(),
|
||||
airlICAOAdd.getText(),
|
||||
airlCallsignAdd.getText(),
|
||||
airlCountryAdd.getText(),
|
||||
airlActiveAdd.getText());
|
||||
airlNameAdd.clear();
|
||||
airlAliasAdd.clear();
|
||||
airlIATAAdd.clear();
|
||||
airlICAOAdd.clear();
|
||||
airlCallsignAdd.clear();
|
||||
airlCountryAdd.clear();
|
||||
airlActiveAdd.getText();
|
||||
tableViewAirlineRD.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.");
|
||||
System.out.println(e);
|
||||
alert.setContentText(e.getMessage());
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters airlines by any field.
|
||||
* These are specified by what the user has typed in the filter boxes.
|
||||
* Updates the GUI accordingly.
|
||||
* @see AirlineFilter
|
||||
*/
|
||||
public void filterAirlines() {
|
||||
//The filter function also operates like a search function
|
||||
//theDataSet = getParent().getCurrentDataset();
|
||||
AirlineFilter filter = new AirlineFilter(theDataSet.getAirlines());
|
||||
if (airlNameFilter.getText() != null) {
|
||||
filter.filterName(airlNameFilter.getText());
|
||||
}
|
||||
if (airlAliasFilter.getText() != null) {
|
||||
filter.filterAlias(airlAliasFilter.getText());
|
||||
}
|
||||
if (airlIATAFilter.getText() != null) {
|
||||
filter.filterIATA(airlIATAFilter.getText());
|
||||
}
|
||||
if (airlICAOFilter.getText() != null) {
|
||||
filter.filterICAO(airlICAOFilter.getText());
|
||||
}
|
||||
if (airlCallsignFilter.getText() != null) {
|
||||
filter.filterCallsign(airlCallsignFilter.getText());
|
||||
}
|
||||
if (airlCountryFilter.getText() != null) {
|
||||
filter.filterCountry(airlCountryFilter.getText());
|
||||
}
|
||||
if (airlActiveFilter.getText() != null) {
|
||||
filter.filterActive(airlActiveFilter.getText());
|
||||
}
|
||||
//Sets the data according to the criteria specified by the user.
|
||||
tableViewAirlineRD.setItems(FXCollections.<Airline>observableArrayList(filter.getFilteredData()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a single selected airline entry from the database.
|
||||
* Updates the GUI accordingly.
|
||||
* @see Dataset
|
||||
*/
|
||||
public void deleteAirline() {
|
||||
//Gets an airline from the table and deletes it before updating the table
|
||||
Airline toDelete = tableViewAirlineRD.getSelectionModel().getSelectedItem();
|
||||
theDataSet.deleteAirline(toDelete);
|
||||
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Opens the Airline Filter form.
|
||||
*/
|
||||
@@ -220,6 +109,32 @@ public class AirlineRDController extends Controller {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
tableViewAirlineRD.setItems(FXCollections.<Airline>observableArrayList(theDataSet.getAirlines()));
|
||||
}
|
||||
|
||||
// public void setData(Dataset data) {
|
||||
// this.theDataSet = data;
|
||||
// }
|
||||
//
|
||||
// public Dataset getData() {
|
||||
// return theDataSet;
|
||||
// }
|
||||
//
|
||||
// public void setDataL(ObservableList re) {
|
||||
// this.dataL = re;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a single selected airline entry from the database.
|
||||
* Updates the GUI accordingly.
|
||||
* @see Dataset
|
||||
*/
|
||||
public void deleteAirline() {
|
||||
//Gets an airline from the table and deletes it before updating the table
|
||||
Airline toDelete = tableViewAirlineRD.getSelectionModel().getSelectedItem();
|
||||
theDataSet.deleteAirline(toDelete);
|
||||
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="370.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.AirlineRDController">
|
||||
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="370.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.AirlineAddController">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="280.0" minWidth="10.0" prefWidth="125.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="515.0" minWidth="10.0" prefWidth="445.0" />
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="370.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.AirlineRDController">
|
||||
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="370.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.AirlineFilterController">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="280.0" minWidth="10.0" prefWidth="125.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="515.0" minWidth="10.0" prefWidth="445.0" />
|
||||
|
||||
Reference in New Issue
Block a user