Fixed a bug from Route Filter and implemented Airport Filter in GUI
This commit is contained in:
@@ -83,7 +83,7 @@ public class AirportFilter extends Filter{
|
||||
}
|
||||
|
||||
public void filterLatitude(String latitude){
|
||||
String regexCode = "(?i).*"+latitude+".*";
|
||||
String regexCode = ".*"+latitude+".*";
|
||||
int index = 0;
|
||||
while(index < filteredList.size()){
|
||||
if (!String.valueOf(filteredList.get(index).getLatitude()).matches(regexCode)){
|
||||
@@ -95,7 +95,7 @@ public class AirportFilter extends Filter{
|
||||
}
|
||||
|
||||
public void filterLongitude(String longitude){
|
||||
String regexCode = "(?i).*"+longitude+".*";
|
||||
String regexCode = ".*"+longitude+".*";
|
||||
int index = 0;
|
||||
while(index < filteredList.size()){
|
||||
if (!String.valueOf(filteredList.get(index).getLongitude()).matches(regexCode)){
|
||||
@@ -107,7 +107,7 @@ public class AirportFilter extends Filter{
|
||||
}
|
||||
|
||||
public void filterAltitude(String altitude){
|
||||
String regexCode = "(?i).*"+altitude+".*";
|
||||
String regexCode = ".*"+altitude+".*";
|
||||
int index = 0;
|
||||
while(index < filteredList.size()){
|
||||
if (!String.valueOf(filteredList.get(index).getAltitude()).matches(regexCode)){
|
||||
@@ -146,7 +146,7 @@ public class AirportFilter extends Filter{
|
||||
String regexCode = "(?i).*"+DST+".*";
|
||||
int index = 0;
|
||||
while(index < filteredList.size()){
|
||||
if (!filteredList.get(index).getCountry().getDST().matches(regexCode)){
|
||||
if (!filteredList.get(index).getDST().matches(regexCode)){
|
||||
filteredList.remove(index);
|
||||
}else{
|
||||
index++;
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RouteFilter extends Filter{
|
||||
String regexCode = "(?i).*"+stops+".*";
|
||||
int index = 0;
|
||||
while(index < filteredList.size()){
|
||||
if (!filteredList.get(index).getArrivalAirport().matches(regexCode)){
|
||||
if (!String.valueOf(filteredList.get(index).getStops()).matches(regexCode)){
|
||||
filteredList.remove(index);
|
||||
}else{
|
||||
index++;
|
||||
|
||||
@@ -12,6 +12,7 @@ import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.util.Callback;
|
||||
import seng202.group9.Controller.AirportFilter;
|
||||
import seng202.group9.Controller.App;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Core.Airport;
|
||||
@@ -74,6 +75,29 @@ 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;
|
||||
|
||||
public void load() {
|
||||
@@ -136,4 +160,42 @@ public class AirportRDController extends Controller{
|
||||
theDataSet.deleteAirport(toDelete);
|
||||
tableViewAirportRD.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class RouteRDController extends Controller {
|
||||
|
||||
public void filterRoutes(){
|
||||
RouteFilter filter = new RouteFilter(theDataSet.getRoutes());
|
||||
if (rAirlineFilter.getText() != null && !rAirlineFilter.getText().equals("")) {
|
||||
if (rAirlineFilter.getText() != null) {
|
||||
//System.out.println("Hello over here");
|
||||
filter.filterAirline(rAirlineFilter.getText());
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<Font size="29.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<ScrollPane hbarPolicy="ALWAYS" layoutX="14.0" layoutY="469.0" prefHeight="54.0" prefViewportHeight="29.0" prefViewportWidth="1095.0" prefWidth="772.0" vbarPolicy="NEVER">
|
||||
<ScrollPane hbarPolicy="ALWAYS" layoutX="14.0" layoutY="469.0" prefHeight="54.0" prefViewportHeight="29.0" prefViewportWidth="1095.0" prefWidth="764.0" vbarPolicy="NEVER">
|
||||
<content>
|
||||
<Pane prefHeight="39.0" prefWidth="1633.0">
|
||||
<children>
|
||||
@@ -52,17 +52,17 @@
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpIATAFFABox" layoutX="839.0" layoutY="4.0" prefHeight="31.0" prefWidth="87.0" promptText="IATA/FAA">
|
||||
<TextField fx:id="airpIATAFFABox" layoutX="839.0" layoutY="4.0" prefHeight="31.0" prefWidth="75.0" promptText="IATA/FAA">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpICAOBox" layoutX="926.0" layoutY="4.0" prefHeight="31.0" prefWidth="48.0" promptText="ICAO">
|
||||
<TextField fx:id="airpICAOBox" layoutX="914.0" layoutY="3.0" prefHeight="31.0" prefWidth="61.0" promptText="ICAO">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpLatitudeBox" layoutX="974.0" layoutY="4.0" prefHeight="31.0" prefWidth="100.0" promptText="Latitude">
|
||||
<TextField fx:id="airpLatitudeBox" layoutX="975.0" layoutY="3.0" prefHeight="31.0" prefWidth="100.0" promptText="Latitude">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
@@ -87,17 +87,17 @@
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<Label layoutX="2.0" layoutY="7.0" prefHeight="25.0" prefWidth="87.0" text="Enter Values:" />
|
||||
<Label layoutX="2.0" layoutY="7.0" prefHeight="25.0" prefWidth="87.0" text="Add Airport:" />
|
||||
<ComboBox fx:id="airpDSTCBox" layoutX="1349.0" layoutY="3.0" prefHeight="31.0" prefWidth="83.0" promptText="DST" />
|
||||
</children>
|
||||
</Pane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<Button layoutX="14.0" layoutY="526.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="125.0" text="Analyse" />
|
||||
<Button layoutX="662.0" layoutY="526.0" mnemonicParsing="false" onAction="#addAirportSingle" prefHeight="25.0" prefWidth="125.0" text="Add" />
|
||||
<Pane layoutX="15.0" layoutY="60.0" prefHeight="403.0" prefWidth="772.0">
|
||||
<Button layoutX="653.0" layoutY="526.0" mnemonicParsing="false" onAction="#addAirportSingle" prefHeight="25.0" prefWidth="125.0" text="Add" />
|
||||
<Pane layoutX="15.0" layoutY="60.0" prefHeight="342.0" prefWidth="764.0">
|
||||
<children>
|
||||
<TableView fx:id="tableViewAirportRD" prefHeight="403.0" prefWidth="772.0">
|
||||
<TableView fx:id="tableViewAirportRD" prefHeight="340.0" prefWidth="765.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="airpIDcol" prefWidth="81.00003051757812" text="Airport ID" />
|
||||
<TableColumn fx:id="airpNamecol" prefWidth="350.0" text="Name" />
|
||||
@@ -121,6 +121,71 @@
|
||||
</contextMenu>
|
||||
</TableView>
|
||||
</children></Pane>
|
||||
<ScrollPane layoutX="15.0" layoutY="408.0" prefHeight="54.0" prefWidth="713.0">
|
||||
<content>
|
||||
<Pane prefHeight="32.0" prefWidth="1596.0">
|
||||
<children>
|
||||
<Label layoutX="14.0" layoutY="6.0" text="Filter :" />
|
||||
<TextField fx:id="airpNameFilter" layoutX="64.0" layoutY="3.0" prefHeight="31.0" prefWidth="350.0" promptText="Name">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpCityFilter" layoutX="414.0" layoutY="3.0" prefHeight="31.0" prefWidth="200.0" promptText="City">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpCountryFilter" layoutX="614.0" layoutY="3.0" prefHeight="31.0" prefWidth="200.0" promptText="Country">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpIATAFFAFilter" layoutX="814.0" layoutY="3.0" prefHeight="31.0" prefWidth="87.0" promptText="IATA/FAA">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpICAOFilter" layoutX="901.0" layoutY="3.0" prefHeight="31.0" prefWidth="61.0" promptText="ICAO">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpLatitudeFilter" layoutX="962.0" layoutY="3.0" prefHeight="31.0" prefWidth="100.0" promptText="Latitude">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpLongitudeFilter" layoutX="1062.0" layoutY="3.0" prefHeight="31.0" prefWidth="100.0" promptText="Longitude">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpAltitudeFilter" layoutX="1162.0" layoutY="3.0" prefHeight="31.0" prefWidth="75.0" promptText="Altitude">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpTimezoneFilter" layoutX="1237.0" layoutY="3.0" prefHeight="31.0" prefWidth="100.0" promptText="Timezone">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpTzFilter" layoutX="1395.0" layoutY="3.0" prefHeight="31.0" prefWidth="200.0" promptText="Tz database time zone">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
<TextField fx:id="airpDSTFilter" layoutX="1337.0" layoutY="3.0" prefHeight="31.0" prefWidth="58.0" promptText="DST">
|
||||
<padding>
|
||||
<Insets left="2.0" right="2.0" />
|
||||
</padding>
|
||||
</TextField>
|
||||
</children>
|
||||
</Pane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<Button layoutX="735.0" layoutY="420.0" mnemonicParsing="false" onAction="#filterAirports" prefHeight="31.0" prefWidth="40.0" text="Go" />
|
||||
</children>
|
||||
</Pane>
|
||||
</children>
|
||||
|
||||
Reference in New Issue
Block a user