Added in the right click, delete option for the flight points in the table.

main
Liam Beckett 9 years ago
parent be3413a373
commit 3508518cdd

@ -17,6 +17,7 @@ import javax.swing.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.ResourceBundle;
/**
@ -194,6 +195,21 @@ public class FlightRDController extends Controller {
}
}
public void deletePoint() {
FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem();
int pathID = toDelete.getIndex();
LinkedHashMap<Integer, FlightPath> flightPathDict = theDataSet.getFlightPathDictionary();
FlightPath toDeletesPath = flightPathDict.get(pathID);
theDataSet.deleteFlightPoint(toDelete, toDeletesPath);
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary().get(pathID));
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
}
public void flightAnalyser(){
JOptionPane.showMessageDialog(null, "This is not Implemented yet");
}

@ -1,14 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ContextMenu?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
@ -22,7 +19,7 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightRDController">
<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.FlightRDController">
<children>
<ScrollPane hbarPolicy="NEVER" prefHeight="603.0" prefWidth="751.0" vbarPolicy="NEVER">
<content>
@ -34,8 +31,8 @@
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="193.0" minHeight="10.0" prefHeight="57.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="521.0" minHeight="10.0" prefHeight="521.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="62.0" minHeight="0.0" prefHeight="19.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="521.0" minHeight="10.0" prefHeight="513.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="62.0" minHeight="0.0" prefHeight="28.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<GridPane GridPane.rowIndex="1">
@ -44,13 +41,13 @@
<ColumnConstraints hgrow="SOMETIMES" maxWidth="651.0" minWidth="10.0" prefWidth="638.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Pane prefHeight="434.0" prefWidth="158.0">
<Pane prefHeight="505.0" prefWidth="162.0">
<children>
<Button layoutX="32.0" layoutY="486.0" mnemonicParsing="false" onAction="#newPath" prefHeight="25.0" prefWidth="99.0" text="New" />
<ListView fx:id="flightPathListView" layoutX="19.0" layoutY="25.0" prefHeight="450.0" prefWidth="125.0" />
<Button layoutX="32.0" layoutY="480.0" mnemonicParsing="false" onAction="#newPath" prefHeight="25.0" prefWidth="99.0" text="New" />
<ListView fx:id="flightPathListView" layoutX="19.0" layoutY="25.0" prefHeight="444.0" prefWidth="125.0" />
<Label layoutX="16.0" text="Flight Path File(s)">
<font>
<Font size="15.0" />
@ -146,6 +143,13 @@
<TableColumn fx:id="flightLegDisCol" prefWidth="75.0" text="Leg Dist" />
<TableColumn fx:id="flightTotDisCol" prefWidth="75.0" text="Tot Dist" />
</columns>
<contextMenu>
<ContextMenu>
<items>
<MenuItem mnemonicParsing="false" onAction="#deletePoint" text="Delete" />
</items>
</ContextMenu>
</contextMenu>
</TableView>
</children>
</GridPane>

Loading…
Cancel
Save