Merge branch 'Update_Path' into 'master'

Update path



See merge request !22
main
Liam Beckett 9 years ago
commit 12c396a263

Binary file not shown.

@ -467,7 +467,6 @@ public class Dataset {
while (IDResult.next()) { while (IDResult.next()) {
nextID = Integer.parseInt(IDResult.getString("seq")) + 1;//for some reason sqlite3 stores incremental values as a string... nextID = Integer.parseInt(IDResult.getString("seq")) + 1;//for some reason sqlite3 stores incremental values as a string...
} }
System.out.println(nextID);
stmt.close(); stmt.close();
stmt = c.createStatement(); stmt = c.createStatement();
String insertAirportQuery = "INSERT INTO `" + this.name + "_Airport` (`Name`, `City`, `Country`, `IATA/FFA`," + String insertAirportQuery = "INSERT INTO `" + this.name + "_Airport` (`Name`, `City`, `Country`, `IATA/FFA`," +
@ -1611,7 +1610,6 @@ public class Dataset {
stmt.close(); stmt.close();
int index = flightPath.getFlightPoints().indexOf(flightPoint); int index = flightPath.getFlightPoints().indexOf(flightPoint);
System.out.println(index);
if (index == 0){ if (index == 0){
try { 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 departureAirport
* @param arrivalAirport * @param arrivalAirport
*/ */

@ -37,8 +37,6 @@ public class FlightRDController extends Controller {
@FXML @FXML
private TableColumn<FlightPoint, String> flightTypeCol; private TableColumn<FlightPoint, String> flightTypeCol;
@FXML @FXML
private TableColumn<FlightPoint, String> flightViaCol;
@FXML
private TableColumn<FlightPoint, String> flightAltitudeCol; private TableColumn<FlightPoint, String> flightAltitudeCol;
@FXML @FXML
private TableColumn<FlightPoint, String> flightLatCol; private TableColumn<FlightPoint, String> flightLatCol;
@ -92,6 +90,7 @@ public class FlightRDController extends Controller {
flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() { flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) { public void handle(MouseEvent event) {
String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem(); String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem();
if (flightPathDisplayNameClicked!=null) {
String[] segments = flightPathDisplayNameClicked.split("_"); String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0]; String pathIdClicked = segments[0];
@ -103,6 +102,7 @@ public class FlightRDController extends Controller {
flightPaths = theDataSet.getFlightPaths(); flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight(); ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints)); 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 * Used to load the table for the Flight points initially from the MenuController
*/ */
public void load() { public void load() {
if (theDataSet != null) {
theDataSet = getParent().getCurrentDataset(); theDataSet = getParent().getCurrentDataset();
try { try {
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path 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")); flightIdCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("ID"));
flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name")); flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name"));
flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type")); flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type"));
flightViaCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Via"));
flightAltitudeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Altitude")); flightAltitudeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Altitude"));
flightLatCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Latitude")); flightLatCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Latitude"));
flightLongCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Longitude")); flightLongCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Longitude"));
@ -139,6 +139,7 @@ public class FlightRDController extends Controller {
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight(); ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints)); flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
} }
}
/** /**
* Will take the inputs from the text fields and adds the point to the current flight path. * 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(); flightPathListView();
} }
/**
* Function for the 'Move Up' right click option on the points in the flight table.
*/
public void movePointUp(){ public void movePointUp(){
FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem(); FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem();
int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex(); int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex();
try{ try{
theDataSet.moveFlightPoint(toMove, toMoveIndex-1); if (toMoveIndex != 0) {
theDataSet.moveFlightPoint(toMove, toMoveIndex - 1);
}
} catch (DataException e) { } catch (DataException e) {
e.printStackTrace(); e.printStackTrace();
} }
updateTable(currentPathIndex); updateTable(currentPathIndex);
updatePaths();
} }
/**
* Function for the 'Move Down' right click option on the points in the flight table.
*/
public void movePointDown(){ public void movePointDown(){
FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem(); FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem();
int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex(); int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex();
try{ try{
theDataSet.moveFlightPoint(toMove, toMoveIndex+1); if (toMoveIndex != flightTableView.getItems().size()-1) {
theDataSet.moveFlightPoint(toMove, toMoveIndex + 1);
}
} catch (DataException e) { } catch (DataException e) {
e.printStackTrace(); e.printStackTrace();
} }
updateTable(currentPathIndex); updateTable(currentPathIndex);
updatePaths();
} }
/** /**
@ -257,6 +269,27 @@ public class FlightRDController extends Controller {
flightTableView.refresh(); 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. * Will link to the flight analyser when implemented.
*/ */
@ -266,8 +299,10 @@ public class FlightRDController extends Controller {
@Override @Override
public void loadOnce(){ public void loadOnce(){
if (theDataSet != null) {
flightPathListView(); flightPathListView();
} }
}
public void flightSummaryButton() { public void flightSummaryButton() {
replaceSceneContent(SceneCode.FLIGHT_SUMMARY); replaceSceneContent(SceneCode.FLIGHT_SUMMARY);

@ -155,6 +155,7 @@ public class FlightSummaryController extends Controller {
flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() { flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) { public void handle(MouseEvent event) {
String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem(); String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem();
if (flightPathDisplayNameClicked!=null) {
String[] segments = flightPathDisplayNameClicked.split("_"); String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0]; String pathIdClicked = segments[0];
@ -162,6 +163,7 @@ public class FlightSummaryController extends Controller {
.get(Integer.parseInt(pathIdClicked))); .get(Integer.parseInt(pathIdClicked)));
currentPathId = Integer.parseInt(pathIdClicked); currentPathId = Integer.parseInt(pathIdClicked);
} }
}
}); });
flightPathListView.setItems(flightList); flightPathListView.setItems(flightList);
} catch (Exception e) { } catch (Exception e) {
@ -173,11 +175,12 @@ public class FlightSummaryController extends Controller {
* Used to load the page from the MenuController. * Used to load the page from the MenuController.
*/ */
public void load() { public void load() {
if (theDataSet != null) {
try { try {
theDataSet = getParent().getCurrentDataset(); theDataSet = getParent().getCurrentDataset();
ArrayList<FlightPath> flightPaths; ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths(); flightPaths = theDataSet.getFlightPaths();
for(int i = 0; i<flightPaths.size(); i++ ){ for (int i = 0; i < flightPaths.size(); i++) {
int pathID = flightPaths.get(i).getID(); int pathID = flightPaths.get(i).getID();
String pathSource = flightPaths.get(i).departsFrom(); String pathSource = flightPaths.get(i).departsFrom();
String pathDestin = flightPaths.get(i).arrivesAt(); String pathDestin = flightPaths.get(i).arrivesAt();
@ -186,13 +189,12 @@ public class FlightSummaryController extends Controller {
} }
flightPathListView.setItems(flightList); flightPathListView.setItems(flightList);
flightSummaryListView(); flightSummaryListView();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (theDataSet.getFlightPaths().size() > 0){ if (theDataSet.getFlightPaths().size() > 0) {
map = new Map(mapView, theDataSet.getFlightPaths().get(0).getRoutePath()); map = new Map(mapView, theDataSet.getFlightPaths().get(0).getRoutePath());
}else{ } else {
map = new Map(mapView, new RoutePath()); map = new Map(mapView, new RoutePath());
} }
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() { flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@ -204,6 +206,7 @@ public class FlightSummaryController extends Controller {
} }
}); });
} }
}
/** /**
* Removes the selected path from the list view of paths and from the database. * Removes the selected path from the list view of paths and from the database.

Loading…
Cancel
Save