diff options
author | Ben Burwell <ben.burwell@trifecta.com> | 2016-11-19 23:13:49 -0500 |
---|---|---|
committer | Ben Burwell <ben.burwell@trifecta.com> | 2016-11-19 23:13:49 -0500 |
commit | c893302e307b6471b8c3c7f57f46b6c92e7a55ef (patch) | |
tree | a18a86ed230a0a3cabbdb51c7cf418d8987de7f3 /src/main/java/com/benburwell/planes/gui/airportstable | |
parent | a448320cc4661f9304a8323d6c0e05f1f0fee2b3 (diff) |
Refactor tabbing
Diffstat (limited to 'src/main/java/com/benburwell/planes/gui/airportstable')
-rw-r--r-- | src/main/java/com/benburwell/planes/gui/airportstable/AirportsComponent.java | 34 | ||||
-rw-r--r-- | src/main/java/com/benburwell/planes/gui/airportstable/NavigationAidsTableModel.java | 57 |
2 files changed, 91 insertions, 0 deletions
diff --git a/src/main/java/com/benburwell/planes/gui/airportstable/AirportsComponent.java b/src/main/java/com/benburwell/planes/gui/airportstable/AirportsComponent.java new file mode 100644 index 0000000..8739de7 --- /dev/null +++ b/src/main/java/com/benburwell/planes/gui/airportstable/AirportsComponent.java @@ -0,0 +1,34 @@ +package com.benburwell.planes.gui.airportstable; + +import com.benburwell.planes.data.Airport; +import com.benburwell.planes.data.CSVObjectStore; +import com.benburwell.planes.gui.Tabbable; +import com.benburwell.planes.gui.navigationaids.AirportsTableModel; + +import javax.swing.*; + +/** + * Created by ben on 11/19/16. + */ +public class AirportsComponent implements Tabbable { + private JScrollPane scrollPane = new JScrollPane(); + private JTable table = new JTable(); + private AirportsTableModel tableModel; + + public AirportsComponent(CSVObjectStore<Airport> airportStore) { + this.tableModel = new AirportsTableModel(airportStore.getObjects()); + this.table = new JTable(this.tableModel); + this.table.setFillsViewportHeight(true); + this.scrollPane = new JScrollPane(table); + } + + @Override + public JComponent getComponent() { + return this.scrollPane; + } + + @Override + public String getName() { + return "Airports"; + } +} diff --git a/src/main/java/com/benburwell/planes/gui/airportstable/NavigationAidsTableModel.java b/src/main/java/com/benburwell/planes/gui/airportstable/NavigationAidsTableModel.java new file mode 100644 index 0000000..3ce098f --- /dev/null +++ b/src/main/java/com/benburwell/planes/gui/airportstable/NavigationAidsTableModel.java @@ -0,0 +1,57 @@ +package com.benburwell.planes.gui.airportstable; + +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; + } +} |