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 *
014 */
015public class VersionTableColumnModel extends DefaultTableColumnModel {
016
017    public static final int COL_VERSION = 0;
018    public static final int COL_REFERENCE = 1;
019    public static final int COL_CURRENT = 2;
020    public static final int COL_DATE = 3;
021    public static final int COL_USER = 4;
022
023    protected void createColumns() {
024        TableColumn col = null;
025        VersionTable.RadioButtonRenderer bRenderer = new VersionTable.RadioButtonRenderer();
026
027        // column 0 - Version
028        col = new TableColumn(0);
029        /* translation note: 3 letter abbr. for "Version" */
030        col.setHeaderValue(tr("Ver"));
031        col.setCellRenderer(new VersionTable.AlignedRenderer(SwingConstants.CENTER));
032        col.setResizable(false);
033        addColumn(col);
034        // column 1 - Reference
035        col = new TableColumn(1);
036        col.setHeaderValue(tr("A"));
037        col.setCellRenderer(bRenderer);
038        col.setCellEditor(new VersionTable.RadioButtonEditor());
039        col.setResizable(false);
040        addColumn(col);
041        // column 2 - Current
042        col = new TableColumn(2);
043        col.setHeaderValue(tr("B"));
044        col.setCellRenderer(bRenderer);
045        col.setCellEditor(new VersionTable.RadioButtonEditor());
046        col.setResizable(false);
047        addColumn(col);
048        // column 3 - Date
049        col = new TableColumn(3);
050        col.setHeaderValue(tr("Date"));
051        col.setResizable(false);
052        addColumn(col);
053        // column 4 - User
054        col = new TableColumn(4);
055        col.setHeaderValue(tr("User"));
056        col.setResizable(false);
057        addColumn(col);
058    }
059
060    /**
061     * Creates a new {@code VersionTableColumnModel}.
062     */
063    public VersionTableColumnModel() {
064        createColumns();
065    }
066}