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