Merge remote-tracking branch 'origin/master'
Conflicts: src/main/java/seng202/group9/Controller/SceneCode.java
This commit is contained in:
@@ -1,25 +1,22 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import seng202.group9.Controller.App;
|
||||
import seng202.group9.Controller.AirlineFilter;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Core.Airline;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* The GUI controller class for airline_raw_data.fxml.
|
||||
* Extends from the abstract class {@link Controller}.
|
||||
* Created by Sunguin on 2016/09/13.
|
||||
*/
|
||||
public class AirlineRDController extends Controller {
|
||||
|
||||
@FXML
|
||||
private TableView<Airline> tableView;
|
||||
private TableView<Airline> tableViewAirlineRD;
|
||||
@FXML
|
||||
private TableColumn<Airline, String> airlIDcol;
|
||||
@FXML
|
||||
@@ -36,6 +33,7 @@ public class AirlineRDController extends Controller {
|
||||
private TableColumn<Airline, String> airlCountrycol;
|
||||
@FXML
|
||||
private TableColumn<Airline, String> airlActivecol;
|
||||
|
||||
@FXML
|
||||
private TextField airlNameBox;
|
||||
@FXML
|
||||
@@ -49,13 +47,51 @@ public class AirlineRDController extends Controller {
|
||||
@FXML
|
||||
private TextField airlCountryBox;
|
||||
@FXML
|
||||
//private TextField airlActiveBox;
|
||||
private ComboBox<String> airlActiveCBox;
|
||||
|
||||
@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;
|
||||
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
//Dummy function to test the add button.
|
||||
//Will edit when ID is added automatically.
|
||||
/**
|
||||
* Loads the initial airline data to the GUI table.
|
||||
* Also sets up the dropdown menu options.
|
||||
*/
|
||||
public void load() {
|
||||
airlIDcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ID"));
|
||||
airlNamecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Name"));
|
||||
airlAliascol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Alias"));
|
||||
airlIATAcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("IATA"));
|
||||
airlICAOcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ICAO"));
|
||||
airlCallsigncol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CallSign"));
|
||||
airlCountrycol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CountryName"));
|
||||
airlActivecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Active"));
|
||||
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
|
||||
|
||||
airlActiveCBox.setValue("Y");
|
||||
airlActiveCBox.getItems().addAll("Y", "N");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a single airline entry to the database.
|
||||
* Takes in values from the GUI the user has typed in.
|
||||
* @see Dataset
|
||||
*/
|
||||
public void addAirlineSingle() {
|
||||
try {
|
||||
theDataSet.addAirline(
|
||||
@@ -73,7 +109,8 @@ public class AirlineRDController extends Controller {
|
||||
airlCallsignBox.clear();
|
||||
airlCountryBox.clear();
|
||||
airlActiveCBox.getSelectionModel().clearSelection();
|
||||
tableView.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
|
||||
airlActiveCBox.setValue("Y");
|
||||
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
|
||||
} catch ( Exception e ) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Airline Data Error");
|
||||
@@ -83,21 +120,46 @@ public class AirlineRDController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public void load() {
|
||||
airlIDcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ID"));
|
||||
airlNamecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Name"));
|
||||
airlAliascol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Alias"));
|
||||
//Need to check IATA and ICAO
|
||||
airlIATAcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("IATA"));
|
||||
airlICAOcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ICAO"));
|
||||
airlCallsigncol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CallSign"));
|
||||
airlCountrycol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CountryName"));
|
||||
airlActivecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Active"));
|
||||
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
tableView.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
|
||||
//ObservableList<String> activeOptions= FXCollections.observableArrayList("Y", "N");
|
||||
airlActiveCBox.getItems().addAll("Y", "N");
|
||||
/**
|
||||
* Deletes a single selected airline entry from the database.
|
||||
* Updates the GUI accordingly.
|
||||
* @see Dataset
|
||||
*/
|
||||
public void deleteAirline() {
|
||||
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.
|
||||
* Updates the GUI accordingly.
|
||||
* @see AirlineFilter
|
||||
*/
|
||||
public void filterAirlines() {
|
||||
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());
|
||||
}
|
||||
tableViewAirlineRD.setItems(FXCollections.<Airline>observableArrayList(filter.getFilteredData()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.web.WebView;
|
||||
import seng202.group9.Controller.App;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Controller.SceneCode;
|
||||
import seng202.group9.Core.Airline;
|
||||
import seng202.group9.Core.Airport;
|
||||
import seng202.group9.Core.Position;
|
||||
import seng202.group9.Core.RoutePath;
|
||||
import seng202.group9.Map.Map;
|
||||
|
||||
/**
|
||||
* Created by michael on 14/09/2016.
|
||||
@@ -18,6 +25,8 @@ public class AirlineSummaryController extends Controller{
|
||||
@FXML
|
||||
private TableView<Airline> tableView;
|
||||
@FXML
|
||||
private WebView mapView;
|
||||
@FXML
|
||||
private TableColumn<Airline, String> columnName;
|
||||
@FXML
|
||||
private TableColumn<Airline, String> columnAlias;
|
||||
@@ -30,14 +39,28 @@ public class AirlineSummaryController extends Controller{
|
||||
|
||||
private Dataset currentData = null;
|
||||
|
||||
private Map map;
|
||||
|
||||
public void load() {
|
||||
columnName.setCellValueFactory(new PropertyValueFactory<Airline, String>("Name"));
|
||||
columnAlias.setCellValueFactory(new PropertyValueFactory<Airline, String>("Alias"));
|
||||
columnCountry.setCellValueFactory(new PropertyValueFactory<Airline, String>("Country"));
|
||||
columnCountry.setCellValueFactory(new PropertyValueFactory<Airline, String>("CountryName"));
|
||||
columnIATA.setCellValueFactory(new PropertyValueFactory<Airline, String>("IATA"));
|
||||
columnActive.setCellValueFactory(new PropertyValueFactory<Airline, String>("Active"));
|
||||
currentData = getParent().getCurrentDataset();
|
||||
tableView.setItems(FXCollections.observableArrayList(currentData.getAirlines()));
|
||||
map = new Map(mapView, new RoutePath());
|
||||
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Airline>() {
|
||||
public void changed(ObservableValue<? extends Airline> observable, Airline oldValue, Airline newValue) {
|
||||
Airline selectedAirline= currentData.getAirlines().get(tableView.getSelectionModel().getSelectedIndices().get(0));
|
||||
for (int i = 0 ; i < currentData.getAirports().size(); i ++){
|
||||
if (currentData.getAirports().get(i).getCountryName().equals(selectedAirline.getCountryName())){
|
||||
map.displayAirport(new RoutePath(new Position(currentData.getAirports().get(i).getLatitude(), currentData.getAirports().get(i).getLongitude())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void airlineRawDataButton() {
|
||||
|
||||
@@ -1,26 +1,19 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import com.sun.javafx.collections.ObservableListWrapper;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.value.ObservableStringValue;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.util.Callback;
|
||||
import seng202.group9.Controller.App;
|
||||
import seng202.group9.Controller.AirportFilter;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Controller.SceneCode;
|
||||
import seng202.group9.Core.Airport;
|
||||
import seng202.group9.Core.City;
|
||||
import seng202.group9.Core.Country;
|
||||
|
||||
import static javafx.collections.FXCollections.observableArrayList;
|
||||
|
||||
/**
|
||||
* The GUI controller class for airport_raw_data.fxml.
|
||||
* Extends from the abstract class {@link Controller}.
|
||||
* Created by Sunguin on 2016/09/13.
|
||||
*/
|
||||
public class AirportRDController extends Controller{
|
||||
@@ -75,8 +68,35 @@ public class AirportRDController extends Controller{
|
||||
@FXML
|
||||
private TextField airpTzBox;
|
||||
|
||||
@FXML
|
||||
private TextField airpNameFilter;
|
||||
@FXML
|
||||
private TextField airpCityFilter;
|
||||
@FXML
|
||||
private TextField airpCountryFilter;
|
||||
@FXML
|
||||
private TextField airpIATAFFAFilter;
|
||||
@FXML
|
||||
private TextField airpICAOFilter;
|
||||
@FXML
|
||||
private TextField airpLatitudeFilter;
|
||||
@FXML
|
||||
private TextField airpLongitudeFilter;
|
||||
@FXML
|
||||
private TextField airpAltitudeFilter;
|
||||
@FXML
|
||||
private TextField airpTimezoneFilter;
|
||||
@FXML
|
||||
private TextField airpDSTFilter;
|
||||
@FXML
|
||||
private TextField airpTzFilter;
|
||||
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
/**
|
||||
* Loads the initial airport data to the GUI table.
|
||||
* Also sets up the dropdown menu options.
|
||||
*/
|
||||
public void load() {
|
||||
airpIDcol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ID"));
|
||||
airpNamecol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
|
||||
@@ -91,29 +111,18 @@ public class AirportRDController extends Controller{
|
||||
airpDSTcol.setCellValueFactory(new PropertyValueFactory<Airport, String>("DST"));
|
||||
airpTzcol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Tz"));
|
||||
|
||||
// airpTimezonecol.setCellFactory(new Callback<TableColumn<Airport, String>, TableCell<Airport, String>>() {
|
||||
//
|
||||
// @Override
|
||||
// public TableCell<Airport, City> call(TableColumn<Airport, City> param) {
|
||||
// TableCell<Airport, City> timeZoneCell = new TableCell<Airport, City>() {
|
||||
// @Override
|
||||
// protected void updateItem(City timezone, boolean empty) {
|
||||
// if (timezone != null) {
|
||||
// Label timeZoneLabel = new Label(timezone.getTimeOlson());
|
||||
// setGraphic(timeZoneLabel);
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// return timeZoneCell;
|
||||
// }
|
||||
// });
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
tableViewAirportRD.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
|
||||
tableViewAirportRD.setItems(observableArrayList(theDataSet.getAirports()));
|
||||
|
||||
airpDSTCBox.setValue("E");
|
||||
airpDSTCBox.getItems().addAll("E", "A", "S", "O", "Z", "N", "U");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a single airport entry in the database.
|
||||
* Takes in values from the GUI the user has typed in.
|
||||
* @see Dataset
|
||||
*/
|
||||
public void addAirportSingle() {
|
||||
try {
|
||||
theDataSet.addAirport(
|
||||
@@ -137,6 +146,7 @@ public class AirportRDController extends Controller{
|
||||
airpAltitudeBox.clear();
|
||||
airpTimezoneBox.clear();
|
||||
airpDSTCBox.getSelectionModel().clearSelection();
|
||||
airpDSTCBox.setValue("E");
|
||||
airpTzBox.clear();
|
||||
tableViewAirportRD.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
|
||||
} catch ( Exception e ) {
|
||||
@@ -147,7 +157,63 @@ public class AirportRDController extends Controller{
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
||||
public void airportAnalyserButton(){
|
||||
|
||||
public void airportAnalyserButton() {
|
||||
replaceSceneContent(SceneCode.AIRPORT_ANALYSER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a single selected airport entry from the database.
|
||||
* Updates the GUI accordingly.
|
||||
* @see Dataset
|
||||
*/
|
||||
public void deleteAirport(){
|
||||
Airport toDelete = tableViewAirportRD.getSelectionModel().getSelectedItem();
|
||||
theDataSet.deleteAirport(toDelete);
|
||||
tableViewAirportRD.setItems(observableArrayList(theDataSet.getAirports()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the airports table by any field.
|
||||
* These are specified by what the user has typed in the filter boxes.
|
||||
* Updates the GUI accordingly.
|
||||
* @see AirportFilter
|
||||
*/
|
||||
public void filterAirports() {
|
||||
AirportFilter filter = new AirportFilter(theDataSet.getAirports());
|
||||
if (airpNameFilter.getText() != null) {
|
||||
filter.filterName(airpNameFilter.getText());
|
||||
}
|
||||
if (airpCityFilter.getText() != null) {
|
||||
filter.filterCity(airpCityFilter.getText());
|
||||
}
|
||||
if (airpCountryFilter.getText() != null) {
|
||||
filter.filterCountry(airpCountryFilter.getText());
|
||||
}
|
||||
if (airpIATAFFAFilter.getText() != null) {
|
||||
filter.filterIATA_FFA(airpIATAFFAFilter.getText());
|
||||
}
|
||||
if (airpICAOFilter.getText() != null) {
|
||||
filter.filterICAO(airpICAOFilter.getText());
|
||||
}
|
||||
if (airpLatitudeFilter.getText() != null) {
|
||||
filter.filterLatitude(airpLatitudeFilter.getText());
|
||||
}
|
||||
if (airpLongitudeFilter.getText() != null) {
|
||||
filter.filterLongitude(airpLongitudeFilter.getText());
|
||||
}
|
||||
if (airpAltitudeFilter.getText() != null) {
|
||||
filter.filterAltitude(airpAltitudeFilter.getText());
|
||||
}
|
||||
if (airpTimezoneFilter.getText() != null) {
|
||||
filter.filterTimezone(airpTimezoneFilter.getText());
|
||||
}
|
||||
if (airpDSTFilter.getText() != null) {
|
||||
filter.filterDST(airpDSTFilter.getText());
|
||||
}
|
||||
if (airpTzFilter.getText() != null) {
|
||||
filter.filterOlson(airpTzFilter.getText());
|
||||
}
|
||||
tableViewAirportRD.setItems(FXCollections.<Airport>observableArrayList(filter.getFilteredData()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.web.WebView;
|
||||
import seng202.group9.Controller.App;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Controller.SceneCode;
|
||||
import seng202.group9.Core.Airport;
|
||||
import seng202.group9.Core.Position;
|
||||
import seng202.group9.Core.RoutePath;
|
||||
import seng202.group9.Map.Map;
|
||||
|
||||
/**
|
||||
* Created by michael on 14/09/2016.
|
||||
@@ -17,6 +23,8 @@ public class AirportSummaryController extends Controller{
|
||||
@FXML
|
||||
private TableView<Airport> tableView;
|
||||
@FXML
|
||||
private WebView mapView;
|
||||
@FXML
|
||||
private TableColumn<Airport, String> columnName;
|
||||
@FXML
|
||||
private TableColumn<Airport, String> columnCity;
|
||||
@@ -29,6 +37,8 @@ public class AirportSummaryController extends Controller{
|
||||
|
||||
private Dataset currentData = null;
|
||||
|
||||
private Map map;
|
||||
|
||||
public void airportRawDataButton() {
|
||||
replaceSceneContent(SceneCode.AIRLINE_RAW_DATA);
|
||||
}
|
||||
@@ -51,5 +61,13 @@ public class AirportSummaryController extends Controller{
|
||||
columnAltitude.setCellValueFactory(new PropertyValueFactory<Airport, String>("Altitude"));
|
||||
currentData = getParent().getCurrentDataset();
|
||||
tableView.setItems(FXCollections.observableArrayList(currentData.getAirports()));
|
||||
map = new Map(mapView, new RoutePath());
|
||||
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Airport>() {
|
||||
public void changed(ObservableValue<? extends Airport> observable, Airport oldValue, Airport newValue) {
|
||||
System.out.println("loading");
|
||||
Airport selectedAirport= currentData.getAirports().get(tableView.getSelectionModel().getSelectedIndices().get(0));
|
||||
map.displayAirport(new RoutePath( new Position(selectedAirport.getLatitude(), selectedAirport.getLongitude())));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import javax.swing.*;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
@@ -179,7 +180,7 @@ public class FlightRDController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a pop up dialog which prompts the user for two ICAO airport codes which will use when creating a new path
|
||||
* Creates a pop up dialog which prompts the user for two ICAO airport codes which will use when creating a new path.
|
||||
*/
|
||||
public void newPath() {
|
||||
NewPathPopUp dialogBox = new NewPathPopUp();
|
||||
@@ -193,7 +194,43 @@ public class FlightRDController extends Controller {
|
||||
flightPathListView();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Removes the selected point from the table and database.
|
||||
*/
|
||||
public void deletePoint() {
|
||||
FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem();
|
||||
int pathID = toDelete.getIndex();
|
||||
LinkedHashMap<Integer, FlightPath> flightPathDict = theDataSet.getFlightPathDictionary();
|
||||
FlightPath toDeletesPath = flightPathDict.get(pathID);
|
||||
theDataSet.deleteFlightPoint(toDelete, toDeletesPath);
|
||||
|
||||
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary().get(pathID));
|
||||
|
||||
ArrayList<FlightPath> flightPaths;
|
||||
flightPaths = theDataSet.getFlightPaths();
|
||||
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
|
||||
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the selected path from the list view of paths and from the database.
|
||||
*/
|
||||
public void deletePath() {
|
||||
String toDeleteStr = flightPathListView.getSelectionModel().getSelectedItem();
|
||||
String[] segments = toDeleteStr.split("_");
|
||||
String pathIdClicked = segments[0];
|
||||
|
||||
int toDeleteIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
|
||||
.get(Integer.parseInt(pathIdClicked)));
|
||||
|
||||
theDataSet.deleteFlightPath(toDeleteIndex);
|
||||
flightPathListView.getItems().clear();
|
||||
flightPathListView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Will link to the flight analyser when implemented.
|
||||
*/
|
||||
public void flightAnalyser(){
|
||||
JOptionPane.showMessageDialog(null, "This is not Implemented yet");
|
||||
}
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.web.WebView;
|
||||
import seng202.group9.Controller.App;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Controller.SceneCode;
|
||||
import seng202.group9.Core.FlightPath;
|
||||
import seng202.group9.Core.RoutePath;
|
||||
import seng202.group9.Map.Map;
|
||||
import seng202.group9.Core.FlightPoint;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -23,30 +31,67 @@ public class FlightSummaryController extends Controller {
|
||||
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
private int currentPathId = 0;
|
||||
private int currentPathIndex = 0;
|
||||
|
||||
@FXML
|
||||
private Button flightRawData;
|
||||
|
||||
private Map map;
|
||||
@FXML
|
||||
private WebView mapView;
|
||||
@FXML
|
||||
ListView<String> flightPathListView;
|
||||
final ObservableList<String> flightList = FXCollections.observableArrayList();
|
||||
|
||||
/**
|
||||
* Changes to the Flight Raw Data Scene when the Raw Data Button is clicked
|
||||
* Changes to the Flight Raw Data Scene when the Raw Data Button is clicked.
|
||||
*/
|
||||
public void handleRawDataButton() {
|
||||
replaceSceneContent(SceneCode.FLIGHT_RAW_DATA);
|
||||
}
|
||||
|
||||
public void airportSummaryButton() {
|
||||
replaceSceneContent(SceneCode.AIRPORT_SUMMARY);
|
||||
}
|
||||
/**
|
||||
* Changes to the Airport Summary Scene when the Airport is clicked.
|
||||
*/
|
||||
public void airportSummaryButton() { replaceSceneContent(SceneCode.AIRPORT_SUMMARY); }
|
||||
|
||||
/**
|
||||
* Changes to the Route Summary Scene when the Route Button is clicked.
|
||||
*/
|
||||
public void routeSummaryButton() {
|
||||
replaceSceneContent(SceneCode.ROUTE_SUMMARY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes to the Airline Summary Scene when the Airline Button is clicked.
|
||||
*/
|
||||
public void airlineSummaryButton() {
|
||||
replaceSceneContent(SceneCode.AIRLINE_SUMMARY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the Flight paths into the List View and waits for a mouse clicked event for which it will update the table
|
||||
* to display the selected Flight paths points. Called from the MenuController.
|
||||
*/
|
||||
public void flightPathListView() {
|
||||
try {
|
||||
ArrayList<FlightPath> flightPaths;
|
||||
flightPaths = theDataSet.getFlightPaths();
|
||||
for(int i = 0; i<flightPaths.size(); i++ ) {
|
||||
int pathID = flightPaths.get(i).getID();
|
||||
String pathSource = flightPaths.get(i).departsFrom();
|
||||
String pathDestin = flightPaths.get(i).arrivesAt();
|
||||
String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin;
|
||||
flightList.add(flightPathDisplayName);
|
||||
}
|
||||
flightPathListView.setItems(flightList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Used to load the page from the MenuController.
|
||||
*/
|
||||
public void load() {
|
||||
try {
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
@@ -64,6 +109,32 @@ public class FlightSummaryController extends Controller {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (theDataSet.getFlightPaths().size() > 0){
|
||||
map = new Map(mapView, theDataSet.getFlightPaths().get(0).getRoutePath());
|
||||
}else{
|
||||
map = new Map(mapView, new RoutePath());
|
||||
}
|
||||
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
|
||||
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
||||
//map.displayRoute(theDataSet.getFlightPaths().get(flightPathListView.getSelectionModel().getSelectedIndices().get(0)).getRoutePath());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the selected path from the list view of paths and from the database.
|
||||
*/
|
||||
public void deletePath() {
|
||||
String toDeleteStr = flightPathListView.getSelectionModel().getSelectedItem();
|
||||
String[] segments = toDeleteStr.split("_");
|
||||
String pathIdClicked = segments[0];
|
||||
|
||||
int toDeleteIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
|
||||
.get(Integer.parseInt(pathIdClicked)));
|
||||
|
||||
theDataSet.deleteFlightPath(toDeleteIndex);
|
||||
flightPathListView.getItems().clear();
|
||||
flightPathListView();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,14 @@ import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import seng202.group9.Controller.App;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Controller.SceneCode;
|
||||
import seng202.group9.Controller.RouteFilter;
|
||||
import seng202.group9.Core.Route;
|
||||
|
||||
/**
|
||||
* The GUI controller class for route_raw_data.fxml.
|
||||
* Extends from the abstract class {@link Controller}.
|
||||
* Created by Sunguin on 2016/09/14.
|
||||
*/
|
||||
public class RouteRDController extends Controller {
|
||||
@@ -48,34 +50,25 @@ public class RouteRDController extends Controller {
|
||||
@FXML
|
||||
private TextField rEquipmentBox;
|
||||
|
||||
@FXML
|
||||
private TextField rAirlineFilter;
|
||||
@FXML
|
||||
private TextField rSourceFilter;
|
||||
@FXML
|
||||
private TextField rDestFilter;
|
||||
@FXML
|
||||
private TextField rCodeshareFilter;
|
||||
@FXML
|
||||
private TextField rStopsFilter;
|
||||
@FXML
|
||||
private TextField rEquipmentFilter;
|
||||
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
public void addRouteSingle() {
|
||||
try {
|
||||
theDataSet.addRoute(
|
||||
rAirlineBox.getText(),
|
||||
rSourceBox.getText(),
|
||||
rDestBox.getText(),
|
||||
rCodeshareCBox.getSelectionModel().getSelectedItem().toString(),
|
||||
rStopsBox.getText(),
|
||||
rEquipmentBox.getText()
|
||||
);
|
||||
rAirlineBox.clear();
|
||||
rSourceBox.clear();
|
||||
rDestBox.clear();
|
||||
rCodeshareCBox.getSelectionModel().clearSelection();
|
||||
rStopsBox.clear();
|
||||
rEquipmentBox.clear();
|
||||
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
|
||||
} catch ( Exception e ) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Route Data Error");
|
||||
alert.setHeaderText("Error adding a custom route entry.");
|
||||
alert.setContentText(e.getMessage());
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the initial route data to the GUI table.
|
||||
* Also sets up the dropdown menu options.
|
||||
*/
|
||||
public void load() {
|
||||
rAirlineCol.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineName"));
|
||||
rAirlineIDCol.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineID"));
|
||||
@@ -90,9 +83,82 @@ public class RouteRDController extends Controller {
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
|
||||
|
||||
rCodeshareCBox.setValue("");
|
||||
rCodeshareCBox.getItems().addAll("Y", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a single route entry in the database.
|
||||
* Takes in values from the GUI the user has typed in.
|
||||
* @see Dataset
|
||||
*/
|
||||
public void addRouteSingle() {
|
||||
try {
|
||||
theDataSet.addRoute(
|
||||
rAirlineBox.getText(),
|
||||
rSourceBox.getText(),
|
||||
rDestBox.getText(),
|
||||
rCodeshareCBox.getSelectionModel().getSelectedItem().toString(),
|
||||
rStopsBox.getText(),
|
||||
rEquipmentBox.getText()
|
||||
);
|
||||
rAirlineBox.clear();
|
||||
rSourceBox.clear();
|
||||
rDestBox.clear();
|
||||
rCodeshareCBox.getSelectionModel().clearSelection();
|
||||
rCodeshareCBox.setValue("");
|
||||
rStopsBox.clear();
|
||||
rEquipmentBox.clear();
|
||||
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
|
||||
} catch ( Exception e ) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Route Data Error");
|
||||
alert.setHeaderText("Error adding a custom route entry.");
|
||||
alert.setContentText(e.getMessage());
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a single selected route entry from the database.
|
||||
* Updates the GUI accordingly.
|
||||
* @see Dataset
|
||||
*/
|
||||
public void deleteRoute(){
|
||||
Route toDelete = tableViewRouteRD.getSelectionModel().getSelectedItem();
|
||||
theDataSet.deleteRoute(toDelete);
|
||||
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the routes table by any field.
|
||||
* These are specified by what the user has typed in the filter boxes.
|
||||
* Updates the GUI accordingly.
|
||||
* @see RouteFilter
|
||||
*/
|
||||
public void filterRoutes(){
|
||||
RouteFilter filter = new RouteFilter(theDataSet.getRoutes());
|
||||
if (rAirlineFilter.getText() != null) {
|
||||
filter.filterAirline(rAirlineFilter.getText());
|
||||
}
|
||||
if (rSourceFilter.getText() != null) {
|
||||
filter.filterSourceAirport(rSourceFilter.getText());
|
||||
}
|
||||
if (rDestFilter.getText() != null) {
|
||||
filter.filterDestinationAirport(rDestFilter.getText());
|
||||
}
|
||||
if (rCodeshareFilter.getText() != null) {
|
||||
filter.filterCodeshare(rCodeshareFilter.getText());
|
||||
}
|
||||
if (rStopsFilter.getText() != null) {
|
||||
filter.filterDestinationStops(rStopsFilter.getText());
|
||||
}
|
||||
if (rEquipmentFilter.getText() != null) {
|
||||
filter.filterEquipment(rEquipmentFilter.getText());
|
||||
}
|
||||
tableViewRouteRD.setItems(FXCollections.<Route>observableArrayList(filter.getFilteredData()));
|
||||
}
|
||||
|
||||
public void analyse_Button() {
|
||||
replaceSceneContent(SceneCode.ROUTE_ANALYSER);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.web.WebView;
|
||||
import seng202.group9.Controller.App;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Controller.SceneCode;
|
||||
import seng202.group9.Core.Position;
|
||||
import seng202.group9.Core.Route;
|
||||
import seng202.group9.Core.RoutePath;
|
||||
import seng202.group9.Map.Map;
|
||||
|
||||
/**
|
||||
* Created by michael on 14/09/2016.
|
||||
@@ -17,6 +23,8 @@ public class RouteSummaryController extends Controller{
|
||||
@FXML
|
||||
private TableView<Route> tableView;
|
||||
@FXML
|
||||
private WebView mapView;
|
||||
@FXML
|
||||
private TableColumn<Route, String> columnAirline;
|
||||
@FXML
|
||||
private TableColumn<Route, String> columnDepart;
|
||||
@@ -27,16 +35,39 @@ public class RouteSummaryController extends Controller{
|
||||
@FXML
|
||||
private TableColumn<Route, String> columnEquipment;
|
||||
|
||||
private Map map;
|
||||
|
||||
private Dataset currentData = null;
|
||||
|
||||
public void load() {
|
||||
columnAirline.setCellValueFactory(new PropertyValueFactory<Route, String>("Airline"));
|
||||
columnAirline.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineName"));
|
||||
columnDepart.setCellValueFactory(new PropertyValueFactory<Route, String>("DepartureAirport"));
|
||||
columnArrive.setCellValueFactory(new PropertyValueFactory<Route, String>("ArrivalAirport"));
|
||||
columnStops.setCellValueFactory(new PropertyValueFactory<Route, String>("Stops"));
|
||||
columnEquipment.setCellValueFactory(new PropertyValueFactory<Route, String>("Equipment"));
|
||||
currentData = getParent().getCurrentDataset();
|
||||
tableView.setItems(FXCollections.observableArrayList(currentData.getRoutes()));
|
||||
map = new Map(mapView, new RoutePath());
|
||||
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Route>() {
|
||||
public void changed(ObservableValue<? extends Route> observable, Route oldValue, Route newValue) {
|
||||
System.out.println("loading");
|
||||
Route selectedRoute= currentData.getRoutes().get(tableView.getSelectionModel().getSelectedIndices().get(0));
|
||||
if (selectedRoute.getSourceAirport() != null && selectedRoute.getDestinationAirport() != null) {
|
||||
map.displayRoute(new RoutePath(
|
||||
new Position(selectedRoute.getSourceAirport().getLatitude(), selectedRoute.getSourceAirport().getLongitude()),
|
||||
new Position(selectedRoute.getDestinationAirport().getLatitude(), selectedRoute.getDestinationAirport().getLongitude())
|
||||
));
|
||||
}else if (selectedRoute.getSourceAirport() == null && selectedRoute.getDestinationAirport() != null){
|
||||
map.displayAirport(new RoutePath(
|
||||
new Position(selectedRoute.getDestinationAirport().getLatitude(), selectedRoute.getDestinationAirport().getLongitude())
|
||||
));
|
||||
}else if (selectedRoute.getSourceAirport() != null && selectedRoute.getDestinationAirport() == null){
|
||||
map.displayAirport(new RoutePath(
|
||||
new Position(selectedRoute.getSourceAirport().getLatitude(), selectedRoute.getSourceAirport().getLongitude())
|
||||
));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
public void routeRawDataButton() {
|
||||
replaceSceneContent(SceneCode.ROUTE_RAW_DATA);
|
||||
|
||||
Reference in New Issue
Block a user