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,17 +90,19 @@ 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();
String[] segments = flightPathDisplayNameClicked.split("_"); if (flightPathDisplayNameClicked!=null) {
String pathIdClicked = segments[0]; String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0];
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary() currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
.get(Integer.parseInt(pathIdClicked))); .get(Integer.parseInt(pathIdClicked)));
currentPathId = Integer.parseInt(pathIdClicked); currentPathId = Integer.parseInt(pathIdClicked);
ArrayList<FlightPath> flightPaths; ArrayList<FlightPath> flightPaths;
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,27 +117,28 @@ 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() {
theDataSet = getParent().getCurrentDataset(); if (theDataSet != null) {
try { theDataSet = getParent().getCurrentDataset();
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path try {
} catch (DataException e) { currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
e.printStackTrace(); } catch (DataException e) {
} e.printStackTrace();
flightIdCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("ID")); }
flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name")); flightIdCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("ID"));
flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type")); flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name"));
flightViaCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Via")); flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type"));
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"));
flightHeadCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Heading")); flightHeadCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Heading"));
flightLegDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("LegDistance")); flightLegDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("LegDistance"));
flightTotDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("totalDistance")); flightTotDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("totalDistance"));
ArrayList<FlightPath> flightPaths; ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths(); flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight(); ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints)); flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
}
} }
/** /**
@ -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,7 +299,9 @@ public class FlightRDController extends Controller {
@Override @Override
public void loadOnce(){ public void loadOnce(){
flightPathListView(); if (theDataSet != null) {
flightPathListView();
}
} }
public void flightSummaryButton() { public void flightSummaryButton() {

@ -155,12 +155,14 @@ 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();
String[] segments = flightPathDisplayNameClicked.split("_"); if (flightPathDisplayNameClicked!=null) {
String pathIdClicked = segments[0]; String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0];
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
.get(Integer.parseInt(pathIdClicked))); currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
currentPathId = Integer.parseInt(pathIdClicked); .get(Integer.parseInt(pathIdClicked)));
currentPathId = Integer.parseInt(pathIdClicked);
}
} }
}); });
flightPathListView.setItems(flightList); flightPathListView.setItems(flightList);
@ -173,36 +175,37 @@ 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() {
try { if (theDataSet != null) {
theDataSet = getParent().getCurrentDataset(); try {
ArrayList<FlightPath> flightPaths; theDataSet = getParent().getCurrentDataset();
flightPaths = theDataSet.getFlightPaths(); ArrayList<FlightPath> flightPaths;
for(int i = 0; i<flightPaths.size(); i++ ){ flightPaths = theDataSet.getFlightPaths();
int pathID = flightPaths.get(i).getID(); for (int i = 0; i < flightPaths.size(); i++) {
String pathSource = flightPaths.get(i).departsFrom(); int pathID = flightPaths.get(i).getID();
String pathDestin = flightPaths.get(i).arrivesAt(); String pathSource = flightPaths.get(i).departsFrom();
String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin; String pathDestin = flightPaths.get(i).arrivesAt();
flightList.add(flightPathDisplayName); String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin;
} flightList.add(flightPathDisplayName);
flightPathListView.setItems(flightList);
flightSummaryListView();
} 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) {
int index = flightPathListView.getSelectionModel().getSelectedIndices().get(0);
if (index != -1) {
map.displayRoute(theDataSet.getFlightPaths().get(index).getRoutePath());
} }
flightPathListView.setItems(flightList);
flightSummaryListView();
} 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) {
int index = flightPathListView.getSelectionModel().getSelectedIndices().get(0);
if (index != -1) {
map.displayRoute(theDataSet.getFlightPaths().get(index).getRoutePath());
}
}
});
}
} }
/** /**

Loading…
Cancel
Save