Implemented the delete option for the flight paths on the Summary and Raw Data pages.
This commit is contained in:
@@ -180,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() {
|
public void newPath() {
|
||||||
NewPathPopUp dialogBox = new NewPathPopUp();
|
NewPathPopUp dialogBox = new NewPathPopUp();
|
||||||
@@ -194,7 +194,9 @@ public class FlightRDController extends Controller {
|
|||||||
flightPathListView();
|
flightPathListView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Removes the selected point from the table and database.
|
||||||
|
*/
|
||||||
public void deletePoint() {
|
public void deletePoint() {
|
||||||
FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem();
|
FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem();
|
||||||
int pathID = toDelete.getIndex();
|
int pathID = toDelete.getIndex();
|
||||||
@@ -210,6 +212,9 @@ public class FlightRDController extends Controller {
|
|||||||
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the selected path from the list view of paths and from the database.
|
||||||
|
*/
|
||||||
public void deletePath() {
|
public void deletePath() {
|
||||||
String toDeleteStr = flightPathListView.getSelectionModel().getSelectedItem();
|
String toDeleteStr = flightPathListView.getSelectionModel().getSelectedItem();
|
||||||
String[] segments = toDeleteStr.split("_");
|
String[] segments = toDeleteStr.split("_");
|
||||||
@@ -223,6 +228,9 @@ public class FlightRDController extends Controller {
|
|||||||
flightPathListView();
|
flightPathListView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will link to the flight analyser when implemented.
|
||||||
|
*/
|
||||||
public void flightAnalyser(){
|
public void flightAnalyser(){
|
||||||
JOptionPane.showMessageDialog(null, "This is not Implemented yet");
|
JOptionPane.showMessageDialog(null, "This is not Implemented yet");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,17 @@ package seng202.group9.GUI;
|
|||||||
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.ListView;
|
import javafx.scene.control.ListView;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
import seng202.group9.Controller.App;
|
import seng202.group9.Controller.App;
|
||||||
import seng202.group9.Controller.Dataset;
|
import seng202.group9.Controller.Dataset;
|
||||||
import seng202.group9.Controller.SceneCode;
|
import seng202.group9.Controller.SceneCode;
|
||||||
import seng202.group9.Core.FlightPath;
|
import seng202.group9.Core.FlightPath;
|
||||||
|
import seng202.group9.Core.FlightPoint;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -22,31 +25,63 @@ import java.util.ResourceBundle;
|
|||||||
public class FlightSummaryController extends Controller {
|
public class FlightSummaryController extends Controller {
|
||||||
|
|
||||||
private Dataset theDataSet = null;
|
private Dataset theDataSet = null;
|
||||||
|
private int currentPathId = 0;
|
||||||
|
private int currentPathIndex = 0;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button flightRawData;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
ListView<String> flightPathListView;
|
ListView<String> flightPathListView;
|
||||||
final ObservableList<String> flightList = FXCollections.observableArrayList();
|
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() {
|
public void handleRawDataButton() {
|
||||||
replaceSceneContent(SceneCode.FLIGHT_RAW_DATA);
|
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() {
|
public void routeSummaryButton() {
|
||||||
replaceSceneContent(SceneCode.ROUTE_SUMMARY);
|
replaceSceneContent(SceneCode.ROUTE_SUMMARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes to the Airline Summary Scene when the Airline Button is clicked.
|
||||||
|
*/
|
||||||
public void airlineSummaryButton() {
|
public void airlineSummaryButton() {
|
||||||
replaceSceneContent(SceneCode.AIRLINE_SUMMARY);
|
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() {
|
public void load() {
|
||||||
try {
|
try {
|
||||||
theDataSet = getParent().getCurrentDataset();
|
theDataSet = getParent().getCurrentDataset();
|
||||||
@@ -65,5 +100,21 @@ public class FlightSummaryController extends Controller {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.ContextMenu?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.ListView?>
|
<?import javafx.scene.control.ListView?>
|
||||||
|
<?import javafx.scene.control.MenuItem?>
|
||||||
<?import javafx.scene.control.ScrollPane?>
|
<?import javafx.scene.control.ScrollPane?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
@@ -45,7 +47,14 @@
|
|||||||
<children>
|
<children>
|
||||||
<Pane prefHeight="461.0" prefWidth="175.0" GridPane.rowIndex="1">
|
<Pane prefHeight="461.0" prefWidth="175.0" GridPane.rowIndex="1">
|
||||||
<children>
|
<children>
|
||||||
<ListView fx:id="flightPathListView" layoutX="20.0" layoutY="27.0" prefHeight="404.0" prefWidth="125.0" />
|
<ListView fx:id="flightPathListView" layoutX="20.0" layoutY="27.0" prefHeight="404.0" prefWidth="125.0">
|
||||||
|
<contextMenu>
|
||||||
|
<ContextMenu>
|
||||||
|
<items>
|
||||||
|
<MenuItem mnemonicParsing="false" onAction="#deletePath" text="Delete" />
|
||||||
|
</items>
|
||||||
|
</ContextMenu>
|
||||||
|
</contextMenu></ListView>
|
||||||
<Label layoutX="26.0" layoutY="4.0" text="Flight Path File(s)">
|
<Label layoutX="26.0" layoutY="4.0" text="Flight Path File(s)">
|
||||||
<font>
|
<font>
|
||||||
<Font size="15.0" />
|
<Font size="15.0" />
|
||||||
|
|||||||
Reference in New Issue
Block a user