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    /** Column index for editor */
028    public static final int COL_EDITOR = 5;
029
030    /**
031     * Creates a new {@code VersionTableColumnModel}.
032     */
033    public VersionTableColumnModel() {
034        createColumns();
035    }
036
037    protected void createColumns() {
038        VersionTable.RadioButtonRenderer bRenderer = new VersionTable.RadioButtonRenderer();
039
040        // column 0 - Version
041        TableColumn col = new TableColumn(COL_VERSION);
042        /* translation note: 3 letter abbr. for "Version" */
043        col.setHeaderValue(tr("Ver"));
044        col.setCellRenderer(new VersionTable.AlignedRenderer(SwingConstants.CENTER));
045        col.setResizable(false);
046        addColumn(col);
047        // column 1 - Reference
048        col = new TableColumn(COL_REFERENCE);
049        col.setHeaderValue(tr("A"));
050        col.setCellRenderer(bRenderer);
051        col.setCellEditor(new VersionTable.RadioButtonEditor());
052        col.setResizable(false);
053        addColumn(col);
054        // column 2 - Current
055        col = new TableColumn(COL_CURRENT);
056        col.setHeaderValue(tr("B"));
057        col.setCellRenderer(bRenderer);
058        col.setCellEditor(new VersionTable.RadioButtonEditor());
059        col.setResizable(false);
060        addColumn(col);
061        // column 3 - Date
062        col = new TableColumn(COL_DATE);
063        col.setHeaderValue(tr("Date"));
064        col.setResizable(false);
065        addColumn(col);
066        // column 4 - User
067        col = new TableColumn(COL_USER);
068        col.setHeaderValue(tr("User"));
069        col.setResizable(false);
070        addColumn(col);
071        // column 5 - Editor
072        col = new TableColumn(COL_EDITOR);
073        col.setHeaderValue(tr("Editor"));
074        col.setResizable(false);
075        addColumn(col);
076    }
077}