Implemented Abstract Controller class which made code a lot short and easier to read
This commit is contained in:
@@ -23,15 +23,10 @@ import java.util.ResourceBundle;
|
||||
* Controller for the Flights Summary Scene.
|
||||
* Created by Liam Beckett on 13/09/2016.
|
||||
*/
|
||||
public class FlightSummaryController implements Initializable {
|
||||
public class FlightSummaryController extends Controller {
|
||||
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
App parent;
|
||||
public void setApp(App parent){
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@FXML
|
||||
private Button flightRawData;
|
||||
|
||||
@@ -40,11 +35,25 @@ public class FlightSummaryController implements Initializable {
|
||||
final ObservableList<String> flightList = FXCollections.observableArrayList();
|
||||
|
||||
/**
|
||||
* Loads the Flight paths into the List View and is called from the MenuController.
|
||||
* Changes to the Flight Raw Data Scene when the Raw Data Button is clicked
|
||||
*/
|
||||
public void flightPathListView() {
|
||||
public void handleRawDataButton() {
|
||||
replaceSceneContent(SceneCode.FLIGHT_RAW_DATA);
|
||||
}
|
||||
|
||||
public void airportSummaryButton() {
|
||||
replaceSceneContent(SceneCode.AIRPORT_SUMMARY);
|
||||
}
|
||||
public void routeSummaryButton() {
|
||||
replaceSceneContent(SceneCode.ROUTE_SUMMARY);
|
||||
}
|
||||
public void airlineSummaryButton() {
|
||||
replaceSceneContent(SceneCode.AIRLINE_SUMMARY);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
try {
|
||||
theDataSet = this.parent.getCurrentDataset();
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
ArrayList<FlightPath> flightPaths = new ArrayList();
|
||||
flightPaths = theDataSet.getFlightPaths();
|
||||
for(int i = 0; i<flightPaths.size(); i++ ){
|
||||
@@ -60,60 +69,5 @@ public class FlightSummaryController implements Initializable {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes to the Flight Raw Data Scene when the Raw Data Button is clicked
|
||||
*/
|
||||
public void handleRawDataButton() {
|
||||
try {
|
||||
FlightRawDataController rawDataController = (FlightRawDataController)
|
||||
parent.replaceSceneContent(SceneCode.FLIGHT_RAW_DATA);
|
||||
rawDataController.setApp(parent);
|
||||
rawDataController.loadTables();
|
||||
rawDataController.flightPathListView();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void airportSummaryButton() {
|
||||
try {
|
||||
AirportSummaryController summaryController = (AirportSummaryController)
|
||||
parent.replaceSceneContent(SceneCode.AIRPORT_SUMMARY);
|
||||
summaryController.setApp(parent);
|
||||
summaryController.loadTables();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void routeSummaryButton() {
|
||||
try {
|
||||
RouteSummaryController summaryController = (RouteSummaryController)
|
||||
parent.replaceSceneContent(SceneCode.ROUTE_SUMMARY);
|
||||
summaryController.setApp(parent);
|
||||
summaryController.loadTables();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void airlineSummaryButton() {
|
||||
try {
|
||||
AirlineSummaryController summaryController = (AirlineSummaryController)
|
||||
parent.replaceSceneContent(SceneCode.AIRLINE_SUMMARY);
|
||||
summaryController.setApp(parent);
|
||||
summaryController.loadTables();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user