001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.history;
003
004import static org.openstreetmap.josm.tools.I18n.tr;
005
006import javax.swing.SwingConstants;
007import javax.swing.table.DefaultTableColumnModel;
008import javax.swing.table.TableColumn;
009import javax.swing.table.TableColumnModel;
010
011/**
012 * The {@link TableColumnModel} for the table with the list of versions
013 * @since 1709
014 */
015public class VersionTableColumnModel extends DefaultTableColumnModel {
016
017    /** Column index for version */
018    public static final int COL_VERSION = 0;
019    /** Column index for reference */
020    public static final int COL_REFERENCE = 1;
021    /** Column index for current */
022    public static final int COL_CURRENT = 2;
023    /** Column index for date */
024    public static final int COL_DATE = 3;
025    /** Column index for user */
026    public static final int COL_USER = 4;
027
028    /**
029     * Creates a new {@code VersionTableColumnModel}.
030     */
031    public VersionTableColumnModel() {
032        createColumns();
033    }
034
035    protected void createColumns() {
036        VersionTable.RadioButtonRenderer bRenderer = new VersionTable.RadioButtonRenderer();
037
038        // column 0 - Version
039        TableColumn col = new TableColumn(COL_VERSION);
040        /* translation note: 3 letter abbr. for "Version" */
041        col.setHeaderValue(tr("Ver"));
042        col.setCellRenderer(new VersionTable.AlignedRenderer(SwingConstants.CENTER));
043        col.setResizable(false);
044        addColumn(col);
045        // column 1 - Reference
046        col = new TableColumn(COL_REFERENCE);
047        col.setHeaderValue(tr("A"));
048        col.setCellRenderer(bRenderer);
049        col.setCellEditor(new VersionTable.RadioButtonEditor());
050        col.setResizable(false);
051        addColumn(col);
052        // column 2 - Current
053        col = new TableColumn(COL_CURRENT);
054        col.setHeaderValue(tr("B"));
055        col.setCellRenderer(bRenderer);
056        col.setCellEditor(new VersionTable.RadioButtonEditor());
057        col.setResizable(false);
058        addColumn(col);
059        // column 3 - Date
060        col = new TableColumn(COL_DATE);
061        col.setHeaderValue(tr("Date"));
062        col.setResizable(false);
063        addColumn(col);
064        // column 4 - User
065        col = new TableColumn(COL_USER);
066        col.setHeaderValue(tr("User"));
067        col.setResizable(false);
068        addColumn(col);
069    }
070}