Updated add and filter for airlines. Working on serialisable file
This commit is contained in:
Binary file not shown.
@@ -132,7 +132,15 @@ public class App extends Application
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Menu COntroller of the App.
|
||||
* Gets the current session.
|
||||
* @return
|
||||
*/
|
||||
public Session getSession() {
|
||||
return this.session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Menu Controller of the App.
|
||||
* @return
|
||||
*/
|
||||
public MenuController getMenuController() {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package seng202.group9.Controller;
|
||||
|
||||
import javafx.collections.ObservableList;
|
||||
import seng202.group9.Core.Airline;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Created by fwy13 on 16/09/16.
|
||||
@@ -10,7 +12,7 @@ import java.io.Serializable;
|
||||
*/
|
||||
public class Session implements Serializable {
|
||||
private SceneCode sceneDisplayed;
|
||||
private ObservableList filteredAirlines;
|
||||
private HashMap<String, Airline> filteredAirlines;
|
||||
|
||||
/**
|
||||
* Constructor for a new session
|
||||
@@ -44,7 +46,11 @@ public class Session implements Serializable {
|
||||
return sceneDisplayed;
|
||||
}
|
||||
|
||||
// public void setFilteredAirlines(ObservableList airlines) {
|
||||
// this.filteredAirlines = airlines;
|
||||
// }
|
||||
public void setFilteredAirlines(HashMap airlines) {
|
||||
this.filteredAirlines = airlines;
|
||||
}
|
||||
|
||||
public HashMap<String, Airline> getFilteredAirlines() {
|
||||
return filteredAirlines;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ package seng202.group9.GUI;
|
||||
import javafx.collections.FXCollections;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -25,6 +27,8 @@ public class AirlineAddController extends Controller {
|
||||
private TextField airlCountryAdd;
|
||||
@FXML
|
||||
private TextField airlActiveAdd;
|
||||
@FXML
|
||||
private Button addButton;
|
||||
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
@@ -53,6 +57,16 @@ public class AirlineAddController extends Controller {
|
||||
airlCallsignAdd.clear();
|
||||
airlCountryAdd.clear();
|
||||
airlActiveAdd.clear();
|
||||
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Airline Add Successful");
|
||||
alert.setHeaderText("New Airline added!");
|
||||
alert.setContentText("Your new airline has been successfully added into the database.");
|
||||
alert.showAndWait();
|
||||
|
||||
Stage stage = (Stage) addButton.getScene().getWindow();
|
||||
stage.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Airline Data Error");
|
||||
@@ -60,6 +74,7 @@ public class AirlineAddController extends Controller {
|
||||
alert.setContentText(e.getMessage());
|
||||
alert.showAndWait();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
||||
@@ -3,11 +3,19 @@ package seng202.group9.GUI;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
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.AirlineFilter;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Controller.Session;
|
||||
import seng202.group9.Core.Airline;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Created by Sunguin on 2016/09/22.
|
||||
*/
|
||||
@@ -28,8 +36,11 @@ public class AirlineFilterController extends Controller {
|
||||
private TextField airlCountryFilter;
|
||||
@FXML
|
||||
private TextField airlActiveFilter;
|
||||
@FXML
|
||||
private Button applyButton;
|
||||
|
||||
private Dataset theDataSet = null;
|
||||
private Session currentSession = null;
|
||||
|
||||
/**
|
||||
* Filters airlines by any field.
|
||||
@@ -61,10 +72,29 @@ public class AirlineFilterController extends Controller {
|
||||
if (airlActiveFilter.getText() != null) {
|
||||
filter.filterActive(airlActiveFilter.getText());
|
||||
}
|
||||
//session.setFilteredAirlines(FXCollections.observableArrayList(filter.getFilteredData()));
|
||||
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Airline Filter Successful");
|
||||
alert.setHeaderText("Airline data filtered!");
|
||||
alert.setContentText("Your airline data has been successfully filtered.");
|
||||
alert.showAndWait();
|
||||
|
||||
//currentSession.setFilteredAirlines(FXCollections.observableArrayList(filter.getFilteredData()));
|
||||
|
||||
HashMap<String, Airline> airlinesHM = new HashMap<String, Airline>();
|
||||
ArrayList<Airline> airlines = filter.getFilteredData();
|
||||
for (Airline airline: airlines) {
|
||||
airlinesHM.put(airline.getName(), airline);
|
||||
}
|
||||
currentSession.setFilteredAirlines(airlinesHM);
|
||||
|
||||
Stage stage = (Stage) applyButton.getScene().getWindow();
|
||||
stage.close();
|
||||
|
||||
}
|
||||
|
||||
public void load() {
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
currentSession = getParent().getSession();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,7 @@ 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.Controller.*;
|
||||
import seng202.group9.Core.Airline;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -47,11 +44,9 @@ public class AirlineRDController extends Controller {
|
||||
@FXML
|
||||
private TableColumn<Airline, String> airlActiveCol;
|
||||
|
||||
|
||||
//Set an empty Dataset to be assigned later.
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
private ObservableList dataL = null;
|
||||
private Session currentSession = null;
|
||||
|
||||
/**
|
||||
* Loads the initial airline data to the GUI table.
|
||||
@@ -71,6 +66,8 @@ public class AirlineRDController extends Controller {
|
||||
//Assigning the Dataset to the current Dataset's airlines and displaying it in a table
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
|
||||
|
||||
currentSession = getParent().getSession();
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +84,7 @@ public class AirlineRDController extends Controller {
|
||||
*/
|
||||
public void openFilter() {
|
||||
createPopUpStage(SceneCode.AIRLINE_FILTER, 600, 370);
|
||||
//tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
|
||||
tableViewAirlineRD.setItems(FXCollections.observableArrayList(currentSession.getFilteredAirlines().values()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Button mnemonicParsing="false" onAction="#addAirlineSingle" text="Add Airline" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="8" />
|
||||
<Button fx:id="addButton" mnemonicParsing="false" onAction="#addAirlineSingle" text="Add Airline" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="8" />
|
||||
<TextField fx:id="airlNameAdd" prefHeight="31.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="airlAliasAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
|
||||
<TextField fx:id="airlIATAAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="3" />
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<Button mnemonicParsing="false" onAction="#filterAirlines" text="Apply Conditions" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="8" />
|
||||
<Button fx:id="applyButton" mnemonicParsing="false" onAction="#filterAirlines" text="Apply Conditions" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="8" />
|
||||
<TextField fx:id="airlNameFilter" prefHeight="31.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="airlAliasFilter" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
|
||||
<TextField fx:id="airlIATAFilter" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="3" />
|
||||
|
||||
Reference in New Issue
Block a user