summaryrefslogtreecommitdiff
path: root/src/main/java/com/benburwell/planes/gui/navigationaids
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/benburwell/planes/gui/navigationaids')
-rw-r--r--src/main/java/com/benburwell/planes/gui/navigationaids/AirportsTableModel.java56
-rw-r--r--src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidComponent.java10
-rw-r--r--src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidsTableModel.java57
3 files changed, 64 insertions, 59 deletions
diff --git a/src/main/java/com/benburwell/planes/gui/navigationaids/AirportsTableModel.java b/src/main/java/com/benburwell/planes/gui/navigationaids/AirportsTableModel.java
new file mode 100644
index 0000000..2850196
--- /dev/null
+++ b/src/main/java/com/benburwell/planes/gui/navigationaids/AirportsTableModel.java
@@ -0,0 +1,56 @@
+package com.benburwell.planes.gui.navigationaids;
+
+import com.benburwell.planes.data.Airport;
+
+import javax.swing.table.AbstractTableModel;
+import java.util.List;
+
+/**
+ * Created by ben on 11/19/16.
+ */
+public class AirportsTableModel extends AbstractTableModel {
+ public final String[] COLUMN_HEADERS = {"Identifier", "Name", "Country", "Municipality", "Scheduled Service", "IATA Code", "Local Code"};
+
+ public List<Airport> airports;
+
+ public AirportsTableModel(List<Airport> airports) {
+ this.airports = airports;
+ }
+
+ @Override
+ public String getColumnName(int columnIndex) {
+ return COLUMN_HEADERS[columnIndex];
+ }
+
+ @Override
+ public int getRowCount() {
+ return airports.size();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return COLUMN_HEADERS.length;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ Airport airport = this.airports.get(rowIndex);
+ switch (columnIndex) {
+ case 0:
+ return airport.getIdent();
+ case 1:
+ return airport.getName();
+ case 2:
+ return airport.getIsoCountry();
+ case 3:
+ return airport.getMunicipality();
+ case 4:
+ return airport.isScheduledService();
+ case 5:
+ return airport.getIataCode();
+ case 6:
+ return airport.getLocalCode();
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidComponent.java b/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidComponent.java
index 1ad7e3e..1238873 100644
--- a/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidComponent.java
+++ b/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidComponent.java
@@ -2,14 +2,15 @@ package com.benburwell.planes.gui.navigationaids;
import com.benburwell.planes.data.CSVObjectStore;
import com.benburwell.planes.data.NavigationAid;
-import com.benburwell.planes.gui.ViewComponent;
+import com.benburwell.planes.gui.Tabbable;
+import com.benburwell.planes.gui.airportstable.NavigationAidsTableModel;
import javax.swing.*;
/**
* Created by ben on 11/19/16.
*/
-public class NavigationAidComponent implements ViewComponent {
+public class NavigationAidComponent implements Tabbable {
private JTable table;
private NavigationAidsTableModel tableModel;
private JScrollPane scrollPane;
@@ -25,4 +26,9 @@ public class NavigationAidComponent implements ViewComponent {
public JComponent getComponent() {
return this.scrollPane;
}
+
+ @Override
+ public String getName() {
+ return "Navigation Aids";
+ }
}
diff --git a/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidsTableModel.java b/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidsTableModel.java
deleted file mode 100644
index 90b05eb..0000000
--- a/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidsTableModel.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.benburwell.planes.gui.navigationaids;
-
-import com.benburwell.planes.data.CSVObjectStore;
-import com.benburwell.planes.data.NavigationAid;
-
-import javax.swing.table.AbstractTableModel;
-
-/**
- * Created by ben on 11/19/16.
- */
-public class NavigationAidsTableModel extends AbstractTableModel {
- private final String[] COLUMN_NAMES = { "Ident", "Type", "Frequency", "DME Frequency", "DME Channel", "Usage Type", "Power", "Airport" };
- private CSVObjectStore<NavigationAid> store;
-
- public NavigationAidsTableModel(CSVObjectStore<NavigationAid> store) {
- this.store = store;
- }
-
- @Override
- public int getRowCount() {
- return this.store.getObjects().size();
- }
-
- @Override
- public String getColumnName(int col) {
- return COLUMN_NAMES[col];
- }
-
- @Override
- public int getColumnCount() {
- return this.COLUMN_NAMES.length;
- }
-
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
- NavigationAid aid = this.store.getObjects().get(rowIndex);
- switch (columnIndex) {
- case 0:
- return aid.getIdent();
- case 1:
- return aid.getType();
- case 2:
- return aid.getFrequency();
- case 3:
- return aid.getDmeFrequency();
- case 4:
- return aid.getDmeChannel();
- case 5:
- return aid.getUsageType();
- case 6:
- return aid.getPower();
- case 7:
- return aid.getAssociatedAirport();
- }
- return null;
- }
-}