Merge branch 'WIP_Flight_ListView_Click_Response' into 'master'
flight list view click response See merge request !6
This commit is contained in:
@@ -101,12 +101,14 @@ public class App extends Application
|
|||||||
System.out.println(currentDataset.importRoute("res/Samples/Routes.txt"));
|
System.out.println(currentDataset.importRoute("res/Samples/Routes.txt"));
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
//testing out flight parser
|
||||||
try {
|
try {
|
||||||
System.out.println(currentDataset.importFlight("res/Samples/NZCH-WSSS.csv"));
|
System.out.println(currentDataset.importFlight("res/Samples/NZCH-WSSS.csv"));
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}*/
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ 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.ListView;
|
import javafx.scene.control.ListView;
|
||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
import javafx.scene.control.cell.PropertyValueFactory;
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
|
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.Core.FlightPath;
|
import seng202.group9.Core.FlightPath;
|
||||||
@@ -15,6 +17,7 @@ import seng202.group9.Core.FlightPoint;
|
|||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,25 +61,44 @@ public class FlightRawDataController implements Initializable {
|
|||||||
final ObservableList<String> flightList = FXCollections.observableArrayList();
|
final ObservableList<String> flightList = FXCollections.observableArrayList();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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() {
|
public void flightPathListView() {
|
||||||
try {
|
try {
|
||||||
ArrayList<FlightPath> flightPaths = new ArrayList();
|
ArrayList<FlightPath> flightPaths = new ArrayList();
|
||||||
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();
|
||||||
String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin;
|
String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin;
|
||||||
flightList.add(flightPathDisplayName);
|
flightList.add(flightPathDisplayName);
|
||||||
}
|
}
|
||||||
|
flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||||
|
public void handle(MouseEvent event) {
|
||||||
|
String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem();
|
||||||
|
String[] segments = flightPathDisplayNameClicked.split("_");
|
||||||
|
String pathIdClicked = segments[0];
|
||||||
|
|
||||||
|
ArrayList<FlightPath> flightPaths;
|
||||||
|
flightPaths = theDataSet.getFlightPaths();
|
||||||
|
ArrayList<FlightPoint> flightPoints = flightPaths.get(Integer.parseInt(pathIdClicked)-1).getFlight();
|
||||||
|
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
flightPathListView.setItems(flightList);
|
flightPathListView.setItems(flightList);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function used to load the table for the Flight points initially from the MenuController
|
||||||
|
*/
|
||||||
public void loadTables() {
|
public void loadTables() {
|
||||||
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"));
|
||||||
@@ -91,14 +113,13 @@ public class FlightRawDataController implements Initializable {
|
|||||||
|
|
||||||
theDataSet = this.parent.getCurrentDataset();
|
theDataSet = this.parent.getCurrentDataset();
|
||||||
|
|
||||||
ArrayList<FlightPath> flightPaths = new ArrayList();
|
ArrayList<FlightPath> flightPaths;
|
||||||
flightPaths = theDataSet.getFlightPaths();
|
flightPaths = theDataSet.getFlightPaths();
|
||||||
int firstID = flightPaths.get(0).getID();
|
int firstID = flightPaths.get(0).getID();
|
||||||
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
|
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
|
||||||
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Controller for the Flights Summary Scene.
|
||||||
* Created by Liam Beckett on 13/09/2016.
|
* Created by Liam Beckett on 13/09/2016.
|
||||||
*/
|
*/
|
||||||
public class FlightSummaryController implements Initializable {
|
public class FlightSummaryController implements Initializable {
|
||||||
@@ -25,11 +26,13 @@ public class FlightSummaryController implements Initializable {
|
|||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
ListView<String> flightPathListView;
|
ListView<String> flightPathListView;
|
||||||
final ObservableList<String> flightList = FXCollections.observableArrayList();
|
final ObservableList<String> flightList = FXCollections.observableArrayList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the Flight paths into the List View and is called from the MenuController.
|
||||||
|
*/
|
||||||
public void flightPathListView() {
|
public void flightPathListView() {
|
||||||
try {
|
try {
|
||||||
theDataSet = this.parent.getCurrentDataset();
|
theDataSet = this.parent.getCurrentDataset();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightSummaryController">
|
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightSummaryController">
|
||||||
<children>
|
<children>
|
||||||
<ScrollPane prefHeight="800.0" prefWidth="800.0">
|
<ScrollPane hbarPolicy="NEVER" prefHeight="800.0" prefWidth="800.0" vbarPolicy="NEVER">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane prefHeight="600.0" prefWidth="800.0">
|
<AnchorPane prefHeight="600.0" prefWidth="800.0">
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightRawDataController">
|
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightRawDataController">
|
||||||
<children>
|
<children>
|
||||||
<ScrollPane hbarPolicy="NEVER" prefHeight="603.0" prefWidth="751.0" vbarPolicy="ALWAYS">
|
<ScrollPane hbarPolicy="NEVER" prefHeight="603.0" prefWidth="751.0" vbarPolicy="NEVER">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane prefHeight="371.0" prefWidth="600.0">
|
<AnchorPane prefHeight="371.0" prefWidth="600.0">
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
Reference in New Issue
Block a user