001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.dialogs.relation; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006import javax.swing.table.DefaultTableColumnModel; 007import javax.swing.table.TableColumn; 008 009import org.openstreetmap.josm.data.osm.DataSet; 010import org.openstreetmap.josm.data.osm.Relation; 011 012public class MemberTableColumnModel extends DefaultTableColumnModel { 013 014 /** 015 * Constructs a new {@code MemberTableColumnModel}. 016 * @param ds the data set. Must not be null 017 * @param relation the relation. Can be null 018 */ 019 public MemberTableColumnModel(DataSet ds, Relation relation) { 020 TableColumn col = null; 021 022 // column 0 - the member role 023 col = new TableColumn(0); 024 col.setHeaderValue(tr("Role")); 025 col.setResizable(true); 026 col.setPreferredWidth(100); 027 col.setCellRenderer(new MemberTableRoleCellRenderer()); 028 col.setCellEditor(new MemberRoleCellEditor(ds, relation)); 029 addColumn(col); 030 031 // column 1 - the member 032 col = new TableColumn(1); 033 col.setHeaderValue(tr("Refers to")); 034 col.setResizable(true); 035 col.setPreferredWidth(300); 036 col.setCellRenderer(new MemberTableMemberCellRenderer()); 037 addColumn(col); 038 039 // column 2 - 040 col = new TableColumn(2); 041 col.setHeaderValue(""); 042 col.setResizable(false); 043 col.setPreferredWidth(20); 044 col.setCellRenderer(new MemberTableLinkedCellRenderer()); 045 addColumn(col); 046 } 047}