summaryrefslogtreecommitdiff
path: root/src/main/java/com/benburwell/planes/gui/NavigationAidsTableModel.java
blob: 064ca255c232b1a88b1828548a672fe79af395af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.benburwell.planes.gui;

import com.benburwell.planes.data.NavigationAid;
import com.benburwell.planes.data.NavigationAidStore;

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 NavigationAidStore store;

    public NavigationAidsTableModel(NavigationAidStore store) {
        this.store = store;
    }

    @Override
    public int getRowCount() {
        return this.store.getNavigationAids().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.getNavigationAids().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;
    }
}