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.table.DefaultTableColumnModel; 007import javax.swing.table.TableColumn; 008import javax.swing.table.TableColumnModel; 009 010/** 011 * The {@link TableColumnModel} for the table with the list of versions 012 * @since 1709 013 */ 014public class VersionTableColumnModel extends DefaultTableColumnModel { 015 016 /** Column index for version */ 017 public static final int COL_VERSION = 0; 018 /** Column index for reference */ 019 public static final int COL_REFERENCE = 1; 020 /** Column index for current */ 021 public static final int COL_CURRENT = 2; 022 /** Column index for date */ 023 public static final int COL_DATE = 3; 024 /** Column index for user */ 025 public static final int COL_USER = 4; 026 /** Column index for editor */ 027 public static final int COL_EDITOR = 5; 028 029 /** 030 * Creates a new {@code VersionTableColumnModel}. 031 */ 032 public VersionTableColumnModel() { 033 createColumns(); 034 } 035 036 protected void createColumns() { 037 VersionTable.RadioButtonRenderer bRenderer = new VersionTable.RadioButtonRenderer(); 038 039 // column 0 - Version 040 TableColumn col = new TableColumn(COL_VERSION); 041 /* translation note: 3 letter abbr. for "Version" */ 042 col.setHeaderValue(tr("Ver")); 043 col.setCellRenderer(new VersionTableCellRenderer()); 044 col.setResizable(false); 045 addColumn(col); 046 // column 1 - Reference 047 col = new TableColumn(COL_REFERENCE); 048 col.setHeaderValue(tr("A")); 049 col.setCellRenderer(bRenderer); 050 col.setCellEditor(new VersionTable.RadioButtonEditor()); 051 col.setResizable(false); 052 addColumn(col); 053 // column 2 - Current 054 col = new TableColumn(COL_CURRENT); 055 col.setHeaderValue(tr("B")); 056 col.setCellRenderer(bRenderer); 057 col.setCellEditor(new VersionTable.RadioButtonEditor()); 058 col.setResizable(false); 059 addColumn(col); 060 // column 3 - Date 061 col = new TableColumn(COL_DATE); 062 col.setHeaderValue(tr("Date")); 063 col.setResizable(false); 064 addColumn(col); 065 // column 4 - User 066 col = new TableColumn(COL_USER); 067 col.setHeaderValue(tr("User")); 068 col.setResizable(false); 069 addColumn(col); 070 // column 5 - Editor 071 col = new TableColumn(COL_EDITOR); 072 col.setHeaderValue(tr("Editor")); 073 col.setResizable(false); 074 addColumn(col); 075 } 076}