001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.dialogs.changeset; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006import javax.swing.table.DefaultTableColumnModel; 007import javax.swing.table.TableColumn; 008 009/** 010 * The column model for the changeset table 011 * @since 2689 012 */ 013public class ChangesetCacheTableColumnModel extends DefaultTableColumnModel { 014 015 private final ChangesetCacheTableCellRenderer renderer = new ChangesetCacheTableCellRenderer(); 016 017 protected void createColumn(int modelIndex, String headerValue, int preferredWidth, int width) { 018 TableColumn col = new TableColumn(modelIndex); 019 col.setHeaderValue(headerValue); 020 col.setResizable(true); 021 if (width > -1) { 022 col.setWidth(width); 023 } 024 col.setPreferredWidth(preferredWidth); 025 col.setCellRenderer(renderer); 026 addColumn(col); 027 } 028 029 protected void createColumns() { 030 031 // column 0 - Id 032 createColumn(0, tr("ID"), 20, 20); 033 034 // column 1 - Upload comment 035 createColumn(1, tr("Comment"), 200, -1); 036 037 // column 2 - Open 038 createColumn(2, tr("Open"), 50, -1); 039 040 // column 3 - User 041 createColumn(3, tr("User"), 50, -1); 042 043 // column 4 - Created at 044 createColumn(4, tr("Created at"), 100, -1); 045 046 // column 5 - Closed at 047 createColumn(5, tr("Closed at"), 100, -1); 048 } 049 050 /** 051 * Creates a new {@code ChangesetCacheTableColumnModel}. 052 */ 053 public ChangesetCacheTableColumnModel() { 054 createColumns(); 055 } 056}