From c6f5c41b7ddbae5b81cd994934a3914d1e366763 Mon Sep 17 00:00:00 2001 From: Sunguin Peng Date: Thu, 22 Sep 2016 15:44:22 +1200 Subject: [PATCH] Initial Commit --- res/userdb.db | Bin 8387584 -> 8387584 bytes .../group9/GUI/AirlineRDController.java | 161 ++++++++++------ src/main/resources/airline_add_form.fxml | 82 ++++++++ src/main/resources/airline_filter_form.fxml | 81 ++++++++ src/main/resources/airline_raw_data.fxml | 181 ++++++------------ 5 files changed, 326 insertions(+), 179 deletions(-) create mode 100644 src/main/resources/airline_add_form.fxml create mode 100644 src/main/resources/airline_filter_form.fxml diff --git a/res/userdb.db b/res/userdb.db index 4ed487654814cd8370c1674f904d118286f24358..d91c0228b31a16564dfcfdffcedbde0d859acbf9 100644 GIT binary patch delta 535 zcmWmB$1;Oq7=Y3I5~2i&PJ$3b@4XYf_by(&_g<4MzOiLx#@a2I+)DN?frX9Xu{c+7 zyx+fiFP^NLJlkBF_(X}OBuI%~i9t!Qk`N_EC80{fl!PmZP-0RNsU%8C^t+hfKJ^ye ztKax#{`oMtHM8!;ZgO5edIA>2AQo|mM*2-&iCp9% z9|b5x5sFcQQk0<_6{tiNs!@Yl)S(^?Xhaj5(SlaAp&c%Cpc7r_Mh|+?hkguT5JMQo z2u3l6aZF$mQ<%mKW-*6(EMO6CEJ3i06|7)601wy=#I>|zi5IKUx}aEue2;tc1w W!2it^u5p7~+~FP%eow&TbNm4Wlnzq> delta 531 zcmWN=MNUHj6hP6Ge%y*n3q^{%yB2qM%ER5=%ix76?17{!AZ&%fAFu}|oxwfH@%sO) zUcT8ao_B}a;&~Aji%NisRmD&VR0&cERtZrFRS8oGSBX%GREbiF{uJBCug@5pHhhNP z_VZ=LZ+;uErWwOn#xb4=Ok@(1nZi`s>0lbu>0|~onZ<0nn8RG=F`or2WD$#5!cvy8 zoE5BO6{}gpTGp|i4Qyl+o7uuvwy~WZ?4+Ar>}C&p*~fkkaF9bB<_JeQ#&J$?l2e@K z3}-pVc`k5~OI)UhD-^DBjqBXtCbziF9qw|E`#j(wk9f=zp7M<6yx=9Tc+DH$@{ad> N;3J>DO!L|0{0A?~H_!k8 diff --git a/src/main/java/seng202/group9/GUI/AirlineRDController.java b/src/main/java/seng202/group9/GUI/AirlineRDController.java index 12bcef9..c1f8081 100644 --- a/src/main/java/seng202/group9/GUI/AirlineRDController.java +++ b/src/main/java/seng202/group9/GUI/AirlineRDController.java @@ -1,15 +1,26 @@ package seng202.group9.GUI; import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.layout.Pane; +import javafx.stage.Modality; +import javafx.stage.Stage; +import javafx.stage.StageStyle; import seng202.group9.Controller.AirlineFilter; +import seng202.group9.Controller.App; import seng202.group9.Controller.Dataset; +import seng202.group9.Controller.SceneCode; import seng202.group9.Core.Airline; import javax.swing.*; - +import java.io.IOException; +//make a class for the scenes to get the data I guess /** * The GUI controller class for airline_raw_data.fxml. * Extends from the abstract class {@link Controller}. @@ -20,37 +31,37 @@ public class AirlineRDController extends Controller { @FXML private TableView tableViewAirlineRD; @FXML - private TableColumn airlIDcol; + private TableColumn airlIDCol; @FXML - private TableColumn airlNamecol; + private TableColumn airlNameCol; @FXML - private TableColumn airlAliascol; + private TableColumn airlAliasCol; @FXML - private TableColumn airlIATAcol; + private TableColumn airlIATACol; @FXML - private TableColumn airlICAOcol; + private TableColumn airlICAOCol; @FXML - private TableColumn airlCallsigncol; + private TableColumn airlCallsignCol; @FXML - private TableColumn airlCountrycol; + private TableColumn airlCountryCol; @FXML - private TableColumn airlActivecol; + private TableColumn airlActiveCol; //Setting up text fields for adding data @FXML - private TextField airlNameBox; + private TextField airlNameAdd; @FXML - private TextField airlAliasBox; + private TextField airlAliasAdd; @FXML - private TextField airlIATABox; + private TextField airlIATAAdd; @FXML - private TextField airlICAOBox; + private TextField airlICAOAdd; @FXML - private TextField airlCallsignBox; + private TextField airlCallsignAdd; @FXML - private TextField airlCountryBox; + private TextField airlCountryAdd; @FXML - private ComboBox airlActiveCBox; + private TextField airlActiveAdd; //Setting up text fields for filtering data @FXML @@ -77,22 +88,37 @@ public class AirlineRDController extends Controller { */ public void load() { //Sets up the table columns to be ready for use for Airline data - airlIDcol.setCellValueFactory(new PropertyValueFactory("ID")); - airlNamecol.setCellValueFactory(new PropertyValueFactory("Name")); - airlAliascol.setCellValueFactory(new PropertyValueFactory("Alias")); - airlIATAcol.setCellValueFactory(new PropertyValueFactory("IATA")); - airlICAOcol.setCellValueFactory(new PropertyValueFactory("ICAO")); - airlCallsigncol.setCellValueFactory(new PropertyValueFactory("CallSign")); - airlCountrycol.setCellValueFactory(new PropertyValueFactory("CountryName")); - airlActivecol.setCellValueFactory(new PropertyValueFactory("Active")); + airlIDCol.setCellValueFactory(new PropertyValueFactory("ID")); + airlNameCol.setCellValueFactory(new PropertyValueFactory("Name")); + airlAliasCol.setCellValueFactory(new PropertyValueFactory("Alias")); + airlIATACol.setCellValueFactory(new PropertyValueFactory("IATA")); + airlICAOCol.setCellValueFactory(new PropertyValueFactory("ICAO")); + airlCallsignCol.setCellValueFactory(new PropertyValueFactory("CallSign")); + airlCountryCol.setCellValueFactory(new PropertyValueFactory("CountryName")); + airlActiveCol.setCellValueFactory(new PropertyValueFactory("Active")); //Assigning the Dataset to the current Dataset's airlines and displaying it in a table theDataSet = getParent().getCurrentDataset(); tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines())); + } + + /** + * Opens the Airline add form. + */ + public void openAdd() { + try { + FXMLLoader loader = new FXMLLoader(); + Parent root = loader.load(getClass().getClassLoader().getResource("airline_add_form.fxml")); + Stage filter = new Stage(); + filter.initModality(Modality.APPLICATION_MODAL); + filter.setResizable(false); + filter.setTitle("Add New Airline"); + filter.setScene(new Scene(root, 600, 370)); + filter.show(); + } catch (IOException e) { + e.printStackTrace(); + } - //Initializes the value for the drop-down menu for Active for adding a new Airline - airlActiveCBox.setValue("Y"); - airlActiveCBox.getItems().addAll("Y", "N"); } /** @@ -103,45 +129,35 @@ public class AirlineRDController extends Controller { 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( - airlNameBox.getText(), - airlAliasBox.getText(), - airlIATABox.getText(), - airlICAOBox.getText(), - airlCallsignBox.getText(), - airlCountryBox.getText(), - airlActiveCBox.getSelectionModel().getSelectedItem().toString()); - airlNameBox.clear(); - airlAliasBox.clear(); - airlIATABox.clear(); - airlICAOBox.clear(); - airlCallsignBox.clear(); - airlCountryBox.clear(); - airlActiveCBox.getSelectionModel().clearSelection(); - airlActiveCBox.setValue("Y"); + 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 ) { + } 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(); } } - /** - * 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())); - } - /** * Filters airlines by any field. * These are specified by what the user has typed in the filter boxes. @@ -150,6 +166,7 @@ public class AirlineRDController extends Controller { */ 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()); @@ -176,6 +193,36 @@ public class AirlineRDController extends Controller { tableViewAirlineRD.setItems(FXCollections.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. + */ + public void openFilter() { + try { + Parent root = FXMLLoader.load(getClass().getResource("/airline_filter_form.fxml")); + final Stage filter = new Stage(); + filter.initModality(Modality.APPLICATION_MODAL); + filter.setResizable(false); + filter.setTitle("Airline Filter"); + filter.setScene(new Scene(root, 600, 370)); + filter.show(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** * Analyses the current data and creates a graph based on the data. * Currently not implemented yet. @@ -183,4 +230,8 @@ public class AirlineRDController extends Controller { public void analyse_Button() { JOptionPane.showMessageDialog(null, "This is not Implemented yet"); } + + public void airlineSummaryButton() { + replaceSceneContent(SceneCode.AIRLINE_SUMMARY); + } } diff --git a/src/main/resources/airline_add_form.fxml b/src/main/resources/airline_add_form.fxml new file mode 100644 index 0000000..1a31a01 --- /dev/null +++ b/src/main/resources/airline_add_form.fxml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + +