Merge branch 'Update_Path' into 'master'
Update path See merge request !22
This commit is contained in:
Binary file not shown.
@@ -467,7 +467,6 @@ public class Dataset {
|
||||
while (IDResult.next()) {
|
||||
nextID = Integer.parseInt(IDResult.getString("seq")) + 1;//for some reason sqlite3 stores incremental values as a string...
|
||||
}
|
||||
System.out.println(nextID);
|
||||
stmt.close();
|
||||
stmt = c.createStatement();
|
||||
String insertAirportQuery = "INSERT INTO `" + this.name + "_Airport` (`Name`, `City`, `Country`, `IATA/FFA`," +
|
||||
@@ -1611,7 +1610,6 @@ public class Dataset {
|
||||
stmt.close();
|
||||
|
||||
int index = flightPath.getFlightPoints().indexOf(flightPoint);
|
||||
System.out.println(index);
|
||||
|
||||
if (index == 0){
|
||||
try {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class FlightPath {
|
||||
}
|
||||
|
||||
/**
|
||||
* COnstructor for FlightPath from dataset add later the ID needs to be set from database.
|
||||
* Constructor for FlightPath from dataset add later the ID needs to be set from database.
|
||||
* @param departureAirport
|
||||
* @param arrivalAirport
|
||||
*/
|
||||
|
||||
@@ -37,8 +37,6 @@ public class FlightRDController extends Controller {
|
||||
@FXML
|
||||
private TableColumn<FlightPoint, String> flightTypeCol;
|
||||
@FXML
|
||||
private TableColumn<FlightPoint, String> flightViaCol;
|
||||
@FXML
|
||||
private TableColumn<FlightPoint, String> flightAltitudeCol;
|
||||
@FXML
|
||||
private TableColumn<FlightPoint, String> flightLatCol;
|
||||
@@ -92,6 +90,7 @@ public class FlightRDController extends Controller {
|
||||
flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem();
|
||||
if (flightPathDisplayNameClicked!=null) {
|
||||
String[] segments = flightPathDisplayNameClicked.split("_");
|
||||
String pathIdClicked = segments[0];
|
||||
|
||||
@@ -103,6 +102,7 @@ public class FlightRDController extends Controller {
|
||||
flightPaths = theDataSet.getFlightPaths();
|
||||
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
|
||||
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
@@ -117,6 +117,7 @@ public class FlightRDController extends Controller {
|
||||
* Used to load the table for the Flight points initially from the MenuController
|
||||
*/
|
||||
public void load() {
|
||||
if (theDataSet != null) {
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
try {
|
||||
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
|
||||
@@ -126,7 +127,6 @@ public class FlightRDController extends Controller {
|
||||
flightIdCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("ID"));
|
||||
flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name"));
|
||||
flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type"));
|
||||
flightViaCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Via"));
|
||||
flightAltitudeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Altitude"));
|
||||
flightLatCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Latitude"));
|
||||
flightLongCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Longitude"));
|
||||
@@ -139,6 +139,7 @@ public class FlightRDController extends Controller {
|
||||
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
|
||||
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Will take the inputs from the text fields and adds the point to the current flight path.
|
||||
@@ -222,27 +223,38 @@ public class FlightRDController extends Controller {
|
||||
flightPathListView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for the 'Move Up' right click option on the points in the flight table.
|
||||
*/
|
||||
public void movePointUp(){
|
||||
FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem();
|
||||
int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex();
|
||||
try{
|
||||
if (toMoveIndex != 0) {
|
||||
theDataSet.moveFlightPoint(toMove, toMoveIndex - 1);
|
||||
}
|
||||
} catch (DataException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
updateTable(currentPathIndex);
|
||||
|
||||
updatePaths();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for the 'Move Down' right click option on the points in the flight table.
|
||||
*/
|
||||
public void movePointDown(){
|
||||
FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem();
|
||||
int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex();
|
||||
try{
|
||||
if (toMoveIndex != flightTableView.getItems().size()-1) {
|
||||
theDataSet.moveFlightPoint(toMove, toMoveIndex + 1);
|
||||
}
|
||||
} catch (DataException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
updateTable(currentPathIndex);
|
||||
updatePaths();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,6 +269,27 @@ public class FlightRDController extends Controller {
|
||||
flightTableView.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the flight path list view so that it displays the correct names for the paths
|
||||
*/
|
||||
private void updatePaths(){
|
||||
try {
|
||||
flightPathListView.getItems().clear();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Will link to the flight analyser when implemented.
|
||||
*/
|
||||
@@ -266,8 +299,10 @@ public class FlightRDController extends Controller {
|
||||
|
||||
@Override
|
||||
public void loadOnce(){
|
||||
if (theDataSet != null) {
|
||||
flightPathListView();
|
||||
}
|
||||
}
|
||||
|
||||
public void flightSummaryButton() {
|
||||
replaceSceneContent(SceneCode.FLIGHT_SUMMARY);
|
||||
|
||||
@@ -155,6 +155,7 @@ public class FlightSummaryController extends Controller {
|
||||
flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem();
|
||||
if (flightPathDisplayNameClicked!=null) {
|
||||
String[] segments = flightPathDisplayNameClicked.split("_");
|
||||
String pathIdClicked = segments[0];
|
||||
|
||||
@@ -162,6 +163,7 @@ public class FlightSummaryController extends Controller {
|
||||
.get(Integer.parseInt(pathIdClicked)));
|
||||
currentPathId = Integer.parseInt(pathIdClicked);
|
||||
}
|
||||
}
|
||||
});
|
||||
flightPathListView.setItems(flightList);
|
||||
} catch (Exception e) {
|
||||
@@ -173,6 +175,7 @@ public class FlightSummaryController extends Controller {
|
||||
* Used to load the page from the MenuController.
|
||||
*/
|
||||
public void load() {
|
||||
if (theDataSet != null) {
|
||||
try {
|
||||
theDataSet = getParent().getCurrentDataset();
|
||||
ArrayList<FlightPath> flightPaths;
|
||||
@@ -186,7 +189,6 @@ public class FlightSummaryController extends Controller {
|
||||
}
|
||||
flightPathListView.setItems(flightList);
|
||||
flightSummaryListView();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -204,6 +206,7 @@ public class FlightSummaryController extends Controller {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the selected path from the list view of paths and from the database.
|
||||
|
||||
Reference in New Issue
Block a user